nikola
nikola copied to clipboard
Enable superscript as a footnote-reference option
There doesn't seem to be a way to make Nikola output superscript footnotes. I see some CSS in rst_base.css that hints at supporting it, though I also see the same about the brackets
style, and I'm not sure how either are being chosen to be the output style by a nikola build
. There's also a line in the CHANGES.txt
file Made footnote references be superscripted.
but I'm not seeing it work that way.
For example, if you write the following reStructuredText:
This has a footnote [0]_.
.. [0] a footnote
You'll end up with something like the following HTML:
This has a footnote <a class="footnote-reference brackets" href="#id4" id="id1">0</a>
which shows up in the [0]
form in the rendered page.
If I add 'footnote_references': 'superscript',
to the end of the following dictionary:
https://github.com/getnikola/nikola/blob/ec7acd2c68992b00a09486a05262b7b2a070cef4/nikola/plugins/compile/rest/init.py#L115-L128
Then the output changes to the following HTML, apparently per footnote_references in Docutils.
This has a footnote <a class="footnote-reference superscript" href="#id4" id="id1">0</a>
which shows up as a superscript 0
.
Request
I'm wondering if there could be a FOOTNOTE_REFERENCES_STYLE
config option that one could be set to superscript
to allow this?
Hmmm why not just style footnote-reference? It does look like a superscript in my site at least :-)
I'm not sure if it's because my site is basically base-jinja
plus some minor CSS tweaks or what, but for example https://briancurtin.com/articles/using-elastic-apm-to-visualize-asyncio-behavior/#id3 only became a superscript reference like yours after I added that dictionary change.
First of all, sorry about taking 3 months to answer!
With a more careful look at my site, that has a <sup>
in it .... and it was done using markdown :-P
I'll take a real look with reSt in a few hours.
Ok, the default-default-default, straight-from-master takes this:
Write your post here. [1]_
.. [1] A footnote.
And does this:
<a class="footnote-reference brackets" href="#id2" id="id1">1</a>
And that looks like this:
So, not really sure, but I suspect something is overloading something else in your specific CSS.
Hi, I had the same issue and went into the rabbit hole. Since this issue isn't closed I'm going to "necrobump" it.
- Nikola v8.2.2
- Docutils v1:0.18.1-1
Input:
Write your post here. [*]_
.. [*] test
Expected output:
<a class="footnote-reference brackets" href="posts/test/#footnote-1" id="footnote-reference-1" role="doc-noteref">
<span class="fn-bracket">[</span>
*
<span class="fn-bracket">]</span>
</a>
Output:
<a class="footnote-reference brackets" href="posts/test/#footnote-1" id="footnote-reference-1" role="doc-noteref">
::before
<span class="fn-bracket">[</span>
*
<span class="fn-bracket">]</span>
::after
</a>
Apparently docutils are giving one pair of extra brackets to the output since 0.18 according to this issue. Those are the ::before
and ::after
lines, that's an upstream issue.
Also, I'd like to not have the other pair of brackets there, so like this:
<a class="footnote-reference superscript" href="posts/test/#footnote-1" id="footnote-reference-1" role="doc-noteref"> * </a>
Maybe in that case there needs to be ::before
and ::after
which insert <sup>
, <\sup>
? In any case, the rest/__init__.py
change suggested by @briancurtin works as a workaround in that case.
Apparently the docutils issue is being resolved.
I've looked into the docutils source and the fn-bracket
is being added to the footnote in all cases, I guess I'll have to patch my own version then.
Aaand apparently the other pair of brackets which is inserted on Nikola's side is fixed in master as of 6 days ago, thanks @Kwpolska !
Still doesn't change the fact that I'll be patching my copy of docutils to not have any brackets in my footnotes, as docutils put them in regardless.