vim-pandoc / vim-pandoc-legacy

[UNSUPPORTED/use vim-pandoc/vim-pandoc] vim bundle for pandoc users
143 stars 23 forks source link

Working with multiple syntax files #42

Open fncll opened 12 years ago

fncll commented 12 years ago

I don't know if this is possible with vim-pandoc, but some syntax files can work alongside others, for instance set ft=php.html, and properly highlight the embedded code. It would be nice if Pandoc could do that too... often I work with code destined to be HTML but which has PHP code embedded. However, it seems I have to choose one syntax file or the other because, with both, only the first listed has any effect.

I guess this is really a feature suggestion. Sorry if this is not where such things go...

dsanson commented 12 years ago

The existing syntax/pandoc.vim file does support embedded HTML, using the HTML syntax file. One thing it does not support currently is highlighting of code blocks based on the {.lang} attribute.

But maybe I'm not understanding what you are after. Is it that you want to embed pandoc into php, with something like php.pandoc?

fncll commented 12 years ago

Yes: I work on my web pages in Markdown, but as it is destined ultimately to be converted to HTML, it also has PHP code in the same file. So being able to use ft=php.pandoc would be very useful.

fncll commented 12 years ago

Also, I'm not sure what I am doing wrong (if I understand your comment about embedded html) because set ft=pandoc.html doesn't do anything to give syntax coloring to HTML in my markdown document and the reverse only colors the html sections.

dsanson commented 12 years ago

Hmm.

Looks like embedded HTML sort of works for me, but not really. Embedded LaTeX highlight is working fine, though. Neither requires adding a suffix to the filetype. Embedded HTML highlighting will be disabled if you set g:pandoc_no_spans = 1 for performance reasons.

Here's the bug: the only time HTML gets highlighted is when it occurs on a new line, proceeded by whitespace. So in the following example, the tag gets highlighted on the first line, but nothing else works.

  <a href="test">test</a>
<a href="test">test</a>
A link <a href="test">test</a>

So that clearly needs to be fixed. I looked at the syntax file and honestly I'm not sure what is going wrong. The regex seems to match tags that occur anywhere on a line. But maybe Felipe will have more insight.

I'm not sure what would need to be done to make the pandoc filetype "compatible" with other filetypes. I take it that goes beyond just syntax highlighting, and relates to snippets and autocompletion and all the rest. But if it can be done it sounds like a good idea.

dsanson commented 12 years ago

Okay. Just verified that the embedded HTML works both with the included markdown syntax file and with plasticboy's markdown mode.

The obvious difference between standard markdown and pandoc markdown is that pandoc allows markdown within html tags, e.g., <a href="test">*test*</a>. Perhaps that is the root of the problem here.