Welcome to djangocms-equation’s documentation!

djangocms-equation

PyPi Version Supported Python Versions License

Test Status Documentation Status Code Coverage Docstring Coverage This project is using Percy.io for visual regression testing.

Codacy code quality Total alerts Language grade: Python Language grade: JavaScript

Dependabot Status Code style Python: black Code style TypeScript: prettier

DjangoCMS plugin to write equations, utilizing KaTeX

Features

  • Enables the use of LaTeX for equations with django-cms

  • Live editing of LaTeX Code, via KaTeX

  • Out of the box support for mhchem

  • Configurable allowing of copying of equation LaTeX code

Installation

Install the plugin from PyPi

$ pip install djangocms-equation

Add the plugin to the installed apps in the settings.py of your django-cms project.

"INSTALLED_APPS": [..., "djangocms_equation"]

For the Equations to be properly displayed in djangocms-text-ckeditor, while edit them, you need to add the css file to the allowed files of ckeditor. To do this simply add the following lines to your settings.py of your django-cms project.

CKEDITOR_SETTINGS = {
    "contentsCss": ["/static/djangocms_equation/css/change_form_template.css"]
}

Note:

The equations might not be rendered properly in ckeditor-windows, when they are added the first time. This can be fixed by saving the text plugin or having another equation on the page.

To allow copying of equations LaTeX code, add the following line to your settings.py.

"KATEX_EQUATION_SETTINGS" = {"allow_copy": True}

Credits

This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.

Installation

Stable release

To install djangocms-equation, run this command in your terminal:

$ pip install djangocms-equation

This is the preferred method to install djangocms-equation, as it will always install the most recent stable release.

If you don’t have pip installed, this Python installation guide can guide you through the process.

From sources

The sources for djangocms-equation can be downloaded from the Github repo.

You can either clone the public repository:

$ git clone git://github.com/s-weigand/djangocms-equation

Or download the tarball:

$ curl  -OL https://github.com/s-weigand/djangocms-equation/tarball/master

Once you have a copy of the source, you can install it with:

$ python setup.py install

Credits

Development Lead

Contributors

None yet. Why not be the first?

History

0.2.4 (2021-05-11)

  • Upgraded KaTeX to 0.13.9

  • Updated javascript dependencies to fix security issues

0.2.3 (2021-05-04)

  • Upgraded KaTeX to 0.13.5

0.2.2 (2021-03-29)

  • Added official python 3.9 support

  • Upgraded KaTeX to 0.13.0

0.2.1 (2020-08-09)

  • Added official python 3.8 support

0.2.0 (2020-08-09)

  • Upgraded KaTeX to 0.12.0

  • Dropped support for Django 2.0

0.1.1 (2020-02-20)

  • Added project urls and removed conda badge

0.1.0 (2020-02-20)

  • First release on PyPI.

Contributing

Contributions are welcome, and they are greatly appreciated! Every little bit helps, and credit will always be given.

You can contribute in many ways:

Types of Contributions

Report Bugs

Report bugs at https://github.com/s-weigand/djangocms-equation/issues.

If you are reporting a bug, please include:

  • Your operating system name and version.

  • Any details about your local setup that might be helpful in troubleshooting.

  • Detailed steps to reproduce the bug.

Fix Bugs

Look through the GitHub issues for bugs. Anything tagged with “bug” and “help wanted” is open to whoever wants to implement it.

Implement Features

Look through the GitHub issues for features. Anything tagged with “enhancement” and “help wanted” is open to whoever wants to implement it.

Write Documentation

djangocms-equation could always use more documentation, whether as part of the official djangocms-equation docs, in docstrings, or even on the web in blog posts, articles, and such.

Submit Feedback

The best way to send feedback is to file an issue at https://github.com/s-weigand/djangocms-equation/issues.

If you are proposing a feature:

  • Explain in detail how it would work.

  • Keep the scope as narrow as possible, to make it easier to implement.

  • Remember that this is a volunteer-driven project, and that contributions are welcome :)

Get Started!

Ready to contribute? Here’s how to set up djangocms_equation for local development.

  1. Fork the djangocms_equation repo on GitHub.

  2. Clone your fork locally:

    $ git clone git@github.com:your_name_here/djangocms_equation.git
    
  3. Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development:

    $ mkvirtualenv djangocms_equation
    $ cd djangocms-equation/
    $ pip install -r requirements_dev.txt
    $ pip install -e .
    
  4. Install the pre-commit hooks, for quality assurance:

    $ pre-commit install && pre-commit install -t pre-push
    
  5. Create a branch for local development:

    $ git checkout -b name-of-your-bugfix-or-feature
    

    Now you can make your changes locally.

  6. When you’re done making changes, check that your changes pass flake8 and the tests, including testing other Python versions with tox and docker-compose:

    $ docker-compose up -d
    $ tox
    

    Docker compose is needed for the integration tests, which use selenium and the selenium docker images.

  7. Commit your changes and push your branch to GitHub:

    $ git add .
    $ git commit -m "Your detailed description of your changes."
    $ git push origin name-of-your-bugfix-or-feature
    
  8. Submit a pull request through the GitHub website.

Pull Request Guidelines

Before you submit a pull request, check that it meets these guidelines:

  1. The pull request should include tests.

  2. If the pull request adds functionality, the docs should be updated. Put your new functionality into a function with a docstring, and add the feature to the list in README.rst.

  3. The pull request should work for Python 3.5, 3.6 and 3.7. Check https://github.com/s-weigand/djangocms-equation/actions and make sure that the tests pass for all supported Python versions.

Note

Due to racing conditions in the integration tests, which I couldn’t completely eliminate, the CI might fail for some tests. In this case just write a comment, so I know to restart the test suite.

Tips

To run a subset of tests:

$ py.test tests.test_djangocms_equation

Deploying

A reminder for the maintainers on how to deploy. Make sure all your changes are committed (including an entry in HISTORY.rst). Then run:

$ bumpversion patch # possible: major / minor / patch
$ git push
$ git push --tags

Github actions will then deploy to PyPI if tests pass.

Python Source Documentation

Documentation of the Python source code. The auto generated Documentation mainly contains methods and attributes which are inherited from the corresponding classes of django-cms, but since the actual source code is very short you can just click the [source] link on top of each class. The auto generated documentation of the inherited classes is given to give insight on the actual finished objects.

cms_plugins.EquationPlugin

Implementation of the actual plugin.

forms.EquationForm

Inputs which are used in the Equation editing dialog.

models.EquationPluginModel

Database model of saved Equations.

Indices and tables