Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 1d70045

Browse files
committed
Refactor maths config options to nested structure
1 parent 3c1169c commit 1d70045

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/editor/deserialize.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,11 @@ function parseElement(n: HTMLElement, partCreator: PartCreator, lastNode: HTMLEl
143143
// math nodes are translated back into delimited latex strings
144144
if (n.hasAttribute("data-mx-maths")) {
145145
const delimLeft = (n.nodeName == "SPAN") ?
146-
(SdkConfig.get()['latex_maths_delims'] || {})['inline_left'] || "\\(" :
147-
(SdkConfig.get()['latex_maths_delims'] || {})['display_left'] || "\\[";
146+
((SdkConfig.get()['latex_maths_delims'] || {})['inline'] || {})['left'] || "\\(" :
147+
((SdkConfig.get()['latex_maths_delims'] || {})['display'] || {})['left'] || "\\[";
148148
const delimRight = (n.nodeName == "SPAN") ?
149-
(SdkConfig.get()['latex_maths_delims'] || {})['inline_right'] || "\\)" :
150-
(SdkConfig.get()['latex_maths_delims'] || {})['display_right'] || "\\]";
149+
((SdkConfig.get()['latex_maths_delims'] || {})['inline'] || {})['right'] || "\\)" :
150+
((SdkConfig.get()['latex_maths_delims'] || {})['display'] || {})['right'] || "\\]";
151151
const tex = n.getAttribute("data-mx-maths");
152152
return partCreator.plain(delimLeft + tex + delimRight);
153153
} else if (!checkDescendInto(n)) {

src/editor/serialize.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ export function htmlSerializeIfNeeded(model: EditorModel, {forceHTML = false} =
9292
patternNames.forEach(function(patternName) {
9393
patternTypes.forEach(function(patternType) {
9494
// get the regex replace pattern from config or use the default
95-
const pattern = (SdkConfig.get()["latex_maths_delims"] ||
96-
{})[patternType + "_pattern_" + patternName] ||
95+
const pattern = (((SdkConfig.get()["latex_maths_delims"] ||
96+
{})[patternType] || {})["pattern"] || {})[patternName] ||
9797
patternDefaults[patternName][patternType];
9898

9999
md = md.replace(RegExp(pattern, "gms"), function(m, p1, p2) {

0 commit comments

Comments
 (0)