fix: keep the padding under the widest list marker - #371
Merged
Conversation
`LIST_ITEM_HEAD_LENGTH` was the length of the longest marker CommonMark reads and the widest padding after it, which is one character short of what reading that padding needs. The run is measured against the character that ends it rather than against its own length, because a run of five or more spaces opens indented code inside the item and leaves the content one space past the marker, and the lookahead expressing that has nothing to look at when the head stops on the last space of the run. Only a nine-digit ordered marker followed by four spaces reaches that boundary; every shorter marker leaves the head with a content character to spare.
Azganoth
force-pushed
the
bug/widest-marker-padding
branch
from
September 2, 2026 18:26
a2af30a to
47da15c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
An ordered list item written with a nine-digit marker and four spaces before its content came back with one space.
That is the single marker-and-padding combination
leafdownListFormcould not read,and it is a boundary of the padding preservation #317 delivered rather than a class of its own.
LIST_ITEM_HEAD_LENGTHwas 14: nine digits, a delimiter, and four spaces,which is the longest marker CommonMark reads together with the widest run it reads as padding after it.
Reading that run needs one character more than writing it does.
LIST_ITEM_PADDING_PATTERNmeasures the run against the character that ends it,/^ {1,4}(?=[^\t\n\r ])/u,because five or more spaces open indented code inside the item and leave the content one space past the marker;
the lookahead is what separates the two.
At the boundary the head stopped on the last space of the run, the lookahead had nothing to look at,
and the padding fell back to the default of one space.
The head now reaches one character past the widest marker and padding together.
Related Issue
Closes #369
Verification
markdownCompatibility.test.tsgains two rows to the group asserting an item's marker padding.The widest marker carrying the widest padding fails on the pre-change source;
the row one space short of it passes, which is what makes the pair a guard rather than a restatement of the fix.
The extra character can only reach an item whose marker and padding together are exactly the old head length,
and a nine-digit ordered marker is the only marker long enough to get there.
That was measured rather than reasoned, by driving the editor mount used by the plugin tests over the neighbouring cases, none of which moved:
Those neighbours are covered by the existing rows in the same group and by
corpusRoundTrip.test.ts,so they are not added again as committed rows; the list above records what the boundary change was checked against.
The frontend checks pass.
Not verified: the five-space rows still round-trip differently, because indented code inside a list item is rewritten as a fenced block.
That is an open class under #251 and is untouched here —
only the padding those items are written at was in question, and it is correct.
Notes
The behavior this restores is promised by an entry already sitting in
Unreleased, from fix: keep the marker and numbers a list was authored with #355:"The spaces between a marker and its content are kept too."
No released version has the working behavior, so no user met the defect,
and a second entry would describe a fix to something that never shipped.
docs/specification.mdalready states the rule correctly underSerialization And Outputand needed no edit.the task marker is read from the slice between an item's marker and its content,
while the head length this changes bounds only the marker and padding read.