• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

liran-funaro / sphinx-markdown-builder / 43187979780
100%

Build:
DEFAULT BRANCH: main
Ran 12 Nov 2026 09:03AM UTC
Jobs 4
Files 5
Run time 1min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

12 Nov 2026 09:02AM UTC coverage: 100.0%. Remained the same
43187979780

push

github

web-flow
Fix IndexError on a code block with a code class and no language (#126)

## Summary

`visit_literal_block` guessed the language from `node["classes"][1]`
whenever `"code"` was in the classes. A `.. code-block::` with `:class:
code` and no language has `classes == ["code"]`, so the build crashed
with `IndexError`. Sphinx sets `language` on every literal block before
the writer runs: its `Code` directive replaces docutils' `code` and sets
it, and the `HighlightLanguageTransform` post-transform fills it in for
any literal block that lacks it. Both hold in Sphinx 5.1.0 (our minimum)
and 9.0.4; `make doc-xml` also shows all 18 existing literal blocks in
the fixtures have it. So the fix reads `node.get("language", "")` only
and drops the guess. A tree comment records this (RULES 7).

## Why the guess existed

It came from doctree2md (vendored in 00e60eb, 2018), written for plain
docutils and Sphinx < 2, where `.. code:: python` produced
`classes=["code", "python"]` and no `language`. Upstream nb2plots later
kept it only behind a `# Sphinx < 2` branch
(matthew-brett/nb2plots@93eadc79a). Here, `if "language" in node` was
added on top (clayrisser/sphinx-markdown-builder#23,
clayrisser/sphinx-markdown-builder#41,
clayrisser/sphinx-markdown-builder#43), so under any supported Sphinx
the guess was always overwritten. Its only remaining effects were the
crash and picking the wrong class when another class came first.

## Cases compared (main vs this PR)

| Case | main | this PR | HTML builder |
|---|---|---|---|
| docutils-style node `classes=["code","python"]` from a directive |
`default` | `default` | `default` |
| `.. code:: python` | `python` | `python` | `python` |
| `.. code-block:: python` + `:class: extra` | `python` | `python` |
`python` |
| same docutils-style node added in `doctree-resolved` (after
post-transforms) | `python` | (none) | `default` |
| `.. code-block::` + `:class: code` | crash | `default` | — |

The only difference is a node injected aft... (continued)

1 of 1 new or added line in 1 file covered. (100.0%)

770 of 770 relevant lines covered (100.0%)

4.0 hits per line

Jobs
ID Job ID Ran Files Coverage
1 python-3.11 - 43187979780.1 12 Nov 2026 09:03AM UTC 5
100.0
GitHub Action Run
2 python-3.13 - 43187979780.2 12 Nov 2026 09:03AM UTC 5
100.0
GitHub Action Run
3 python-3.14 - 43187979780.3 12 Nov 2026 09:03AM UTC 5
100.0
GitHub Action Run
4 python-3.12 - 43187979780.4 12 Nov 2026 09:03AM UTC 5
100.0
GitHub Action Run
Source Files on build 43187979780
  • Tree
  • List 5
  • Changed 1
  • Source Changed 1
  • Coverage Changed 1
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Repo
  • Github Actions Build #43187979780
  • 8ae6a0ba on github
  • Prev Build on main (#43183779725)
  • Next Build on main (#43188910137)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc