aboutsummaryrefslogtreecommitdiff
path: root/pandoc-lua-engine/test/lua/module
AgeCommit message (Collapse)Author
2025-07-19Lua: add `normalize` function to *Pandoc* objectsAlbert Krewinkel
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-05-28Lua: add function `pandoc.mediabag.make_data_uri`.Albert Krewinkel
The function takes a MIME type and raw data from which it creates an RFC 2397 data URI. Closes: #10876
2025-05-14Lua: accept filename-contents pairs as env for `pandoc.read`Albert Krewinkel
Key-value pairs, mapping from filename to contents, can be used to fill the ersatz file system used in the reader sandbox.
2025-05-14Lua: allow to pass files to the `pandoc.read` sandboxAlbert Krewinkel
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-13Lua: support sandboxed parsing with `pandoc.read`.Albert Krewinkel
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
2024-12-10Lua: support more elements as input to `pandoc.utils.stringify`.Albert Krewinkel
Elements of type Caption, Cell, TableHead, and TableFoot can now be stringified. Fixes: #10450
2024-10-14Lua: Remove prefixes from Lua type namesAlbert Krewinkel
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-06-08Lua: add function `pandoc.template.get`.Albert Krewinkel
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 <[email protected]>
2024-06-08Lua: keep CommonState object in the registryAlbert Krewinkel
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-08Lua: add tests for PANDOC_STATE globalAlbert Krewinkel
2024-06-07Lua: allow passing an environment to `run_lua_filter`.Albert Krewinkel
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-01Lua: Set `pandoc.List` as default metatable for JSON listsAlbert Krewinkel
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-05-10Lua: add a `pandoc.log` module.Albert Krewinkel
2024-04-16Lua: add new module `pandoc.image`Albert Krewinkel
The module provides basic querying functions for image properties.
2024-02-03Shared: `makeSections` behavior changes.John MacFarlane
+ When the optional base level parameter is provided, we no longer ensure that the sequence of heading levels is gapless [behavior change]. Instead, we set the lowest heading level to the specified base level, and adjust the others accordingly. If an author wants to skip a level, e.g. from level 1 to level 3, they can do that. In general, the heading levels specified in the source document are preserved; `makeSections` only puts them into a hierarchical structure. Closes #9398. + Section numbers are now assigned so that the top level gets `1`, no matter what heading level is used. So, even if the top heading level is 2, numbers will be `1`, `2`, etc. rather than `0.1`, `0.2`, as in the past. Closes #5071. + We revert to the old behavior when the `--number-offset` option is used. So, for example, if a document begins with a level-3 heading, and `--number-offset=1,2` is used, the top-level section numbers will be `1.2.1`, `1.2.2`, etc. This is mainly for backwards-compatibility.
2024-01-30Update lua tests for change to toTOCTree.John MacFarlane
2023-03-20Lua: fix json.encode for nested AST elements.Albert Krewinkel
Ensures that objects with nested AST elements can be encoded as JSON.
2023-03-20Lua: load text module as `pandoc.text`.Albert Krewinkel
This only affects the name in the Lua-internal documentation. It is still possible to load the modules via `require 'text'`, although this is deprecated.
2023-03-19Lua tests: add more tests for pandoc.mediabag.Albert Krewinkel
2023-02-11Lua: add module `pandoc.json` to handle JSON encodingAlbert Krewinkel
Closes: #8605
2023-02-09Lua: add field `chunk_template` to WriterOptions objects [API change]Albert Krewinkel
The PathTemplate type exported from Text.Pandoc.Chunks is now an instance of the ToJSON and FromJSON classes. Closes: #8607
2023-01-18Lua: add function pandoc.format.extensions.Albert Krewinkel
This simplifies the creation of custom readers and writers that are based on built-in formats.
2023-01-15T.P.Chunks changes.John MacFarlane
+ Re-use `toTocTree` in constructing `chunkedTOC`. Previously we used an entirely different function toTOCTree'. + Improve `tocToList` so that it avoids empty lists of items that are omitted because they are below the toc depth. pandoc-lua-engine: + Fix structure tests in light of last change. T.P.Writers.ChunkedHTML: + Reuse `tocToList` in `buildTOC`. T.P.Writers.EPUB: + Adjust EPUB writer for Chunks changes.
2023-01-15Lua: add module `pandoc.structure`.Albert Krewinkel
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-13Update pandoc-lua-engine test: test for Figure, not Null.John MacFarlane
2023-01-12Replace `--epub-chapter-level` with `--split-level`.John MacFarlane
Rationale: we need this splitting level now not just in EPUB but in chunked HTML. `--epub-chapter-level` will still function as a deprecated synonynm. `epub-chapter-level` will also continue to work in defaults files, ande `epub_chapter_level` will still work for Lua marshalling. [API changes] Text.Pandoc.App.Opt: remove `optEpubChapterLevel`, add `optSplitLevel`. Text.Pandoc.Options: remove `writerEpubChapterLevel`, add `writerSplitLevel`.
2022-12-20Shared: use LineBreak as default block sep in blocksToInlinesAlbert Krewinkel
This change also affects the `pandoc.utils.blocks_to_inlines` Lua function. Closes: #8499
2022-12-16Lua: allow table structure as format spec.Albert Krewinkel
This allows to pass structured values as format specifiers to `pandoc.write` and `pandoc.read`.
2022-12-08Shared: change defaultBlocksSeparator to PARAGRAPH SEPARATORAlbert Krewinkel
This Unicode char (U+2029) is intended as a semantic separator between paragraphs; it is cleaner and less intrusive than the pilcrow sign that we used before. This also changes the default `sep` value used in the `pandoc.utils.blocks_to_inlines` Lua function.
2022-10-27Fix test for template marshaling.Albert Krewinkel
2022-10-27Lua: allow strings in place of compiled templates.Albert Krewinkel
This allows to use a string as parameter to `pandoc.template.apply` and in the WriterOptions `template` field. Closes: #8321
2022-10-11Lua: add function `pandoc.template.apply`Albert Krewinkel
The new function applies a context, containing variable assignments, to a template.
2022-10-08[API Change] Add new module "Text.Pandoc.Format"Albert Krewinkel
The module provides functions and types for format spec parsing and processing. The function `parseFormatSpec` was moved from Text.Pandoc.Extensions to the new module and renamed to `parseFlavoredFormat`. It now operates in a PandocMonad and is based on the updated types.
2022-10-05Lua: fix tests on Windows broken in previous commit.Albert Krewinkel
2022-10-05Lua: produce more informative error messages for pandoc errorsAlbert Krewinkel
Errors are reported in Lua in the same words in which they would be reported in the terminal.
2022-10-04Lua: add new module `pandoc.format`.Albert Krewinkel
The module provides functions to query the set of extensions supported by formats, and the set of extension enabled per default.
2022-09-30[API Change] Extract Lua code into new package pandoc-lua-engineAlbert Krewinkel
The flag 'lua53` must now be used with that package if pandoc is to be compiled against Lua 5.3.