Comments (6)
Yes, that should count as a lazy continuation.
from commonmark-hs.
I don't understand why the lazy line isn't being handled properly. Look at blockQuoteSpec for an analogy. This one should behave the same!
from commonmark-hs.
The disanalogy is actually in blockFinalize.
I wonder if that's the clue.
from commonmark-hs.
Evidence for this: if you change blockFinalize for footnote to defaultFinalizer, then the lazy line appears in a regular paragraph.
from commonmark-hs.
OK, I think I understand now what is happening.
In processLine, we close unmatched blocks
https://github.com/jgm/commonmark-hs/blob/master/commonmark/src/Commonmark/Blocks.hs#L138-L147
and in this case that would mean we close the footnote when we hit the unindented line. At this point the note's paragraph just contains "bar".
Laziness is handled at
https://github.com/jgm/commonmark-hs/blob/master/commonmark/src/Commonmark/Blocks.hs#L154-L159
Essentially, when we hit a lazy continuation, we simply add the closed blocks back to the node stack and proceed as before.
Normally, this works fine! But in the case of footnoteBlockSpec, it doesn't, because in this case blockFinalize has a side effect -- it updates the reference map with the note contents.
In fact, the reference map will be updated again after the re-added footnote is closed again (this time with "baz"). So at this point there will be two entries with key "foo." But lookupReference
is set up to prefer the first entry in case of duplicates, so we get the defective one.
from commonmark-hs.
Solution? I'm not sure. It does seem non-ideal that in our treatment of lazy lines, we end up calling blockFinalize twice (or even more) for the same block, even though in most cases this is harmless. So, perhaps, instead of closing the blocks at line 138, we should wait until we actually detect a new block -- at that point we'd need to close the unmatched ones. If no new block is detected, then, unless we had a lazy line, we could close unmatched blocks, but if we had a lazy line, we'd still have the unmatched blocks open and wouldn't need to re-add them. This might even improve performance a bit when there are lots of lazy lines.
from commonmark-hs.
Related Issues (20)
- [fuzz result] parser sees links with unbalanced `[]` inside
- [fuzz result] nested empty list with two trailing blank lines causes the outer list to be parsed as loose
- [fuzz result] footnote definition labels with blank lines are allowed HOT 1
- `commonmark-pandoc`: calculate relative cell widths for pipe tables HOT 11
- Tests fail with "Stack space overflow" on big endian systems HOT 1
- [fuzz result] Link def title trailing backslash
- Support for GitHub markdown alerts {Note, Important, Tip...} HOT 14
- [fuzzing result] deeply nested list with blank lines causes outer list to not parse as loose
- [fuzz result] code span vanishes when link destination is ` HOT 5
- [fuzz result] [commonmark-pandoc] footnotes in footnotes HOT 3
- [fuzz result] inline processing instructions can't parse more than once in a block? HOT 2
- [fuzz result] HTML declaration blocks do not follow spec 0.30
- [fuzz result] counterintuitive list tightness
- Quadratic output size explosion with tables extension HOT 5
- gfm parsing oddity with links and raw HTML HOT 6
- GFM + Rebase relative paths incorrectly rebases URLs with Unicode characters HOT 1
- [fuzz result] backslashing `&` entities doesn't escape them in link destinations HOT 1
- autolink_bare_uris doesn't work correctly in 3.1.12.x for URLs with dot, comma, parenthesis etc. HOT 1
- Challenges Outputting Context-Dependent Things To Text HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from commonmark-hs.