python-markdown-math


Namepython-markdown-math JSON
Version 0.8 PyPI version JSON
download
home_pagehttps://github.com/mitya57/python-markdown-math
SummaryMath extension for Python-Markdown
upload_time2020-11-03 17:33:05
maintainer
docs_urlNone
authorDmitry Shachnev
requires_python>=3.6
licenseBSD 3-Clause License
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI
coveralls test coverage No coveralls.
            [![Travis CI status](https://api.travis-ci.org/mitya57/python-markdown-math.svg)][Travis]

[Travis]: https://travis-ci.org/mitya57/python-markdown-math

Math extension for Python-Markdown
==================================

This extension adds math formulas support to [Python-Markdown].

[Python-Markdown]: https://github.com/Python-Markdown/markdown

Installation
------------

### Install from PyPI

```
$ pip install python-markdown-math
```

### Install locally

Use `setup.py build` and `setup.py install` to build and install this
extension, respectively.

The extension name is `mdx_math`, so you need to add that name to your
list of Python-Markdown extensions.
Check [Python-Markdown documentation] for details on how to load
extensions.

[Python-Markdown documentation]: https://python-markdown.github.io/reference/#extensions

Usage
-----

To use this extension, you need to include [MathJax] library in HTML files, like:

```html
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/mathjax@2/MathJax.js">
</script>
```

[MathJax]: https://www.mathjax.org/

Also, you need to specify a configuration for MathJax. Please note that
most of standard configurations include `tex2jax` extension, which is not needed
with this code.

Example of configuration for MathJax 2.x:

```html
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
  config: ["MMLorHTML.js"],
  jax: ["input/TeX", "output/HTML-CSS", "output/NativeMML"],
  extensions: ["MathMenu.js", "MathZoom.js"]
});
</script>
```

If you want to use MathJax 3.x, you need to teach it to understand 2.x-style
`<script>` tags. See the [upgrading documentation] on how to do it.
Alternatively, you may use the [Arithmatex] extension which has a generic
output mode, that does not require such special configuration.

To pass the extension to Python-Markdown, use `mdx_math` as extension name.
For example:

```python
>>> md = markdown.Markdown(extensions=['mdx_math'])
>>> md.convert('$$e^x$$')
'<p>\n<script type="math/tex; mode=display">e^x</script>\n</p>'
```

Usage from the command line:

```
$ echo "\(e^x\)" | python3 -m markdown -x mdx_math
<p>
<script type="math/tex">e^x</script>
</p>
```

[upgrading documentation]: https://docs.mathjax.org/en/latest/upgrading/v2.html#math-script-example
[Arithmatex]: https://facelessuser.github.io/pymdown-extensions/extensions/arithmatex/

Math Delimiters
---------------

For inline math, use `\(...\)`.

For standalone math, use `$$...$$`, `\[...\]` or `\begin...\end`.

The single-dollar delimiter (`$...$`) for inline math is disabled by
default, but can be enabled by passing `enable_dollar_delimiter=True`
in the extension configuration.

If you want to use [GitLab-style delimiters] (``$`...`$`` for inline math,
and a code block-like `` ```math...``` `` syntax for standalone), use
`use_gitlab_delimiters=True` configuration option.

If you want to this extension to generate a preview node (which will be shown
when MathJax has not yet processed the node, or when JavaScript is unavailable),
use `add_preview=True` configuration option.

[GitLab-style delimiters]: https://gitlab.com/gitlab-org/gitlab/blob/master/doc/user/markdown.md#math

Notes
-----

If you use [ReText](https://github.com/retext-project/retext), this extension
is not needed as it is included by default.

This extension also works with Katex.  Use the following in your page `<head>`:

```html
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex/dist/katex.min.css" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/katex/dist/katex.min.js" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/katex/dist/contrib/mathtex-script-type.min.js" defer></script>
```



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/mitya57/python-markdown-math",
    "name": "python-markdown-math",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "",
    "author": "Dmitry Shachnev",
    "author_email": "mitya57@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/ec/17/e7e3f3fce951b8adec10987834f4b2fa721ebd9bd6651ce2a4f39c4c544d/python-markdown-math-0.8.tar.gz",
    "platform": "",
    "description": "[![Travis CI status](https://api.travis-ci.org/mitya57/python-markdown-math.svg)][Travis]\n\n[Travis]: https://travis-ci.org/mitya57/python-markdown-math\n\nMath extension for Python-Markdown\n==================================\n\nThis extension adds math formulas support to [Python-Markdown].\n\n[Python-Markdown]: https://github.com/Python-Markdown/markdown\n\nInstallation\n------------\n\n### Install from PyPI\n\n```\n$ pip install python-markdown-math\n```\n\n### Install locally\n\nUse `setup.py build` and `setup.py install` to build and install this\nextension, respectively.\n\nThe extension name is `mdx_math`, so you need to add that name to your\nlist of Python-Markdown extensions.\nCheck [Python-Markdown documentation] for details on how to load\nextensions.\n\n[Python-Markdown documentation]: https://python-markdown.github.io/reference/#extensions\n\nUsage\n-----\n\nTo use this extension, you need to include [MathJax] library in HTML files, like:\n\n```html\n<script type=\"text/javascript\" src=\"https://cdn.jsdelivr.net/npm/mathjax@2/MathJax.js\">\n</script>\n```\n\n[MathJax]: https://www.mathjax.org/\n\nAlso, you need to specify a configuration for MathJax. Please note that\nmost of standard configurations include `tex2jax` extension, which is not needed\nwith this code.\n\nExample of configuration for MathJax 2.x:\n\n```html\n<script type=\"text/x-mathjax-config\">\nMathJax.Hub.Config({\n  config: [\"MMLorHTML.js\"],\n  jax: [\"input/TeX\", \"output/HTML-CSS\", \"output/NativeMML\"],\n  extensions: [\"MathMenu.js\", \"MathZoom.js\"]\n});\n</script>\n```\n\nIf you want to use MathJax 3.x, you need to teach it to understand 2.x-style\n`<script>` tags. See the [upgrading documentation] on how to do it.\nAlternatively, you may use the [Arithmatex] extension which has a generic\noutput mode, that does not require such special configuration.\n\nTo pass the extension to Python-Markdown, use `mdx_math` as extension name.\nFor example:\n\n```python\n>>> md = markdown.Markdown(extensions=['mdx_math'])\n>>> md.convert('$$e^x$$')\n'<p>\\n<script type=\"math/tex; mode=display\">e^x</script>\\n</p>'\n```\n\nUsage from the command line:\n\n```\n$ echo \"\\(e^x\\)\" | python3 -m markdown -x mdx_math\n<p>\n<script type=\"math/tex\">e^x</script>\n</p>\n```\n\n[upgrading documentation]: https://docs.mathjax.org/en/latest/upgrading/v2.html#math-script-example\n[Arithmatex]: https://facelessuser.github.io/pymdown-extensions/extensions/arithmatex/\n\nMath Delimiters\n---------------\n\nFor inline math, use `\\(...\\)`.\n\nFor standalone math, use `$$...$$`, `\\[...\\]` or `\\begin...\\end`.\n\nThe single-dollar delimiter (`$...$`) for inline math is disabled by\ndefault, but can be enabled by passing `enable_dollar_delimiter=True`\nin the extension configuration.\n\nIf you want to use [GitLab-style delimiters] (``$`...`$`` for inline math,\nand a code block-like `` ```math...``` `` syntax for standalone), use\n`use_gitlab_delimiters=True` configuration option.\n\nIf you want to this extension to generate a preview node (which will be shown\nwhen MathJax has not yet processed the node, or when JavaScript is unavailable),\nuse `add_preview=True` configuration option.\n\n[GitLab-style delimiters]: https://gitlab.com/gitlab-org/gitlab/blob/master/doc/user/markdown.md#math\n\nNotes\n-----\n\nIf you use [ReText](https://github.com/retext-project/retext), this extension\nis not needed as it is included by default.\n\nThis extension also works with Katex.  Use the following in your page `<head>`:\n\n```html\n<link rel=\"stylesheet\" href=\"https://cdn.jsdelivr.net/npm/katex/dist/katex.min.css\" crossorigin=\"anonymous\">\n<script src=\"https://cdn.jsdelivr.net/npm/katex/dist/katex.min.js\" crossorigin=\"anonymous\"></script>\n<script src=\"https://cdn.jsdelivr.net/npm/katex/dist/contrib/mathtex-script-type.min.js\" defer></script>\n```\n\n\n",
    "bugtrack_url": null,
    "license": "BSD 3-Clause License",
    "summary": "Math extension for Python-Markdown",
    "version": "0.8",
    "project_urls": {
        "Homepage": "https://github.com/mitya57/python-markdown-math"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4d36d16118345ff5f503d4d1c708e8427ed2213f2af7aaffac9d59010e665b5c",
                "md5": "74e793e81f5d0723b0e10c756dd457f3",
                "sha256": "c685249d84b5b697e9114d7beb352bd8ca2e07fd268fd4057ffca888c14641e5"
            },
            "downloads": -1,
            "filename": "python_markdown_math-0.8-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "74e793e81f5d0723b0e10c756dd457f3",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 5858,
            "upload_time": "2020-11-03T17:33:02",
            "upload_time_iso_8601": "2020-11-03T17:33:02.998369Z",
            "url": "https://files.pythonhosted.org/packages/4d/36/d16118345ff5f503d4d1c708e8427ed2213f2af7aaffac9d59010e665b5c/python_markdown_math-0.8-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ec17e7e3f3fce951b8adec10987834f4b2fa721ebd9bd6651ce2a4f39c4c544d",
                "md5": "c35018274585b418651986c6f586b6f4",
                "sha256": "8564212af679fc18d53f38681f16080fcd3d186073f23825c7ce86fadd3e3635"
            },
            "downloads": -1,
            "filename": "python-markdown-math-0.8.tar.gz",
            "has_sig": false,
            "md5_digest": "c35018274585b418651986c6f586b6f4",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 8509,
            "upload_time": "2020-11-03T17:33:05",
            "upload_time_iso_8601": "2020-11-03T17:33:05.462784Z",
            "url": "https://files.pythonhosted.org/packages/ec/17/e7e3f3fce951b8adec10987834f4b2fa721ebd9bd6651ce2a4f39c4c544d/python-markdown-math-0.8.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2020-11-03 17:33:05",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "mitya57",
    "github_project": "python-markdown-math",
    "travis_ci": true,
    "coveralls": false,
    "github_actions": false,
    "lcname": "python-markdown-math"
}
        
Elapsed time: 0.11524s