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

Vue: Handle more edge cases #950

Merged
merged 1 commit into from Apr 1, 2024
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 6 additions & 4 deletions lexers/embedded/vue.xml
Expand Up @@ -83,9 +83,10 @@
<token type="LiteralString"/>
</bygroups>
</rule>
<rule pattern="(:[\S]+)(=&#34;[\S]+&#34;)">
<rule pattern="(:[\S]+)(=)(&#34;[\S]+&#34;)">
<bygroups>
<token type="NameTag"/>
<token type="Operator"/>
<token type="LiteralString"/>
</bygroups>
</rule>
Expand All @@ -104,9 +105,10 @@
<token type="Punctuation"/>
</bygroups>
</rule>
<rule pattern="(v-[\w]+)(=&#34;[\S]+&#34;)(&gt;)">
<rule pattern="(v-[\w]+)(=)(&#34;[\S ]+&#34;)(&gt;|\s)">
<bygroups>
<token type="NameTag"/>
<token type="Operator"/>
<token type="LiteralString"/>
<token type="Punctuation"/>
</bygroups>
Expand Down Expand Up @@ -258,14 +260,14 @@
</rule>
</state>
<state name="vue">
<rule pattern="(&lt;)([\w]+)">
<rule pattern="(&lt;)([\w-]+)">
<bygroups>
<token type="Punctuation"/>
<token type="NameTag"/>
</bygroups>
<push state="tag"/>
</rule>
<rule pattern="(&lt;)(/)([\w]+)(&gt;)">
<rule pattern="(&lt;)(/)([\w-]+)(&gt;)">
<bygroups>
<token type="Punctuation"/>
<token type="Punctuation"/>
Expand Down
6 changes: 6 additions & 0 deletions lexers/testdata/vue.actual
@@ -1,5 +1,11 @@
<template>
<button class="button">This is MyButton</button>
<ul-extendded v-if="examples.length" bordered>
<li
v-for="example in examples"
:key="`${example.id}`"
/>
</ul-extendded>
</template>

<script>
Expand Down
28 changes: 28 additions & 0 deletions lexers/testdata/vue.expected
Expand Up @@ -18,6 +18,34 @@
{"type":"Punctuation","value":"\u003c/"},
{"type":"NameTag","value":"button"},
{"type":"Punctuation","value":"\u003e"},
{"type":"Text","value":"\n "},
{"type":"Punctuation","value":"\u003c"},
{"type":"NameTag","value":"ul-extendded"},
{"type":"Text","value":" "},
{"type":"NameTag","value":"v-if"},
{"type":"Operator","value":"="},
{"type":"LiteralString","value":"\"examples.length\""},
{"type":"Punctuation","value":" "},
{"type":"NameAttribute","value":"bordered"},
{"type":"Punctuation","value":"\u003e"},
{"type":"Text","value":"\n "},
{"type":"Punctuation","value":"\u003c"},
{"type":"NameTag","value":"li"},
{"type":"Text","value":"\n "},
{"type":"NameTag","value":"v-for"},
{"type":"Operator","value":"="},
{"type":"LiteralString","value":"\"example in examples\""},
{"type":"Punctuation","value":"\n"},
{"type":"Text","value":" "},
{"type":"NameTag","value":":key"},
{"type":"Operator","value":"="},
{"type":"LiteralString","value":"\"`${example.id}`\""},
{"type":"Text","value":"\n "},
{"type":"Punctuation","value":"/\u003e"},
{"type":"Text","value":"\n "},
{"type":"Punctuation","value":"\u003c/"},
{"type":"NameTag","value":"ul-extendded"},
{"type":"Punctuation","value":"\u003e"},
{"type":"Text","value":"\n"},
{"type":"Punctuation","value":"\u003c/"},
{"type":"NameTag","value":"template"},
Expand Down