Skip to main content

Wagtail StreamField block for rendering mathematical equations

Project description

wagtail-polymath

License: BSD-3-Clause Ruff PyPI version Build status

Links

wagtail-polymath allows you to write equations in your Wagtail content using markup and render them beautifully.

wagtail-polymath provides a MathBlock so you can write equations in markup (TeX, MathML, ASCIIMath) and render them with MathJax. It features a live preview:

MathBlock uses MathJax for rendering so there is very little to do on the front end. Simply include the MathJax JS and render the raw MathBlock content as you would for any other streamfield plain text block.

wagtail-polymath even includes a template tag to include the MathJax JS for you from a CDN. By default, MathJax is configured to accept all recognised markup (TeX, MathML, ASCIIMath) and renders them to HTML. To change the configuration, you can pass the desired config command to the templatetag. See the MathJax documentation for possible configurations.

For help on using the markup languages see the relevant MathJax documentation (e.g. https://docs.mathjax.org/en/v2.7-latest/tex.html) and the markup language-specific documentation (e.g. https://en.wikibooks.org/wiki/LaTeX)

Quickstart

Install wagtailmath:

pip install wagtailmath

Add it to your INSTALLED_APPS:

# settings.py

INSTALLED_APPS = (
    # ...
    "wagtailmath",
    # ...
)

Use MathBlock in your StreamField content:

from wagtailmath.blocks import MathBlock

class MyPage(Page):
    body = StreamField([
        ('heading', blocks.CharBlock(classname="full title")),
        ('paragraph', blocks.RichTextBlock()),
        ('equation', MathBlock())
    ])

Use the mathjax template tag in your front end template to load the MathJax library:

{% load wagtailmath %}
...

<script src="{% mathjax %}"></script>

Contributing

All contributions are welcome! See CONTRIBUTING.md

Supported versions:

  • Python 3.8, 3.9, 3.10, 3.11, 3.12
  • Django 4.2, 5.0
  • Wagtail 5.2 (LTS), 6.0, 6.1

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

wagtailmath-1.3.0.tar.gz (9.6 kB view details)

Uploaded Source

Built Distribution

wagtailmath-1.3.0-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

File details

Details for the file wagtailmath-1.3.0.tar.gz.

File metadata

  • Download URL: wagtailmath-1.3.0.tar.gz
  • Upload date:
  • Size: 9.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.32.3

File hashes

Hashes for wagtailmath-1.3.0.tar.gz
Algorithm Hash digest
SHA256 723c26fd6749efcf9981d215b8ec34f67bfbdf902997db931aa26bb803537265
MD5 84fb1dd71d61abed8b7fc51ffa797a04
BLAKE2b-256 6e33b4448bc13661dee7c1ec2ee2780d7ac82c674a095d43bab9397da4e57026

See more details on using hashes here.

File details

Details for the file wagtailmath-1.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for wagtailmath-1.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f49d46c1caf3979cd305ec77cf3066ecdb2630bb211fc5b8d7666706289fe252
MD5 69f12309957d57e04539954e067b38ab
BLAKE2b-256 9136181854475eddfccfc592e67cdf42aba22016e4f15b9fc64340173be51a03

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