bludit-plugins / parsedown-extra

Parsedown Extra Plugin for Bludit
1 stars 3 forks source link

Footnotes print HTML verbatim #3

Open DivineDominion opened 5 years ago

DivineDominion commented 5 years ago

Footnotes are parsed, but HTML escaped at the moment. Will investigate how to fix this tomorrow.

Example

Example input:

[^2019-02-12-gehirn-mantel]: Nach meinem aktuellen Stand ist das faktisch nicht ganz richtig, aber auch im Falle der Korrektheit ist dies keine gute Begründung.

Example output:

<li id="fn:2019-02-12-gehirn-mantel">
&lt;p&gt;Nach meinem aktuellen Stand ist das faktisch nicht ganz richtig, aber auch im Falle der Korrektheit ist dies keine gute Begründung.&amp;#160;&lt;a href="#fnref1:2019-02-12-gehirn-mantel" rev="footnote" class="footnote-backref"&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
</li>
DivineDominion commented 5 years ago

The culprit is Parsedown::element. It processed the footnote text's HTML and escaped it in

// snip
        if (isset($Element['text']))
        {
            $markup .= '>';

            if (!isset($Element['nonNestables']))
            {
                $Element['nonNestables'] = array();
            }

            if (isset($Element['handler']))
            {
                $markup .= $this->{$Element['handler']}($Element['text'], $Element['nonNestables']);
            }
            else
            {
                $markup .= self::escape($Element['text'], true);
            }

            $markup .= '</'.$Element['name'].'>';
        }
// snip

The escaping can be circumvented when you specify "handler" => "text". I don't know if that breaks different things, but I'll open a PR for this change :)

dignajar commented 5 years ago

Hi, have you ask the author of the library ? https://github.com/erusev/parsedown-extra Maybe we need to update the library to a newer version.

DivineDominion commented 5 years ago

Could be -- the upstream library looks totally different in some places, so I'm not even sure it's compatible. It build the $Element in a different way -- And I'm too new to the bludit pipeline to test this reasonably quick. At the moment, I'm only at the level of hacking together stuff that kinda works :)

I'd suggest checking it out as a submodule (but then the plugin could break when the lib goes away, and be hard to download), or reference the exact commit of the external dependency for diffing. Like, I don't even know if this file was modifies in this repo, or if it's the vanilla checkout from yesteryear.