Skip to content

Code block rewrite - #72

Draft
RensDimmendaal wants to merge 5 commits into
mainfrom
code-block-rewrite
Draft

RensDimmendaal wants to merge 5 commits into
mainfrom
code-block-rewrite

Conversation

@RensDimmendaal

@RensDimmendaal RensDimmendaal commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

aidialog PR #55 preserves notebook directives such as code-fold and code-summary as data-code-fold and data-code-summary attributes on Markdown code fences. This keeps the display settings available without making aidialog decide how code should appear on the page.

This PR adds a code_block callback to mdhtml’s existing rewrite() API. So Octavo can use it to read those attributes and wrap code in a collapsed section with the requested label. Other callers can use the same callback for their own code-block transformations.

The callback returns replacement Markdown or None to leave the block alone. mdhtml handles the surrounding lists, block quotes, and footnotes. GFM export also turns attributed fences into ordinary language fences so GitHub still highlights the code.
Added tests for these cases, including task lists and footnotes that previously broke during rewriting. The Python and Rust test suites passed.

@RensDimmendaal
RensDimmendaal marked this pull request as draft September 22, 2026 10:15

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.

1 participant