A caret line inside an open caption is caption text, not a second caption - #274
Merged
Conversation
The caption collector gathered continuation lines until a blank line or a new block, and a line starting with the caption marker counted as a new block. So the first caption ended there and the second parsed as another caption, which on a table REPLACED the first - its text was discarded with nothing to show for it. djot.js keeps it: an adjacent caret line is an ordinary continuation line of the open caption, and its caret is literal text. This library tracks djot.js, so parity decides it. Before, the caption read `Second`. Now it reads `First\n^ Second`. Everything else is unchanged and now has a test: a blank line between the two caret lines still means the second caption replaces the first, a plain continuation line still continues the caption, and two captioned tables in one document still keep their own captions. The collector is shared, so an image and a block quote caption swallow an adjacent caret line too. That is deliberate: a caption is one block, and its continuation rule cannot depend on what it attaches to. Neither target lost text before, so this only makes them consistent.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #274 +/- ##
=========================================
Coverage 92.42% 92.42%
- Complexity 3682 3683 +1
=========================================
Files 109 109
Lines 10440 10440
=========================================
Hits 9649 9649
Misses 791 791 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
A table caption silently discards its own text.
On master the caption reads
Second.Firstis gone - not moved, not rendered elsewhere, dropped.The cause is the caption collector: it gathers continuation lines until a blank line or a new block, and a line starting with the caption marker counts as a new block. So the first caption ends there, the second parses as another caption, and on a table the second overwrites the first.
What decides the fix
djot.js (checked at 596e7fc) keeps the text, because an adjacent caret line is an ordinary continuation line of the open caption and its caret is literal:
This library tracks djot.js, so parity decides it rather than taste. (The sibling project Carve rules the same input differently - the second line stays a paragraph - but that is an explicit divergence in a different language, not a candidate here.)
The change is one condition in the collector: a line whose only claim to being a new block is the caption marker no longer ends the caption.
Unchanged, and now pinned by tests
Each of these already matched djot.js and still does:
Deliberate consequence on the other caption targets
The collector is shared, so an image and a block quote caption now swallow an adjacent caret line as well:
Before: a figure captioned
First, plus a separate paragraph^ Second. After: the caption readsFirst\n^ Second.A caption is one block and its continuation rule should not depend on what it attaches to, so this is consistency rather than collateral. Neither target was losing text before, so nothing is rescued here either - say the word and I will narrow the condition to the table path, which is a one-line difference.