Skip to main content

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

Project details


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.21-py3-none-any.whl (3.4 MB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for doenetml_to_pretext-0.7.21-py3-none-any.whl
Algorithm Hash digest
SHA256 6e45bd67c73665c904576153e31d03c92fe98207dfa80e2c786d43f98bc0873b
MD5 9ef4150d743615e8746bbe5badab2283
BLAKE2b-256 93ea563cb224b8c49f667790bf96679b0f16344e540fd76a7c5e3a679bc45ef0

See more details on using hashes here.

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

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