Skip to content

Commit

Permalink
fix: resolve conflict with markdown-it-katex plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
yndx-birman committed Sep 17, 2021
1 parent e0ff0b1 commit 26870c6
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 1 deletion.
24 changes: 24 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"eslint": "^5.16.0",
"markdown-it": "^12.0.2",
"markdown-it-implicit-figures": "^0.9.0",
"markdown-it-katex": "^2.0.3",
"mocha": "^7.1.1",
"nyc": "^14.1.1"
},
Expand Down
2 changes: 1 addition & 1 deletion patterns.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ module.exports = options => {
{
position: -1,
content: utils.hasDelimiters('end', options),
type: (t) => t !== 'code_inline'
type: (t) => t !== 'code_inline' && t !== 'math_inline'
}
]
}
Expand Down
8 changes: 8 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
const assert = require('assert');
const Md = require('markdown-it');
const implicitFigures = require('markdown-it-implicit-figures');
const katex = require('markdown-it-katex');
const attrs = require('./');
const utils = require('./utils.js');

Expand Down Expand Up @@ -320,6 +321,13 @@ function describeTestsWithOptions(options, postText) {
assert.equal(md.render(replaceDelimiters(src, options)), expected);
});

it(replaceDelimiters('should work with plugin katex', options), () => {
md = md.use(katex);
const mdWithOnlyKatex = Md().use(katex);
src = '$\\sqrt{a}$';
assert.equal(md.render(src), mdWithOnlyKatex.render(src));
});

it(replaceDelimiters('should not apply inside `code{.red}`', options), () => {
src = 'paragraph `code{.red}`';
expected = '<p>paragraph <code>code{.red}</code></p>\n';
Expand Down

0 comments on commit 26870c6

Please sign in to comment.