Code Monkey home page Code Monkey logo

sphinx-math-dollar's Introduction

sphinx-math-dollar

sphinx-math-dollar is a Sphinx extension to let you write LaTeX math using $$.

To enable install it

pip install sphinx-math-dollar

or

conda install -c conda-forge sphinx-math-dollar

Then in your conf.py, add 'sphinx_math_dollar' to your extensions list:

extensions = ['sphinx_math_dollar', 'sphinx.ext.mathjax']

mathjax_config = {
    'tex2jax': {
        'inlineMath': [ ["\\(","\\)"] ],
        'displayMath': [["\\[","\\]"] ],
    },
}

The mathjax_config is needed to prevent MathJax from parsing dollar signs which are ignored by the extension because they should not be parsed as math.

You will now be able to use dollar signs for math, like $\int\sin(x)\,dx$, which will produce $intsin(x),dx$. You can also use double dollar signs for display math, like $$\int\sin(x)\,dx$$, which produces $$intsin(x),dx$$ (if you are reading this on GitHub, look at the version built by Sphinx here). The usual Sphinx :math: and .. math:: directives will also continue to work.

The extension will also work with docstrings when combined with the sphinx.ext.autodoc extension.

Configuration

sphinx-math-dollar uses a blacklist to determine which docutils nodes should not be parsed. The default blacklist is

(FixedTextElement, literal, math)

FixedTextElement covers the Simple Body Elements nodes.

Any docutils node that is contained in a blacklisted node or a subclass of a blacklisted node will not have $math$ parsed as LaTeX.

You can modify this by setting math_dollar_node_blacklist in conf.py. For example, to also prevent $math$ from rendering in headers nodes, add

from sphinx_math_dollar import NODE_BLACKLIST
from docutils.nodes import header

math_dollar_node_blacklist = NODE_BLACKLIST + (header,)

Note that configuring this variable replaces the default, so it is recommended to always include the above default values (NODE_BLACKLIST) in addition to additional nodes.

To debug which nodes are skipped, set the environment variable MATH_DOLLAR_DEBUG=1 or set math_dollar_debug = True in conf.py.

If you feel a node should always be part of the default blacklist, please make a pull request.

License

MIT.

sphinx-math-dollar's People

Contributors

asmeurer avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.