1

I recently upgraded to vim 8.2.0100 on Mac, and the markdown highlighting appears to have changed to be buggy.

Here is an example:

Normal syntax *Highlighting has started* Highlight continues
Highlight continues...

meaning the second * does not stop the highlighting on italics.

I see that echo &filetype returns markdown, and that :scriptnames includes (among many other files) /usr/local/Cellar/vim/8.2.0100/share/vim/vim82/syntax/markdown.vim

In the markdown syntax file, I see:

" start matches a non-whitespace character if preceeded by a * OR a * followed by a non-whitespace character.
" end   matches a non-whitespace character if preceeded by a * OR a * followed by a non-whitespace character
exe 'syn region markdownItalic matchgroup=markdownItalicDelimiter start="\S\@<=\*\|\*\S\@=" end="\S\@<=\*\|\*\S\@=" skip="\\*" contains=markdownLineStart,@Spell' . s:concealends

The comments are my own attempt to understand the syntax.

I have tried changing it a bunch, including just setting start="ic" and end="xc", but that doesn't work; I have the same problem where the start turns on the highlighting, but the end fails to turn it off.

This happens even with vim <filename> -u NONE (after I set the filetype to markdown and turn on syntax), meaning my .vimrc is not related

What am I missing in how to edit syntax files, or why doesn't the end get any matches?

Edit: I have noticed that it also does not work with Bold (**Bold**), and the bold will continue on through the rest of the document. Other segments, notably ```, do stop their changes.

3

Turns out it's just broke in 8.2.0100.

Here's the committed fix: https://github.com/tpope/vim-markdown/commit/e875717243fbea38189f5590a25a05809f03672b

The problem was with the skip="\\*". It was supposed to match the literal characters \*, so that you could display a literal * in markdown. However, \\ makes a literal \, so he was instead skipping any amount of \ characters, which included 0 backslash characters, which meant "skip everything". \\\* instead matches a literal \*, which is what you should write to display a literal * in your markdown output.

TL;DR: Change all instances of skip="\\*" in markdown.vim to skip="\\\*" and everything works.

| improve this answer | |
  • 1
    Yah, I emailed Tim Pope about it when I noticed. It should make it to the next upstream release. – D. Ben Knoble Jan 14 at 23:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.