Skip to content

fix(jsii-pacmak): Python target crashes on h5 and h6 Markdown headings - #5292

Open
Thanatos9404 wants to merge 1 commit into
aws:mainfrom
Thanatos9404:fix/pacmak-md2rst-h5-h6-headings
Open

Thanatos9404 wants to merge 1 commit into
aws:mainfrom
Thanatos9404:fix/pacmak-md2rst-h5-h6-headings

Conversation

@Thanatos9404

@Thanatos9404 Thanatos9404 commented Oct 19, 2026 •

Copy link
Copy Markdown

A level 5 or 6 Markdown heading (##### or ######) in a doc comment makes jsii-pacmak fail when it generates the Python package, with TypeError: Cannot read properties of undefined (reading 'repeat'). md2rst looks up an underline character for each heading level in a list with only four entries, so levels 5 and 6 read past the end. Only the Python target uses md2rst.

This adds ~ and + for levels 5 and 6. Output for levels 1 to 4 doesn't change.

Tests: added a level %d heading case for levels 1 to 6 to test/python.test.ts. On main levels 5 and 6 fail with the TypeError, and with this change all six pass.

Side note: the underline never actually shows up in the output at any level, because textOf(node) is empty for heading nodes. I left that alone so existing docstrings don't change.

Fixes #4418


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

md2rst picks a reStructuredText underline character for each heading
level from a list that only had four entries. A level 5 or 6 heading in
a doc comment therefore threw "TypeError: Cannot read properties of
undefined (reading 'repeat')", and jsii-pacmak failed to generate the
Python package.

Add underline characters for levels 5 and 6. Output for levels 1 to 4
does not change.

Fixes aws#4418

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

jsii-pacmak: H5 tags on Markdown files break Python packaging

1 participant