From f9fb410cd962d0ca17d8de849e3839ca4dcece2f Mon Sep 17 00:00:00 2001 From: Albert Krewinkel Date: Fri, 6 Feb 2026 09:44:41 +0100 Subject: [PATCH] Lua: add new function `pandoc.types.Sources`. This provides access to the `Sources` abstraction that pandoc uses for input files. Closes: #11441 --- doc/lua-filters.md | 72 ++++++++++++++++++- .../src/Text/Pandoc/Lua/Marshal/Sources.hs | 32 ++++++--- .../src/Text/Pandoc/Lua/Module.hs | 2 +- .../src/Text/Pandoc/Lua/Module/Types.hs | 66 ++++++++++++----- .../test/lua/module/pandoc-types.lua | 28 ++++++++ tools/update-lua-module-docs.lua | 2 + 6 files changed, 175 insertions(+), 27 deletions(-) diff --git a/doc/lua-filters.md b/doc/lua-filters.md index 62d29ec3b..ae864e89d 100644 --- a/doc/lua-filters.md +++ b/doc/lua-filters.md @@ -4197,13 +4197,22 @@ Returns: `documentation (object[, format])` +Return the documentation for a function or module defined by +pandoc. Throws an error if there is no documentation for the given +object. + +The result format can be any textual format accepted by +`pandoc.write`, and the documentation will be returned in that +format. Additionally, the special format `blocks` is accepted, in +which case the documentation is returned as [Blocks]. + Parameters: `object` : Retrieve documentation for this object (any) `format` -: result format (string\|table) +: result format; defaults to `'ansi'` (string\|table) Returns: @@ -7218,6 +7227,66 @@ Returns: *Since: 2.7.3* +### Sources {#pandoc.types.Sources} + +`Sources (srcs)` + +Creates a new Sources element, i.e., a list of [Source] items. + +Pandoc's text readers expect the input text to be paired with +information on where the text originated, e.g., a file name. This +abstraction is provided via the `Sources` type. + +Pandoc accepts a range of objects wherever a *Sources* list is +expected: + +- a list of [Source] items; +- a simple string, which becomes an unnamed source; +- a list of table objects, where each table contains the fields + `name` (the filepath) and `text` (the file contents) + +A Sources list can be converted to a string via the default +`tostring` Lua function. This will concatenate all source items. + +Parameters: + +`srcs` +: sources (string\|{string,\...}\|table) + +Returns: + +- new Sources object ({[Source],\...}) + +*Since: 3.9.1* + +## Types {#pandoc.types-types} + +### Source {#type-pandoc.types.Source} + +### Version {#type-pandoc.types.Version} + +#### Methods + +##### Version.must_be_at_least {#Version.must_be_at_least} + +`Version.must_be_at_least (self, reference[, msg])` + +Parameters: + +`self` +: version to check ([Version]) + +`reference` +: minimum version ([Version]) + +`msg` +: alternative message (string) + +Returns: + +Returns no result, and throws an error if this version is older +than `reference`. +