Skip to content

Commit 89efab6

Browse files
authored
Merge pull request #36 from mathjax/updates_to_lab
Updates to lab
2 parents 9b19ac3 + cfd2c09 commit 89efab6

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ nmp install mj-context-menu
2424

2525
Create a symbolic link for the context menu. MathJax expects it to be _in parallel_ to its code.
2626

27-
``` sheel
27+
``` shell
2828
ln -s node_modules/mj-context-menu
2929
```
3030

lib/v3-lab.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,21 @@ const Lab = window.Lab = {
158158
return math;
159159
},
160160

161+
readInput() {
162+
let input = this.input.value;
163+
if (this.format !== 'MathML') {
164+
return input;
165+
}
166+
input = input.trim();
167+
if (!input.match(/^<math/)) {
168+
input = '<math xmlns="http://www.w3.org/1998/Math/MathML">' + input;
169+
}
170+
if (!input.match(/\/math>$/)) {
171+
input += '</math>';
172+
}
173+
return input;
174+
},
175+
161176
/**
162177
* Perform the typesetting of the math in the proper format
163178
*/
@@ -175,7 +190,7 @@ const Lab = window.Lab = {
175190
// set its metrics, and link it to the text element created above, then
176191
// add it to the document's math list.
177192
//
178-
this.mathItem = this.MathItem(this.input.value, this.output);
193+
this.mathItem = this.MathItem(this.readInput(), this.output);
179194
this.doc.clear();
180195
this.doc.math.push(this.mathItem);
181196

0 commit comments

Comments
 (0)