Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errors when including syntax highlighted vim code block in a note #68

Closed
citizenmatt opened this issue Jun 17, 2014 · 4 comments
Closed

Comments

@citizenmatt
Copy link

If you create a note and type something like:

{{{vim
let g:vim_foo=1
}}}

the code block is correctly highlighted as vim code. However, if you add a new code block with a different language, e.g.

{{{java
}}}

as soon as you hit escape, you see the following errors:

Error detected while processing /usr/local/Cellar/macvim/7.4-73/MacVim.app/Contents/Resources/vim/runtime/syntax/vim.vim:
line  752:
E403: syntax sync: line continuations pattern specified twice
Press ENTER or type command to continue
Error detected while processing function xolox#notes#refresh_syntax..xolox#notes#highlight_sources:
line   21:
E170: Missing :endfor
Press ENTER or type command to continue
Error detected while processing function xolox#notes#refresh_syntax:
line    5:
E171: Missing :endif

and the new code block doesn't get syntax highlighting.

xolox added a commit that referenced this issue Jun 17, 2014
@xolox
Copy link
Owner

xolox commented Jun 17, 2014

Thanks for the clear bug report. This should now be fixed. Happy Vimming!

@xolox xolox closed this as completed Jun 17, 2014
@citizenmatt
Copy link
Author

Wow, that was fast, thanks! I was just about to add a comment - I've been able to work around this error by only calling syntax_include once for each language, but I don't know vim script well enough to produce a decent patch, and my hacked version doesn't handle things nicely if a block is removed and then added again...

BTW, I know the code's MIT, but would you mind if I pinched this code for a PR for vim-markdown (full credit, of course)?

@xolox
Copy link
Owner

xolox commented Jun 17, 2014

I would love to have this feature in Vim's markdown mode but it wasn't high priority enough to ever implement :-] so I would say go for it! I actually have a pull request open for vim-markdown myself (tpope/vim-markdown#9) but it was never merged (my fault), might have to pick that up again soon (I miss it).

Edit: Apparently I was talking about a different vim-markdown, but who cares, pinch it wherever you want, it's MIT ;-)

@citizenmatt
Copy link
Author

Yeah, I've been looking at plasticboy's vim-markdown, which seems to have a few more features than the standard one from Mr Pope. Very cool PR, too, with the conceal features, and very interesting discussion, too. Tricky one to get right...

I've submitted a PR (preservim/vim-markdown#93) for just the syntax highlighting of code blocks, which makes a very nice addition to the formatting of the doc. I've handled the duplicate running of scripts a little differently, only including the new syntax if it's not already included. Seems to work fine.

Thanks for the original code!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants