Question

vim's default syntax highlighting for markdown is based on vanilla markdown, which considers every tab or four-space indented line to be the beginning of a code block. From markdown.vim:

syn region markdownCodeBlock start="    \|\t" end="$" contained

However, I use kramdown, which allows for footnotes (as do some others, such as Pandoc, Markdown Extra, and MultiMarkdown). I've come up with this rule modification to allow for syntax highlighting and spell checking within footnotes but not code blocks:

syn region markdownCodeBlock start="\(\[\^.*\]:\n\)\@<!    \|\t" end="$" contained

It's less than perfect, however, because it doesn't allow footnotes to start on the same line as their instantiation, doesn't allow for code blocks inside footnotes, and doesn't allow for multi-paragraph footnotes. Any suggestions for how to do this better?

Was it helpful?

Solution

You can use vim-pandoc. It doesn't correctly highlight code inside footnotes, but addresses the rest of those issues. Unfortunately, it doesn't work great with some other less common parts of kramdown syntax (such as tables), so it's not a perfect fix.

Its default setting uses vim's conceal feature extensively; if you don't like this, you can turn it off:

:set cole=0
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top