277 Commits

Author SHA1 Message Date
Enrico Spinielli 090cb52f0a Fix typo in lua-filters.md (#11724)
Removed duplicated 'using'
2026-06-23 01:46:54 +02:00
Albert Krewinkel 62ac67cff4 Lua: Add constructor pandoc.TableBody 2026-04-23 15:19:56 +02:00
Albert Krewinkel e38494be9a doc/lua-filters.md: Re-indent definition list items
This is due to the changes in commit 8ce63ffe2.
2026-04-23 15:19:50 +02:00
Albert Krewinkel f9fb410cd9 Lua: add new function pandoc.types.Sources.
This provides access to the `Sources` abstraction that pandoc uses for
input files.

Closes: #11441
2026-02-09 22:03:06 +01:00
John MacFarlane 5f398e9698 Fix a couple small documentation errors.
Closes #11408.
2026-01-21 09:54:35 +01:00
Albert Krewinkel 9219a313e9 Lua: add function pandoc.utils.documentation (#11383)
Closes #10999.

This is now used to generate much of the Lua API documentation.
2026-01-15 09:59:58 +01:00
Albert Krewinkel 8f8ea44d02 Lua: add function pandoc.with_state
The function allows to run a callback with a modified pandoc state. This
provides the ability to temporarily modify the resource path, the user
data directory, and the HTTP request headers.

Closes: #10859
2026-01-02 11:10:09 -05:00
Emmanuel Ferdman 8a76a6fef1 Correct anchor references to pandoc.text module documentation (#11205)
Closes #11111.
2025-10-10 10:14:59 +02:00
Albert Krewinkel 204ea63107 doc/lua-filters.md: remove outdated notes about lpeg/re globals.
The globals hold the same values that are returned by `require 'lpeg'`
and `require 're'`, respectively. This was changed in pandoc 3.3.
2025-09-04 16:40:07 +02:00
Albert Krewinkel a36654b222 Lua: add function pandoc.structure.unique_identifier.
The function generates element identifiers based on inlines content.
It's primary use case is the programmatic generation of ID, similar to
what the `auto_identifiers` extension provides for many formats.
2025-08-12 21:37:35 +02:00
Albert Krewinkel 68d80cc9d9 Lua: add functions pandoc.text.superscript and subscript.
The functions convert numbers and parentheses to superscript and
subscript, respectively.
2025-08-12 08:47:49 +02:00
Albert Krewinkel 75aee7a23c Lua: use proper interface functions to access the CommonState.
- The `PANDOC_STATE` is no longer a userdata object, but a table that
  behaves like the old object.

- Log messages in `PANDOC_STATE.log` are now in temporal order.
2025-08-01 10:04:14 -07:00
R. N. West (Nat) 9d56205784 docs: Don't encourage returning tables of filters from Lua filters (#11000)
See #10995. Use the `Pandoc:walk` method instead.
2025-07-29 16:16:38 -07:00
Albert Krewinkel 01a305af58 Lua: add function pandoc.path.exists.
The functions allows to check the existence of file-system objects.
2025-07-23 19:31:03 +02:00
Albert Krewinkel 9893fe8c65 Lua: add normalize function to *Pandoc* objects
This function performs a normalization of Pandoc documents. E.g.,
multiple successive spaces are collapsed, and tables are normalized such
that all rows and columns contain the same number of cells.

Closes: #10356
2025-07-19 15:42:37 +02:00
Sean Soon 2b31cb4a4b doc/lua-filters.md: Add example on using pandoc.Table constructor. (#10956) 2025-07-10 09:46:07 +02:00
Albert Krewinkel 6b81649771 Lua: add more UTF-8-aware file operations to pandoc.system.
Functions that expect UTF-8-encoded filenames should make it easier to
write platform-independent scripts, as the encoding of the actual
filename depends on the system.

Additionally, this also adds a generalized method to run commands, and
functions to retrieve XDG directory names.

The new functions are `command`, `copy`, `read_file`, `remove`,
`rename`, `times`, `write_file`, `xdg`.
2025-06-30 09:56:08 -06:00
Albert Krewinkel 2de6f2eb83 doc/lua-filters: fix docs for pandoc.Cite. 2025-06-23 13:02:20 +02:00
Albert Krewinkel c92cc277f5 doc/lua-filters.md: add missing docs for pandoc.Caption 2025-05-28 14:00:42 +02:00
Albert Krewinkel e6bd65ee19 doc/lua-filters.md: Re-generate docs
Pandoc now uses fewer spaces when outputting list items.
2025-05-28 13:56:08 +02:00
Albert Krewinkel ce5e2a2efc Lua: add function pandoc.mediabag.make_data_uri.
The function takes a MIME type and raw data from which it creates an
RFC 2397 data URI.

Closes: #10876
2025-05-28 13:19:01 +02:00
Albert Krewinkel 992842d07b Lua: accept filename-contents pairs as env for pandoc.read
Key-value pairs, mapping from filename to contents, can be used to fill
the ersatz file system used in the reader sandbox.
2025-05-14 09:17:24 -07:00
Albert Krewinkel 5b896bc1a9 Lua: allow to pass files to the pandoc.read sandbox
The sandbox is now enabled if the fourth parameter is a list of files.
The files are read and then made available in the sandbox via a mock
file system.
2025-05-14 09:17:24 -07:00
Albert Krewinkel 31f74fac06 Lua: support sandboxed parsing with pandoc.read.
The function `pandoc.read` is now taking an optional fourth parameter
that specifies the environment in which the parser will be run. Passing
the string `sandbox` as the argument causes the reader to run in a
sandbox, thereby preventing all access to the network and file system.

Closes: #10831
2025-05-13 23:38:36 +02:00
R. N. West 7930fd143d doc/lua-filters.md: Add missing html_math_method 'katex' 2025-02-24 16:45:13 +01:00
Albert Krewinkel 6c31896c29 doc/lua-filters: add note about extensions handling in read and write 2025-02-04 10:46:47 +01:00
R. N. West (Nat) 77fca2d61a doc/lua-filters.md: Correct luacheck URL (#10589) 2025-01-31 08:56:47 -08:00
R. N. West (Nat) f17de990b4 doc/lua-filters.md: Add static analysis paragraph to debugging section (#10568) 2025-01-29 13:22:04 -08:00
John MacFarlane 4814067f5a lua-filters.md: document system.os return values.
Closes #10523.
2025-01-11 10:25:46 -08:00
Albert Krewinkel 8c96c6e776 doc/lua-filters.md: Fix links to constructors.
This was broken when the respective sections started to be
autogenerated.
2024-12-10 11:06:37 +01:00
Andreas Deininger eeb8b1eb3a Fix typos (#10349) 2024-11-06 10:04:33 -08:00
Albert Krewinkel 734227a59d doc/lua-filters.md: document pandoc.List:iter method
List objects have a new function `iter` that returns an iterator
function that returns the next list item on each call.
2024-10-14 07:15:34 +02:00
Albert Krewinkel a37035caa1 doc/lua-filters.md: list functions in pandoc.utils alphabetically 2024-10-01 12:24:13 +02:00
Albert Krewinkel 4cf6ddb027 Lua: allow returning a single filter from filter files
It is now possible to return a single filter from a filter file, e.g.

``` lua
-- Switch single- and double quotes
return {
  Quoted = function (q)
    elem.quotetype = elem.quotetype == 'SingleQuote'
      and 'DoubleQuote' or 'SingleQuote'
    return elem
  end
}

The filter must not contain numerical indexes, or it might be treated as
a list of filters.
2024-10-01 12:23:36 +02:00
Albert Krewinkel 8aa796f30a Lua: support character styling via pandoc.layout
The `Doc` values produced and handled by the `pandoc.layout` module can
now be styled using `bold`, `italic`, `underlined`, or `strikeout`. The
style is ignored in normal rendering, but becomes visible when rendering
to ANSI output. The `pandoc.layout.render` function now takes a third
parameter that defines the output style, either *plain* or *ansi*.
2024-09-21 15:20:34 +02:00
Albert Krewinkel 05aa18420f Lua: update List module
The module now comes with a method `:at(index[, def])` that allows to access
indices, accepts negative indices to count from the end, and will return the
`def` value as a default if the list has no item at the given position.

Furthermore, the list constructor `pandoc.List` now accepts iterators. E.g.,
`pandoc.List(text:gmatch '%S+')` returns the list of words in `text`.

Closes: #9835
2024-09-21 10:10:35 +02:00
Albert Krewinkel 790abcf414 lua-filters.md: Partially autogenerate docs for module "pandoc"
The documentation system isn't powerful enough to generate the full
documentation automatically.
2024-07-08 16:30:45 +02:00
Albert Krewinkel e6f298f19f doc/lua-filters.md: Fix outdated docs
Documentation of math and quoting related functions and fields was
updated. The docs had been outdated since at least pandoc 2.17.
2024-06-11 16:45:24 +02:00
Albert Krewinkel 7b85353780 doc/lua-filters.md: correct return type of pandoc.layout.render. 2024-06-10 07:28:00 +02:00
Albert Krewinkel d416619298 doc/lua-filters.md: Document operators of the "Doc" type. 2024-06-10 07:10:15 +02:00
Albert Krewinkel da4a55a985 lua-filters: auto-generate docs for pandoc.layout module. 2024-06-09 22:19:57 +02:00
Albert Krewinkel 9af5b1ca8b Lua: add function pandoc.template.get.
The function allows to specify a template with the same argument value
that would be used with the `--template` command line parameter.

Closes: #9854

Co-authored-by: Carsten Gips <cagix@hsbi.de>
2024-06-08 08:42:47 -07:00
Albert Krewinkel bfb0475d67 doc/lua-filters: autogenerate docs for module pandoc.template 2024-06-07 20:36:29 +02:00
Albert Krewinkel 430d525378 Lua: allow passing an environment to run_lua_filter.
The default is now to use a *copy* of the global environment when running a
filter; this ensures better separation when `run_lua_filter` is used multiple
times. A custom environment can be specified via the optional third parameter.
2024-06-07 08:36:24 +02:00
Albert Krewinkel 04dba0d771 Lua: fix typo in run_lua_filter
Fixes previous commit ad68ff34ae.
2024-05-28 13:46:18 +02:00
Albert Krewinkel ad68ff34ae Lua: add function pandoc.utils.run_lua_filter (#9803) 2024-05-27 14:20:31 -07:00
Albert Krewinkel e5c135e68e Lua: add a pandoc.log module. 2024-05-10 19:03:29 -07:00
Albert Krewinkel 0f29d8195e Lua: use hslua-module-zip-1.1.3 to fix the windows build 2024-05-05 21:16:31 +02:00
Albert Krewinkel 018922d10f Lua: use newest zip module.
This adds a `symlink` function to Entry objects, allowing to check if an
entry represents a symbolic link.
2024-05-05 17:54:33 +02:00
Albert Krewinkel 32f0ed9ea3 Lua: improve pandoc.json.decode docs. 2024-05-05 00:25:29 +02:00