Revert to internal option

This commit is contained in:
J. Ryan Stinnett 2021-05-10 17:36:33 +01:00
parent 9c8e89ff79
commit 7821e00bc6
3 changed files with 15 additions and 9 deletions

View file

@ -22,7 +22,6 @@ import { AllHtmlEntities } from 'html-entities';
import SettingsStore from '../settings/SettingsStore';
import SdkConfig from '../SdkConfig';
import cheerio from 'cheerio';
import * as htmlparser2 from 'htmlparser2';
export function mdSerialize(model: EditorModel) {
return model.parts.reduce((html, part) => {
@ -117,16 +116,22 @@ export function htmlSerializeIfNeeded(model: EditorModel, {forceHTML = false} =
const parser = new Markdown(md);
if (!parser.isPlainText() || forceHTML) {
// feed Markdown output to HTML parser
const phtml = cheerio.load(htmlparser2.parseDocument(parser.toHTML(), {
const phtml = cheerio.load(parser.toHTML(), {
// @ts-ignore: The `_useHtmlParser2` internal option is the
// simplest way to both parse and render using `htmlparser2`.
_useHtmlParser2: true,
decodeEntities: false,
}));
});
if (SettingsStore.getValue("feature_latex_maths")) {
// original Markdown without LaTeX replacements
const parserOrig = new Markdown(orig);
const phtmlOrig = cheerio.load(htmlparser2.parseDocument(parserOrig.toHTML(), {
const phtmlOrig = cheerio.load(parserOrig.toHTML(), {
// @ts-ignore: The `_useHtmlParser2` internal option is the
// simplest way to both parse and render using `htmlparser2`.
_useHtmlParser2: true,
decodeEntities: false,
}));
});
// since maths delimiters are handled before Markdown,
// code blocks could contain mangled content.