fix(tostring): add footnote pattern to LPeg parser for correct table column widths#484
Merged
OXY2DEV merged 1 commit intoOXY2DEV:mainfrom Mar 20, 2026
Conversation
…column widths The tostring module (used for table column width calculation) had no pattern for footnote references like [^1] or [^label]. These were falling through to hyperlink_no_src, which strips [ and ] but keeps the ^ character, producing a width 1 character too wide. Add a dedicated footnote LPeg pattern that: - Matches [^label] syntax (placed before hyperlink in token priority) - Strips [^ and ] delimiters (matching actual renderer behavior) - Looks up footnote config for icon/corner/padding decorations - Returns the correct visual string for width measurement This fixes misaligned table columns for rows containing footnote references.
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.
Problem
The
tostringmodule (lua/markview/renderers/markdown/tostring.lua) is used to compute the visual (post-conceal) width of table cells for column alignment. It had no pattern for footnote references like[^1]or[^label].These fell through to the
hyperlink_no_srcpattern, which strips[and]but keeps the^character, producing a visual string one character too wide.tostringreturned[^1] ^1(width 4) 1(width 3)[^long-descriptive-footnote-name] ^long-descriptive-footnote-name(width 37) long-descriptive-footnote-name(width 36)This caused misaligned columns in any table row containing footnote references.
Fix
Add a dedicated
footnoteLPeg pattern and capture function that:[^label]syntax, placed beforehyperlinkin the token priority list[^and]delimiters, matching the actual renderer behavior (markdown_inline.luaconceals 2 bytes[^and 1 byte])Verification