• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

MakerGYT/markdown-it-latex2img: LaTex plugin for markdown-it markdown parser,Pla ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

MakerGYT/markdown-it-latex2img

开源软件地址(OpenSource Url):

https://github.com/MakerGYT/markdown-it-latex2img

开源编程语言(OpenSource Language):

JavaScript 88.0%

开源软件介绍(OpenSource Introduction):

Markdown-it-latex2img

Build Status NPM version npm GitHub stars

LaTex plugin for markdown-it markdown parser, Server side MathJax Renderer.

Background

Related

  • markdown-it-math: It was originally designed to render MathML.
  • markdown-it-mathjax: Just to bypass LaTeX math for mathjax processing, need to import mathjax
  • markdown-it-katex: Need to include the KaTeX stylesheet

Demand

  • Place LaTeX Math equation on anywhere
  • Accurate and fast, supports rendering of diverse formulas

Feature

  • Convert Latex syntax to image tags
  • Support inline and block formulas
  • Rendering results support multi-end use, such as WeChat Mini Program

Sample

Demo

Screenshot:

Install

Node.js:

npm install markdown-it-latex2img --save

Browser (CDN):

Usage

Node.js

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

Browser

Differences in browser. If you load script directly into the page, without package system, module will add itself globally as window.markdownitLatex2img.

<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/[email protected]/dist/markdown-it.min.js" crossorigin="anonymous"></script>
<script>
  var md = window.markdownit();
  md.use(window.markdownitLatex2img);
</script>

Hexo

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.

  1. Install
npm i hexo-renderer-markdown-it --save
npm i markdown-it-latex2img --save
  1. Config
# _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 speed

Options(optional)

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:

# _config.yml
markdown:
  plugins:
    - name: markdown-it-latex2img
      options:
        style: 'filter: opacity(90%);transform:scale(0.85);text-align:center;'

Convention

Markup is based on pandoc definition. Mathjax pointed out

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.

# 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) 
}
$$

Dependencies

Case

License

MIT © MakerGYT




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap