Markdown-it-latex2img



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/markdown-it@11.0.0/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 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

License

MIT MakerGYT

Markdown-it-latex2img的更多相关文章

  1. NiceMark——我的Markdown编辑器

    NiceMark--我的Markdown编辑器 闲来无事,写了一个Markdown编辑器.基于electron,完全采用Web前段技术(Html,css,JavaScript)实现.代码已托管在Git ...

  2. Markdown 图片助手-MarkdownPicPicker

    title: Markdown 图片助手 v0.1 toc: true comments: true date: 2016-06-04 16:40:06 tags: [Python, Markdown ...

  3. 前端学Markdown

    前面的话   我个人理解,Markdown就是一个富文本编辑器语言,类似于sass对于css的功能,Markdown也可以叫做HTML预处理器,只不过它是一门轻量级的标记语言,可以更简单的实现HTML ...

  4. 好用的Markdown编辑器一览 readme.md 编辑查看

    https://github.com/pandao/editor.md https://pandao.github.io/editor.md/examples/index.html Editor.md ...

  5. mac好用的markdown编辑器

    在刚开始接触markdown的时候,就被吸引了.此后一直在找贴心的好用的markdown编辑器.印象笔记和马克飞象配合着用也是挺好的,唯一的缺点就是比较封闭,发个笔记的链接给同学,还得注册才能看,导致 ...

  6. Markdown学习笔记

    分为两步: 1.阅读Markdown中文官网的文档 2.下载MarkdownPad2将中文官网中文档的例子敲一遍,其中Markdownpad2为官网中推荐的编辑器 备注: 如果只看中文官网文档,不边看 ...

  7. Linux 中优秀的文本化编辑思想大碰撞(Markdown、LaTeX、MathJax)

    这样一个标题可能不太准确,因为确实无法准确地解释什么叫"文本化编辑思想".其实我这篇随笔主要是想探讨 Markdown.LaTeX.MathJax,有兴趣的朋友可以继续往下看,同时 ...

  8. Markdown是怎样接管我的各种的写作工作的

    对于一个程序猿来说,没有什么比单纯的写代码更能让人兴奋了.如果能让你像写代码一样写文档,不用再面对那些繁琐的样式,你会怎么看?它就是Markdown!即使博客园已经有不少介绍的文章了,但是我依然还是不 ...

  9. markdown常用语法总结

    转自markdown示例[模板] 1.1.段落标题 根据原文中的文档标题可以对应设置标题. # 一级标题## 二级标题### 三级标题 效果 => 一级标题 二级标题 三级标题 1.2.斜体.加 ...

  10. 基于 Cmd MarkDown 的 markdown 语法学习

    首先我要打一个属于干货的广告:CmdMarkDown 是非常好用的markdown编辑器软件,支持全平台,由作业部落出品,分为客户端与WEB端两种使用场景. 本篇博客学习的markdown语法都是基于 ...

随机推荐

  1. (Java实现) 数塔问题

    数塔问题(使用动态规划思路求解) 如图所示,给定一个正整数构成的三角形,如下所示: 在下面的数字三角形中寻找一条从顶部到底边的路径, 使得路径上所经过的数字之和最大. 路径上的每一步都只能往左下或者右 ...

  2. Java实现 蓝桥杯VIP 算法训练 集合运算

    问题描述 给出两个整数集合A.B,求出他们的交集.并集以及B在A中的余集. 输入格式 第一行为一个整数n,表示集合A中的元素个数. 第二行有n个互不相同的用空格隔开的整数,表示集合A中的元素. 第三行 ...

  3. java实现第五届蓝桥杯海盗分金币

    海盗分金币 有5个海盗,相约进行一次帆船比赛. 比赛中天气发生突变,他们被冲散了. 恰巧,他们都先后经过途中的一个无名的荒岛,并且每个人都信心满满,觉得自己是第一个经过该岛的人. 第一个人在沙滩上发现 ...

  4. java实现第七届蓝桥杯圆圈舞

    圆圈舞 题目描述 春天温暖的阳光照耀着大地,正是草原上的小动物们最快乐的时候.小动物们在草原上开了一个舞会,欢度这美好的时光. 舞会上最重要的一个环节就是跳圆舞曲,n只小动物手拉手围成一大圈,随着音乐 ...

  5. iOS — 内存分配与分区

    1  RAM ROM RAM:运行内存,不能掉电存储.ROM:存储性内存,可以掉电存储,例如内存卡.Flash.      由于RAM类型不具备掉电存储能力(即一掉电数据消失),所以app程序一般存放 ...

  6. ReentrantLock原理分析

    一 UML类图 通过类图ReentrantLock是同步锁,同一时间只能有一个线程获取到锁,其他获取该锁的线程会被阻塞而被放入AQS阻塞队列中.ReentrantLock类继承Lock接口:内部抽象类 ...

  7. elementUI+国际化

    1. 先创建一个lang 文件夹,创建两个js文件en.js(英文), zh.js(中文), 另外创建一个index.js文件(用于) en.js zh.js (两者必须保持一致) 2. 在index ...

  8. Docker+Selenium+TestNG+Maven+Jenkins环境搭建

    一.Selenium环境准备 standalone-chrome Docker容器启动: docker pull selenium/standalone-chrome version: '3' ser ...

  9. fopen函数中的mode参数

    fopen FILE * fopen ( const char * filename, const char * mode ); 其中,参数mode可取以下值: "r"read: ...

  10. PowerApps Component Framework PCF 部署

    PowerApps PCF 可以满足复杂的功能, 我们可以使用PCF来创建复杂的PowerApps. 这里附上微软的package code componet 教程(https://docs.micr ...