Comments (10)
This has actually been the proper behavior since MMD-3 (peg-multimarkdown). Because of the way that parsing occurs, it was much easier to implement this way. Not that it's impossible to go back to the old way (MMD-2), but the effort has not been worth the gain as compared to all the other things I'm working on.
If someone is interested in tweaking html.c
to identify the last proper position to handle this, I'll certainly consider changes. But from my initial efforts, it's not a trivial change.
from multimarkdown-4.
cool thanks, i'll take a gander and see if i can submit a pull request. thanks for your response!
from multimarkdown-4.
I intentionally left this open so that others would see it. I'll reopen.
from multimarkdown-4.
As an update, I dug into this some more, and it still doesn't seem trivial. For example, a multiparagraph footnote has as structure something like this (simplified):
Footnote
List
Paragraph
List
Paragraph
List
Paragraph
Since a child cannot know anything about its parent, there is currently no way for a paragraph to know whether there is another paragraph (or anything else for that matter) following it. So in order to change this, it seems as though the only approach would be to change the parser to identify the last paragraph and flag it separately. I may come back to this, but for now it is a low priority. As always, I'm happy to look at pull requests if someone else is so inclined.
from multimarkdown-4.
huh, that's weird, so i know that html.c iterates over each node and sees if a paragraph specifies a footnote
as part of the scratch
it passes down.
so a multi ΒΆ footnote renders like this:
but what i'm wondering is whether or not it's possible for the LISTITEM case to inspect the scratch
property and coopt it from any of its descendents.
that certainly adds a slight performance hit, but at least the listitem renderer can look for the footnote and move it onto the last child if it's present. or optionally if xhtml compliance isn't tooo important, you could just have it be rendered by the listitem handler and not close the <p>
tag.
does that sound too weird?
from multimarkdown-4.
The "LIST" I refer to is a part of MMD parsing, not a <li>
or <ol>
. It's a way of stringing multiple elements together, but the "List" itself doesn't affect the output (e.g. a "linked list" in programming theory). The <li>
you note in your example doesn't actually exist. It is simply written out as part of the "wrapper" around the contents of the footnote.
I suppose one could have the parsing "LIST" check for footnote status, but there would be a few problems:
-
"LISTS" are used all over the place, so a small performance hit could have much larger real world implications. The time cost for this particular example would probably not be worth it for the payoff (IMO, others may weight this differently).
-
I simplified the example, there are actually a couple of layers of lists, so even that would require some creative thinking.
As for the idea of moving the link outside the <p>
tag, or not closing the <p>
, that's a non-starter.... ;)
Yes, I use the "scratch_pad" as a place to stick stuff that can be referenced from any node. I suppose when writing the footnote to HTML, a separate function could traverse the node_tree and work backwards to figure out where the last <p>
or similar element was. Then it would have to use a counter/flag system via the scratch_pad to indicate where the return link should be placed.
from multimarkdown-4.
interesting, i think i'll need to look more at the internal data structure that mmd uses in order to see if it's possible to share the footnote data earlier on in the process so that the footnote can either be attached to the last list's paragraph or to the parent itself. I'm a bit hazy on what the internal structure that is rendered or how it's built, so maybe i should spend some time looking at that first and then post any thoughts i have on that front. thanks for clarifying!
from multimarkdown-4.
Like many (most?) "non-trivial" problems, they're only non-trivial until you come up with a new perspective.
I pre-determine the last paragraph, and then count down until we get to it. Pretty easy. ;)
Should now be working as of (2fe7465)
from multimarkdown-4.
you, sir, are a gentleman and a scholar.
from multimarkdown-4.
Let me know if you find problems.
As an aside, it does apply the link to the last paragraph in the footnote. If there's something after the last paragraph that isn't a para, or doesn't contain a para, the link won't be at the end of the footnote. Send me an example, and we'll see if there's any further tweaks, but I promise nothing. ;)
from multimarkdown-4.
Related Issues (20)
- MMD header key and value left in HTML head after conversion HOT 2
- Request: Include Paths to CLI HOT 8
- {{TOC}} Error with variables in a heading HOT 1
- Empty double quotes inside a table cell breaks layout HOT 1
- fancy lists (letters instead of numbers) HOT 1
- Removing comments HOT 3
- Special characters in metadata values/variables HOT 1
- Well formed HTML/XML with missing figure definition HOT 2
- Invalid XML/HTML with Markdown inside nested block element tags HOT 1
- ![Alt text](/path/to/img.jpg "Optional title") syntax currently broken HOT 1
- Reference labels should be case-insensitive HOT 1
- Support for rST-style Admonitions HOT 2
- Can I get line/column information from a node? HOT 5
- Incorrect works code blocks? HOT 3
- Can you add support strikethrough text? HOT 1
- Support for indexes HOT 3
- Custom Block Syntax HOT 3
- Ampersand in bibliographical references is not converted to &. HOT 1
- Problems with spaces after footnotes in .FODT output HOT 3
- Crashes while freeing a g_string HOT 12
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 multimarkdown-4.