@awesome-fe/translate
Version:
Translation utils
29 lines • 1.03 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.htmlCommentInlineTokenizer = void 0;
var pattern = /^<!--(.*?)-->/s;
function htmlCommentInlineTokenizer(eat, value, silent) {
var matches = pattern.exec(value);
if (matches) {
try {
if (silent || !matches) {
// either we are not eating (silent) or the match failed
return !!matches;
}
return eat(matches[0])({
type: 'comment',
value: matches[1],
});
}
catch (e) {
this.file.fail('Unmatched plain HTML inline tag: ' + e.message);
}
}
}
exports.htmlCommentInlineTokenizer = htmlCommentInlineTokenizer;
htmlCommentInlineTokenizer.locator = function (value, fromIndex) {
var searchFromIndexPattern = new RegExp(pattern);
searchFromIndexPattern.lastIndex = fromIndex;
return value.search(searchFromIndexPattern);
};
//# sourceMappingURL=html-comment-inline-tokenizer.js.map