# 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
Raw data
{
"_id": null,
"home_page": "https://github.com/a358003542/md4mathjax",
"name": "md4mathjax",
"maintainer": "wanze",
"docs_url": null,
"requires_python": "",
"maintainer_email": "a358003542@outlook.com",
"keywords": "markdown,python,mathjax",
"author": "wanze",
"author_email": "a358003542@outlook.com",
"download_url": "https://files.pythonhosted.org/packages/47/0b/c59cce80b6960041ff8201e1c5ad08e98c2ed0359ca15d3ebae5e7772591/md4mathjax-0.1.3.tar.gz",
"platform": "",
"description": "# md4mathjax\nthis 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.\n\n\u539f\u63d2\u4ef6\u505a\u4e86\u5f88\u591a\u989d\u5916\u7684\u5de5\u4f5c\uff0c\u4f46\u73b0\u5728mathjax\u5bf9\u4e8e\u6570\u5b66\u516c\u5f0f\u5199\u6cd5\u4e0a\u7684\u652f\u6301\u5df2\u7ecf\u5f88\u5f3a\u5927\u4e86\uff0c\u5f88\u591a\u989d\u5916\u7684\u5de5\u4f5c\u90fd\u662f\u6ca1\u6709\u5fc5\u8981\u7684\u4e86\u3002\n\n\u672c\u63d2\u4ef6\u505a\u7684\u4e24\u4e2a\u5de5\u4f5c\u4e00\u5c31\u662f\u68c0\u6d4bmarkdown\u6587\u6863\u91cc\u9762\u662f\u5426\u6709\u6570\u5b66\u516c\u5f0f\uff0c\u5982\u679c\u6709\u5219\u63d2\u5165\u4e0b\u9762\u8fd9\u6bb5js\u4ee3\u7801\u3002\n\n\u672c\u63d2\u4ef6\u8fd8\u6709\u4e00\u4e2a\u5de5\u4f5c\u5c31\u662f\u5c06\u68c0\u6d4b\u5230\u7684\u6570\u5b66\u516c\u5f0f\u5c01\u88c5\u8fdb `class=math` \u7684span\u6216\u8005div\u73af\u5883\u4e2d\u3002\u8fd9\u7ed9\u540e\u7eedcss\u8c03\u914d\u63d0\u4f9b\u4e86\u4fbf\u5229\u3002\n\n\u6b64\u5916\u56e0\u4e3amarkdown\u7684EscapeInlineProcessor\u673a\u5236\u5b58\u5728\uff0c\u5982\u679c\u4e0d\u8fdb\u884c\u5904\u7406 `\\(...\\)` `\\[...\\)` \u8fd9\u4e24\u4e2a\u5199\u6cd5\u90fd\u4f1a\u51fa\u9519\u7684\uff0c\u672c\u63d2\u4ef6\u7ecf\u8fc7\u5904\u7406\u5c06\u6570\u5b66\u516c\u5f0f\u7edf\u4e00\u8f6c\u4e3a `$...$` \u548c `$$ ... $$` \u8fd9\u6837\u7684\u5f62\u5f0f\u4e86\u3002\n\n\u5f88\u7b80\u5355\u76f4\u89c2\u7684\u4e00\u4e2a\u63d2\u4ef6\uff0c\u540c\u65f6\u53c8\u5b8c\u6210\u4e86\u5fc5\u8981\u7684\u5de5\u4f5c\u3002tests\u6587\u4ef6\u5939\u4e0b\u53ef\u4ee5\u6709\u8f93\u51fahtml\u6587\u4ef6\u53c2\u8003\u3002\n\n## Usage\nThis Extension is writing in the Python-Markdown Recommend way, so basically it's usage can reference the Python-Markdown Extension Usage document. \n\n\u672c\u63d2\u4ef6\u5728\u5199\u6cd5\u662fPython-Markdown\u7684\u7edf\u4e00\u5199\u6cd5\uff0c\u56e0\u6b64\u4f7f\u7528\u53ef\u4ee5\u53c2\u770bPython-Markdown\u7684\u63d2\u4ef6\u4f7f\u7528\u6587\u6863\u3002\n\n### in pelican\n\n```\nMARKDOWN = {\n 'extensions': [\n 'md4mathjax'\n ],\n}\n```\n\n## \u53c2\u6570\n### auto_insert \ndefault True \n\n\u662f\u5426\u6839\u636e\u6587\u7ae0\u6709\u5426\u6570\u5b66\u516c\u5f0f\u6765\u6dfb\u52a0mathjax\n\nbased on the markdown file does have the math equations to decide whether add the mathjax\nscript\n\n### tag_class \ndefault math\n\nlike \n```\n<div class=\"math\">$\\pi$</div>\n```\n\n### mathjax_src\ndefault https://cdn.jsdelivr.net/npm/mathjax@3.2.0/es5/tex-mml-chtml.js\n\n### mathjax_id\ndefault MathJax-script\n\n### mathjax_settings\n\ndefault \n\n```\nDEFUALT_MATHJAX_SETTING = r\"\"\"\nwindow.MathJax = {\n tex: {\n inlineMath: [['$', '$'], ['\\\\(', '\\\\)']],\n displayMath: [[\"$$\", \"$$\"], ['\\\\[', '\\\\]']],\n packages: {\n '[+]': ['mhchem']\n }\n },\n loader: {\n load: ['[tex]/mhchem']\n },\n}\n\"\"\"\n```\n\nIn python assign this value do not forget the prefix `r` .\n\n\n## CHANGELOG\n### 0.1.3\nfix escape issue.\n\n### 0.1.2\nREADME \n\n### 0.1.1\n\u89e3\u51b3\u4e86\u548ctoc\u63d2\u4ef6\u4e0d\u517c\u5bb9\u7684\u95ee\u9898\u3002\n\nfixed a problem which is conflicted with the toc extension\n\n### 0.1.0\n\u521d\u6b65\u7f16\u5199\u5b8c\u6210\n\nproject started\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "python-markdown extension for support mathjax",
"version": "0.1.3",
"project_urls": {
"Homepage": "https://github.com/a358003542/md4mathjax"
},
"split_keywords": [
"markdown",
"python",
"mathjax"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "76f5e2c4a54246e52e42ea7f5a133fd0bc8c898ecc8c202b9f2f95d9330ed5d8",
"md5": "e672f4922f13b10444af9f252b23e72d",
"sha256": "06336f4ef3e8a43458ca7cf4ebda0d56632ec6bcee8d0e861aa71a82035e28b1"
},
"downloads": -1,
"filename": "md4mathjax-0.1.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "e672f4922f13b10444af9f252b23e72d",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 5712,
"upload_time": "2022-01-18T21:18:42",
"upload_time_iso_8601": "2022-01-18T21:18:42.859218Z",
"url": "https://files.pythonhosted.org/packages/76/f5/e2c4a54246e52e42ea7f5a133fd0bc8c898ecc8c202b9f2f95d9330ed5d8/md4mathjax-0.1.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "470bc59cce80b6960041ff8201e1c5ad08e98c2ed0359ca15d3ebae5e7772591",
"md5": "dd00f2df75b0936c93aa586270e05e18",
"sha256": "d0b5286c863ea4025e768e904c5c73747f869e1af83dd9be4392bd4a0f4590f3"
},
"downloads": -1,
"filename": "md4mathjax-0.1.3.tar.gz",
"has_sig": false,
"md5_digest": "dd00f2df75b0936c93aa586270e05e18",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 6718,
"upload_time": "2022-01-18T21:18:44",
"upload_time_iso_8601": "2022-01-18T21:18:44.826840Z",
"url": "https://files.pythonhosted.org/packages/47/0b/c59cce80b6960041ff8201e1c5ad08e98c2ed0359ca15d3ebae5e7772591/md4mathjax-0.1.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2022-01-18 21:18:44",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "a358003542",
"github_project": "md4mathjax",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [
{
"name": "markdown",
"specs": [
[
">=",
"3.0"
]
]
}
],
"lcname": "md4mathjax"
}