Convert DoenetML to PreTeXt using Deno
Project description
doenetml-to-pretext
Python package for converting DoenetML to PreTeXt using Deno.
Requires Deno at runtime. Conversions shell out to Deno, so it must be available on your
PATH(or install thedenopip package).pip install doenetml-to-pretextalone does not install Deno.
Installation
pip install doenetml-to-pretext
The wheel bundles the compiled JavaScript converter, but you must supply Deno
yourself — either a system install on PATH or pip install deno.
Usage
from doenetml_to_pretext import convert_doenetml_to_pretext
doenetml = '<p>Hello <m>\\frac{1}{2}</m></p>'
pretext_xml = convert_doenetml_to_pretext(doenetml)
print(pretext_xml)
Requirements
- Python 3.8+
- Deno
API
convert_doenetml_to_pretext(doenetml: str, timeout: int = 30000) -> str
Converts a DoenetML XML string to PreTeXt XML.
Parameters:
doenetml(str): DoenetML XML source codetimeout(int): Timeout in milliseconds for conversion (default: 30000)
Returns:
- str: PreTeXt XML output
Raises:
ConversionError: If conversion failsBrowserError: If browser initialization failsTimeoutError: If conversion times out
Examples
Simple conversion
from doenetml_to_pretext import convert_doenetml_to_pretext
xml = '<p>Test</p>'
result = convert_doenetml_to_pretext(xml)
With error handling
from doenetml_to_pretext import convert_doenetml_to_pretext, ConversionError
try:
result = convert_doenetml_to_pretext('<p>Test</p>')
except ConversionError as e:
print(f"Conversion failed: {e}")
Development
Install dev dependencies:
pip install -e ".[dev]"
Build a wheel (.whl) (might need pip install build first):
python -m build --wheel
The built wheel will be placed in dist/.
Run tests:
pytest
Publishing
Releases are published to PyPI
automatically by the
publish-doenetml-to-pretext-python.yml
GitHub Actions workflow, using Trusted Publishing
(OIDC) — no API token is stored.
- Version: derived from
packages/doenetml/package.json, so it stays in lockstep with@doenet/doenetml. There is no separate version to bump here. - Trigger: GitHub
releaseevents only (the same trigger as the npm production release), never pushes tomain. Cutting a release whose tag matches thedoenetmlversion publishes the matching wheel. - Dry run: the workflow can be run manually (
workflow_dispatch) targeting TestPyPI to validate packaging before a real release.
The wheel bundles the built JS assets from ../doenetml-to-pretext, so that
package must be built first; the workflow (and the npm run build wireit graph)
handles this automatically.
License
AGPL-3.0-or-later
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 Distributions
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 doenetml_to_pretext-0.7.21-py3-none-any.whl.
File metadata
- Download URL: doenetml_to_pretext-0.7.21-py3-none-any.whl
- Upload date:
- Size: 3.4 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6e45bd67c73665c904576153e31d03c92fe98207dfa80e2c786d43f98bc0873b
|
|
| MD5 |
9ef4150d743615e8746bbe5badab2283
|
|
| BLAKE2b-256 |
93ea563cb224b8c49f667790bf96679b0f16344e540fd76a7c5e3a679bc45ef0
|
Provenance
The following attestation bundles were made for doenetml_to_pretext-0.7.21-py3-none-any.whl:
Publisher:
publish-doenetml-to-pretext-python.yml on Doenet/DoenetML
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
doenetml_to_pretext-0.7.21-py3-none-any.whl -
Subject digest:
6e45bd67c73665c904576153e31d03c92fe98207dfa80e2c786d43f98bc0873b - Sigstore transparency entry: 2175041500
- Sigstore integration time:
-
Permalink:
Doenet/DoenetML@cfb75f6e4396f585b0bae939c8b7da3a12325945 -
Branch / Tag:
refs/tags/v0.7.21 - Owner: https://github.com/Doenet
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-doenetml-to-pretext-python.yml@cfb75f6e4396f585b0bae939c8b7da3a12325945 -
Trigger Event:
release
-
Statement type: