@minamorl/markdown-next 2.1.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/src/parser.js +11 -6
- package/package.json +1 -1
package/lib/src/parser.js
CHANGED
|
@@ -118,10 +118,11 @@ class Parser {
|
|
|
118
118
|
return mapper(tag)(join(children));
|
|
119
119
|
});
|
|
120
120
|
});
|
|
121
|
-
// Math expressions
|
|
121
|
+
// Math expressions - output raw $...$ for MathJax to process
|
|
122
122
|
// Inline math: $...$
|
|
123
123
|
const mathInline = P.seqMap(P.string("$").notFollowedBy(P.string("$")), P.regexp(/[^\$\r\n]+/), P.string("$"), (_1, content, _3) => {
|
|
124
|
-
|
|
124
|
+
// Output raw $...$ for MathJax auto-detection
|
|
125
|
+
return "$" + content + "$";
|
|
125
126
|
});
|
|
126
127
|
const inline = P.alt(pluginInline, aozoraRuby, anchor, img, em, strong, code, mathInline, htmlSelfClosing, htmlElement, P.regexp(/[^\r\n<=-\[\]\*\`\@|\$]+/), P.regexp(/./));
|
|
127
128
|
// Table cell content - supports inline elements
|
|
@@ -179,7 +180,9 @@ class Parser {
|
|
|
179
180
|
const paragraph = paragraphLine
|
|
180
181
|
.map(mapper("p"));
|
|
181
182
|
const listIndent = P.string(" ");
|
|
182
|
-
|
|
183
|
+
// List item content - supports inline elements including math
|
|
184
|
+
const liInlineContent = P.alt(mathInline, anchor, img, em, strong, code, P.regexp(/[^\r\n\[\]\*\`\$]+/), P.regexp(/./));
|
|
185
|
+
const liSingleLine = liInlineContent.atLeast(0).map(join);
|
|
183
186
|
const ulStart = P.string("- ").or(P.string("* "));
|
|
184
187
|
const olStart = P.regexp(/[0-9]+\. /);
|
|
185
188
|
let liLevel = [1];
|
|
@@ -357,9 +360,11 @@ class Parser {
|
|
|
357
360
|
: join([_1, pluginName, args, _2, content]);
|
|
358
361
|
});
|
|
359
362
|
// Block math: $$...$$ (must be on its own line or surrounded by newlines)
|
|
360
|
-
|
|
361
|
-
const
|
|
362
|
-
|
|
363
|
+
// Content can include anything except $$ (including single $, newlines, etc.)
|
|
364
|
+
const mathBlockContent = P.regexp(/[\s\S]*?(?=\$\$)/);
|
|
365
|
+
const mathBlock = P.seqMap(P.regexp(/^\$\$/), mathBlockContent, P.string("$$"), P.alt(linebreak, P.eof), (_1, content, _3, _4) => {
|
|
366
|
+
// Output raw $$...$$ for MathJax auto-detection
|
|
367
|
+
return "$$" + content.trim() + "$$";
|
|
363
368
|
});
|
|
364
369
|
const block = P.alt(P.regexp(/\s+/).result(""), pluginBlock, h1Special, h2Special, h6, h5, h4, h3, h2, h1, table, codeBlock, mathBlock, lists, blockquote, paragraph, linebreak.result(""));
|
|
365
370
|
this.acceptables = P.alt(block).many().map(join);
|
package/package.json
CHANGED