-
-
Notifications
You must be signed in to change notification settings - Fork 13
feat: add an option to customize tag content type #12
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
Conversation
To parse Vue SFC, we need paser everything as |
Yes. |
I'm not a Vue user, but there are claims that it supports |
I guess it's possible that |
Right,
const {parse} = require("@vue/compiler-sfc"); // 3.0.0-beta.2
const parsed = parse(`
<template><div></div></template>
<script>export default { }</script>
// <abc>
<style></style>
`);
console.log(parsed.errors) // ["SyntaxError: Element is missing end tag (4:4)"]
|
I'll merge this PR tomorrow if there is no objection/question. |
I checked the "Vue SFC Spec" about comments before, but people actually use js style comments, and at least it works in |
Relying on the implementation detail does not look like a good idea, I think we should follow the spec and push people to use the correct comment style just like what you did. |
Looking forward to see improve vue parse with this. |
@ikatyang Thank you!! |
Fixes #11
The tag content type resolution happens in the lexing phase so there is no info for element stack, i.e., something like
getTagContentType(tagName, elementStack)
is not possible under this architecture, which means there is no way to identify if an element is a root element, so we probably need to do two-pass parsing for the Vue SFC, one for the root elements and one for<template>
s.cc @sosukesuzuki @fisker @thorn0