@@ -25,6 +25,7 @@ const { locStart, locEnd } = require("./loc.js");
2525 * @typedef {import('angular-html-parser/lib/compiler/src/ml_parser/ast').Element } Element
2626 * @typedef {import('angular-html-parser/lib/compiler/src/ml_parser/parser').ParseTreeResult } ParserTreeResult
2727 * @typedef {Omit<import('angular-html-parser').ParseOptions, 'canSelfClose'> & {
28+ * name?: 'html' | 'angular' | 'vue' | 'lwc';
2829 * recognizeSelfClosing?: boolean;
2930 * normalizeTagName?: boolean;
3031 * normalizeAttributeName?: boolean;
@@ -365,6 +366,7 @@ function _parse(text, options, parserOptions, shouldParseFrontMatter = true) {
365366 * @param {ParserOptions } parserOptions
366367 */
367368function createParser ( {
369+ name,
368370 recognizeSelfClosing = false ,
369371 normalizeTagName = false ,
370372 normalizeAttributeName = false ,
@@ -374,14 +376,18 @@ function createParser({
374376} = { } ) {
375377 return {
376378 parse : ( text , parsers , options ) =>
377- _parse ( text , options , {
378- recognizeSelfClosing,
379- normalizeTagName,
380- normalizeAttributeName,
381- allowHtmComponentClosingTags,
382- isTagNameCaseSensitive,
383- getTagContentType,
384- } ) ,
379+ _parse (
380+ text ,
381+ { parser : name , ...options } ,
382+ {
383+ recognizeSelfClosing,
384+ normalizeTagName,
385+ normalizeAttributeName,
386+ allowHtmComponentClosingTags,
387+ isTagNameCaseSensitive,
388+ getTagContentType,
389+ }
390+ ) ,
385391 hasPragma,
386392 astFormat : "html" ,
387393 locStart,
@@ -392,13 +398,15 @@ function createParser({
392398module . exports = {
393399 parsers : {
394400 html : createParser ( {
401+ name : "html" ,
395402 recognizeSelfClosing : true ,
396403 normalizeTagName : true ,
397404 normalizeAttributeName : true ,
398405 allowHtmComponentClosingTags : true ,
399406 } ) ,
400- angular : createParser ( ) ,
407+ angular : createParser ( { name : "angular" } ) ,
401408 vue : createParser ( {
409+ name : "vue" ,
402410 recognizeSelfClosing : true ,
403411 isTagNameCaseSensitive : true ,
404412 getTagContentType : ( tagName , prefix , hasParent , attrs ) => {
@@ -414,6 +422,6 @@ module.exports = {
414422 }
415423 } ,
416424 } ) ,
417- lwc : createParser ( ) ,
425+ lwc : createParser ( { name : "lwc" } ) ,
418426 } ,
419427} ;
0 commit comments