Skip to content

🐛 Block quote directives: split every attribution, and drop no content - #1248

Merged
chrisjsewell merged 2 commits into
masterfrom
maint/epigraph-attribution
Nov 26, 2026
Merged

chrisjsewell merged 2 commits into
masterfrom
maint/epigraph-attribution

Conversation

@chrisjsewell

Copy link
Copy Markdown
Member

epigraph, highlights and pull-quote parse their content with MockState.block_quote, which is meant to behave
like docutils' Body.block_quote. In 5.2.0 it splits off only the FIRST attribution and keeps only the lines before
it, so content is lost:

  • Two attributions. Everything after the first attribution is dropped: the second quote, the second attribution
    and any trailing paragraph. The first attribution also absorbs the blank line after it (a stray \n).
  • An unindented continuation. A continuation line is kept only if it is indented exactly to where the
    attribution's text starts; --- Who, + of Somewhere loses of Somewhere (docutils keeps it).
  • A badly-shaped continuation. Continuation lines whose indents disagree are, for docutils, not an attribution at
    all (the lines stay a paragraph); 5.2.0 makes the first line the attribution and drops the rest.
  • A code fence holding a -- line. The split runs over raw lines, so a fence whose body has a blank line and then
    -- … is cut there: the rest of the fence becomes the attribution, and the closing fence and what follows it are
    dropped.

Change

block_quote now loops as docutils' does: split_attribution splits off ONE attribution and returns the remaining
lines; their leading blank lines are skipped (as docutils skips them), and the rest start the next block quote, until
no lines are left. split_attribution and check_attribution follow docutils' (parsers/rst/states.py): an
attribution starts on a line after a blank line that follows some body, its continuation lines run to the next blank
line and must share one indent (which may be none), and a shape whose indents disagree is not an attribution.

The one addition Markdown needs: a line inside a code or directive fence (```, ~~~, and ::: when
colon_fence is enabled) never starts an attribution. A fence left open runs to the end of its container, as in
CommonMark: one opened inside a list item closes at the first non-blank line indented less than the item's content.

Tests

Six docutil_directives.md fixtures:

  • epigraph-two-attributions, epigraph-unindented-continuation, epigraph-bad-continuation, epigraph-fence: each
    fails on 5.2.0 and passes after the change.
  • epigraph-blank-before-closer (a blank line between the last attribution and the closing fence makes no empty
    block quote) and epigraph-fence-in-list-item (a fence left open in a list item does not hide a -- Who after the
    item): both pass on 5.2.0, and guard the two ways a loop over the remainder and a fence-aware split could go wrong.

The existing epigraph, highlights and pull-quote fixtures are unchanged and pass, and so does the rest of the
suite.

Behaviour change

A document that relied on the dropped lines being dropped will now show them, and a second -- … paragraph now starts
a second block quote with its own attribution, as in reStructuredText.

@chrisjsewell
chrisjsewell merged commit aee2a71 into master Nov 26, 2026
24 checks passed
@chrisjsewell
chrisjsewell deleted the maint/epigraph-attribution branch November 26, 2026 12:53
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