Kirby

Markdown (Extra) Footnotes don’t render as HTML but text

Hi,

I’m using Kirby’s Markdown Extra config-setting and want to use the Footnotes feature in blog articles:

template.php:

<?php echo $page->text()->kirbytext() ?>

article.txt:

text:
foo bar baz [^note1].

[^note1]: footnote foo.

And while I get valid HTML for the footnotes list itself, the content of the footnote list items is not rendered as HTML but as plain text so I get this as output (not as HTML source):

 1. <p>footnote foo.&#160;<a href="#fnref1:note1" rev="footnote" class="footnote-backref">&#8617;</a></p> 

I’m using Kirby 2.5.12 (confirmed for 2.5.10+ as well). Any ideas? Thanks for any hint.

You could decode the html entities with a regex in a custom kirbytext post filter.

// filters which are called AFTER markdown and tags are parsed
kirbytext::$post[] = function($kirbytext, $value) {
  return preg_replace_callback('/(&lt;p&gt;.*rev="footnote".*&gt;&lt;\/p&gt)/s', function($match) {
    return html_entity_decode($match[0]);
  }, $value);
};

Or have a look at this plugin.
Haven’t tested the plugin though.

The question is: why would I need to do this. The markdown library itself that is used supports footnotes completely correct and standalone this works fine.
So I wonder what Kirby does that it doesn’t work anymore in the Kirby context.

And to be honest I don’t want to use another plugin for a functionality that should work already.

Anselm

1 Like

Seems to be a problem with the used version of the parsedown package.
I just updated the packages (parsedown, parsedown-extra) and it seems to work fine with the currently available versions.

Just found that there is already an issue:

Right, that seems to be the exact issue then. Thanks for your help and research, I’ll see if I can help fixing it and wait for the release. Cheers!

Hi there. I just experienced the same issue and would be happy to know if there was any update on this?
I am using kirby 2.5.12 and tested the footnotes plugin as a last resort, but this breaks my kirbytext markup and renders the text into one big glob of text.
This means, effectively, there is no way of using footnotes one way or the other with kirby 2.5.10+ which is quite disappointing.

Is there any plan to actually fix this issue in Kirby 2.5.whatever? I’m running 2.5.12, which appears to be the latest, and this is a problem. I’m really not sure I have the time to upgrade to Kirby 3, nor are all the plugins I need available.

I wouldn’t have thought so - you can no longer buy a K2 licence after all. @texnixe will be able to confirm this but i’m pretty sure K2 will only get security & bug fixes going forward, rather then feature updates. Wether this counts as a bug, I don’t know.

Are the options listed above not a way forward for you?

Well, as someone else pointed out, the plugin alternative doesn’t actually work, either. I will probably have to try the regex. It’s a rabbit hole I would rather not go down, but…

Well, as the problem seems to lie with the parsedown third party library, the fix might be as simple as just updating that library, so you might get lucky. :slight_smile: Reading the github trail, it seems to have effected a few other CMS systems.