{"id":30991646,"url":"https://github.com/martin005/comrak-ext","last_synced_at":"2026-01-26T15:01:29.818Z","repository":{"id":313277535,"uuid":"1050386318","full_name":"Martin005/comrak-ext","owner":"Martin005","description":"Extended Python bindings for the Comrak Rust library, a fast CommonMark/GFM parser","archived":false,"fork":false,"pushed_at":"2026-01-19T18:22:54.000Z","size":165,"stargazers_count":3,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-01-20T00:46:51.900Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://pypi.org/project/comrak-ext/","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Martin005.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-09-04T11:06:07.000Z","updated_at":"2025-11-11T12:22:44.000Z","dependencies_parsed_at":"2025-09-05T02:19:16.964Z","dependency_job_id":"95317202-a7df-481c-b59f-681127476933","html_url":"https://github.com/Martin005/comrak-ext","commit_stats":null,"previous_names":["martin005/comrak-ext"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/Martin005/comrak-ext","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Martin005%2Fcomrak-ext","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Martin005%2Fcomrak-ext/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Martin005%2Fcomrak-ext/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Martin005%2Fcomrak-ext/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Martin005","download_url":"https://codeload.github.com/Martin005/comrak-ext/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Martin005%2Fcomrak-ext/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28781308,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-26T13:55:28.044Z","status":"ssl_error","status_checked_at":"2026-01-26T13:55:26.068Z","response_time":59,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-09-12T20:45:34.674Z","updated_at":"2026-01-26T15:01:29.813Z","avatar_url":"https://github.com/Martin005.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# comrak-ext\n\n\u003c!-- [![downloads](https://static.pepy.tech/badge/comrak-ext/month)](https://pepy.tech/project/comrak-ext) --\u003e\n\n[![uv](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/uv/main/assets/badge/v0.json)](https://github.com/astral-sh/uv)\n[![pdm-managed](https://img.shields.io/badge/pdm-managed-blueviolet)](https://pdm.fming.dev)\n[![PyPI](https://img.shields.io/pypi/v/comrak-ext.svg)](https://pypi.org/project/comrak-ext)\n[![Supported Python versions](https://img.shields.io/pypi/pyversions/comrak-ext.svg)](https://pypi.org/project/comrak-ext)\n[![License](https://img.shields.io/pypi/l/comrak-ext.svg)](https://pypi.python.org/pypi/comrak-ext)\n[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/Martin005/comrak-ext/master.svg)](https://results.pre-commit.ci/latest/github/Martin005/comrak-ext/master)\n\nExtended Python bindings for the Comrak Rust library, a fast CommonMark/GFM parser. Fork of [lmmx/comrak](https://github.com/lmmx/comrak).\n\n## Installation\n\n```bash\npip install comrak-ext\n```\n\n### Requirements\n\n- Python 3.9+\n\n## Features\n\nFast Markdown to HTML parser in Rust, shipped for Python via PyO3.\n\n## API\n\n### `markdown_to_html`\n\nRender Markdown to HTML:\n\n```python\nfrom comrak import ExtensionOptions, markdown_to_html\nextension_options = ExtensionOptions()\nmarkdown_to_html(\"foo :smile:\", extension_options)\n# '\u003cp\u003efoo :smile:\u003c/p\u003e\\n'\n\nextension_options.shortcodes = True\nmarkdown_to_html(\"foo :smile:\", extension_options)\n# '\u003cp\u003efoo 😄\u003c/p\u003e\\n'\n```\n\n### `markdown_to_commonmark`\n\nRender Markdown to CommonMark:\n\n```python\nfrom comrak import RenderOptions, ListStyleType, markdown_to_commonmark\n\nrender_options = RenderOptions()\nmarkdown_to_commonmark(\"- one\\n- two\\n- three\", render_options=render_options)\n\n# '- one\\n- two\\n- three\\n' – default is Dash\nrender_options.list_style = ListStyleType.Plus\nmarkdown_to_commonmark(\"- one\\n- two\\n- three\", render_options=render_options)\n# '+ one\\n+ two\\n+ three\\n'\n```\n\n### `markdown_to_xml`\n\nRender Markdown to XML:\n\n```python\nfrom comrak import RenderOptions, markdown_to_xml\n\nrender_options = RenderOptions(sourcepos=True)\nmarkdown_to_xml(\"Hello, **Markdown**!\", render_options=render_options)\n# '\u003c?xml version=\"1.0\" encoding=\"UTF-8\"?\u003e\\n\u003c!DOCTYPE document SYSTEM \"CommonMark.dtd\"\u003e\\n\u003cdocument sourcepos=\"1:1-1:20\" xmlns=\"http://commonmark.org/xml/1.0\"\u003e\\n  \u003cparagraph sourcepos=\"1:1-1:20\"\u003e\\n    \u003ctext sourcepos=\"1:1-1:7\" xml:space=\"preserve\"\u003eHello, \u003c/text\u003e\\n    \u003cstrong sourcepos=\"1:8-1:19\"\u003e\\n      \u003ctext sourcepos=\"1:10-1:17\" xml:space=\"preserve\"\u003eMarkdown\u003c/text\u003e\\n    \u003c/strong\u003e\\n    \u003ctext sourcepos=\"1:20-1:20\" xml:space=\"preserve\"\u003e!\u003c/text\u003e\\n  \u003c/paragraph\u003e\\n\u003c/document\u003e\\n'\n```\n\n### `parse_document`\n\nParse Markdown into an abstract syntax tree (AST):\n\n```python\nfrom comrak import ExtensionOptions, Document, Text, Paragraph, parse_document\n\nextension_options = ExtensionOptions(front_matter_delimiter = \"---\")\n\nmd_content = \"\"\"---\nThis is a text in FrontMatter\n---\n\nHello, Markdown!\n\"\"\"\n\nx = parse_document(md_content, extension_options)\nassert isinstance(x.node_value, Document)\nassert not hasattr(x.node_value, \"value\")\nassert len(x.children) == 2\n\nassert isinstance(x.children[0].node_value, FrontMatter)\nassert isinstance(x.children[0].node_value.value, str)\nassert x.children[0].node_value.value.strip() == \"---\\nThis is a text in FrontMatter\\n---\"\n\nassert isinstance(x.children[1].node_value, Paragraph)\nassert len(x.children[1].children) == 1\nassert isinstance(x.children[1].children[0].node_value, Text)\nassert isinstance(x.children[1].children[0].node_value.value, str)\nassert x.children[1].children[0].node_value.value == \"Hello, Markdown!\"\n```\n\n### `format_html`\n\nFormat an AST back to HTML:\n\n```python\nfrom comrak import parse_document, format_html\n\np = parse_document(\"\u003e Greentext blockquote requires a space after `\u003e`\")\n\nformat_html(p)\n# '\u003cblockquote\u003e\\n\u003cp\u003eGreentext blockquote requires a space after \u003ccode\u003e\u0026gt;\u003c/code\u003e\u003c/p\u003e\\n\u003c/blockquote\u003e\\n'\n```\n\n### `format_commonmark`\n\nFormat an AST back to CommonMark:\n\n```python\nfrom comrak import parse_document, format_commonmark\n\np = parse_document(\"\u003e Greentext blockquote requires a space after `\u003e`\")\n\nformat_commonmark(p)\n# '\u003e Greentext blockquote requires a space after `\u003e`\\n'\n```\n\n### `format_xml`\n\nFormat an AST back to XML:\n\n```python\nfrom comrak import parse_document, format_xml\n\np = parse_document(\"\u003e Greentext blockquote requires a space after `\u003e`\")\n\nformat_xml(p)\n# '\u003c?xml version=\"1.0\" encoding=\"UTF-8\"?\u003e\\n\u003c!DOCTYPE document SYSTEM \"CommonMark.dtd\"\u003e\\n\u003cdocument xmlns=\"http://commonmark.org/xml/1.0\"\u003e\\n  \u003cblock_quote\u003e\\n    \u003cparagraph\u003e\\n      \u003ctext xml:space=\"preserve\"\u003eGreentext blockquote requires a space after \u003c/text\u003e\\n      \u003ccode xml:space=\"preserve\"\u003e\u0026gt;\u003c/code\u003e\\n    \u003c/paragraph\u003e\\n  \u003c/block_quote\u003e\\n\u003c/document\u003e\\n'\n```\n\n### Options\n\nAll options are exposed in a simple manner and can be used with all functions.\n\nRefer to the [Comrak docs](https://docs.rs/comrak/latest/comrak/struct.Options.html) for all available options.\n\n## Benchmarks\n\nTested with small (8 lines) and medium (1200 lines) markdown strings\n\n- vs. [markdown](https://pypi.org/project/markdown): 15x faster (S/M)\n- vs. [markdown2](https://pypi.org/project/markdown2): 20x (S) - 60x (M) faster\n\n## Contributing\n\nMaintained by [Martin005](https://github.com/Martin005). Contributions welcome!\n\n1. **Issues \u0026 Discussions**: Please open a GitHub issue or discussion for bugs, feature requests, or questions.\n2. **Pull Requests**: PRs are welcome!\n   - Install the dev extra (e.g. with [uv](https://docs.astral.sh/uv/): `uv pip install -e .[dev]`)\n   - Run tests (when available) and include updates to docs or examples if relevant.\n   - If reporting a bug, please include the version and the error message/traceback if available.\n\n## License\n\nLicensed under the 2-Clause BSD License. See [LICENSE](https://github.com/Martin005/comrak-ext/blob/master/LICENSE) for all the details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmartin005%2Fcomrak-ext","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmartin005%2Fcomrak-ext","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmartin005%2Fcomrak-ext/lists"}