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实现) 自然数的拆分

    题目描述 任何一个大于1的自然数n,总可以拆分成若干个小于n的自然数之和.拆分成的数字相同但顺序不同被看做是相同的方案,如果1+3与3+1被看做是同一种方案. 输入 输入待拆分的自然数n. 输出 如样 ...

  2. Java实现 基础算法 水仙花数

    public class 水仙花数 { public static void main(String[] args) { for (int i = 100; i < 1000; i++) { i ...

  3. java实现低碳生活大奖赛

    某电视台举办了低碳生活大奖赛.题目的计分规则相当奇怪: 每位选手需要回答 10 个问题(其编号为 1 到 10),越后面越有难度. 答对的,当前分数翻倍:答错了则扣掉与题号相同的分数(选手必须回答问题 ...

  4. java实现黄金队列

    ** 黄金队列** 黄金分割数0.618与美学有重要的关系.舞台上报幕员所站的位置大约就是舞台宽度的0.618处,墙上的画像一般也挂在房间高度的0.618处,甚至股票的波动据说也能找到0.618的影子 ...

  5. python自学Day05(自学书籍python编程从入门到实践)

    第6章 字典 6.1 一个简单的字典 先跟随书本创建一个简单的字典感受一下. alien_0 = {'color':'green','points':5} print(alien_0['color'] ...

  6. Java基础(十一)

    一.连接到服务器 telnet是一种用于网络编程的非常强大的测试工具,你可以在命令shell中输入telnet来启动它. 二.实现服务器 服务器循环体: 1.通过输入数据流从客户端接收一个命令. 2. ...

  7. Linux的文件系统及文件缓存知识点整理

    Linux的文件系统 文件系统的特点 文件系统要有严格的组织形式,使得文件能够以块为单位进行存储. 文件系统中也要有索引区,用来方便查找一个文件分成的多个块都存放在了什么位置. 如果文件系统中有的文件 ...

  8. 温故知新-java虚拟机

    文章目录 java虚拟机是什么? jvm的体系结构 第一个类加载子系统 类的生命周期 加载器分类 类加载机制 第二个运行时数据区(内存结构) GC算法和收集器 如何判断对象可以被回收? 如何判断一个常 ...

  9. OAuth + Security - 6 - 自定义授权模式

    我们知道OAuth2的官方提供了四种令牌的获取,简化模式,授权码模式,密码模式,客户端模式.其中密码模式中仅仅支持我们通过用户名和密码的方式获取令牌,那么我们如何去实现一个我们自己的令牌获取的模式呢? ...

  10. 附022.Kubernetes_v1.18.3高可用部署架构一

    kubeadm介绍 kubeadm概述 参考附003.Kubeadm部署Kubernetes. kubeadm功能 参考附003.Kubeadm部署Kubernetes. 本方案描述 本方案采用kub ...