Skip to content

Commit b08ddd3

Browse files
committed
Version 0.9.7
1 parent cc3ea7d commit b08ddd3

File tree

7 files changed

+76
-43
lines changed

7 files changed

+76
-43
lines changed

package-lock.json

Lines changed: 35 additions & 31 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "markdown-it-texmath",
3-
"version": "0.9.6",
3+
"version": "0.9.7",
44
"description": "markdown-it extension for rendering TeX Math",
55
"keywords": [
66
"TeX",
@@ -20,7 +20,7 @@
2020
},
2121
"license": "MIT",
2222
"devDependencies": {
23-
"katex": "^0.13.11",
24-
"markdown-it": "^12.0.6"
23+
"katex": "^0.15.1",
24+
"markdown-it": "^12.2.0"
2525
}
2626
}

readme.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ Use following links for `texmath.js` and `texmath.css`
123123
But if someone wants to help here out, pull requests are always welcome.
124124

125125
## CHANGELOG
126+
### [0.9.7] on December 07, 2021
127+
* Redundant `</math>` end-tag with display-mode equations removed. All modes were affected ... invisible effect though. Thanks to [yuanbug](https://github.com/yuanbug) for reporting.
126128
### [0.9.6] on November 16, 2021
127129
* Small bug in 'dollars' inline-display-mode regex fixed.
128130
### [0.9.5] on November 12, 2021

test/katex-only.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
'use strict';
2+
const katex = require('katex');
3+
const str = katex.renderToString("x", {
4+
throwOnError: false
5+
});
6+
console.log(str);

test/mdmath-endtag-bug.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
notation as column vectors.
2+
3+
$$1$$
4+
5+
\pi
6+
7+
$$3$$ (2)

test/redundant-math-tag-bug.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
'use strict';
2+
const tm = require('../texmath.js');
3+
const md = require('markdown-it')({html:true})
4+
.use(tm, { engine: require('katex'),
5+
delimiters: 'dollars',
6+
katexOptions: { macros: {"\\RR": "\\mathbb{R}"} } });
7+
const str =
8+
`
9+
something
10+
11+
$$\\bold r =\\begin\{pmatrix\}x_1 \\\\ x_2 \\end\{pmatrix\}$$
12+
13+
`;
14+
15+
console.log(md.render(str));

texmath.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,13 @@ texmath.block = (rule) =>
9696
// begin token
9797
let token = state.push(rule.name, 'math', 1); // 'math_block'
9898
token.block = true;
99-
token.markup = rule.tag;
99+
token.tag = rule.tag;
100+
token.markup = '';
100101
token.content = match[1];
101102
token.info = match[match.length-1]; // eq.no
102103
token.map = [ begLine, curline ];
103-
// end token
104-
token = state.push(rule.name+'_end', 'math', -1);
105-
token.block = true;
106-
token.markup = rule.tag;
104+
// token.hidden = true;
105+
// end token ... superfluous ...
107106

108107
state.parentType = parentType;
109108
state.lineMax = lineMax;
@@ -309,15 +308,15 @@ texmath.rules = {
309308
dollars: {
310309
inline: [
311310
{ name: 'math_inline_double',
312-
rex: /\${2}([^]*?[^\\])\${2}/gy,
311+
rex: /\${2}([^$]*?[^\\])\${2}/gy,
313312
tmpl: '<section><eqn>$1</eqn></section>',
314313
tag: '$$',
315314
displayMode: true,
316315
pre: texmath.$_pre,
317316
post: texmath.$_post
318317
},
319318
{ name: 'math_inline',
320-
rex: /\$((?:[^\s\\])|(?:\S.*?[^s\\]))\$/gy,
319+
rex: /\$((?:[^\s\\])|(?:\S.*?[^\s\\]))\$/gy,
321320
tmpl: '<eq>$1</eq>',
322321
tag: '$',
323322
outerSpace: false,
@@ -327,12 +326,12 @@ texmath.rules = {
327326
],
328327
block: [
329328
{ name: 'math_block_eqno',
330-
rex: /\${2}([^]*?[^\\])\${2}\s*?\(([^)\s]+?)\)/gmy,
329+
rex: /\${2}([^$]*?[^\\])\${2}\s*?\(([^)\s]+?)\)/gmy,
331330
tmpl: '<section class="eqno"><eqn>$1</eqn><span>($2)</span></section>',
332331
tag: '$$'
333332
},
334333
{ name: 'math_block',
335-
rex: /\${2}([^]*?[^\\])\${2}/gmy,
334+
rex: /\${2}([^$]*?[^\\])\${2}/gmy,
336335
tmpl: '<section><eqn>$1</eqn></section>',
337336
tag: '$$'
338337
}

0 commit comments

Comments
 (0)