Skip to content

Keep div closers hidden by fences after headings, breaks, tables and list items - #349

Merged
dereuromark merged 4 commits into
masterfrom
fix/div-scan-followup
Nov 11, 2026
Merged

dereuromark merged 4 commits into
masterfrom
fix/div-scan-followup

Conversation

@dereuromark

@dereuromark dereuromark commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Follow-up to #347 (F13, F7). #347 merged at its first commit, before the review fixes were pushed, so master now has a div scanner that reads too many fence lines as paragraph text. This PR carries those fixes plus the cases a wider sweep found.

Fences after single-line blocks and containers

:::
# heading
```
:::
```
:::

On master (since #347), the ::: inside the code block closes the div:

<div>
<h1 id="heading">heading</h1>
<pre><code></code></pre>
</div>
<pre><code>:::
</code></pre>

After (djot.js):

<div>
<h1 id="heading">heading</h1>
<pre><code>:::
</code></pre>
</div>

The div scanner now tracks, besides paragraphs:

  • headings and their continuation lines, thematic breaks, table rows and attribute lines, which open no paragraph a fence line could continue;
  • the marker columns of open list items and whether a paragraph sits in a quote, so an unindented block line ends that paragraph (- i or > q followed by an unindented fence);
  • list and quote marker lines with nothing after them (- [ ], >), which open no paragraph;
  • fences opened inside a list item, which end with the item.

The same shape with a list item:

:::
- i
```
:::
```
:::

Master: the div closes at the first ::: and an empty code block follows it. After: one div holding the list and a code block with :::, as djot.js renders it.

Later table rows follow the first row's rules

| a |
| `a |

Before: a second row with <code>a</code>. After (djot.js):

<table>
<tr>
<td>a</td>
</tr>
</table>
<p>| <code>a |</code></p>

A row whose closing pipe is escaped or inside an open code span ends the table, both for unindented rows and for the indented rows #347 added. djot-php's + continuation rows can still close such a span.

Verification

  • BlockStructureParityTest: 17 cases added, 41 in total. Reverting any one of the changes fails at least two of them.
  • Differential sweeps against djot.js 9790d4d, current master vs this branch:
    • 2,000 divs with headings, fences, tables, quotes, lists and comments: 542 differ from djot.js on master, 312 here (230 fixed, 0 regressed).
    • 2,500 divs and lists with nested containers and fences: 448 on master, 206 here (242 fixed, 0 regressed).
    • 3,000 list, task, quote, table, div and verbatim documents: 509 on master, 506 here (3 fixed, 0 regressed).
  • The scanner does constant work per line except for onlyContainerMarkers(), which runs once when a paragraph opens and stops at the nesting cap.
  • Fenced %%% comments keep hiding a :::, as on master.
  • Codex review (medium): round 1 found that a fenced comment no longer hid the closer; fixed with a test. Round 2: no actionable regression found.

…oser

Review follow-up. The div scanner treated every non-blank line as an
open paragraph, so a fence after a heading, thematic break, table row or
attribute line, or an unindented fence after a list item or quote, was
read as paragraph text and a `:::` inside it closed the div. The scanner
now tracks headings and their continuation lines, single-line blocks, and
the marker columns of open list items and quote paragraphs. A fenced
comment still does not hide the closer, as before.

The table loop also stops at a row whose closing pipe is escaped, the
same rule isTableRow() applies to the first row.
A list or quote marker with nothing after it (`- [ ]`, `>`) opens no
paragraph, so a following fence line is a fence. A fence opened inside a
list item ends when the item does, at the next non-blank line that is not
indented past the item's marker. A heading's continuation stops at a
block line, so a table row or break after a heading ends it.
@codecov

codecov Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.83721% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 93.45%. Comparing base (7902967) to head (29fd247).

Files with missing lines Patch % Lines
src/Parser/BlockParser.php 98.83% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master     #349      +/-   ##
============================================
+ Coverage     93.40%   93.45%   +0.05%     
- Complexity     4950     5007      +57     
============================================
  Files           118      118              
  Lines         13102    13179      +77     
============================================
+ Hits          12238    12317      +79     
+ Misses          864      862       -2     

☔ 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 e1c7b4d into master Nov 11, 2026
6 checks passed
@dereuromark
dereuromark deleted the fix/div-scan-followup branch November 11, 2026 11:13
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