-
Notifications
You must be signed in to change notification settings - Fork 143
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
bug/panic caused by Vue.js syntax definition #176
Comments
have you tried with the |
@keith-hall Yes, however that produces a different error (which I admittedly haven't looked into very far). Regardless, the syntax mentioned in the issue description does work in Sublime but not in Syntect, so it must be a bug if we aim for 1:1 compatibility, at least. I'll try with the |
oh I completely agree, I just saw that there was a more modern syntax that you could try in the interim, until the bug gets fixed :) |
makes perfect sense :) I will dig further soon and let you know what I find! |
Good news! I've just tried with this again, and the error I initially saw:
It turned out I misunderstood this (I thought it was referencing the yaml macros), and in reality it was just complaining about referencing the Stylus syntax which I needed to convert and add. So the Of course, this is still a valid issue for the reason I mentioned before (1:1 compatibility with Sublime) |
A similar (the same?) bug was reported here for OCaml files. This can be reproduced with test.ml let line_count filename =
let f = open_in filename in
let rec loop count =
match try Some (input_line f) with End_of_file -> None
with
| Some(_) -> loop (count+1)
| None -> count in
loop 0 or minimal.ml: with a -> b The stack trace is the same as above:
|
I managed to create this minimal (?) example that triggers the same error: Consider this Sublime Syntax: %YAML 1.2
---
# http://www.sublimetext.com/docs/3/syntax.html
name: Dummy
file_extensions:
- dummy
scope: source.dummy
contexts:
main:
- match: (?=(foo))
captures:
1: keyword
push:
- match: (foo)
captures:
1: keyword and the following
This will cause syntect to panic with:
This is the content of
I don't understand enough about the internals of syntect and sublime syntax definitions, but I believe this is somehow related to the negative lookahead in the If someone can give a hint / point me in the right direction, I can try to look into this. |
I would guess the problem relates to Oniguruma returning the actual positions of the captured groups inside lookarounds - Sublime Text just ignores them (doesn't scope any text from a capture group inside a lookaround). It may be easier (if Oniguruma doesn't expose this information for us to use at Lines 464 to 482 in 703e679
captures: in the YAML) that should apply to the remaining matched groups, and I guess it wouldn't work if the capture group was used in a backreference... Perhaps just removing duplicate operations would help the concrete case given above?
|
@trishume (Tentatively coming back to a kind offer of you regarding requests like this): It would be really great to have a bugfix release of syntect with the PR by @keith-hall included - just in case you find the time. Most issues are easy to workaround somehow, but a |
@sharkdp done, |
@trishume Thank you very much! |
I am using Zola and am trying to vue syntax highlighting work. I used the
Syntect version is 3.2.0 in zola 0.10.1 |
Hmm, I'm not able to reproduce with adding https://github.com/vuejs/vue-syntax-highlight/blob/6eb71bc6bba5e6a284b6d1d3154484da6f366e21/Vue%20Component.sublime-syntax to the Just to check, do you have a |
I am using zola which uses syntect underneath. Since they don't have a Vue sublime syntax, I am using the Vue syntax is in a different place and the JS syntax is loaded by zola, and therefore that might be causing the issue. But, I am not sure since I don't know how zola works. |
Presumably it works for other people using zola and extra syntaxes. I will try when I get chance. I wonder if it could be useful to add a method to the SyntaxSet which will check if any references couldn't be resolved, and if so, list the ones loaded and the unresolved references, for easier debugging as the current panic message doesn't make it obvious where the problem is. |
I have the site open sourced at https://github.com/pksunkara/pksunkara.github.io. You can easily reproduce the bug if you add |
I was able to replicate this bug with Zola v0.10.1. It seems like Zola stores the "extra_syntaxes" separately from the ones it includes by default, so your custom Vue syntax can't find the default JavaScript syntax. The solution is to copy Zola's So the problem really seems to be #278 |
So, zola 0.11.0 is released and I was trying to see if them including the vue syntax by default fixes the issue. Looks like it does not. There is no error but there is no highlighting either. Does the |
It looks like the JavaScript syntax definition Zola is currently using isn't compatible with syntect atm, because it is using branch points, which aren't supported by this library yet. See #271. Probably worth raising an issue on the Zola repo to downgrade the JS syntax definition for now. |
When trying to highlight Vue.js files using the same syntax file that works well in Sublime, Syntect panics:
(only the bits above
syntect::html::highlighted_snippet_for_string
are relevant)I believe the above is pointing to
syntect/src/highlighting/highlighter.rs
Line 119 in 231eafc
The syntax file I am using is here: vue.sublime-syntax (tmLanguage file here)
This file produces the panic (but highlights fine in ST3 with the same syntax file): https://raw.githubusercontent.com/vuejs/vue-cli/0ba111eed859aad02156e807ef71d0052b2e7f17/packages/%40vue/cli-ui-addon-webpack/src/components/ModuleListItem.vue
This file highlights fine in both Syntect and ST3 with the same syntax file: https://raw.githubusercontent.com/vuejs/vue-cli/0ba111eed859aad02156e807ef71d0052b2e7f17/packages/%40vue/cli-ui-addon-webpack/src/components/ModuleList.vue
The text was updated successfully, but these errors were encountered: