Closed N-Wouda closed 3 months ago
Good catch. I would expect no new line between footnote back link and footnote content. This might be expected behavior for footnotes that are referenced more than once.
Looking at the generated HTML output,
```html
[5] | A numerical footnote. Note there's no colon after the ]. |
```html
``````html ```
Personally, I'd prefer the footnotes be generated as they are in mkdoc-material, but I haven't looked at sphinx-immaterial source code yet.
The mkdoc-material
notes look beautiful!
I think we need to override the visit_footnote()
and depart_footnote()
from docutils' HTML writer. Sphinx doesn't seem to reimplement those methods.
def visit_footnote(self, node):
# No native HTML element: use <aside> with ARIA role
# (html4css1 uses tables).
# Wrap groups of footnotes for easier styling.
label_style = self.settings.footnote_references # brackets/superscript
if not isinstance(node.previous_sibling(), type(node)):
self.body.append(f'<aside class="footnote-list {label_style}">\n')
self.body.append(self.starttag(node, 'aside',
classes=[node.tagname, label_style],
role="doc-footnote"))
def depart_footnote(self, node):
self.body.append('</aside>\n')
if not isinstance(node.next_node(descend=False, siblings=True),
type(node)):
self.body.append('</aside>\n')
I did some local testing and adapted the aforementioned visit/depart methods to generate mkdocs-material's div->ol->li structure. However, the blank line persisted, so I think we need to look at CSS inherited from upstream.
I did some local testing and adapted the aforementioned visit/depart methods to generate mkdocs-material's div->ol->li structure. However, the blank line persisted, so I think we need to look at CSS inherited from upstream.
The aside
element seems like a more appropriate element, but that may indeed make it more difficult to keep the styling identical.
As far as the blank line, there is some css from the basic theme that deals with it:
Essentially the footnote identifier is in a span
element and the content is in a p
element. The p
element has display: block
so it starts a new paragraph. To fix it we can make the span
elements float left.
I copied over the CSS from sphinx' basic theme. I altered the paragraph indent to be slightly less than basic theme's CSS.
Rendered results for #313 can be observed on RTD. I think this should resolve the problem, yes?
Thanks @2bndy5 @jbms! 🎉
Fantastic! I'm going to pull this in immediately. Thanks again @2bndy5!
Hello! I'm not sure if this is an issue, or works as desired. In any case, sections with explicit markup (for e.g. footnotes, citations) render with an additional newline between the label and the note. This can be seen in the documentation:
I half hoped these to render as in the docutils examples, with the label and note on the same line:
Other than this super minor thing I'm very happy using
sphinx-immaterial
- big kudos for such great work!