Repository navigation
Parse footnote definitions where they occur - #311
Merged
Merged
Conversation
Footnote bodies were parsed in a pre-pass that only saw unindented definitions at the top level. A definition inside a quote, list item or another note, or with leading spaces, registered an empty note. The same pass also took marker lines that were paragraph continuation or code block content, so `text [^p]` followed by `[^p]: n` showed the line as text and also filled the note. The pre-pass (BlockParser::extractFootnotes()) is gone: each definition is parsed by the block parser where it appears, and a later definition of a label replaces an earlier one, as in djot.js. The body is parsed without the pending block attributes around it. A reference can now precede its definition in parse order, so an "Undefined footnote" warning is dropped at the end when the label turned out to be defined.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #311 +/- ##
=========================================
Coverage 93.06% 93.07%
- Complexity 4718 4721 +3
=========================================
Files 118 118
Lines 12623 12631 +8
=========================================
+ Hits 11748 11756 +8
Misses 875 875 ☔ 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.
Footnote bodies were parsed in a pre-pass that only saw unindented definitions at the top level. Anywhere else the note was registered with no content.
Input:
djot.js
9790d4d, note 1:djot-php before: the same note with an empty
<p>. The same for[^p]: n,- [^p]: n,1. [^p]: nand a definition indented inside another note.The syntax description: "The contents of the note are parsed as block-level content." It sets no column for the marker.
The pre-pass also read lines that are not definitions. With
the second line is paragraph text ("Paragraphs can never be interrupted by other block-level elements"), but djot-php also put
ninto the note. A marker line inside a code block filled the note the same way.Change
The pre-pass (
BlockParser::extractFootnotes(), protected) is removed. The block parser parses each definition where it appears, with the same line collection as before. A later definition of a label replaces an earlier one, as djot.js does. The note body is parsed without the pending block attributes around it.References can now come before their definition in parse order, so the "Undefined footnote" warning is dropped at the end when the label was defined after all.
Measured against djot.js
On the 4853 generated block-family inputs, djot-php differed from djot.js
9790d4don 1686 before (after #310) and 1282 after. 404 cases moved to matching, none the other way.Not in this PR:
- [^p]: nfollowed by an unindentedlazyline. djot.js continues the note, djot-php ends the list. Fixing it in the list tracker alone breaks other cases that depend on how a block-start line after a container paragraph is handled, so it goes with that change.text [^p]then[^p]: nstill differs from djot.js in the second reference'sid(fnref1-2here, none in djot.js). That is the repeated-reference rendering, which the syntax description does not settle.