You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Open textadept 12.4, on the menu go to Tools > Quick Open > Quickly Open Textadept Home.
Select docs/api.md from the filter list and click OK to open it.
Go to line 7533, which is under the heading for textadept.editing.auto_pairs.
On line 7533 there's a pair of empty backticks, after them the text is styled incorrectly, as though the rest of the text is inside a code block. It's easier to see if you're using a dark theme.
The problem is in the code_inline LPEG pattern in lexers/markdown.lua on line 36. Here
The pattern matches any number of leading backticks and then calls a function to determine where the inline code ends. However it interprets any even number sequence of empty backticks as an un-closed region of inline code. Adding an if statement to handle those edge cases fixes the issue. See the new line in the example fix below.
localcode_inline=lpeg.Cmt(lpeg.C(P('`')^1), function(input, index, bt)
-- `foo`, ``foo``, ``foo`bar``, `foo``bar` are all allowed.local_, e=input:find('[^`]' ..bt..'%f[^`]', index)
ifnoteand (#bt%2==0) thenreturnindexend--<<<<< New line <<<<<<return (eor#input) +1end)
When you test this, other interactions with the code_line and code_block LPEG patterns can make it difficult to determine which pattern is causing which styling, but the above fix does work as intended as far as I can tell.
Thanks for all the time you've spent developing Textadept.
The text was updated successfully, but these errors were encountered:
jxzwp
changed the title
Markdown lexer, code_inline not closed for empy backtick pairs
Markdown lexer, code_inline not closed for empty backtick pairs
Jul 12, 2024
Thanks so much for the detailed report and potential fix.
I'm torn on this one because a `` sequence is most likely the beginning of a code sequence. What you found is a product of an HTML generation bug (there should probably be an escape of some sort). However, as you point out, the unfortunate side effect is highlighting the rest of the document incorrectly, so a fix seems reasonable here.
I'll look into fixing the HTML generation bug first. Then I may circle back to this.
For what it's worth, the Markdown lexer is ripe for another refactor. I have a number of issues with it...
Open textadept 12.4, on the menu go to Tools > Quick Open > Quickly Open Textadept Home.
Select docs/api.md from the filter list and click OK to open it.
Go to line 7533, which is under the heading for
textadept.editing.auto_pairs
.On line 7533 there's a pair of empty backticks, after them the text is styled incorrectly, as though the rest of the text is inside a code block. It's easier to see if you're using a dark theme.
The problem is in the
code_inline
LPEG pattern in lexers/markdown.lua on line 36. Herescintillua/lexers/markdown.lua
Line 36 in 0c92946
The pattern matches any number of leading backticks and then calls a function to determine where the inline code ends. However it interprets any even number sequence of empty backticks as an un-closed region of inline code. Adding an if statement to handle those edge cases fixes the issue. See the new line in the example fix below.
When you test this, other interactions with the
code_line
andcode_block
LPEG patterns can make it difficult to determine which pattern is causing which styling, but the above fix does work as intended as far as I can tell.Thanks for all the time you've spent developing Textadept.
The text was updated successfully, but these errors were encountered: