Skip to content

Commit 79d0226

Browse files
author
Christopher Quadflieg
committed
wip: parse pug content
1 parent 106a423 commit 79d0226

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

src/html/parser.ts

+10
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ import { IntermediateTokenizer } from "./intermediate-tokenizer"
4747
import type { Tokenizer } from "./tokenizer"
4848
import type { ParserOptions } from "../common/parser-options"
4949
import { isSFCFile, getScriptParser } from "../common/parser-options"
50+
// import type { Token } from "pug-lexer";
51+
import lex from "pug-lexer";
5052

5153
const DIRECTIVE_NAME = /^(?:v-|[.:@#]).*[^.:@#]$/u
5254
const DT_DD = /^d[dt]$/u
@@ -292,6 +294,14 @@ export class Parser {
292294
}
293295
this.postProcessesForScript = []
294296

297+
// Process pug
298+
const match = /<template\s+lang="pug">(?<content>.*)<\/template>/isu.exec(this.text)
299+
if (match && match.groups && match.groups.content) {
300+
const pugTokens = lex(match.groups.content)
301+
console.log(pugTokens);
302+
303+
}
304+
295305
return this.document
296306
}
297307

src/index.ts

+2
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ export function parseForESLint(
9393
template != null && (templateLang === "html" || templateLang === "pug")
9494
? Object.assign(template, concreteInfo)
9595
: undefined
96+
// if (templateLang === "pug")
97+
// console.log(templateBody)
9698

9799
const scriptParser = getScriptParser(options.parser, rootAST, "script")
98100
let scriptSetup: VElement | undefined

test/fixtures/ast/pug/source.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
<template lang="pug">
2-
Hello!
2+
p {{ greeting }} World!
33
</template>

0 commit comments

Comments
 (0)