Question

I am building an octopress blog. In that blog, a number of entries have footnotes. The markdown files currently denote a footnote like so:

"This is the main text <footnote>and this is the footnote</footnote> where 
we speak of main-text things"

What I want to do is extract the footnotes from the body text and then have access to both the main text AND the footnotes as variables in the layout.

I've made some progress with this by creating a filter but it doesn't work very well because filters always output directly on return and I need to format the footnotes.

Would a generator be more appropriate? A converter? Should I not be using liquid tags at all in this case?

Filters make the most sense to me. Is there a way to get the return value of a filter without it printing to the screen? I currently use this:

{{ content | footnotes }}

But that just dumps the array as one big, unformatted array. If it isn't blindingly obvious already, I'm just getting started with Liquid and I'm a little confused.

Was it helpful?

Solution

Depending on your markdown parser you could just write the footnotes normally in the markdown. This is what I'm using on my blog. This is my config in the _config.yml file:

markdown: rdiscount
rdiscount:
  extensions:
    - autolink
    - footnotes
    - smart

Then I just use footnotes by using [^1] to specify the footnote and

[^1]: My footnote

To show it at the bottom of the screen.

Or are you trying to show footnotes at some other part of the screen and not at the bottom of the post?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top