24 Commits
Author SHA1 Message Date
John MacFarlane 4e07362e75 Bump pandoc-lua-engine to 0.1.1 2023-02-09 22:24:33 -08:00
John MacFarlane 14a248b43d pandoc-lua-engine: require pandoc >= 3.1. 2023-02-09 20:55:00 -08:00
John MacFarlane 3c6e339a36 pandoc-lua-engine: relax version bound to allow pandoc 3.1. 2023-02-08 19:30:05 -08:00
Albert Krewinkel cdf8c69fb9 Lua: add module pandoc.structure.
Adds support for table of contents and chunks handling. The function
`make_sections` has been given a friendlier interface and was moved to
the new module; the old `pandoc.utils.make_sections` has been
deprecated.
2023-01-15 10:47:54 -08:00
John MacFarlane 0b02f177fb Use latest dev pandoc-lua-marshal. 2023-01-13 12:59:13 -08:00
John MacFarlane aa747f194f Require pandoc-types 1.23, update dependencies.
This fails to build because pandoc-lua-marshal still needs updating.
2023-01-13 10:42:07 -08:00
Albert Krewinkel 28fa37e554 CI: test with GHC 9.2.5 and 9.4.4 2023-01-12 22:21:39 +01:00
Albert Krewinkel 8862d5e0dd Lua: add functions pandoc.text.toencoding, pandoc.text.fromencoding.
Closes: #8512
2023-01-03 10:35:22 +01:00
John MacFarlane 063480accd T.P.Scripting: Refactor the scripting engine.
The new type CustomComponents is exported from T.P.Scripting, and the
ScriptEngine fields are changed. Instead of separate fields for custom
readers and writers, we now have a single function that loads any number
of "components" from a script: these may be custom readers, custom
writers, templates for writers, or extension configs. (Note: it's
possible to have a custom reader and a custom writer for a format
together in the same file.)

Pandoc now checks the folder `custom` in the user's data directory for a
matching script if it can't find one in the local directory. Previously,
the `readers` and `writers` data directories were search for custom
readers and writers, respectively. Scripts in those directories must be
moved to the `custom` folder.

Custom readers used to implement a fallback behavior that allowed to
consume just a string value as input to the `Reader` function. This has
been removed, the first argument is now always a list of sources. Use
`tostring` on that argument to get a string.

Closes #8417.

Signed-off-by: Albert Krewinkel <albert@zeitkraut.de>
2022-12-20 20:58:44 -08:00
Albert Krewinkel 928dde57b9 Lua: add pandoc.cli module
Allow processing of CLI options in Lua.
2022-12-12 09:35:21 -08:00
John MacFarlane f038897187 Use doctemplates 0.11.
This avoids a transitive dependency on HsYAML, which we no longer
use in pandoc.
2022-11-21 10:44:59 -08:00
Alexander Batischev 1bea5e8a54 Allow mtl 2.3.1 2022-11-15 11:35:53 -08:00
Albert Krewinkel e243cd696f Lua: add pandoc.scaffolding.Writer (#8377)
This can be used to reduce boilerplate in custom writers.
2022-10-21 10:11:45 -07:00
Albert Krewinkel f711c7f2aa Lua: add new module pandoc.zip
Allows to handle docx and epub files.
2022-10-20 09:11:57 -07:00
Albert Krewinkel 8900b0f953 Lua: Support built-in default templates for custom writers
Custom writers can define a default template via a global `Template`
function; the data directory is no longer searched for a default
template.

Writer authors can restore the old lookup behavior with

``` lua
Template = function ()
  local template
  return template.compile(template.default(PANDOC_SCRIPT_FILE))
end
```
2022-10-14 10:37:37 -07:00
Albert Krewinkel a088cbf563 Lua: support extensions in custom writers
Custom writers can define the extensions that they support via the
global `writer_extensions`. The variable's value must be a table with
all supported extensions as keys, and their default status as values.

E.g., the below specifies that the writer support the extensions `smart`
and `sourcepos`, but only the `smart` extension is enabled by default:

    writer_extensions = {
      smart = true,
      sourcepos = false,
    }
2022-10-10 09:39:18 -07:00
Albert Krewinkel a5ffaaa413 Lua: support custom bytestring readers. 2022-10-10 11:27:42 +02:00
Albert Krewinkel afbf732a83 Lua: cleanup module dependencies
Ensures a cleaner module dependency graph.
2022-10-06 13:45:55 +02:00
Albert Krewinkel 86e009b495 Lua: add new module pandoc.format.
The module provides functions to query the set of extensions supported
by formats, and the set of extension enabled per default.
2022-10-04 13:06:23 -07:00
Albert Krewinkel 6ad05b7451 Lua: ensure that extensions marshaling is consistent. 2022-10-04 16:55:51 +02:00
Albert Krewinkel 8986c03f20 Add test for custom bytestring writers 2022-10-03 19:46:57 +02:00
John MacFarlane f315248865 Remove unused lua53 flag. 2022-10-03 08:50:20 -07:00
Albert Krewinkel c8d08b945c Remove support for Lua 5.3. 2022-10-03 08:47:32 -07:00
Albert Krewinkel 5be9052f5f [API Change] Extract Lua code into new package pandoc-lua-engine
The flag 'lua53` must now be used with that package if pandoc is to be
compiled against Lua 5.3.
2022-09-30 08:33:40 -07:00