You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I need to process footnotes and came up with this extension, if you think it could be a generic way to process footnotes, I'll be happy to open a PR.
# frozen_string_literal: truerequire'reverse_markdown'# Sent as a patch to reverse_markdown# https://github.com/xijo/reverse_markdown/issues/101moduleReverseMarkdownmoduleConvertersclassFootnote < Adefconvert(node,state={})# If the link has a circular reference, we need to check if it's# inside a paragraph or it's the first element of a paragraph or# list item.ifnode['id'] && node['href']&.start_with?('#')parent=node.parent# The link could be contained in a <sup>until%[p li].include?(parent.name)doparent=parent.parent# Don't go further than thisbreakifparent.name == 'body'endfirst_child=parent.first_element_child# If it's the first link on the parent, it's the footnote# itself, otherwise it's the reference.iffirst_child == node || first_child.children.include?(node)"[^#{node['href'].tr('#','')}]:"else"[^#{node['id']}]"end# Just process the link.elsesuperendendendregister:a,Footnote.newendend
Edit: The footnote was pointing to it's id instead of the href for the reference. Also the markdown syntax was incorrect.
The text was updated successfully, but these errors were encountered:
I need to process footnotes and came up with this extension, if you think it could be a generic way to process footnotes, I'll be happy to open a PR.
Edit: The footnote was pointing to it's id instead of the href for the reference. Also the markdown syntax was incorrect.
The text was updated successfully, but these errors were encountered: