-
Notifications
You must be signed in to change notification settings - Fork 27
Description
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
scintillua/lexers/markdown.lua
Line 36 in 0c92946
| local code_inline = lpeg.Cmt(lpeg.C(P('`')^1), function(input, index, bt) |
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.
local code_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)
if not e and (#bt % 2 == 0) then return index end --<<<<< New line <<<<<<
return (e or #input) + 1
end)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.