Deserialize back to math delimiters for editing
This commit is contained in:
parent
becc79d67a
commit
e78734bbf6
2 changed files with 15 additions and 1 deletions
|
@ -534,7 +534,6 @@ export function checkBlockNode(node: Node) {
|
||||||
case "H6":
|
case "H6":
|
||||||
case "PRE":
|
case "PRE":
|
||||||
case "BLOCKQUOTE":
|
case "BLOCKQUOTE":
|
||||||
case "DIV":
|
|
||||||
case "P":
|
case "P":
|
||||||
case "UL":
|
case "UL":
|
||||||
case "OL":
|
case "OL":
|
||||||
|
@ -547,6 +546,9 @@ export function checkBlockNode(node: Node) {
|
||||||
case "TH":
|
case "TH":
|
||||||
case "TD":
|
case "TD":
|
||||||
return true;
|
return true;
|
||||||
|
case "DIV":
|
||||||
|
// don't treat math nodes as block nodes for deserializing
|
||||||
|
return !(node as HTMLElement).hasAttribute("data-mx-maths");
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -130,6 +130,18 @@ function parseElement(n: HTMLElement, partCreator: PartCreator, lastNode: HTMLEl
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case "DIV":
|
||||||
|
case "SPAN": {
|
||||||
|
// math nodes are translated back into delimited latex strings
|
||||||
|
if (n.hasAttribute("data-mx-maths")) {
|
||||||
|
const delim = (n.nodeName == "SPAN") ? "$$" : "$$$";
|
||||||
|
const tex = n.getAttribute("data-mx-maths");
|
||||||
|
return partCreator.plain(delim + tex + delim);
|
||||||
|
} else if (!checkDescendInto(n)) {
|
||||||
|
return partCreator.plain(n.textContent);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
case "OL":
|
case "OL":
|
||||||
state.listIndex.push((<HTMLOListElement>n).start || 1);
|
state.listIndex.push((<HTMLOListElement>n).start || 1);
|
||||||
/* falls through */
|
/* falls through */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue