GithubHelp home page GithubHelp logo

Comments (10)

fletcher avatar fletcher commented on June 13, 2024

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.

nsfmc avatar nsfmc commented on June 13, 2024

cool thanks, i'll take a gander and see if i can submit a pull request. thanks for your response!

from multimarkdown-4.

fletcher avatar fletcher commented on June 13, 2024

I intentionally left this open so that others would see it. I'll reopen.

from multimarkdown-4.

fletcher avatar fletcher commented on June 13, 2024

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.

nsfmc avatar nsfmc commented on June 13, 2024

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:
vyeq

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.

fletcher avatar fletcher commented on June 13, 2024

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:

  1. "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).

  2. 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.

nsfmc avatar nsfmc commented on June 13, 2024

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.

fletcher avatar fletcher commented on June 13, 2024

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.

nsfmc avatar nsfmc commented on June 13, 2024

you, sir, are a gentleman and a scholar.

from multimarkdown-4.

fletcher avatar fletcher commented on June 13, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.