Proper way to add LaTeX (with markdown-it-texmath and katex) to nodebb-plugin-markdown
-
Hello !
I succeeded in adding LaTeX on my nodebb forum but my solution is bad for maintenance (all plugin I found to do that had defaults so I made my own work)... I think there is a greater/more elegant way ; here is the reason for this message .
Here is my method for now :
- I forked nodebb-plugin-markdown (named it nodebb-plugin-markdown-YA).
- I added into package.json these dependencies : katex and markdown-it-texmath.
- I copied katex.min.css from katex to nodebb-plugin-markdown-YA/public/less/katex.min.less.
- I copied "fonts" dir from katex to "nodebb/public".
- I changed nodebb-plugin-markdown/index.js (bof, bof... ). Here is the diff between nodebb-plugin-markdown/index.js and nodebb-plugin-markdown-YA/index.js :
2a3,6 > // YA add-on for LaTeX (markdown-it-texmath + katex) > var katex = require('katex'); > var MarkdownItTexmath = require('markdown-it-texmath').use(katex); > 52c56,57 < href: nconf.get('relative_path') + '/plugins/nodebb-plugin-markdown/styles/' + (Markdown.config.highlightTheme || 'railscasts.css'), --- > // YA change for LaTeX (markdown-it-texmath + katex) - plugin renamed ! > href: nconf.get('relative_path') + '/plugins/nodebb-plugin-markdown-YA/styles/' + (Markdown.config.highlightTheme || 'railscasts.css'), 115c120,123 < parser = new MarkdownIt(_self.config); --- > // YA change for LaTeX (markdown-it-texmath + katex) > // parser = new MarkdownIt(_self.config); > parser = new MarkdownIt(_self.config).use(MarkdownItTexmath, {"delimiters" : 'dollars'}); > 236a245,246 > // YA change for LaTeX (markdown-it-texmath + katex) > // checkboxes make some bad things with LaTeX so desactivate it 238,241c248,251 < parser.use(require('markdown-it-checkbox'), { < divWrap: true, < divClass: 'plugin-markdown', < }); --- > // parser.use(require('markdown-it-checkbox'), { > // divWrap: true, > // divClass: 'plugin-markdown', > // });
Is there a greater way to do these things keeping nodebb-plugin-markdown unchanged and installed ? I can write another plugin to apply my changes (add LaTeX with markdown-it-texmath and katex and remove markdown-it-checkbox use) but is it really possible and, if yes, with which hooks ?
It would be really simpler for maintenance (and also more beautiful... )...
Thanks in advance for help !
-
Precision : step to disable markdown-it-checkbox in code is now not necessary since the following change made by @julianlam in nodebb-plugin-markdown...
How to disable use of markdown-it-checkbox... 路 Issue #108 路 NodeBB/nodebb-plugin-markdown
Hello ! I'm trying to make a nodebb plugin to extend nodebb-plugin-markdown without changing its code... One problem is that I really don't want markdown-it-checkbox (problem with LaTeX formulas parsing, like $P[X]=...$)... I see no opti...
GitHub (github.com)