Menu

#2247 Markdown syntax highlighting confused by indented code block

Bug
closed-fixed
nobody
5
2021-07-26
2021-04-19
R. Polach
No

This problem is seen in Geany 1.36 on Windows 10 (using GTK+ v2.24.32 and GLib
v2.60.6 runtime libraries).

Markdown syntax highlighting is confused, when code block (exactly: the code block's end marks) is indented.
All the text after code block end is blue and ignores all following markdown syntax highlighting.
(When code block's end is not indented, everything is ok.)

Note: The markdown version I use is of pandoc and the indentation is correct according to it -- It is needed (in this example) for making the code block be a part of the list item.

1 Attachments

Discussion

  • Neil Hodgson

    Neil Hodgson - 2021-04-19
    • labels: --> lexilla, markdown
     
  • Neil Hodgson

    Neil Hodgson - 2021-04-19

    Bug reports should include an example file as a text attachment that can be opened in an editor.

    Most likely you are running into code blocks by indentation.
    https://markdown-guide.readthedocs.io/en/latest/basics.html#code-block

     
  • R. Polach

    R. Polach - 2021-04-20

    Adding example file as a text attachment...

     
  • Neil Hodgson

    Neil Hodgson - 2021-04-20
    • status: open --> open-accepted
     
  • Robert Di Pardo

    Robert Di Pardo - 2021-06-29

    I've patched what I think was causing the issue; namely, code fences between multiple backticks could begin anywhere [1], but could only terminate at margins or inline because preceding whitespace was disallowed:

            if (sc.state == SCE_MARKDOWN_CODE2) {
                if (sc.Match("``") && sc.GetRelative(-2) != ' ') {
    

    I've removed the whitespace check.

    Note that a third consecutive backtick is not significant; everything after the second backtick will be styled as SCE_MARKDOWN_CODE2 regardless.

    Because only two backticks are needed to mark the end, the final token wasn't being styled like the rest:

    Lex-Markdown-unpatched-code-fence

    This has also been fixed.

    There was another problem with the rules for SCE_MARKDOWN_CODE. As with italics, an inline code cell should be completely delimited before it's styled:

    Lex-Markdown-unpatched-inline-code

    I've amended inline code styling as was done for italics:

    Lex-Markdown-patched-inline-code


    [1]: As for code fences within triple tildes (~~~), the rules are already consistent: the only place they can appear is at the margin, after a blank line.

     
  • Neil Hodgson

    Neil Hodgson - 2021-06-30
    • status: open-accepted --> open-fixed
     
  • Neil Hodgson

    Neil Hodgson - 2021-07-26
    • status: open-fixed --> closed-fixed
     

Log in to post a comment.