@awesome-fe/translate
Version:
Translation utils
29 lines • 1.06 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.htmlInlineExampleTokenizer = void 0;
var pattern = /^<(code-example|live-example)[\s\S]+?<\/\1>/;
function htmlInlineExampleTokenizer(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: 'htmlRaw',
value: matches[0],
});
}
catch (e) {
this.file.fail('Unmatched plain HTML inline tag: ' + e.message);
}
}
}
exports.htmlInlineExampleTokenizer = htmlInlineExampleTokenizer;
htmlInlineExampleTokenizer.locator = function (value, fromIndex) {
var searchFromIndexPattern = new RegExp(pattern);
searchFromIndexPattern.lastIndex = fromIndex;
return value.search(searchFromIndexPattern);
};
//# sourceMappingURL=html-inline-example-tokenizer.js.map