Skip to content

Recognize an indented list marker at a block boundary#232

Merged
dereuromark merged 1 commit into
masterfrom
fix/indented-top-level-list
Jun 7, 2026
Merged

Recognize an indented list marker at a block boundary#232
dereuromark merged 1 commit into
masterfrom
fix/indented-top-level-list

Conversation

@dereuromark

Copy link
Copy Markdown
Contributor

What

djot treats indentation as significant only for nesting (doc/syntax.md: "Indentation is only significant for list item or footnote nesting"). So a leading-indented list marker at the top level, or after a blank line, is simply a list. Reference djot parses these as lists:

input reference djot-php (before)
- item <ul><li>item <p>- item</p>
\t- item <ul><li>item <p>- item</p>
1. item <ol><li>item <p>1. item</p>

djot-php matched the marker against the raw line, so leading whitespace made parseListItemMarker fail and the line became a paragraph.

Fix

Match the marker on the de-indented line in tryParseList(). The leading indent still becomes the list's base indentation (nested lists already run with a non-zero base, so the existing machinery handles it).

Lazy-continuation lines are unaffected, because they never reach tryParseList():

  • an indented marker continuing an open paragraph (text / - item, no blank) is collected by the paragraph;
  • an indented marker after a list item without a blank line (- a / - b) is collected as that item's continuation.

Both verified to still render as text.

Scope / known edge

This is the parser-side tab gap B from #230/#231. Covers the common case (uniform leading indent). One rare divergence remains: a first item indented with a less-indented sibling ( - a / - b) ends the list early in djot-php, where reference keeps one list. Vanishingly rare; left for the tab-stop work (gap C) if it matters.

Verification

Full unit suite + official djot corpus pass (2498 tests).

djot treats indentation as significant only for nesting, so a leading-
indented list marker (`  - item`, `\t- item`) at the top level or after a
blank line is just a list. djot-php matched the marker against the raw
line, so any leading whitespace made it fall through to a paragraph,
diverging from the reference implementation.

Match the marker on the de-indented line in tryParseList(); the leading
indent still becomes the list's base indentation. Lazy-continuation lines
(an indented marker continuing an open paragraph, or collected as a list
item's continuation without a blank line) never reach tryParseList(), so
that behavior is unchanged.

Full unit suite and official djot corpus pass.
@dereuromark dereuromark added the bug Something isn't working label Jun 7, 2026
@codecov

codecov Bot commented Jun 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.89%. Comparing base (52a66ea) to head (e41c25c).

Additional details and impacted files
@@            Coverage Diff            @@
##             master     #232   +/-   ##
=========================================
  Coverage     91.89%   91.89%           
  Complexity     3523     3523           
=========================================
  Files           106      106           
  Lines          9958     9958           
=========================================
  Hits           9151     9151           
  Misses          807      807           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@dereuromark dereuromark merged commit 9d874ef into master Jun 7, 2026
6 checks passed
@dereuromark dereuromark deleted the fix/indented-top-level-list branch June 7, 2026 14:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant