Skip to content

Fix alerts containing nested blockquotes - #781

Open
Rajatendu1 wants to merge 1 commit into
trentm:masterfrom
Rajatendu1:fix/alerts-nested-blockquotes
Open

Rajatendu1 wants to merge 1 commit into
trentm:masterfrom
Rajatendu1:fix/alerts-nested-blockquotes

Conversation

@Rajatendu1

Copy link
Copy Markdown

An alert containing a nested blockquote is closed at the nested quote's </blockquote>, rather than the matching outer tag. This leaves crossed tags and moves the rest of the alert outside its container.

For example, with extras=["alerts"]:

> [!NOTE]
> Before.
>
> > Nested quote.
>
> After.

Match the closing blockquote at the opening tag's indentation. _block_quote_sub() indents nested quotes by two spaces, so this keeps the complete nested quote inside the alert. Preserve the opening indentation when replacing the block. Alert marker recognition and the rest of the quote parser are unchanged.

Added a native tm-cases fixture covering a quote in an alert, a quote as its first block, an alert inside an ordinary quote, a list-contained alert, and a nested alert. The fixture fails on current master and passes with this change. Includes a changelog entry.

Validation on Linux, Python 3.10.12:

  • cd test && python3 test.py -- -knownfailure: 303 tests pass. The same run on master with the new fixture has one failure; master without it passes 302 tests.
  • python3 test_redos.py: 12 tests pass.
  • Separate structural check: 90 cases fail on master and pass with this change, across all five alert types, blank-line variants, quote depths 1-3, and standalone/quote/list containers.
  • All 297 existing input fixtures rendered with alerts enabled in three safe-mode settings: 891 comparisons have unchanged output, with the salt and email-obfuscation random seed held equal.

The native harness excludes unavailable wavedrom, latex2mathml and emoji tests, plus old-Pygments fixtures incompatible with installed Pygments 2.21.0. Other Python versions, full tox matrix and lint were not run (pycodestyle is unavailable). Expected HTML retains the renderer's whitespace-only indented lines, as existing fixtures do.

Found by source inspection and local reproductions, not a production incident. AI assistance was used for investigation, implementation and testing.

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