Skip to content

Match djot.js on attributes before reference-like lines, marker-line attributes, empty raw blocks and trailing backslash-space - #351

Merged
dereuromark merged 2 commits into
masterfrom
fix/small-conformance-leftovers
Nov 11, 2026
Merged

dereuromark merged 2 commits into
masterfrom
fix/small-conformance-leftovers

Conversation

@dereuromark

@dereuromark dereuromark commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Four small conformance leftovers from the deep-dive fix lanes, plus two adjacent cases the differential sweep found in the same code paths. Output checked against djot.js.

Attribute block before a reference-like line (F24)

A single-line block attribute followed by a [label]: line was dropped unless warnings or implicit heading references turned reference collection on, so the output depended on the warnings option. The attributes are now always queued; a real reference definition consumes them, anything else receives them.

Input:

{.c}
[r]: p q

Before (warnings off):

<p>[r]: p q</p>

After (warnings on or off), as djot.js:

<p class="c">[r]: p q</p>

{y} (the boolean-attribute extension) now gives <p y="">[r]: p q</p> in both modes.

Marker-line attributes over an indented line (F21)

A tight item whose marker line holds {...} sent its lines to the inline parser, so the attribute became an inline one with no target and left a leading soft break. The item lines now go through the block parser, which reads the attribute as a block attribute.

Input:

- {#t .p}
 x

- b

Before:

<ul>
<li>
<p>
x</p>
</li>
<li>
<p>b</p>
</li>
</ul>

After, as djot.js:

<ul>
<li>
<p id="t" class="p">x</p>
</li>
<li>
<p>b</p>
</li>
</ul>

In a tight list (- {#t .p} then x) the paragraph keeps its <p> because it carries attributes, the existing tight-item policy pinned by TightItemParagraphsTest; before, it printed an empty line.

Empty raw block (F25)

A raw block with no lines and one with only blank lines were both stored as "", and the renderer added a newline to both. A blank-only block now keeps its newlines and an empty one renders nothing. Blank lines around real content are still trimmed (pinned by BlockParserTest::testRawBlockTrimsLeadingAndTrailingBlankLines).

Input:

```=html

Before: one empty line. After, as djot.js: no output.

Input:

```=html


```

Before: one empty line. After: two, as djot.js.

Backslash before trailing whitespace at the end of a block

The djot syntax reference: "Backslash before a newline (or before spaces or tabs followed by a newline) is parsed as a hard line break." The last line of a block has no newline left after parsing, so the escape became a non-breaking space. The end of the parsed text now counts as a line end at the top inline level; table cells (text ends at |) and nested inline text (link text) keep the non-breaking space, as in djot.js.

Input (trailing space after the backslash):

x \ 

Before:

<p>x &nbsp;</p>

After, as djot.js:

<p>x<br>
</p>

Found by the sweep, same code paths

A backslash before a tab inside a line was dropped; djot.js keeps it literal (a tab is not escapable).

x\	y

Before <p>x y</p>, after <p>x\ y</p>.

An escaped space in a heading leaked into the id: # x \ y gave id="x-&nbsp;y", now id="x-y" as djot.js.

Verification

  • Every fix has a regression test and a perturbed variant in SmallConformanceLeftoversTest; each fails with its fix reverted. Every case is asserted with warnings off and on.
  • Differential sweep against djot.js, 2 x 1,600 generated documents around these shapes (attribute and reference-line mixes, marker types and indents, raw fences and blank lines, backslash plus whitespace in paragraphs, headings, items, quotes, cells, links): agreement 806 -> 1118 and 822 -> 1109, 0 regressions, output identical with warnings on and off. The remaining differences are the boolean-attribute extension, orphan captions, : definition terms, the trimmed blank lines around raw content, and lazy lines after a reference definition inside a container (pre-existing, unchanged).
  • Timing (best of 5, loaded machine): 2 KB 2.7 -> 3.1 ms, 8 KB 10.4 -> 11.4 ms, 32 KB 42.8 -> 47.2 ms, linear.

Codex review (medium): "I found no actionable regressions in the diff. The test suite passes."

…attributes, empty raw blocks and trailing backslash-space

- A single-line block attribute followed by a [label]: line is always
  queued; a real definition consumes it, otherwise the next block gets it.
  Before, it was dropped unless warnings or implicit heading references
  turned reference collection on.
- A tight list item whose marker line holds {...} parses its lines as
  blocks, so the attributes reach the paragraph below instead of leaving
  a leading soft break.
- A raw block with only blank lines keeps them; an empty raw block
  renders nothing.
- A backslash before trailing spaces or tabs at the end of a block's
  last line is a hard break, as the syntax reference says. Table cells
  and nested inline text keep the non-breaking space.
…te heading id words

djot.js leaves a backslash before a tab that does not end the line as
literal text; the parser dropped the backslash. An escaped space
(non-breaking space) in a heading leaked into the generated id as
&nbsp; instead of separating the words like any other space.
@dereuromark dereuromark added the bug Something isn't working label Nov 11, 2026
@codecov

codecov Bot commented Nov 11, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 82.35294% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.52%. Comparing base (709058d) to head (a7db092).

Files with missing lines Patch % Lines
src/Renderer/MarkdownRenderer.php 0.00% 2 Missing ⚠️
src/Renderer/AnsiRenderer.php 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master     #351      +/-   ##
============================================
+ Coverage     93.50%   93.52%   +0.01%     
- Complexity     5057     5060       +3     
============================================
  Files           118      118              
  Lines         13243    13246       +3     
============================================
+ Hits          12383    12388       +5     
+ Misses          860      858       -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 544860e into master Nov 11, 2026
5 of 6 checks passed
@dereuromark
dereuromark deleted the fix/small-conformance-leftovers branch November 11, 2026 11:54
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