-
Notifications
You must be signed in to change notification settings - Fork 3
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
Rewrite lexer to better match Vue code #2
base: master
Are you sure you want to change the base?
Conversation
Could it be that pygments' JavaScript lexer does not know that Also the Travis CI setup seems to be broken. |
It's the periods in This passes just fine: def test_lexing_directive_vfor(self):
lexer = lexers.get_lexer_by_name('vue')
tokens = lexer.get_tokens('''
<path v-for="link in graph" :key="link">
''')
self.assertEqual (self.__filter_tokens (tokens), [
(Token.Punctuation, '<'),
(Token.Name.Tag, 'path'),
(Token.Name.Tag, 'v-for'),
(Token.Literal.String, '="link in graph" '),
(Token.Name.Tag, ':key'),
(Token.Literal.String, '="link"'),
(Token.Punctuation, '>')
]) Want to update the lexer to account for those? What's wrong with the Travis config? |
Yes, I can give it a try.
Bad luck: I randomly looked at the build for Python 3.3 which is not available anymore.
The other builds work just fine. :)
… Am 25.10.2019 um 16:58 schrieb Michael Herman ***@***.***>:
@lksnmnn <https://github.com/lksnmnn>
It's the periods in graph.links and link.id and the trailing forward slash at the end.
This passes just fine:
def test_lexing_directive_vfor(self):
lexer = lexers.get_lexer_by_name('vue')
tokens = lexer.get_tokens('''
<path v-for="link in graph" :key="link">
''')
self.assertEqual (self.__filter_tokens (tokens), [
(Token.Punctuation, '<'),
(Token.Name.Tag, 'path'),
(Token.Name.Tag, 'v-for'),
(Token.Literal.String, '="link in graph" '),
(Token.Name.Tag, ':key'),
(Token.Literal.String, '="link"'),
(Token.Punctuation, '>')
])
Want to update the lexer to account for those?
What's wrong with the Travis config?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub <#2?email_source=notifications&email_token=ABGAT5OXDV4SS4BJ6QADFRLQQMCSLA5CNFSM4JFB43JKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOECITXGI#issuecomment-546388889>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/ABGAT5KLF6MJ6AHF2SLGLZLQQMCSLANCNFSM4JFB43JA>.
|
I believe I just fixed the error for the object accessor dots. But I think the trailing slash is not as simple to fix. If it is matched, I need to Also I removed 3.3 from the travis config. |
I'd like to remove these Python versions:
Thoughts? |
I believe so. |
Actually, this will capture the trailing forward slash:
def test_trailing_forward_slash(self):
lexer = lexers.get_lexer_by_name('vue')
tokens = lexer.get_tokens('''
<path />
''')
self.assertEqual (self.__filter_tokens (tokens), [
(Token.Punctuation, '<'),
(Token.Name.Tag, 'path'),
(Token.Punctuation, '/'),
(Token.Punctuation, '>'),
]) I think it's probably the order of the lexers now. The |
My fix took care of the dot (it was missing in the longest matcher for a I played a little bit around with the regex and it seems to me that the issue is, that all the special v-xyz matchers must match a Edit: When I remove this from all of the matchers, some other tests fail to match strings in between tags (like: test . the tester expects "test" to be an attribute (which is not correct imo? should be matched to Text, compare: https://github.com/dagwieers/pygments/blob/master/pygments/lexers/html.py) So there is a deeper issue here. Edit2: I think I got it now. I think the right way to this, would be to just extend tag and attribute matchers to allow for v-words, @s and colons to match as attributes. And whatever special syntax vue brings. I think this would slim down the current token list a lot. For now I can highlight my code with this fix, but after I am done with my thesis, I may dive back into this and fix it for good :) Edit3: I got started doing this, but I am stuck now, matching the inner HTML of a tag to text, like so: |
Hm. One weird thing you maybe could help me with is, that I installed my updated version, but pygmentize seems to use the old version somehow. When I remove it from When I add my test file to the unit tests, it tokenizes the code correctly!
Edit: I think this change is on a good way. What we need to add is different highlighting for normal attributes (without a directive or binding) and I'd wished for nicer expression highlighting within directives or bindings. If we want it super clean, the above mentionend separation between template, render and script should be made imho. |
Just getting caught up on this. I'm a little confused on what else needs to be done. |
I Maybe you can have a look and let me know if this going in the right direction :)
|
Hi there,
this PR just adds a failing test case for matching the
v-for
directive correctly.Cheers,
Lukas
Test output