Skip to content

fix(tostring): handle strikethrough markers in visual width calculation#514

Merged
OXY2DEV merged 2 commits into
OXY2DEV:mainfrom
ImmanuelHaffner:fix-tostring-strikethrough-width
Jul 3, 2026
Merged

fix(tostring): handle strikethrough markers in visual width calculation#514
OXY2DEV merged 2 commits into
OXY2DEV:mainfrom
ImmanuelHaffner:fix-tostring-strikethrough-width

Conversation

@ImmanuelHaffner

Copy link
Copy Markdown
Contributor

Strikethrough delimiters (~~text~~) are concealed by the renderer, but the column-width calculation in renderers/markdown/tostring.lua didn'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.strikethrough handler plus an LPEG strike pattern to strip the ~~ delimiters, matching how ==highlight== is already handled.

A test fixture (test/tostring_strikethrough_width.md) is included, in the same style as test/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.

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.
@OXY2DEV OXY2DEV merged commit f92c0fd into OXY2DEV:main Jul 3, 2026
1 check passed
@ImmanuelHaffner ImmanuelHaffner deleted the fix-tostring-strikethrough-width branch July 3, 2026 18:43
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