Use @neilsustc/markdown-it-katex instead of markdown-it-katex.

Mon, 06 Jul 2020 13:01:18 -0500

author
Tuomo Valkonen <tuomov@iki.fi>
date
Mon, 06 Jul 2020 13:01:18 -0500
changeset 28
9b75d0f5e042
parent 26
77cd7b8fb6a6
child 29
d4b0773f5e06

Use @neilsustc/markdown-it-katex instead of markdown-it-katex.
The latter is broken

markdown_it.js file | annotate | diff | comparison | revisions
package.json file | annotate | diff | comparison | revisions
--- a/markdown_it.js	Mon Jul 06 12:35:38 2020 -0500
+++ b/markdown_it.js	Mon Jul 06 13:01:18 2020 -0500
@@ -4,6 +4,22 @@
 var fs = require('fs');
 var hljs = require('highlight.js');
 
+var katexOptions = {
+    throwOnError: false,
+    macros: {
+        "\\iprod": "{\\langle #1, #2\\rangle}",
+        "\\grad": "\\nabla",
+        "\\isect": "\\cap",
+        "\\union": "\\cup",
+        "\\Isect": "\\bigcap",
+        "\\Union": "\\bigcup",
+        "\\supp": "\\mathop{\\mathrm{supp}}",
+        "\\sign": "\\mathop{\\mathrm{sign}}",
+        "\\Id": "\\mathop{\\mathrm{Id}}",
+        "\\linear": "\\mathbb{L}"
+    }
+};
+
 // process.argv[0] seems to be the node executable itself
 if(process.argv.length<=2){
     console.error(`Usage: ${process.argv[1]} input_file`)
@@ -32,10 +48,10 @@
                     }
                     return '';
                 }
-            }),
-            mk = require('markdown-it-katex'),
-            mm = require('markdown-it-mark');
-        md.use(mk).use(mm);
+            })
+        var mk = require('@neilsustc/markdown-it-katex');
+        var mm = require('markdown-it-mark');
+        md.use(mk, katexOptions).use(mm);
         output = md.render(input);
     } catch(e) {
         console.error(e.stack || e.message || String(e));
--- a/package.json	Mon Jul 06 12:35:38 2020 -0500
+++ b/package.json	Mon Jul 06 13:01:18 2020 -0500
@@ -11,9 +11,9 @@
     "example": "example"
   },
   "dependencies": {
+    "@neilsustc/markdown-it-katex": "^0.5.0",
     "highlight.js": "^10.1.1",
     "markdown-it": "^11.0.0",
-    "markdown-it-katex": "^2.0.3",
     "markdown-it-mark": "^3.0.0"
   },
   "devDependencies": {},

mercurial