@awesome-fe/translate
Version:
Translation utils
28 lines • 1.04 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.adocToTinyHtml = void 0;
const create_asciidoctor_1 = require("../utils/create-asciidoctor");
const adoc_1 = require("../utils/adoc");
function adocToTinyHtml(content, options) {
if (!content) {
return '';
}
const doc = (0, create_asciidoctor_1.createAsciidoctor)();
adoc_1.adoc.setSubstitutionsForTranslatableHtml(doc);
try {
const html = doc.convert(content, {
...options,
backend: 'tiny-html',
attributes: { outfilesuffix: '.html', experimental: true },
});
return html
.replace(/^<!DOCTYPE html><html><head><title><\/title><\/head><body>\n+<article>([\s\S]*?)<\/article>\n+<\/body><\/html>$/, '$1')
.replace(/^<article>([\s\S]*?)<\/article>$/g, '$1')
.trim();
}
finally {
adoc_1.adoc.setSubstitutionsForDefaultHtml(doc);
}
}
exports.adocToTinyHtml = adocToTinyHtml;
//# sourceMappingURL=adoc-to-tiny-html.js.map