cosmetic changes (lint)
This commit is contained in:
parent
1b689bb4e1
commit
aded3c9de2
2 changed files with 8 additions and 11 deletions
|
@ -416,24 +416,21 @@ export function bodyToHtml(content: IContent, highlights: string[], opts: IOpts
|
||||||
if (SdkConfig.get()['latex_maths']) {
|
if (SdkConfig.get()['latex_maths']) {
|
||||||
const mathDelimiters = [
|
const mathDelimiters = [
|
||||||
{ pattern: "<div data-mx-maths=\"([^\"]*)\">(.|\\s)*?</div>", display: true },
|
{ pattern: "<div data-mx-maths=\"([^\"]*)\">(.|\\s)*?</div>", display: true },
|
||||||
{ pattern: "<span data-mx-maths=\"([^\"]*)\">(.|\\s)*?</span>", display: false }
|
{ pattern: "<span data-mx-maths=\"([^\"]*)\">(.|\\s)*?</span>", display: false },
|
||||||
];
|
];
|
||||||
|
|
||||||
mathDelimiters.forEach(function (d) {
|
mathDelimiters.forEach(function(d) {
|
||||||
var reg = RegExp(d.pattern, "gm");
|
safeBody = safeBody.replace(RegExp(d.pattern, "gm"), function(m, p1) {
|
||||||
|
|
||||||
safeBody = safeBody.replace(reg, function(match, p1) {
|
|
||||||
return katex.renderToString(
|
return katex.renderToString(
|
||||||
AllHtmlEntities.decode(p1),
|
AllHtmlEntities.decode(p1),
|
||||||
{
|
{
|
||||||
throwOnError: false,
|
throwOnError: false,
|
||||||
displayMode: d.display,
|
displayMode: d.display,
|
||||||
output: "mathml"
|
output: "mathml",
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
delete sanitizeParams.textFilter;
|
delete sanitizeParams.textFilter;
|
||||||
|
|
|
@ -40,7 +40,7 @@ export function mdSerialize(model: EditorModel) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function htmlSerializeIfNeeded(model: EditorModel, {forceHTML = false} = {}) {
|
export function htmlSerializeIfNeeded(model: EditorModel, {forceHTML = false} = {}) {
|
||||||
var md = mdSerialize(model);
|
let md = mdSerialize(model);
|
||||||
|
|
||||||
if (SdkConfig.get()['latex_maths']) {
|
if (SdkConfig.get()['latex_maths']) {
|
||||||
const displayPattern = (SdkConfig.get()['latex_maths_delims'] || {})['display_pattern'] ||
|
const displayPattern = (SdkConfig.get()['latex_maths_delims'] || {})['display_pattern'] ||
|
||||||
|
@ -48,12 +48,12 @@ export function htmlSerializeIfNeeded(model: EditorModel, {forceHTML = false} =
|
||||||
const inlinePattern = (SdkConfig.get()['latex_maths_delims'] || {})['inline_pattern'] ||
|
const inlinePattern = (SdkConfig.get()['latex_maths_delims'] || {})['inline_pattern'] ||
|
||||||
"\\$\\$(([^$]|\\\\\\$)*)\\$\\$";
|
"\\$\\$(([^$]|\\\\\\$)*)\\$\\$";
|
||||||
|
|
||||||
md = md.replace(RegExp(displayPattern, "gm"), function(m,p1) {
|
md = md.replace(RegExp(displayPattern, "gm"), function(m, p1) {
|
||||||
const p1e = AllHtmlEntities.encode(p1);
|
const p1e = AllHtmlEntities.encode(p1);
|
||||||
return `<div data-mx-maths="${p1e}"><code>${p1e}</code></div>`;
|
return `<div data-mx-maths="${p1e}"><code>${p1e}</code></div>`;
|
||||||
});
|
});
|
||||||
|
|
||||||
md = md.replace(RegExp(inlinePattern, "gm"), function(m,p1) {
|
md = md.replace(RegExp(inlinePattern, "gm"), function(m, p1) {
|
||||||
const p1e = AllHtmlEntities.encode(p1);
|
const p1e = AllHtmlEntities.encode(p1);
|
||||||
return `<span data-mx-maths="${p1e}"><code>${p1e}</code></span>`;
|
return `<span data-mx-maths="${p1e}"><code>${p1e}</code></span>`;
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue