Skip to main content

python-markdown extension for support mathjax

Project description

md4mathjax

this is a python-markdown extension. basicly learning from the pelican plugin render-math. and i think inside its code, the mathjax extension split would be better.

原插件做了很多额外的工作,但现在mathjax对于数学公式写法上的支持已经很强大了,很多额外的工作都是没有必要的了。

本插件做的两个工作一就是检测markdown文档里面是否有数学公式,如果有则插入下面这段js代码。

本插件还有一个工作就是将检测到的数学公式封装进 class=math 的span或者div环境中。这给后续css调配提供了便利。

此外因为markdown的EscapeInlineProcessor机制存在,如果不进行处理 \(...\) \[...\) 这两个写法都会出错的,本插件经过处理将数学公式统一转为 $...$$$ ... $$ 这样的形式了。

很简单直观的一个插件,同时又完成了必要的工作。tests文件夹下可以有输出html文件参考。

Usage

This Extension is writing in the Python-Markdown Recommend way, so basically it's usage can reference the Python-Markdown Extension Usage document.

本插件在写法是Python-Markdown的统一写法,因此使用可以参看Python-Markdown的插件使用文档。

in pelican

MARKDOWN = {
    'extensions': [
        'md4mathjax'
    ],
}

参数

auto_insert

default True

是否根据文章有否数学公式来添加mathjax

based on the markdown file does have the math equations to decide whether add the mathjax script

tag_class

default math

like

<div class="math">$\pi$</div>

mathjax_src

default https://cdn.jsdelivr.net/npm/mathjax@3.2.0/es5/tex-mml-chtml.js

mathjax_id

default MathJax-script

mathjax_settings

default

DEFUALT_MATHJAX_SETTING = r"""
window.MathJax = {
  tex: {
    inlineMath: [['$', '$'], ['\\(', '\\)']],
    displayMath: [["$$", "$$"], ['\\[', '\\]']],
    packages: {
      '[+]': ['mhchem']
    }
  },
  loader: {
    load: ['[tex]/mhchem']
  },
}
"""

In python assign this value do not forget the prefix r .

CHANGELOG

0.1.3

fix escape issue.

0.1.2

README

0.1.1

解决了和toc插件不兼容的问题。

fixed a problem which is conflicted with the toc extension

0.1.0

初步编写完成

project started

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

md4mathjax-0.1.3.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

md4mathjax-0.1.3-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file md4mathjax-0.1.3.tar.gz.

File metadata

  • Download URL: md4mathjax-0.1.3.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0

File hashes

Hashes for md4mathjax-0.1.3.tar.gz
Algorithm Hash digest
SHA256 d0b5286c863ea4025e768e904c5c73747f869e1af83dd9be4392bd4a0f4590f3
MD5 dd00f2df75b0936c93aa586270e05e18
BLAKE2b-256 470bc59cce80b6960041ff8201e1c5ad08e98c2ed0359ca15d3ebae5e7772591

See more details on using hashes here.

File details

Details for the file md4mathjax-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: md4mathjax-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 5.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0

File hashes

Hashes for md4mathjax-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 06336f4ef3e8a43458ca7cf4ebda0d56632ec6bcee8d0e861aa71a82035e28b1
MD5 e672f4922f13b10444af9f252b23e72d
BLAKE2b-256 76f5e2c4a54246e52e42ea7f5a133fd0bc8c898ecc8c202b9f2f95d9330ed5d8

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page