Skip to main content

Python port of Markdoc

Project description

markdoc-py

Python port of Markdoc, a Markdown-based authoring framework with custom tags and annotations.

Documentation: https://osks.github.io/markdoc-py/markdocpy.html

Status

This project is under active development. Core parsing, transforming, and HTML rendering are implemented, with fixture-based tests and JS parity fixtures.

JS parity notes

The Python port intentionally tracks JS Markdoc behavior, but some differences can exist while parity work is in progress. To see what is currently covered and any known gaps:

  • spec-parity.md explains the parity scope and lists tracked gaps.
  • tests/spec/manifest.json marks known JS mismatches with xfail_js.
  • tests/test_spec_parity.py enforces parity against committed JS outputs.

Requirements

  • Python 3.13+
  • Node.js (only needed for JS parity fixture generation)

Install (dev)

make env

Quick start

import markdocpy as Markdoc

source = \"\"\"
# Hello

{% note title=\"A\" %}
Body
{% /note %}
\"\"\"

ast = Markdoc.parse(source)
content = Markdoc.transform(ast, {\"tags\": {\"note\": {\"render\": \"note\", \"attributes\": {\"title\": {}}}}})
html = Markdoc.renderers.html(content)

API

ast = Markdoc.parse(source)
content = Markdoc.transform(ast, config)
errors = Markdoc.validate(ast, config)
html = Markdoc.renderers.html(content)

Tests

make test

Lint / format

make lint
make lint-fix
make format

Docs

make docs

Fixtures

Python fixtures:

make fixtures

JS parity fixtures (requires Markdoc build):

cd markdoc
npm install
npm run build

cd pymarkdoc
make fixtures-js

Project layout

markdocpy/
  ast/
  parser/
  renderer/
  schema/
  transform/
  validator/
tests/
  fixtures/
  js/

Project details


Download files

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

Source Distribution

markdoc_py-0.3.0.tar.gz (53.5 kB view details)

Uploaded Source

Built Distribution

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

markdoc_py-0.3.0-py3-none-any.whl (25.0 kB view details)

Uploaded Python 3

File details

Details for the file markdoc_py-0.3.0.tar.gz.

File metadata

  • Download URL: markdoc_py-0.3.0.tar.gz
  • Upload date:
  • Size: 53.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for markdoc_py-0.3.0.tar.gz
Algorithm Hash digest
SHA256 e414a96a2d82ce16bbcbfab376a5f61cbab523caa353abe3e34172923e25fd97
MD5 689e996c5715da9763c3c847bc8cf6ea
BLAKE2b-256 0e0b19223436db234adeb4f17eb88afe39d10dda18f4eb34b5c0349490b6fad6

See more details on using hashes here.

Provenance

The following attestation bundles were made for markdoc_py-0.3.0.tar.gz:

Publisher: publish.yml on osks/markdoc-py

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

File details

Details for the file markdoc_py-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: markdoc_py-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 25.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for markdoc_py-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f68b7a5cf4d926b38979f4efd671a565722b92366e0551929d6e0ea5c5d77222
MD5 cd17690814b8e19cac5d6dc381f54a03
BLAKE2b-256 ee63ac8ffa89530cd0b5231776a95e6f7f2b597f40808a39c88cc2ce4d48be24

See more details on using hashes here.

Provenance

The following attestation bundles were made for markdoc_py-0.3.0-py3-none-any.whl:

Publisher: publish.yml on osks/markdoc-py

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