LaTex plugin for markdown-it markdown parser, Server side MathJax Renderer.
It was originally designed to render MathML.css
Just to bypass LaTeX math for mathjax processing, need to import mathjaxhtml
Need to include the KaTeX stylesheetgit
Demogithub
npm install markdown-it-latex2img --save
const md = require('markdown-it')() .use(require('markdown-it-latex2img')); md.render(`$\\frac {a+1}{b+2}$`) //JavaScript strings require double backslashes, but HTML input and reading files are not required
Differences in browser. If you load script directly into the page, without package system, module will add itself globally as window.markdownitLatex2img
.ajax
<script src="https://cdn.jsdelivr.net/npm/markdown-it-latex2img@latest/dist/markdown-it-latex2img.min.js" crossorigin="anonymous"></script> <script src="https://cdn.jsdelivr.net/npm/markdown-it@11.0.0/dist/markdown-it.min.js" crossorigin="anonymous"></script> <script> var md = window.markdownit(); md.use(window.markdownitLatex2img); </script>
WARNING: No front-end scripts and other Math plugins are required. Remove them ALL before using this plugin.Please use official plugin hexo-renderer-markdown-it(plus) as Renderer.
npm
npm i hexo-renderer-markdown-it --save npm i markdown-it-latex2img --save
# _config.yml markdown: plugins: - markdown-it-latex2img
Default will load mathjax plugin EVERY PAGE during rendering,Does not reduce page speed after generated.Later will support on-demand rendering to improve rendering speedapi
Property | Type | Default | Required | Remarks |
---|---|---|---|---|
server | String | https://math.now.sh | true | ?from=block/inline=inline |
style | String | false | commonly use filter: opacity(75%);transform:scale(0.75);text-align:center; to fit the body font color and size |
If you want to customize options in hexo,please do as follows:bash
# _config.yml markdown: plugins: - name: markdown-it-latex2img options: style: 'filter: opacity(90%);transform:scale(0.85);text-align:center;'
Markup is based on pandoc definition.
Mathjax pointed outmarkdown
The default math delimiters are $$...$$ and [...] for displayed mathematics, and (...) for in-line mathematics.Note in particular that the $...$ in-line delimiters are not used by default.That is because dollar signs appear too often in non-mathematical settings, which could cause some text to be treated as mathematics unexpectedly.
However,most still use $...$, we have followed this habit.hexo
# inline $\frac {a+1}{b+2}$ # The opening $ must have a non-space character immediately to its right, while the closing $ must have a non-space character immediately to its left, and must not be followed immediately by a digit.
# block $$ { e^x=\lim_{n\to\infty} \left( 1+\frac{x}{n} \right)^n \qquad (2) } $$
MIT © MakerGYT