Skip to content

Preserve medial gaps in ::: | line blocks#244

Merged
dereuromark merged 1 commit into
masterfrom
feature/line-block-medial-gaps
Jun 12, 2026
Merged

Preserve medial gaps in ::: | line blocks#244
dereuromark merged 1 commit into
masterfrom
feature/line-block-medial-gaps

Conversation

@dereuromark

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #243. The LineBlockDivExtension preserved only leading indentation; medial and trailing runs of two or more spaces were collapsed by normal inline parsing - so a verse lost the alignment gaps it depends on.

This is the inconsistency Omikhleia raised on djot#29: a line block whose whole point is significant whitespace should keep the medial gap too, not just the leading indent. The canonical example is the caesura of Old English verse:

::: |
Hwaet! We Gardena    in geardagum
theodcyninga       thrym gefrunon
:::

renders (HTML) with the gaps intact:

<div class="line-block">
<p>Hwaet! We Gardena&nbsp;&nbsp;&nbsp;&nbsp;in geardagum<br>
theodcyninga&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;thrym gefrunon</p>
</div>

Rule

  • Leading whitespace (indentation): always preserved, even a single space (unchanged).
  • Inner / trailing runs of two or more columns (medial gaps, inline alignment): now preserved.
  • A single inner space stays an ordinary, collapsible space, so a long line can still wrap between words.

This matches Pandoc's line-block definition (every space the author writes is significant) while keeping ordinary word spacing wrappable.

Implementation

  • Replaces splitLeadingWhitespace with a single appendLine pass that walks each line, emitting preserved columns via the existing internal non-breaking-space placeholder (U+E000) and inline-parsing the text segments between gaps.
  • Per format: &nbsp; in HTML, real U+00A0 in Markdown (survives round-trip, never read as indented code), ordinary space in plain text / ANSI. Tabs expand to four-column stops.

Docs

  • docs/extensions/index.md: medial-gap rule + Beowulf example.
  • docs/guide/syntax.md: cross-reference updated.

LineBlockDivExtension preserved only leading indentation; medial and
trailing runs of two or more spaces were collapsed by normal inline
parsing. That dropped the alignment gaps verse relies on - the caesura of
Old English verse, aligned columns in an address - exactly the
inconsistency raised on djot#29.

Now preserve every leading run plus any inner or trailing run of two or
more columns as non-breaking spaces; a single inner space stays an
ordinary, collapsible space so long lines can still wrap. Tabs expand to
four-column stops. Renders as a non-breaking space in every format:
&nbsp; (HTML), U+00A0 (Markdown), ordinary space (plain text / ANSI).
@dereuromark dereuromark added documentation Improvements or additions to documentation enhancement New feature or request labels Jun 12, 2026
@codecov

codecov Bot commented Jun 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.05%. Comparing base (6818161) to head (e0076bd).

Additional details and impacted files
@@             Coverage Diff              @@
##             master     #244      +/-   ##
============================================
+ Coverage     92.04%   92.05%   +0.01%     
- Complexity     3559     3566       +7     
============================================
  Files           107      107              
  Lines         10078    10093      +15     
============================================
+ Hits           9276     9291      +15     
  Misses          802      802              

☔ 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 30088b9 into master Jun 12, 2026
6 checks passed
@dereuromark dereuromark deleted the feature/line-block-medial-gaps branch June 12, 2026 15:51
dereuromark added a commit to markup-carve/carve-php that referenced this pull request Jun 12, 2026
Port of php-collective/djot-php#244. The line block preserved only LEADING
indentation; inner and trailing runs of two or more columns (medial gaps -
inline alignment such as the caesura of Old English verse) were collapsed by
normal inline parsing. Now they are preserved too, via the U+E000 placeholder,
while a lone inner space stays an ordinary collapsible space so a long line can
still wrap between words. Matches Pandoc's line-block definition (every space
the author writes is significant) and Omikhleia's point on jgm/djot#29.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant