fix(tostring): handle strikethrough markers in visual width calculation#514
Merged
OXY2DEV merged 2 commits intoJul 3, 2026
Merged
Conversation
Add strikethrough handler to strip ~~ markers when computing visual text width. Without this, ~~text~~ in table cells inflated column widths by 4 extra characters (2 per marker pair). - Add md_str.strikethrough() to strip ~~ delimiters - Add LPEG strike pattern for ~~content~~ syntax - Register strike in the token alternatives
Repro for the strikethrough width fix: without stripping ~~ markers in renderers/markdown/tostring.lua, each ~~text~~ span inflated the computed column width by 4, drifting the right border. This fixture mirrors test/tostring_word_attached_emphasis.md: strikethrough rows should align with the plain control rows. Covers single/multiple spans, mixing with bold/italic/code, and escaped/single tildes staying literal.
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.
Strikethrough delimiters (
~~text~~) are concealed by the renderer, but the column-width calculation inrenderers/markdown/tostring.luadidn't strip them. Each~~pair added 2 characters (4 per span) to the computed width, so table columns containing strikethrough were over-wide and the right border drifted.This adds an
md_str.strikethroughhandler plus an LPEGstrikepattern to strip the~~delimiters, matching how==highlight==is already handled.A test fixture (
test/tostring_strikethrough_width.md) is included, in the same style astest/tostring_word_attached_emphasis.md: strikethrough rows should align with the plain control rows. It covers single/multiple spans, mixing with bold/italic/code, and escaped/single tildes staying literal.