Skip to content

MD029: fix corrupted output for zero-padded list markers#2124

Open
chatman-media wants to merge 1 commit into
DavidAnson:mainfrom
chatman-media:fix/md029-zero-padded-fix-corruption
Open

MD029: fix corrupted output for zero-padded list markers#2124
chatman-media wants to merge 1 commit into
DavidAnson:mainfrom
chatman-media:fix/md029-zero-padded-fix-corruption

Conversation

@chatman-media

Copy link
Copy Markdown

The autofix works out how many characters to delete by re-stringifying the parsed number (Number(text).toString().length) instead of measuring the actual marker text. For a marker like 08. that gives 1 instead of 2, so the fix only strips the leading 0 and leaves the rest behind — 08. turns into 18. instead of 1.. Only shows up with leading zeros, which the MD029 doc explicitly calls out as supported for uniform indentation.

Fixed by keeping the source text length around instead of recomputing it from the number. Added a fixture with a zero-padded list that reproduces the corruption and confirmed the fixed output re-lints clean.

The autofix computed how many characters to delete by re-stringifying
the parsed numeric value (Number(text).toString().length), not by
measuring the actual marker text. For a marker like "08." that value
is 1 instead of 2, so the fix only removed the leading "0" and left
garbage behind, e.g. "08." -> "18." instead of "1.". This only shows
up with leading zeros, which the docs call out as an explicitly
supported pattern for uniform indentation.

Added a fixture that reproduces it and checked the fix is idempotent
after the change (re-linting the fixed output finds nothing left).
@DavidAnson

Copy link
Copy Markdown
Owner

Thank you! Please review CONTRIBUTING.md, rebase this off of next branch, and say if you used an LLM to produce this PR. I'll review after that - I have some very minor feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants