Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore footnotes ids when handlings content sections #126

Merged

Conversation

knutwalker
Copy link
Contributor

Footnotes produce a reference that can be linked to and will show up in
the ids part of a page's Ast (see #92).

Footnotes have no directive attached to them, as their referenced
sections are added implicitly when they are processed by the parser.

The contentSection related methods did assume that all nodes in ids
are proper sections, so having footnotes would break layouts that use
such an API, e.g. $page.contentSections().

This commit updates those implementations to expect nodes to not
necessarily have a directive.

Additionally, the logic of hasContentSection is aligned with the
behavior of contentSection(id), so that returning a true value will
not trigger an error when getting the content section.
This would have been possible before id the node with that name is not a
section, however it might have been that, in practice, this was never
the case.

I added a footnote to the sections snapshot to show that rendering this
page does no longer break.

I also considered a change in supermd that would not include footnotes
in the ids list, but that would have lost the ability to #ref-link
to footnotes outside of the footnote rendering itself.

Footnotes produce a reference that can be linked to and will show up in
the `ids` part of a page's Ast (see kristoff-it#92).

Footnotes have no directive attached to them, as their referenced
sections are added implicitly when they are processed by the parser.

The `contentSection` related methods did assume that all nodes in `ids`
are proper sections, so having footnotes would break layouts that use
such an API, e.g. `$page.contentSections()`.

This commit updates those implementations to expect nodes to not
necessarily have a directive.

Additionally, the logic of `hasContentSection` is aligned with the
behavior of `contentSection(id)`, so that returning a true value will
not trigger an error when getting the content section.
This would have been possible before id the node with that name is not a
`section`, however it might have been that, in practice, this was never
the case.

I added a footnote to the sections snapshot to show that rendering this
page does no longer break.
@kristoff-it
Copy link
Owner

great work!

@kristoff-it kristoff-it merged commit 717b3af into kristoff-it:main Mar 12, 2025
@knutwalker knutwalker deleted the content-sections-and-footnotes branch March 12, 2025 08:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants