8000 fix(vue): handle more edge cases for tags by Gusted · Pull Request #1069 · alecthomas/chroma · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix(vue): handle more edge cases for tags #1069

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

Merged
merged 1 commit into from
Apr 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments. 8000
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 9 additions & 21 deletions lexers/embedded/vue.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,25 +64,13 @@
<rule pattern="(-)([\w]+)">
<token type="NameTag"/>
</rule>
<rule pattern="(@[\w]+)(=&#34;[\S]+&#34;)(&gt;)">
<rule pattern="(@[\w.]+)(=&#34;.*?&#34;)?(\/?&gt;|\s)">
<bygroups>
<token type="NameTag"/>
<token type="LiteralString"/>
<token type="Punctuation"/>
</bygroups>
</rule>
<rule pattern="(@[\w]+)(=&#34;[\S]+&#34;)">
<bygroups>
<token type="NameTag"/>
<token type="LiteralString"/>
</bygroups>
</rule>
<rule pattern="(@[\S]+)(=&#34;[\S]+&#34;)">
<bygroups>
<token type="NameTag"/>
<token type="LiteralString"/>
</bygroups>
</rule>
<rule pattern="(:[\S]+)(=)(&#34;[\S]+&#34;)">
<bygroups>
<token type="NameTag"/>
Expand All @@ -96,31 +84,31 @@
<rule pattern="(v-b-[\S]+)">
<token type="NameTag"/>
</rule>
<rule pattern="(v-[\w]+)(=&#34;.+)([:][\w]+)(=&#34;[\w]+&#34;)(&gt;)">
<rule pattern="(v-[\w-]+)(=)(&#34;[\S ]+&#34;)(\/?&gt;|\s)">
<bygroups>
<token type="NameTag"/>
<token type="LiteralString"/>
<token type="NameTag"/>
<token type="Operator"/>
<token type="LiteralString"/>
<token type="Punctuation"/>
</bygroups>
</rule>
<rule pattern="(v-[\w]+)(=)(&#34;[\S ]+&#34;)(&gt;|\s)">
<rule pattern="(v-[\w-]+)(\/?&gt;|\s)">
<bygroups>
<token type="NameTag"/>
<token type="Operator"/>
<token type="LiteralString"/>
<token type="Punctuation"/>
</bygroups>
</rule>
<rule pattern="(v-[\w]+)(&gt;)">
<rule pattern="(v-[\w-]+)(=&#34;.+&#34;)(\/?&gt;|\s)">
<bygroups>
<token type="NameTag"/>
<token type="LiteralString"/>
<token type="Punctuation"/>
</bygroups>
</rule>
<rule pattern="(v-[\w]+)(=&#34;.+&#34;)(&gt;)">
<rule pattern="(v-[\w-]+)(=&#34;.+)([:][\w]+)(=&#34;[\w]+&#34;)(\/?&gt;|\s)">
<bygroups>
<token type="NameTag"/>
<token type="LiteralString"/>
<token type="NameTag"/>
<token type="LiteralString"/>
<token type="Punctuation"/>
Expand Down
11 changes: 11 additions & 0 deletions lexers/testdata/vue.actual
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,17 @@
</ul-extendded>
</template>

<template v-else>
<svg-icon v-if="isViewTag">
<svg-icon v-else-if="isViewTree" name="octicon-git-commit"/>
<svg-icon v-else name="octicon-git-branch"/>
</template>
<template>
<input type="hidden" name="_csrf" :value="csrfToken">
<a @click.stop>
<button @click="menuVisible = !menuVisible" @keyup.enter="menuVisible = !menuVisible"/>
</template>

<script>
export default {
name: "MyButton"
Expand Down
76 changes: 76 additions & 0 deletions lexers/testdata/vue.expected
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,82 @@
{"type":"Punctuation","value":"\u003e"},
{"type":"Text","value":"\n\n"},
{"type":"Punctuation","value":"\u003c"},
{"type":"NameTag","value":"template"},
{"type":"Text","value":" "},
{"type":"NameTag","value":"v-else"},
{"type":"Punctuation","value":"\u003e"},
{"type":"Text","value":"\n\t"},
{"type":"Punctuation","value":"\u003c"},
{"type":"NameTag","value":"svg-icon"},
{"type":"Text","value":" "},
{"type":"NameTag","value":"v-if"},
{"type":"Operator","value":"="},
{"type":"LiteralString","value":"\"isViewTag\""},
{"type":"Punctuation","value":"\u003e"},
{"type":"Text","value":"\n\t"},
{"type":"Punctuation","value":"\u003c"},
{"type":"NameTag","value":"svg-icon"},
{"type":"Text","value":" "},
{"type":"NameTag","value":"v-else-if"},
{"type":"Operator","value":"="},
{"type":"LiteralString","value":"\"isViewTree\" name=\"octicon-git-commit\""},
{"type":"Punctuation","value":"/\u003e"},
{"type":"Text","value":"\n\t"},
{"type":"Punctuation","value":"\u003c"},
{"type":"NameTag","value":"svg-icon"},
{"type":"Text","value":" "},
{"type":"NameTag","value":"v-else"},
{"type":"Punctuation","value":" "},
{"type":"NameAttribute","value":"name"},
{"type":"Operator","value":"="},
{"type":"LiteralString","value":"\"octicon-git-branch\""},
{"type":"Punctuation","value":"/\u003e"},
{"type":"Text","value":"\n"},
{"type":"Punctuation","value":"\u003c/"},
{"type":"NameTag","value":"template"},
{"type":"Punctuation","value":"\u003e"},
{"type":"Text","value":"\n"},
{"type":"Punctuation","value":"\u003c"},
{"type":"NameTag","value":"template"},
{"type":"Punctuation","value":"\u003e"},
{"type":"Text","value":"\n\t"},
{"type":"Punctuation","value":"\u003c"},
{"type":"NameTag","value":"input"},
{"type":"Text","value":" "},
{"type":"NameAttribute","value":"type"},
{"type":"Operator","value":"="},
{"type":"LiteralString","value":"\"hidden\""},
{"type":"Text","value":" "},
{"type":"NameAttribute","value":"name"},
{"type":"Operator","value":"="},
{"type":"LiteralString","value":"\"_csrf\""},
{"type":"Text","value":" "},
{"type":"NameTag","value":":value"},
{"type":"Operator","value":"="},
{"type":"LiteralString","value":"\"csrfToken\""},
{"type":"Punctuation","value":"\u003e"},
{"type":"Text","value":"\n\t"},
{"type":"Punctuation","value":"\u003c"},
{"type":"NameTag","value":"a"},
{"type":"Text","value":" "},
{"type":"NameTag","value":"@click.stop"},
{"type":"Punctuation","value":"\u003e"},
{"type":"Text","value":"\n "},
{"type":"Punctuation","value":"\u003c"},
{"type":"NameTag","value":"button"},
{"type":"Text","value":" "},
{"type":"NameTag","value":"@click"},
{"type":"LiteralString","value":"=\"menuVisible = !menuVisible\""},
{"type":"Punctuation","value":" "},
{"type":"NameTag","value":"@keyup.enter"},
{"type":"LiteralString","value":"=\"menuVisible = !menuVisible\""},
{"type":"Punctuation","value":"/\u003e"},
{"type":"Text","value":"\n"},
{"type":"Punctuation","value":"\u003c/"},
{"type":"NameTag","value":"template"},
{"type":"Punctuation","value":"\u003e"},
{"type":"Text","value":"\n\n"},
{"type":"Punctuation","value":"\u003c"},
{"type":"NameTag","value":"script"},
{"type":"Punctuation","value":"\u003e"},
{"type":"Text","value":"\n "},
Expand Down
0