Note that there are some explanatory texts on larger screens.

plurals
  1. POVim Markdown highlighting (list items and code block conflicts)
    primarykey
    data
    text
    <p>I decide to learn more about vim and its syntax highlighting. Using examples for others, I am creating my own syntax file for Markdown. I have seen <a href="http://www.vim.org/scripts/script.php?script_id=1242" rel="noreferrer">mkd.vim</a> and it has this problem too. My issue is between list items and code block highlighting.</p> <p>Code Block <a href="http://daringfireball.net/projects/markdown/syntax#precode" rel="noreferrer">definition</a>:</p> <ul> <li>first line is blank</li> <li>second line begins with at least 4 spaces or 1 tab</li> <li>block is finished with a blank line</li> </ul> <p>Example:</p> <pre><code>Regular text this is code, monospaced and left untouched by markdown another line of code Regular Text </code></pre> <p>My Vim syntax for code block:</p> <pre><code>syn match mkdCodeBlock /\(\s\{4,}\|\t\{1,}\).*\n/ contained nextgroup=mkdCodeBlock hi link mkdCodeBlock comment </code></pre> <p>Unorder List item <a href="http://daringfireball.net/projects/markdown/syntax#list" rel="noreferrer">definition</a>:</p> <ul> <li>first line is blank</li> <li>second line begins with a [-+*] followed by a space</li> <li>the list is finished with a blank line then a normal (non-list) line</li> <li>in between line items any number of blank lines can be added</li> <li>a sub list is specified by indenting (4 space or 1 tab)</li> <li>a line of normal text after a list item is include as a continuation of that list item</li> </ul> <p>Example:</p> <pre><code>Regular text - item 1 - sub item 1 - sub item 2 - item 2 this is part of item 2 so is this - item 3, still in the same list - sub item 1 - sub item 2 Regular text, list ends above </code></pre> <p>My Vim syntax for unorder list item definition (I only highlight <code>[-+*]</code>):</p> <pre><code>syn region mkdListItem start=/\s*[-*+]\s\+/ matchgroup=pdcListText end=".*" contained nextgroup=mkdListItem,mkdListSkipNL contains=@Spell skipnl syn match mkdListSkipNL /\s*\n/ contained nextgroup=mkdListItem,mkdListSkipNL skipnl hi link mkdListItem operator </code></pre> <p>I cannot get the highlighting to work with the last two rule for list and with a code block.</p> <p>This is an example that breaks my syntax highlighting:</p> <pre><code>Regular text - Item 1 - Item 2 part of item 2 - these 2 line should be highlighted as a list item - but they are highlighted as a code block </code></pre> <p>I currently cannot figure out how to get the highlighting to work the way I want it too</p> <hr> <p>Forgot to add a "global" syntax rule used in both rules listed below. It is to ensure a that they start with a blank line.</p> <pre><code>syn match mkdBlankLine /^\s*\n/ nextgroup=mkdCodeBlock,mkdListItem transparent </code></pre> <hr> <p>Another Note: I should have been more clear. In my syntax file, the List rules appear before the Blockquote Rules</p> <hr>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload