Replies: 2 comments
-
|
I would suggest the following:
1. Walk the Notes content to add a class like “noconvert” to the Links.
2. Process all Links:
2.1. If it has the “noconvert” class, just remove the class.
2.2. If it does not have it, make a footnote.
|
Beta Was this translation helpful? Give feedback.
0 replies
-
|
Excellent, thanks a lot @badumont . I renamed the "noconvert" class to -- Cf.
-- https://garrit.xyz/posts/2024-04-04-pandoc-convert-links-to-footnotes-the-easy-way
-- https://github.com/jgm/pandoc/discussions/9415
-- https://github.com/jgm/pandoc/discussions/11521
function annotate_links(el)
return el:walk {
Link = function (el)
el.classes:insert("link-in-footnote")
return el
end
}
end
function links_as_footnotes(el)
if el.classes:includes("link-in-footnote") then
el.classes:remove(el.classes:find("link-in-footnotes"))
return el
else
el.content:insert(pandoc.Note(pandoc.Para(pandoc.Link(el.target, el.target))))
return el.content
end
end
return {
{Note = annotate_links},
{Link = links_as_footnotes}
}feedback, if you have any, welcome! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi!
I'm trying to improve the filter described here, that convert links to footnotes. My issue is that I don't want the link to be converted if we are already in a footnote, and I don't know how to check that the "surrounding environment" is not a footnote.
This is a bit like the opposite of walk_block, I want to apply a filter if I am not inside a
pandoc.Noteenvironment.This question is related but unfortunately they only discuss how to do something if you are inside a block.
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions