Refactor maths config options to nested structure
This commit is contained in:
parent
3c1169c7a2
commit
1d70045065
2 changed files with 6 additions and 6 deletions
|
@ -143,11 +143,11 @@ function parseElement(n: HTMLElement, partCreator: PartCreator, lastNode: HTMLEl
|
||||||
// math nodes are translated back into delimited latex strings
|
// math nodes are translated back into delimited latex strings
|
||||||
if (n.hasAttribute("data-mx-maths")) {
|
if (n.hasAttribute("data-mx-maths")) {
|
||||||
const delimLeft = (n.nodeName == "SPAN") ?
|
const delimLeft = (n.nodeName == "SPAN") ?
|
||||||
(SdkConfig.get()['latex_maths_delims'] || {})['inline_left'] || "\\(" :
|
((SdkConfig.get()['latex_maths_delims'] || {})['inline'] || {})['left'] || "\\(" :
|
||||||
(SdkConfig.get()['latex_maths_delims'] || {})['display_left'] || "\\[";
|
((SdkConfig.get()['latex_maths_delims'] || {})['display'] || {})['left'] || "\\[";
|
||||||
const delimRight = (n.nodeName == "SPAN") ?
|
const delimRight = (n.nodeName == "SPAN") ?
|
||||||
(SdkConfig.get()['latex_maths_delims'] || {})['inline_right'] || "\\)" :
|
((SdkConfig.get()['latex_maths_delims'] || {})['inline'] || {})['right'] || "\\)" :
|
||||||
(SdkConfig.get()['latex_maths_delims'] || {})['display_right'] || "\\]";
|
((SdkConfig.get()['latex_maths_delims'] || {})['display'] || {})['right'] || "\\]";
|
||||||
const tex = n.getAttribute("data-mx-maths");
|
const tex = n.getAttribute("data-mx-maths");
|
||||||
return partCreator.plain(delimLeft + tex + delimRight);
|
return partCreator.plain(delimLeft + tex + delimRight);
|
||||||
} else if (!checkDescendInto(n)) {
|
} else if (!checkDescendInto(n)) {
|
||||||
|
|
|
@ -92,8 +92,8 @@ export function htmlSerializeIfNeeded(model: EditorModel, {forceHTML = false} =
|
||||||
patternNames.forEach(function(patternName) {
|
patternNames.forEach(function(patternName) {
|
||||||
patternTypes.forEach(function(patternType) {
|
patternTypes.forEach(function(patternType) {
|
||||||
// get the regex replace pattern from config or use the default
|
// get the regex replace pattern from config or use the default
|
||||||
const pattern = (SdkConfig.get()["latex_maths_delims"] ||
|
const pattern = (((SdkConfig.get()["latex_maths_delims"] ||
|
||||||
{})[patternType + "_pattern_" + patternName] ||
|
{})[patternType] || {})["pattern"] || {})[patternName] ||
|
||||||
patternDefaults[patternName][patternType];
|
patternDefaults[patternName][patternType];
|
||||||
|
|
||||||
md = md.replace(RegExp(pattern, "gms"), function(m, p1, p2) {
|
md = md.replace(RegExp(pattern, "gms"), function(m, p1, p2) {
|
||||||
|
|
Loading…
Reference in a new issue