larstvei / ox-gfm

Github Flavored Markdown Back-End for Org Export Engine
230 stars 44 forks source link

Render footnote section as HTML #12

Closed jmromer closed 8 years ago

jmromer commented 8 years ago

Appends a footnote section, transcoded to HTML, to the GFM output. Fixes #11

/cc @jonmagic

Org source

* Heading
test ~one~ two this[fn:1] is some text.
More text have another footnote[fn:2].

* Footnotes

[fn:1] This is a footnote.

[fn:2] This is another footnote.

Output before

  - [Heading](#orgheadline1)

  # Heading<a id="orgheadline1"></a>

  test `one` two this<sup><a id="fnr.1" class="footref" href="#fn.1">1</a></sup> is some text.
  More text have another footnote<sup><a id="fnr.2" class="footref" href="#fn.2">2</a></sup>.

Output after

  - [Heading](#orgheadline1)

  # Heading<a id="orgheadline1"></a>

  test `one` two this<sup><a id="fnr.1" class="footref" href="#fn.1">1</a></sup> is some text.
  More text have another footnote<sup><a id="fnr.2" class="footref" href="#fn.2">2</a></sup>.

  <div id="footnotes">
  <h2 class="footnotes">Footnotes: </h2>
  <div id="text-footnotes">

  <div class="footdef"><sup><a id="fn.1" class="footnum" href="#fnr.1">1</a></sup> <div class="footpara">This is a footnote.</div></div>

  <div class="footdef"><sup><a id="fn.2" class="footnum" href="#fnr.2">2</a></sup> <div class="footpara">This is another footnote.</div></div>

  </div>
  </div>
jonmagic commented 8 years ago

How hard would it be to render the footnotes as markdown instead of html I wonder?

jmromer commented 8 years ago

Good point! I added a naive implementation in a46628a.

Output after

- [Heading](#orgheadline1)

# Heading<a id="orgheadline1"></a>

test `one` two this<sup><a id="fnr.1" class="footref" href="#fn.1">1</a></sup> is some text. More text have another footnote<sup><a id="fnr.2" class="footref" href="#fn.2">2</a></sup>.

## Footnotes

<sup><a id="fn.1" class="footnum" href="#fnr.1">1</a></sup> This is a footnote.

<sup><a id="fn.2" class="footnum" href="#fnr.2">2</a></sup> This is another footnote.
larstvei commented 8 years ago

Nice work @jkrmr!

You might want to consider contributing your org-gfm-footnote-section function to ox-md.el :)

jmromer commented 8 years ago

@larstvei Good idea, thanks! I have a version in a local fork that correctly switches between atx and setext header styles. Contributing to Org turns out to be a little more involved than I expected (FSF release and all that), so I'll keep you posted.