aboutsummaryrefslogtreecommitdiff
path: root/pandoc-lua-engine
AgeCommit message (Collapse)Author
2023-06-22Lua: report warnings from Lua scriptsAlbert Krewinkel
Lua's warning system is plugged into pandoc's reporting architecture. Warnings that are raised with the Lua `warn` function are now reported together with other messages.
2023-06-09Bump pandoc-lua-engine to 0.2.0.1.pandoc-lua-engine-0.2.0.1John MacFarlane
2023-06-09Include lua/module/sample.svg in hackage tarballFelix Yan
Should fix the following error when running tests from Hackage tarball: ``` pandoc.mediabag: [WARNING] Could not fetch resource lua/module/sample.svg: replacing image with description FAIL fetch // populates media bag: File lua/module/sample.svg not found in resource path DEBUG:root:haskell-pandoc-lua-engine: fill // populates media bag: lua/module/pandoc-mediabag.lua:70: expected values to be equal, got 'nil' and 'image/svg+xml' ```
2023-04-16Lua: fix value of PANDOC_SCRIPT_FILE for custom readers & writersAlbert Krewinkel
The value did not hold the actual file path for scripts in the *custom* folder of the datadir. Fixes: #8781
2023-03-27Bump pandoc-lua-engine to 0.2, depend on latest pandocJohn MacFarlane
2023-03-21Lua: Fix typo in pandoc.cli doc string.Albert Krewinkel
2023-03-20T.P.Format: add new function `formatFromFilePaths` [API Change] (#8710)Albert Krewinkel
* T.P.Format: export `formatFromFilePaths` [API change] * Lua: add function `pandoc.format.from_path` * Update lua-filters.md * The old T.P.App.FormatHeuristics module has been removed. This is an alternative to #8693.
2023-03-20Lua: add Windows-specific note to pandoc.cli.repl docsAlbert Krewinkel
2023-03-20lua-filters: auto-generate docs for `pandoc.system` module.Albert Krewinkel
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-20lua-filters.md: Generate docs for pandoc.utilsAlbert Krewinkel
The documentation in the Haskell sources has been updated.
2023-03-19lua-filters.md: auto-generate docs for more modulesAlbert Krewinkel
2023-03-19Lua tests: add more tests for pandoc.mediabag.Albert Krewinkel
2023-03-19Lua: add info on when functions became available in pandocAlbert Krewinkel
2023-03-19lua-filters.md: generate docs from Haskell for pandoc.structureAlbert Krewinkel
2023-03-19lua-filters.md: autogenerate parts of the Lua API docsAlbert Krewinkel
2023-03-18Lua: add pandoc.cli.repl functionAlbert Krewinkel
2023-03-17pandoc-cli: add a Lua REPLAlbert Krewinkel
2023-03-15Lua: keep the Lua stack cleanAlbert Krewinkel
A metatable used during initialization was not properly removed from the stack. Likewise, accessing the CommonState from Lua previously led to the pollution of the Lua stack with a left-over value.
2023-03-13Switch to hslua-2.3Albert Krewinkel
2023-03-12Lua: allow to get the JSON encoding of log messagesAlbert Krewinkel
2023-02-14Lua: add new function pandoc.system.cputime.Albert Krewinkel
The function returns the CPU time consumed by pandoc and can be used to benchmark Lua computations.
2023-02-11Lua: add module `pandoc.json` to handle JSON encodingAlbert Krewinkel
Closes: #8605
2023-02-11Use latest pandoc-lua-marshal release, version 0.2.1.Albert Krewinkel
All major AST elements now have `__tojson` metamethods that return the JSON representation of an element. This allows to JSON-encode these elements with libraries that respect the `__tojson` metamethod, including dkjson.
2023-02-09Bump pandoc-lua-engine to 0.1.1pandoc-lua-engine-0.1.13.1John MacFarlane
2023-02-09pandoc-lua-engine: require pandoc >= 3.1.John MacFarlane
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-02-08pandoc-lua-engine: relax version bound to allow pandoc 3.1.John MacFarlane
2023-01-18Add param to tocToList for numberSections.John MacFarlane
Otherwise sections are always numbered in the TOC, even if `--number-sections` is not used.
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-16Lua: Add function `pandoc.mediabag.write`.Albert Krewinkel
Allows to write the complete mediabag or just a specific file to a given directory.
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-13Remove block constructor Null from the code base.John MacFarlane
It has been removed from pandoc-types.
2023-01-13Update pandoc-lua-engine test: test for Figure, not Null.John MacFarlane
2023-01-13Use latest dev pandoc-lua-marshal.John MacFarlane
2023-01-13Require pandoc-types 1.23, update dependencies.John MacFarlane
This fails to build because pandoc-lua-marshal still needs updating.
2023-01-13Support complex figures. [API change]Albert Krewinkel
Thanks and credit go to Aner Lucero, who laid the groundwork for this feature in the 2021 GSoC project. He contributed many changes, including modifications to the readers for HTML, JATS, and LaTeX, and to the HTML and JATS writers. Shared (Albert Krewinkel): - The new function `figureDiv`, exported from `Text.Pandoc.Shared`, offers a standardized way to convert a figure into a Div element. Readers (Aner Lucero): - HTML reader: `<figure>` elements are parsed as figures, with the caption taken from the respective `<figcaption>` elements. - JATS reader: The `<fig>` and `<caption>` elements are parsed into figure elements, even if the contents is more complex. - LaTeX reader: support for figures with non-image contents and for subfigures. - Markdown reader: paragraphs containing just an image are treated as figures if the `implicit_figures` extension is enabled. The identifier is used as the figure's identifier and the image description is also used as figure caption; all other attributes are treated as belonging to the image. Writers (Aner Lucero, Albert Krewinkel): - DokuWiki, Haddock, Jira, Man, MediaWiki, Ms, Muse, PPTX, RTF, TEI, ZimWiki writers: Figures are rendered like Div elements. - Asciidoc writer: The figure contents is unwrapped; each image in the the figure becomes a separate figure. - Classic custom writers: Figures are passed to the global function `Figure(caption, contents, attr)`, where `caption` and `contents` are strings and `attr` is a table of key-value pairs. - ConTeXt writer: Figures are wrapped in a "placefigure" environment with `\startplacefigure`/`\endplacefigure`, adding the features caption and listing title as properties. Subfigures are place in a single row with the `\startfloatcombination` environment. - DocBook writer: Uses `mediaobject` elements, unless the figure contains subfigures or tables, in which case the figure content is unwrapped. - Docx writer: figures with multiple content blocks are rendered as tables with style `FigureTable`; like before, single-image figures are still output as paragraphs with style `Figure` or `Captioned Figure`, depending on whether a caption is attached. - DokuWiki writer: Caption and "alt-text" are no longer combined. The alt text of a figure will now be lost in the conversion. - FB2 writer: The figure caption is added as alt text to the images in the figure; pre-existing alt texts are kept. - ICML writer: Only single-image figures are supported. The contents of figures with additional elements gets unwrapped. - HTML writer: the alt text is no longer constructed from the caption, as was the case with implicit figures. This reduces duplication, but comes at the risk of images that are missing alt texts. Authors should take care to provide alt texts for all images. Some readers, most notably the Markdown reader with the `implicit_figures` extension, add a caption that's identical to the image description. The writer checks for this and adds an `aria-hidden` attribute to the `<figcaption>` element in that case. - JATS writer: The `<fig>` and `<caption>` elements are used write figures. - LaTeX writer: complex figures, e.g. with non-image contents and subfigures, are supported. The `subfigure` template variable is set if the document contains subfigures, triggering the conditional loading of the *subcaption* package. Contants of figures that contain tables are become unwrapped, as longtable environments are not allowed within figures. - Markdown writer: figures are output as implicit figures if possible, via HTML if the `raw_html` extension is enabled, and as Div elements otherwise. - OpenDocument writer: A separate paragraph is generated for each block element in a figure, each with style `FigureWithCaption`. Behavior for single-image figures therefore remains unchanged. - Org writer: Only the first element in a figure is given a caption; additional block elements in the figure are appended without any caption being added. - RST writer: Single-image figures are supported as before; the contents of more complex images become nested in a container of type `float`. - Texinfo writer: Figures are rendered as float with type `figure`. - Textile writer: Figures are rendered with the help of HTML elements. - XWiki: Figures are placed in a group. Co-authored-by: Aner Lucero <[email protected]>
2023-01-12CI: test with GHC 9.2.5 and 9.4.4Albert Krewinkel
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`.
2023-01-10Update copyright years, it's 2023!Albert Krewinkel
2023-01-03Lua: add functions `pandoc.text.toencoding`, `pandoc.text.fromencoding`.Albert Krewinkel
Closes: #8512
2022-12-20T.P.Scripting: Refactor the scripting engine.John MacFarlane
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 <[email protected]>
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-16Format: use simpler structure for ExtensionsDiff.Albert Krewinkel
2022-12-12Lua: add pandoc.cli moduleAlbert Krewinkel
Allow processing of CLI options in Lua.
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-12-05Lua: support `-D` CLI option for custom writers [API change]Albert Krewinkel
A new error `PandocNoTemplateError` (code 87) is thrown if a template is required but cannot be found.