162 Commits
Author SHA1 Message Date
John MacFarlane fdec82c5d8 pandoc-lua-engine: bump to 0.4.2, bump pandoc bounds. 2025-05-14 14:42:28 -07: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 be9fbb3f67 pandoc-lua-engine: add all test files to the cabal file 2025-05-13 23:41:03 +02: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
John MacFarlane 9bb805adb0 Use citeproc-0.9. Bump citeproc bounds for pandoc, pandoc-lua-engine. 2025-05-12 00:43:39 -07:00
John MacFarlane da45a9c76a pandoc-lua-engine to 0.4.1.1, allow latest containers 2025-03-16 10:58:49 -07:00
John MacFarlane 26ad26b7e6 pandoc-lua-engine: bump to 0.4.1. 2024-12-23 00:51:49 -08:00
Albert Krewinkel a084731070 Lua: support more elements as input to pandoc.utils.stringify.
Elements of type Caption, Cell, TableHead, and TableFoot can now be
stringified.

Fixes: #10450
2024-12-10 11:45:51 +01:00
Albert Krewinkel 64f45fefa7 Lua: add Caption constructor to pandoc module. 2024-12-10 11:06:37 +01:00
John MacFarlane aaf9223b78 Depend on typst 0.6.1 2024-12-07 13:55:11 -08:00
John MacFarlane 920747918c Depend on released pandoc-lua-marshal 0.3.0. 2024-12-07 13:31:33 -08:00
John MacFarlane 809b7da7ca Bump pandoc-lua-engine to 0.4 and depend on it in pandoc-cli. 2024-12-07 12:32:19 -08:00
Andreas Deininger eeb8b1eb3a Fix typos (#10349) 2024-11-06 10:04:33 -08:00
John MacFarlane ec27d4bd22 Bump upper bound for data-default. 2024-10-28 09:41:10 -07:00
Albert Krewinkel d399943759 Lua: Remove prefixes from Lua type names
Lua type names were inconsistent with regard to the use of prefixes; all
prefixes are removed now, and Lua types now have the same name as the
Haskell types.

The use of app-specific prefixes is suggested by the Lua manual to avoid
collisions. However, this shouldn't be a problem with pandoc, as it
cannot be used as a Lua package.

Closes: #8574
2024-10-14 07:53:12 +02:00
John MacFarlane abe86835e1 Depend on latest pandoc-lua-marshall. 2024-10-05 12:45:40 -07:00
John MacFarlane 8ff24ec4e4 Bump pandoc-lua-engine to 0.3.3. 2024-10-05 12:42:08 -07: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 7565a90cec Stop depending on package SHA
Pandoc already depends on `crypton-conntection`, and thus transitively
on `crypton`. The latter provides a vast variety of hashing algorithms
and makes the dependency on SHA unnecessary.
2024-09-29 18:36:56 +02:00
Akash PatelandJohn MacFarlane ca348940e3 Add support for list of figures (lof) and list of tables (lot) (#10029)
Two new command-line options are added:

`--lof[=true|false]`, `--list-of-figures[=true|false]`
`--lot[=true|false]`, `--list-of-tables[=true|false]`

Only docx, latex, and context are supported at this point.

Setting the `lof` and `lot` variables will also work for the formats that are
currently supported.

[API changes]

+ Lua: `list_of_figures` and `list_of_tables` can now be used in writer options.
+ Text.Pandoc.Options:  add `writerListOfFigures` and `writerListOfTables` fields
  to `WriterOptions`.
+ Text.Pandoc.App.Opt: add `optListOfFigures` and `optListOfTables` to `Opt`.

Closes #8245.

Co-authored-by: John MacFarlane <jgm@berkeley.edu>
2024-09-22 11:49:52 -07: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
John MacFarlane a0e0973c63 Bump pandoc-lua-engine to 0.3.2. 2024-09-09 22:13:27 -07:00
John MacFarlane a256f007cf Depend on doclayout 0.5. 2024-09-09 08:18:28 -07:00
John MacFarlane 477e235f6e pandoc-lua-engine: marshall list_tables, epub_title_page writer options. 2024-09-08 09:42:20 -07:00
John MacFarlane 25b9314472 Finishing touches on --link-images:
- Document in defaults file section of MANUAL.
- Add to pandoc-lua-engine writer option marshalling.
- Add to pandoc-server initialization of writer options.
2024-09-08 09:07:55 -07:00
John MacFarlane 45da887ff7 Include accessors for new writer options 2024-09-08 08:52:23 -07:00
John MacFarlane ac98a22bee Bump pandoc version in pandoc-lua-engine. 2024-07-28 13:45:13 -07:00
John MacFarlane 7200b2bbfc Bump pandoc-lua-engine version to 0.3.1, depend on it in pandoc-cli 2024-07-28 13:44:12 -07: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 73ce302479 Harmonize maintainer email addresses in module headers. 2024-07-08 13:27:45 +02:00
Albert Krewinkel 78405f51ae Lua: keep lpeg and re as "loaded" modules.
The modules `lpeg` and `re` are now treated as if they had been
loaded with `require`. Previously the modules were only assigned
to global values, but could be loaded again via `require`,
thereby allowing to use a system-wide installation. However, this
proved to be confusing.

The old behavior can be restored by adding the following lines to
the top of Lua scripts, or to the `init.lua` in the data dir.

    debug.registry()['_LOADED'].lpeg = nil
    debug.registry()['_LOADED'].re = nil
2024-06-28 09:24:41 -06:00
John MacFarlane f5b43c10d3 Bump pandoc version bound in pandoc-lua-engine. 2024-06-24 12:38:38 -07:00
John MacFarlane 7ca6a2b776 Update pandoc-lua-engine to 0.3 2024-06-24 12:29:52 -07:00
Albert Krewinkel 2cc9defda4 Lua: split Init module into more modules.
The module has grown unwieldy and is therefore split into three internal
Haskell modules, `Init`, `Module`, and `Run`.
2024-06-09 16:10:38 +02:00
Albert KrewinkelandCarsten Gips 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 7db19d8cd4 Update more copyright dates to 2024. 2024-06-08 16:46:42 +02:00
Albert Krewinkel 6a88abae3d Lua: keep CommonState object in the registry
The state is an internal value and should be treated as such. The
`PANDOC_STATE` global is merely a copy; unsetting the global no longer
breaks the Lua engine.
2024-06-08 14:39:58 +02:00
Albert Krewinkel d50bd30324 Lua: add tests for PANDOC_STATE global 2024-06-08 14:39:58 +02: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 83de55bb35 Lua: Set pandoc.List as default metatable for JSON lists
Lists created by `pandoc.json.decode` now behave like lists generated
via `pandoc.List`. This also ensures that `pandoc.List` tables are
encoded as JSON arrays when passed to `pandoc.json.encode`.

Fixes: #9834
2024-06-01 21:10:29 +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
John MacFarlane e267e1d7be pandoc-lua-engine: depend on pandoc >= 3.2.
See https://github.com/jgm/pandoc/issues/9755
2024-05-13 08:03:08 -07:00
John MacFarlane b419770850 Bump pandoc, pandoc-cli to 3.2, update changelog.
Also bump pandoc-lua-engine to 0.2.1.5 and allow pandoc 3.2.
2024-05-11 12:01:16 -07:00
Albert Krewinkel e5c135e68e Lua: add a pandoc.log module. 2024-05-10 19:03:29 -07:00
Albert Krewinkel ddc66cad0b Lua: update to pandoc-lua-marshal version 0.2.7.
This fixes counterintuitive behavior of the `content` property on
BulletList and OrderedList items. Unmarshalling of that field now
matches the behavior of the constructor.

Fixes: #8916
2024-05-06 17:06:43 +02:00