Htmlx parser which generates unist/svast AST
npm install htmlx-parser-svastjs
import { parse } from 'htmlx-parser-svast'
const input = 'Heading
';
const result = parse(input);
`
The result returned is as much of the AST as could be generated along with any errors encountered
`ts
declare type ParseResult = {
ast: Root; //Root is a Svast AST node
errors: ParseError[]
};
`
With errors having the type
`ts
type ParseError = {
source: "Lexer" | "Parser"
name: string
message: string
position: {
start: Point,
end: Point
}
}
`
Limitations
* It doesn't implement svast's each block.
* It is slower and larger than svelte-parse.
* HTMLx expressions are parsed by looking for the nearest, unbalanced }.
* The AST builder currently doesn't take full advantage of the error recovery features of chevrotain`.