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 wagtail_polymath:

pip install wagtail_polymath

Add it to your INSTALLED_APPS:

# settings.py

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

Use MathBlock in your StreamField content:

from wagtail_polymath.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 wagtail_polymath %}
...

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

Contributing

All contributions are welcome! See CONTRIBUTING.md

Supported versions:

  • Python 3.10-3.14
  • Django 5.2, 6.0
  • Wagtail 7.0 (LTS), 7.3, 7.4 (LTS)

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

wagtail_polymath-2.0.0.dev1.tar.gz (8.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

wagtail_polymath-2.0.0.dev1-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

Details for the file wagtail_polymath-2.0.0.dev1.tar.gz.

File metadata

  • Download URL: wagtail_polymath-2.0.0.dev1.tar.gz
  • Upload date:
  • Size: 8.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for wagtail_polymath-2.0.0.dev1.tar.gz
Algorithm Hash digest
SHA256 466be95d28543e7852167805453bc1b744fa89867947c2cc620e8c45be1ec8c8
MD5 cd6d3e06717a3a4e6c669d8eef3e5f19
BLAKE2b-256 6cc6619f6d4eb8f2ccfcdd6c479c5e081012fb92227dcbce1830e10973fb5353

See more details on using hashes here.

Provenance

The following attestation bundles were made for wagtail_polymath-2.0.0.dev1.tar.gz:

Publisher: publish.yml on wagtail-nest/wagtail-polymath

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file wagtail_polymath-2.0.0.dev1-py3-none-any.whl.

File metadata

File hashes

Hashes for wagtail_polymath-2.0.0.dev1-py3-none-any.whl
Algorithm Hash digest
SHA256 a49ac6f0b2a901b6dfff8df4c7a63fc655e8942ea070fb11281f31d284ca2264
MD5 d55a224c7aa655aa846647ba83d6e33c
BLAKE2b-256 d69c249beb08849ae11db7135c3e35b35b8b8c57473a01a41f8a8ed41e1a6c7c

See more details on using hashes here.

Provenance

The following attestation bundles were made for wagtail_polymath-2.0.0.dev1-py3-none-any.whl:

Publisher: publish.yml on wagtail-nest/wagtail-polymath

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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