how-to-modify-code-with-ast #51
bowencool
announced in
Announcements
Replies: 2 comments
-
问下具体是用的哪个编译器来处理的 vue 模板? |
Beta Was this translation helpful? Give feedback.
0 replies
-
const { HtmlParser } = require('@starptech/webparser');
const fromWebparser = require('@starptech/hast-util-from-webparser');
const prettyhtml = require('@starptech/prettyhtml');
const toHTML = require('@starptech/prettyhtml-hast-to-html');
const HTML = new HtmlParser();
module.exports = {
parse(code) {
return fromWebparser(HTML.parse(code).rootNodes);
},
stringify(hast, prettyOptions) {
let code = toHTML(hast);
if (prettyOptions) {
code = prettyhtml(code, prettyOptions).contents;
}
return code;
},
}; |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
how-to-modify-code-with-ast
如何用 AST 对代码进行修改(含vue)
https://blog.bowen.cool/zh/posts/how-to-modify-code-with-ast
Beta Was this translation helpful? Give feedback.
All reactions