Skip to main content

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 the deno pip package). pip install doenetml-to-pretext alone 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 code
  • timeout (int): Timeout in milliseconds for conversion (default: 30000)

Returns:

  • str: PreTeXt XML output

Raises:

  • ConversionError: If conversion fails
  • BrowserError: If browser initialization fails
  • TimeoutError: 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 release events only (the same trigger as the npm production release), never pushes to main. Cutting a release whose tag matches the doenetml version 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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

doenetml_to_pretext-0.7.23-py3-none-any.whl (3.5 MB view details)

Uploaded Python 3

File details

Details for the file doenetml_to_pretext-0.7.23-py3-none-any.whl.

File metadata

File hashes

Hashes for doenetml_to_pretext-0.7.23-py3-none-any.whl
Algorithm Hash digest
SHA256 73b35f94bc25c313cf7f24342ca08397b170d2454ebdeeddbc981da0cf13408d
MD5 279fb3e751974849ea189a54c3a29a0f
BLAKE2b-256 e0e7e164ecd251a4f143dfa90236c2786d74fcb84a7f4dfc512777abab67a0c1

See more details on using hashes here.

Provenance

The following attestation bundles were made for doenetml_to_pretext-0.7.23-py3-none-any.whl:

Publisher: publish-doenetml-to-pretext-python.yml on Doenet/DoenetML

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

Release history Release notifications | RSS feed

0.7.26

1 file

0.7.25

1 file

0.7.24

1 file

This release

0.7.23 This release

1 file

0.7.22

1 file

0.7.21

1 file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page