Repository navigation
Fix HTML blocks nested in indented blocks - #1666
inchang-ing wants to merge 4 commits into
Conversation
|
Please edit your initial comment and check the appropriate boxes (add a |
|
I would like to see this tested with |
Raw HTML blocks which start on a line indented by more than three spaces were not extracted by the HTML block preprocessor, as it could not distinguish such a start tag nested within a containing block (a list item, admonition, etc.) from an indented code block. The block parser then treated the HTML as inline content and split it into separate paragraphs at any blank lines within the raw block. The preprocessor now extracts such indented raw blocks, removes the indentation of the start tag from the stashed content, and preserves that indentation on the line which holds the placeholder. The block parser can then make the decision based on the resulting block structure: within a containing block the placeholder is parsed as nested content, whereas an indented code block keeps the placeholder in its content. In the latter case, the RawHtmlPostprocessor escapes the stashed HTML, so indented code blocks are rendered exactly as before. Fixes Python-Markdown#1096
6b8d1e8 to
d433147
Compare
Add TestIndentedHtmlBlockswMdInHTML mirroring the two new regression tests with the md_in_html extension enabled, per maintainer feedback on Python-Markdown#1666. Co-Authored-By: Claude <noreply@anthropic.com>
|
@facelessuser Good point — I've added
Full suite: 1138 tests OK (111 skipped). Also checked the boxes in the PR template per @waylan's request. |
|
You checked |
|
I see you force pushed a change. As the Contributing Guide states:
There have been multiple failures to follow our contributing guidelines. It is disrespectful for the reviewer's time. Please review the guidelines carefully and follow them fully going forward or this PR may be closed. |
An indented raw HTML block which the block parser placed in an indented code block was restored by RawHtmlPostprocessor after serialization, so the codehilite extension never saw the content and its non-Pygments escaping was bypassed (testFormatterLangStrGuessLang failed because quotes were not escaped). Restore such placeholders in a new RawHtmlInCodeTreeprocessor which runs before the hilite treeprocessor (priority 35 vs 30), setting the code text as escaped AtomicString content. The codehilite extension then unescapes and re-escapes the content itself, matching its established output, while documents without codehilite keep the code_escape semantics of ordinary code blocks. Co-Authored-By: Claude <noreply@anthropic.com>
|
Sorry about that — both fair points. The AI disclosure is now filled in: Claude was used to draft the code, tests, docs, changelog entry, commit messages and the description; I reviewed and verified everything before submitting. On the force push: understood, it won't happen again. The two fixes pushed since are regular incremental commits, and everything further will be as well. |
Raw HTML blocks which start on a line indented by more than three spaces were not extracted by the HTML block preprocessor, as it could not distinguish such a start tag nested within a containing block (a list item, admonition, etc.) from an indented code block. The block parser then treated the HTML as inline content and split it into separate paragraphs at any blank lines within the raw block.
The preprocessor now extracts such indented raw blocks, removes the indentation of the start tag from the stashed content, and preserves that indentation on the line which holds the placeholder. The block parser can then make the decision based on the resulting block structure: within a containing block the placeholder is parsed as nested content, whereas an indented code block keeps the placeholder in its content. In the latter case, a
RawHtmlInCodeTreeprocessor(running before thecodehilitetreeprocessor) restores the stashed HTML as escaped text, so indented code blocks are rendered exactly as before, whether or notcodehiliteis enabled.Fixes #1096
Description
AI Assistance Disclosure
No AI tools were used in preparing this PR.
AI tools were used and I have disclosed which ones, and have fully reviewed and verified their output.
AI tools were use to assist with the following:
Specifically, Claude (Anthropic's LLM, via the WorkBuddy agent) was used to draft the code, tests, documentation, changelog entry, commit messages and this description. All output was reviewed, tested and verified by a human before submission.
Checklist