Files
su2026rwep/_extensions/drwater/links-to-citations/links-to-citations.lua
T
2026-05-21 13:37:53 +08:00

16 lines
526 B
Lua
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
--- Remove local links but keep the link text as normal citations
--- Reference: https://stackoverflow.com/a/75559075/19418090
--- Copyright: © 2023 Albert Krewinkel, 2024Present Albert Krewinkel, Tom Ben
--- License: MIT License
function Link(link)
if not link.target:match '^https?://' then
local linkstring = pandoc.utils.stringify(link.content)
local citationmd = string.format('[%s]', linkstring)
return pandoc.utils.blocks_to_inlines(
pandoc.read(citationmd, 'markdown').blocks
)
end
end