Repository navigation
🐛 Block quote directives: split every attribution, and drop no content - #1248
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
epigraph,highlightsandpull-quoteparse their content withMockState.block_quote, which is meant to behavelike docutils'
Body.block_quote. In 5.2.0 it splits off only the FIRST attribution and keeps only the lines beforeit, so content is lost:
and any trailing paragraph. The first attribution also absorbs the blank line after it (a stray
\n).attribution's text starts;
--- Who,+of Somewherelosesof Somewhere(docutils keeps it).all (the lines stay a paragraph); 5.2.0 makes the first line the attribution and drops the rest.
--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 aredropped.
Change
block_quotenow loops as docutils' does:split_attributionsplits off ONE attribution and returns the remaininglines; their leading blank lines are skipped (as docutils skips them), and the rest start the next block quote, until
no lines are left.
split_attributionandcheck_attributionfollow docutils' (parsers/rst/states.py): anattribution 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:::whencolon_fenceis enabled) never starts an attribution. A fence left open runs to the end of its container, as inCommonMark: one opened inside a list item closes at the first non-blank line indented less than the item's content.
Tests
Six
docutil_directives.mdfixtures:epigraph-two-attributions,epigraph-unindented-continuation,epigraph-bad-continuation,epigraph-fence: eachfails 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 emptyblock quote) and
epigraph-fence-in-list-item(a fence left open in a list item does not hide a-- Whoafter theitem): 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,highlightsandpull-quotefixtures are unchanged and pass, and so does the rest of thesuite.
Behaviour change
A document that relied on the dropped lines being dropped will now show them, and a second
-- …paragraph now startsa second block quote with its own attribution, as in reStructuredText.