An authoring system for mathematical diagrams
Project description
PreFigure
PreFigure is a Python package for authoring mathematical diagrams. Following the PreTeXt paradigm, an author creates an XML description of a diagram that PreFigure converts into an image file suitable for including in a text document. By default, PreFigure will create an SVG image that can be included in, say, an HTML document. However, PreFigure prioritizes the creation of accessible diagrams so that annotations can be added that enable a screen reader to easily navigate the diagram. Tactile diagrams can also be created from the same XML source.
More information, including detailed documentation, is available from the PreFigure homepage.
Using PreFigure
You may author and compile PreFigure diagrams in either of two environments:
- PreFigure is available in a GitHub Codespace. This is a free, cloud-based platform that takes care of all the installation details and creates a fully configured working environment. Follow the instructions on that page to create your codespace and then get started authoring diagrams.
- PreFigure may be installed locally as a Python package following the instructions in the Local Installation section below.
Local Installation
PreFigure may be installed locally as a Python package in the usual way using pip. However, there are a few details that require your attention.
-
PreFigure assumes the Python version specified in
pyproject.toml, which is currently 3.10. You may check your local Python version with one of the two commands belowpython -Vpython3 -V -
You are encouraged to install
liblouis, which enables the creation of non-mathematical braille labels in tactile diagrams. PreFigure can still create non-tactile diagrams without this package installed though you will see a non-fatal warning message when you compile diagrams.On a linux machine, use your package manager to install
python3-louiswhile on a Mac, you will want
brew install liblouisAlternatively, you can install
liblouisfollowing these instructions.Within a Python interpreter, you should then be able to
import louiswithout an error. -
You are encouraged to install an additional library to support the Pycairo package. This may not be essential for your local machine, but there is no harm in performing this step and it will guarantee that PreFigure has access to a reqiured package.
-
You are now ready to install PreFigure with
pip install prefig -
You will need a local installation of
nodeandnpmto produce mathematical labels. (Thenodeinstallation includesnpm.) This is a simple process, but you should search to find the instructions for your operating system. On a Ubuntu machine, it's as easy asapt install nodejs
Usage
Once PreFigure is installed, help is available with
prefig --help
or, say,
prefig build --help
PreFigure source files can be compiled into SVG images using one of the following two commands, with the first command creating a regular SVG file while the second produces a tactile version of the diagram.
prefig build foo.xml
prefig build -f tactile foo.xml
By default, the output appears in output/foo.svg and output/foo.xml, where the XML output contains the annotations used by a screen reader.
To view the resulting diagram, use either
prefig view foo
prefig view -i foo
The first command will open the diagram in a browser using the diagcess library, which enables a reader to explore the annotations interactively. The second command ignores the annotations and simply opens the SVG diagram in a browser.
You may wish to perform the following steps to set up your authoring environment (these are automatically performed in a codespace):
-
To initialize your local installation, use
prefig initwhich will use
npmto install some MathJax modules. It will also install the Braille29 font needed for tactile diagrams. If the MathJax modules are not installed when you attempt to build a diagram, PreFigure will attempt to install them when you build your first diagram. -
You may install a set of examples for exploration in the current directory using
prefig examples -
You may initialize a new PreFigure project in the current directory using
prefig newThis copies the
diagcesstools and a default publication file into the current directory and creates asourcedirectory in which to author diagrams.
Acknowledgements
Volker Sorge has provided crucial support for this project as well as access to the diagcess library for navigating an image with a screen reader.
The MathJax module mj-sre-page.js included with this distribution was created by Davide Cervone and Volker Sorge.
Thanks also to the PreTeXt community, and especially Rob Beezer, for support and inspiration. This project was developed with support from the UTMOST Project
License
PreFigure is distributed with a GPL license.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file prefig-0.2.2.dev20240922053208.tar.gz.
File metadata
- Download URL: prefig-0.2.2.dev20240922053208.tar.gz
- Upload date:
- Size: 89.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.10.15 Linux/6.8.0-1014-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1388105fe067e76db3acf52a2deef9633c74ec93affccf3b5c39c356d0347d86
|
|
| MD5 |
d781f8c5f66b3795214433f4ff96ad2c
|
|
| BLAKE2b-256 |
53379101e31d8e80dfeb44127da958c264677f9223925f03221549d4070e95d8
|
File details
Details for the file prefig-0.2.2.dev20240922053208-py3-none-any.whl.
File metadata
- Download URL: prefig-0.2.2.dev20240922053208-py3-none-any.whl
- Upload date:
- Size: 108.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.10.15 Linux/6.8.0-1014-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2899b1a1b2f3a42674871641585a746c0a5a08a873ba3df5dfefdabf0bf45d13
|
|
| MD5 |
7b55bd54c9092632840cac9af89376bc
|
|
| BLAKE2b-256 |
5f5231f6ec9213cc9c554240c88018881836f9238311d546cb5a3628b12e963b
|