Markdown-it-latex2img
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
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.
- Install
npm i hexo-renderer-markdown-it --save
npm i markdown-it-latex2img --save
- 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的更多相关文章
- NiceMark——我的Markdown编辑器
NiceMark--我的Markdown编辑器 闲来无事,写了一个Markdown编辑器.基于electron,完全采用Web前段技术(Html,css,JavaScript)实现.代码已托管在Git ...
- Markdown 图片助手-MarkdownPicPicker
title: Markdown 图片助手 v0.1 toc: true comments: true date: 2016-06-04 16:40:06 tags: [Python, Markdown ...
- 前端学Markdown
前面的话 我个人理解,Markdown就是一个富文本编辑器语言,类似于sass对于css的功能,Markdown也可以叫做HTML预处理器,只不过它是一门轻量级的标记语言,可以更简单的实现HTML ...
- 好用的Markdown编辑器一览 readme.md 编辑查看
https://github.com/pandao/editor.md https://pandao.github.io/editor.md/examples/index.html Editor.md ...
- mac好用的markdown编辑器
在刚开始接触markdown的时候,就被吸引了.此后一直在找贴心的好用的markdown编辑器.印象笔记和马克飞象配合着用也是挺好的,唯一的缺点就是比较封闭,发个笔记的链接给同学,还得注册才能看,导致 ...
- Markdown学习笔记
分为两步: 1.阅读Markdown中文官网的文档 2.下载MarkdownPad2将中文官网中文档的例子敲一遍,其中Markdownpad2为官网中推荐的编辑器 备注: 如果只看中文官网文档,不边看 ...
- Linux 中优秀的文本化编辑思想大碰撞(Markdown、LaTeX、MathJax)
这样一个标题可能不太准确,因为确实无法准确地解释什么叫"文本化编辑思想".其实我这篇随笔主要是想探讨 Markdown.LaTeX.MathJax,有兴趣的朋友可以继续往下看,同时 ...
- Markdown是怎样接管我的各种的写作工作的
对于一个程序猿来说,没有什么比单纯的写代码更能让人兴奋了.如果能让你像写代码一样写文档,不用再面对那些繁琐的样式,你会怎么看?它就是Markdown!即使博客园已经有不少介绍的文章了,但是我依然还是不 ...
- markdown常用语法总结
转自markdown示例[模板] 1.1.段落标题 根据原文中的文档标题可以对应设置标题. # 一级标题## 二级标题### 三级标题 效果 => 一级标题 二级标题 三级标题 1.2.斜体.加 ...
- 基于 Cmd MarkDown 的 markdown 语法学习
首先我要打一个属于干货的广告:CmdMarkDown 是非常好用的markdown编辑器软件,支持全平台,由作业部落出品,分为客户端与WEB端两种使用场景. 本篇博客学习的markdown语法都是基于 ...
随机推荐
- 使用Mac的Remote Desktop Manager连接ubuntu16.04 & Win10的远程桌面
疫情严重,公司实行远程办公.自己只有mac电脑,苦于3个系统间跨平台建立远程桌面. 今天,终于尝试成功!特来记录,以防别人踩坑! Mac远程软件安装 Remote Desktop Manager软件非 ...
- (Java实现) 洛谷 P1071 潜伏者
题目描述 R国和 S国正陷入战火之中,双方都互派间谍,潜入对方内部,伺机行动.历尽艰险后,潜伏于 S国的 R 国间谍小 C终于摸清了 S 国军用密码的编码规则: 1. S 国军方内部欲发送的原信息经过 ...
- C# winform 学习(三)
目标 1.windows程序简介 2.窗体的常用属性和事件 3.显示消息框 4.多窗体应用 一.程序简介 1.特点:所见即所得,通过事件实现用户与界面的交互 2.程序结构 1)窗体文件(每个窗体至少有 ...
- Java实现猜底牌问题(贪婪法)
1 问题描述 设计一种策略,使在下面的游戏中,期望提问的次数达到最小.有一副纸牌,是由1张A,2张2,3张3,-9张9组成的,一共包含45张牌.有人从这副牌洗过的牌中抽出一张牌,问一连串可以回答是或否 ...
- java实现第五届蓝桥杯锦标赛
锦标赛 这题小编能力有限,还望大佬解决 题目描述 如果要在n个数据中挑选出第一大和第二大的数据(要求输出数据所在位置和值),使用什么方法比较的次数最少?我们可以从体育锦标赛中受到启发. 如图[1.pn ...
- Elasticsearch系列---生产数据备份恢复方案
前言 生产环境中运行的组件,只要有数据存储,定时备份.灾难恢复是必修课,mysql数据库的备份方案已经非常成熟,Elasticsearch也同样有成熟的数据备份.恢复方案,我们来了解一下. 概要 本篇 ...
- OpenSSH详解
OpenSSH详解(思维导图) 1. SSH概述 SSH 软件架构 认证方式 2. OpenSSH 2.1 客户端程序ssh 配置文件 ssh命令 客户端免密登录 scp sftp 2.2 服务端程序 ...
- Linux基础:pkill命令总结
本文只总结一些常用的用法,更详细的说明见man pkill和pkill --help. pkill命令 pkill命令:通过进程名杀死进程. 语法格式 Usage: pkill [options] & ...
- unittest实现用例运行失败截图
把这个方法放到父类basecase(unittest.TestCase)就行了 #coding: utf-8 import unittest, random, os, traceback from s ...
- LaTeX中常用代码段snippets(持续更新)
1.displaymath 单行数学环境,不带编号. \begin{displaymath} This\ is\ displaymath\ envirment.\ I\ don 't\ have\ a ...