mirror of https://github.com/vector-im/riot-web
made single and double $ default delimiters
parent
3f9f1d03c8
commit
839bae21ae
|
@ -136,11 +136,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)) {
|
||||||
|
|
|
@ -46,9 +46,9 @@ export function htmlSerializeIfNeeded(model: EditorModel, {forceHTML = false} =
|
||||||
|
|
||||||
if (SettingsStore.getValue("feature_latex_maths")) {
|
if (SettingsStore.getValue("feature_latex_maths")) {
|
||||||
const displayPattern = (SdkConfig.get()['latex_maths_delims'] || {})['display_pattern'] ||
|
const displayPattern = (SdkConfig.get()['latex_maths_delims'] || {})['display_pattern'] ||
|
||||||
"\\$\\$\\$(([^$]|\\\\\\$)*)\\$\\$\\$";
|
|
||||||
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);
|
||||||
|
|
Loading…
Reference in New Issue