gettalong / kramdown

kramdown is a fast, pure Ruby Markdown superset converter, using a strict syntax definition and supporting several common extensions.
http://kramdown.gettalong.org
Other
1.72k stars 274 forks source link

Allow for footnotes div to have a custom class name #814

Closed blaurascon closed 2 months ago

blaurascon commented 2 months ago

Hey! I'm running into a similar issue as in #670 - footnotes are being excluded from Firefox reader view. I use footnotes a lot, mostly for tangential thoughts that don't fit well with the flow of the post, but for which an aside doesn't feel appropriate. Their omission from readers isn't ideal.

I found that it's because of class="footnotes". If I copy the generated HTML into a post with no footnotes, and change the class from footnotes to something more generic (e.g. just notes), reader view grabs them just fine. I would not be surprised if some of these readers are omitting things labeled as "footnotes" as clutter.

Caveat: As far as I've been able to test, this seems to primarily be an issue with Firefox's reader view specifically. Using a Firefox addon reader mode (Tranquility Reader), Reading Mode in Chrome, or Immersive Reader in Edge all display the footnotes as expected, even with class="footnotes". I'm having a hard time finding any info on why Firefox's reader view is behaving this way.

Changing the class assigned to the footnotes div seems to alleviate this issue, but I can't really see a way to tell Kramdown to assign an alternate / custom class to the main footnotes div, since the class name seems to be hard-coded in this line: https://github.com/gettalong/kramdown/blob/bd678ecb59f70778fdb3b08bdcd39e2ab7379b45/lib/kramdown/converter/html.rb#L530

Are there any alternative ways to do this that I've missed, or would this be best accomplished with a code change to allow for assigning this div class a name similar to how footnote IDs can have a custom prefix?

Thanks! (And thanks for Kramdown!)

gettalong commented 2 months ago

The solution from #670 would also apply in this case: Sub-class the HTML converter and provide the custom output you need for footnote generation.