From 2bae6817371905a1c3282f1fe114095c32b7b5e8 Mon Sep 17 00:00:00 2001 From: Mike Fiedler Date: Sun, 19 Oct 2025 18:56:06 -0400 Subject: [PATCH 1/6] chore: replace cmarkgfm with comrak Signed-off-by: Mike Fiedler --- pyproject.toml | 4 ++-- readme_renderer/markdown.py | 36 ++++++++++++++++++++++++++++-------- 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index ddbc2ed..0307a8f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -36,7 +36,7 @@ classifiers = [ requires-python = ">=3.9" [project.optional-dependencies] -md = ["cmarkgfm>=0.8.0"] +md = ["comrak>=0.0.6"] [tool.setuptools] include-package-data = true @@ -66,6 +66,6 @@ enable_error_code = [ [[tool.mypy.overrides]] # These modules do not yet have types available. module = [ - "cmarkgfm.*" + "comrak.*" ] ignore_missing_imports = true diff --git a/readme_renderer/markdown.py b/readme_renderer/markdown.py index 6e71a43..ff0b8da 100644 --- a/readme_renderer/markdown.py +++ b/readme_renderer/markdown.py @@ -30,16 +30,36 @@ ) try: - import cmarkgfm - from cmarkgfm.cmark import Options as cmarkgfmOptions + import comrak + + gfm_extension_options = comrak.ExtensionOptions() + gfm_extension_options.autolink = True + gfm_extension_options.strikethrough = True + gfm_extension_options.table = True + gfm_extension_options.tagfilter = True + gfm_extension_options.tasklist = True + + common_render_options = comrak.RenderOptions() + common_render_options.unsafe_ = True # handled by nh3 + variants: Dict[str, Callable[[str], str]] = { - "GFM": lambda raw: cast(str, cmarkgfm.github_flavored_markdown_to_html( - raw, options=cmarkgfmOptions.CMARK_OPT_UNSAFE - )), - "CommonMark": lambda raw: cast(str, cmarkgfm.markdown_to_html( - raw, options=cmarkgfmOptions.CMARK_OPT_UNSAFE - )), + "GFM": lambda raw: cast( + str, + comrak.render_markdown( + raw, + extension_options=gfm_extension_options, + render_options=common_render_options, + ), + ), + "CommonMark": lambda raw: cast( + str, + comrak.render_markdown( + raw, + render_options=common_render_options, + ), + ), } + except ImportError: warnings.warn(_EXTRA_WARNING) variants = {} From 011e52bc82221358dee95ccc5246585be7013a93 Mon Sep 17 00:00:00 2001 From: Mike Fiedler Date: Sun, 19 Oct 2025 19:04:25 -0400 Subject: [PATCH 2/6] test: update test to conform to comrak Signed-off-by: Mike Fiedler --- tests/fixtures/test_GFM_010.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/fixtures/test_GFM_010.html b/tests/fixtures/test_GFM_010.html index 9ca0fb3..3a0861e 100644 --- a/tests/fixtures/test_GFM_010.html +++ b/tests/fixtures/test_GFM_010.html @@ -1 +1 @@ -

This text~~~~ is ~~~~curious.

+

This ~text~~~~ is ~~~~curious~.

From 580ccf797c13f726dc9d06b4d87195cd7c6f2bef Mon Sep 17 00:00:00 2001 From: Mike Fiedler Date: Sun, 19 Oct 2025 19:20:09 -0400 Subject: [PATCH 3/6] test: downgrade python version until wheels exist comrak doesn't yet have a 3.14 wheel, downgrade/skip 3.14 for now instead of adding a rust toolchain. Signed-off-by: Mike Fiedler --- .github/workflows/ci.yml | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c608186..cbb6749 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,7 +14,8 @@ jobs: - "3.11" - "3.12" - "3.13" - - "3.14" + # TODO: Revert when comrak supports 3.14 + # - "3.14" steps: - name: Check out repository uses: actions/checkout@v4 @@ -38,8 +39,10 @@ jobs: - name: Install Python uses: actions/setup-python@v5 with: - python-version: "3.x" - check-latest: true + # TODO: Revert to "3.x" when comrak supports 3.14 + # python-version: "3.x" + # check-latest: true + python-version: "3.13" - name: Install dependencies run: python -m pip install tox - name: Run linting @@ -55,8 +58,10 @@ jobs: - name: Install Python uses: actions/setup-python@v5 with: - python-version: "3.x" - check-latest: true + # TODO: Revert to "3.x" when comrak supports 3.14 + # python-version: "3.x" + # check-latest: true + python-version: "3.13" - name: Install dependencies run: python -m pip install tox - name: Test packaging From cb23648b1ae9f28d5f53d11ebac87539ee76b472 Mon Sep 17 00:00:00 2001 From: Mike Fiedler Date: Sun, 26 Oct 2025 08:07:41 -0400 Subject: [PATCH 4/6] Revert "test: downgrade python version until wheels exist" This reverts commit 580ccf797c13f726dc9d06b4d87195cd7c6f2bef. --- .github/workflows/ci.yml | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cbb6749..c608186 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,8 +14,7 @@ jobs: - "3.11" - "3.12" - "3.13" - # TODO: Revert when comrak supports 3.14 - # - "3.14" + - "3.14" steps: - name: Check out repository uses: actions/checkout@v4 @@ -39,10 +38,8 @@ jobs: - name: Install Python uses: actions/setup-python@v5 with: - # TODO: Revert to "3.x" when comrak supports 3.14 - # python-version: "3.x" - # check-latest: true - python-version: "3.13" + python-version: "3.x" + check-latest: true - name: Install dependencies run: python -m pip install tox - name: Run linting @@ -58,10 +55,8 @@ jobs: - name: Install Python uses: actions/setup-python@v5 with: - # TODO: Revert to "3.x" when comrak supports 3.14 - # python-version: "3.x" - # check-latest: true - python-version: "3.13" + python-version: "3.x" + check-latest: true - name: Install dependencies run: python -m pip install tox - name: Test packaging From 77a5040c88e35c467ef1c535ff9c893e4666afdb Mon Sep 17 00:00:00 2001 From: Mike Fiedler Date: Sun, 26 Oct 2025 08:08:04 -0400 Subject: [PATCH 5/6] Revert "test: update test to conform to comrak" This reverts commit 011e52bc82221358dee95ccc5246585be7013a93. --- tests/fixtures/test_GFM_010.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/fixtures/test_GFM_010.html b/tests/fixtures/test_GFM_010.html index 3a0861e..9ca0fb3 100644 --- a/tests/fixtures/test_GFM_010.html +++ b/tests/fixtures/test_GFM_010.html @@ -1 +1 @@ -

This ~text~~~~ is ~~~~curious~.

+

This text~~~~ is ~~~~curious.

From 00ba2826413639f5ebe799d8bb79ff3843a33ad2 Mon Sep 17 00:00:00 2001 From: Mike Fiedler Date: Sun, 26 Oct 2025 08:08:12 -0400 Subject: [PATCH 6/6] update to latest release including 3.14 wheel Signed-off-by: Mike Fiedler --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 0307a8f..cc4bbbb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -36,7 +36,7 @@ classifiers = [ requires-python = ">=3.9" [project.optional-dependencies] -md = ["comrak>=0.0.6"] +md = ["comrak>=0.0.8"] [tool.setuptools] include-package-data = true