From 7a70b87facffe5f2daaaa58af9fadad89b81a9e9 Mon Sep 17 00:00:00 2001 From: Albert Krewinkel <albert@zeitkraut.de> Date: Fri, 17 Dec 2021 17:32:28 +0100 Subject: Lua: add function `pandoc.utils.references` List with all cited references of a document. Closes: #7752 --- src/Text/Pandoc/Lua/Module/Utils.hs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/Text/Pandoc/Lua/Module') diff --git a/src/Text/Pandoc/Lua/Module/Utils.hs b/src/Text/Pandoc/Lua/Module/Utils.hs index 8bb185500..6d0130dc2 100644 --- a/src/Text/Pandoc/Lua/Module/Utils.hs +++ b/src/Text/Pandoc/Lua/Module/Utils.hs @@ -25,9 +25,11 @@ import Data.Version (Version) import HsLua as Lua import HsLua.Class.Peekable (PeekError) import HsLua.Module.Version (peekVersionFuzzy, pushVersion) +import Text.Pandoc.Citeproc (getReferences) import Text.Pandoc.Definition import Text.Pandoc.Error (PandocError) import Text.Pandoc.Lua.Marshal.AST +import Text.Pandoc.Lua.Marshal.Reference import Text.Pandoc.Lua.PandocLua (PandocLua (unPandocLua)) import qualified Data.Digest.Pure.SHA as SHA @@ -95,6 +97,18 @@ documentedModule = Module =#> functionResult pushVersion "Version" "new Version object" #? "Creates a Version object." + , defun "references" + ### (unPandocLua . getReferences Nothing) + <#> parameter peekPandoc "Pandoc" "doc" "document" + =#> functionResult (pushPandocList pushReference) "table" + "lift of references" + #? mconcat + [ "Get references defined inline in the metadata and via an external " + , "bibliography. Only references that are actually cited in the " + , "document (either with a genuine citation or with `nocite`) are " + , "returned. URL variables are converted to links." + ] + , defun "run_json_filter" ### (\doc filterPath margs -> do args <- case margs of -- cgit v1.2.3