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

Syntax error in tagged code block breaks highlighting outside the code block. #283

Open
nybblr opened this issue May 15, 2019 · 5 comments

Comments

@nybblr
Copy link

nybblr commented May 15, 2019

Hey folks, I'm using vim-pandoc for editing a coding book. Most of the book is incomplete JavaScript code samples. It seems that when there is a syntax error in a marked code snippet — such as a missing parenthesis or curly — it breaks all following syntax highlighting. Here's an example:

# Hello world

Here's a code block with a syntax error:

```javascript
let app = express();
app.use((req, res) => {
  /* ... */
```

When I continue afterwards, the `missing` parenthesis and *curly* break syntax highlighting outside the code block.

Since the book is primarily made of incomplete snippets, it's tricky to workaround and makes it difficult to spellcheck or spot other errors.

Thoughts? Is this a can of worms in Vim's syntax highlighting engine?

@fmoralesc fmoralesc transferred this issue from vim-pandoc/vim-pandoc May 15, 2019
@fmoralesc
Copy link
Member

It seems like this is problematic even for github's markdown parser ;)

Some embedded syntax files can create this kind of conflict, there isn't really anything that can be done as a general fix really (the solution would be to fix the javascript syntax so that it behaves differently when it is embedded, but it's not obvious how do to it...) :(

@alerque
Copy link
Member

alerque commented May 15, 2019

Does vim really not let us limit the scope of any applicable embedded rules based on our rules for where the scope ends?

@fmoralesc
Copy link
Member

Not really. Some cases are just pathological. I remember a case where ruby or perl embeds would cause this sort of thing. The problem is that in some cases the match doesn't terminate, and the highlighting doesn't yield (I think the underlying issue is the same that we have when a rule fails and it ends breaking the rest of the file...).

@alerque
Copy link
Member

alerque commented May 16, 2019

@nybblr Apparently the answer is "this is a can of worms". See also #236.

I poked around a little and it looks like Neovim issue 9876 is one thing to keep an eye on. Also we've talked before about using Pandoc itself to determine the block context, but that would require implementing the change noted in Pandoc issue 4565. Neither of these things help you with your project right now, but we'll be keeping an eye on them for the long term.

@nybblr
Copy link
Author

nybblr commented May 16, 2019

Ooo, I am intrigued, thanks for poking around @alerque.

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

No branches or pull requests

3 participants