aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlbert Krewinkel <[email protected]>2022-08-11 22:29:11 +0200
committerJohn MacFarlane <[email protected]>2022-08-13 12:30:13 -0700
commit5a99747063bea86ce83b1609773542f799b9a6bb (patch)
tree22bda022ab6c19f62105ebb5761f999e8296d3da /src
parenteb1826740711319eccade8a634c03d747f461930 (diff)
Lua: add function `pandoc.utils.citeproc`
The function runs the *citeproc* processor on a Pandoc document. Exposing this functionality to Lua allows to make citation processing part of a filter or writer, simplifies the creation of multiple bibliographies, and enables the use of varying citation styles in different parts of a document.
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Lua/Module/Utils.hs12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Lua/Module/Utils.hs b/src/Text/Pandoc/Lua/Module/Utils.hs
index 14796b146..6c373ae2f 100644
--- a/src/Text/Pandoc/Lua/Module/Utils.hs
+++ b/src/Text/Pandoc/Lua/Module/Utils.hs
@@ -25,7 +25,7 @@ import Data.Maybe (fromMaybe)
import Data.Version (Version)
import HsLua as Lua
import HsLua.Module.Version (peekVersionFuzzy, pushVersion)
-import Text.Pandoc.Citeproc (getReferences)
+import Text.Pandoc.Citeproc (getReferences, processCitations)
import Text.Pandoc.Definition
import Text.Pandoc.Error (PandocError)
import Text.Pandoc.Lua.Marshal.AST
@@ -59,6 +59,16 @@ documentedModule = Module
<#> opt (parameter (peekList peekInline) "list of inlines" "inline" "")
=#> functionResult pushInlines "list of inlines" ""
+ , defun "citeproc"
+ ### unPandocLua . processCitations
+ <#> parameter peekPandoc "Pandoc" "doc" "document"
+ =#> functionResult pushPandoc "Pandoc" "processed document"
+ #? T.unwords
+ [ "Process the citations in the file, replacing them with "
+ , "rendered citations and adding a bibliography. "
+ , "See the manual section on citation rendering for details."
+ ]
+
, defun "equals"
### equal
<#> parameter pure "AST element" "elem1" ""