aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Lua
AgeCommit message (Collapse)Author
2022-01-29Switch to hslua-2.1Albert Krewinkel
This allows for some code simplification and improves stability.
2022-01-04Lua: add `pandoc.template` moduleAlbert Krewinkel
The module provides a `compile` function to use strings as templates.
2022-01-04Lua: marshal templates as opaque userdata valuesAlbert Krewinkel
2022-01-04Lua: add `pandoc.WriterOptions` constructorAlbert Krewinkel
2022-01-04Lua: add function `pandoc.write`Albert Krewinkel
2022-01-02Copyright notices: update for 2022Albert Krewinkel
2022-01-01Lua: provide global `PANDOC_WRITER_OPTIONS` [API change]Albert Krewinkel
API changes: - The function T.P.Filter.applyFilters now takes a filter environment of type `Environment`, instead of a ReaderOptions value. The `Environment` type is exported from `T.P.Filter` and allows to combine ReaderOptions and WriterOptions in a single value. - Global, exported from T.P.Lua, has a new type constructor `PANDOC_WRITER_OPTIONS`. Closes: #5221
2022-01-01Lua: marshal ReaderOptions field `extensions`, `track_changes` via JSONAlbert Krewinkel
Extensions are now available as a list of strings; the track-changes settings are given as the kebab-case representation used in JSON.
2021-12-31Lua: use global state when parsing documents in `pandoc.read`Albert Krewinkel
The function `pandoc.read` is updated to use the same state that was used while parsing the main input files. This ensures that log messages are preserved and that images embedded in the input are added to the mediabag.
2021-12-31Lua: cleanup stack in peekReadOptionsTableAlbert Krewinkel
A ReaderOptions element was left on top of the stack when the `peekReadOptionsTable` function was invoked.
2021-12-30Lua: allow binary (byte string) readers to be used with `pandoc.read`Albert Krewinkel
2021-12-25Lua: improve handling of empty caption, body by `from_simple_table`Albert Krewinkel
Create truly empty table caption and body when these are empty in the simple table. Fixes: #7776
2021-12-21Lua: simplify code of pandoc.utils.stringifyAlbert Krewinkel
Minor behavior change: plain strings nested in tables are now included in the result string.
2021-12-21Lua: simplify and deprecate function `pandoc.utils.equals`Albert Krewinkel
The function is no longer required for element comparisons; it is now an alias for the `==` operator.
2021-12-21Lua: add new library function `pandoc.utils.type`.Albert Krewinkel
The function behaves like the default `type` function from Lua's standard library, but is aware of pandoc userdata types. A typical use-case would be to determine the type of a metadata value.
2021-12-21Lua: fix return types of `blocks_to_inlines`, `make_sections`Albert Krewinkel
Ensures the returned lists have the correct type (`Inlines` and `Blocks`, respectively).
2021-12-20Lua: use more natural representation for Reference valuesAlbert Krewinkel
Omit `false` boolean values, push integers as numbers.
2021-12-19Custom writer: assign default Pandoc object to global PANDOC_DOCUMENTAlbert Krewinkel
The default Pandoc object is now non-strict, i.e., only the parts of the document that are accessed will be marshaled to Lua. A special type is no longer necessary. This change also makes it possible to use the global variable with library functions such as `pandoc.utils.references`, or to inspect the document contents with `walk()`.
2021-12-19Lua: fixup, should have been part of previous commitAlbert Krewinkel
2021-12-17Lua: add function `pandoc.utils.references`Albert Krewinkel
List with all cited references of a document. Closes: #7752
2021-12-11Custom reader: ensure old Readers continue to workAlbert Krewinkel
Retry conversion by passing a string instead of sources when the `Reader` fails with a message that hints at an outdated function. A deprecation notice is reported in that case.
2021-12-11Custom reader: pass list of sources instead of concatenated textAlbert Krewinkel
The first argument passed to Lua `Reader` functions is no longer a plain string but a richer data structure. The structure can easily be converted to a string by applying `tostring`, but is also a list with elements that contain each the *text* and *name* of each input source as a property of the respective name. A small example is added to the custom reader documentation, showcasing its use in a reader that creates a syntax-highlighted code block for each source code file passed as input. Existing readers must be updated.
2021-12-10Switch to released pandoc-lua-marshal-0.1.2Albert Krewinkel
Cell values are now marshaled as userdata objects; a constructor function for table cells is provided as `pandoc.Cell`.
2021-12-09Lua: update to latest pandoc-lua-marshal (0.1.1)Albert Krewinkel
- `walk` methods are added to `Block` and `Inline` values; the methods are similar to `pandoc.utils.walk_block` and `pandoc.utils.walk_inline`, but apply to filter also to the element itself, and therefore return a list of element instead of a single element. - Functions of name `Doc` are no longer accepted as alternatives for `Pandoc` filter functions. This functionality was undocumented.
2021-11-29Lua: remove `pandoc.utils.text` (#7720)Albert Krewinkel
The new `pandoc.Inlines` function behaves identical on string input, but allows other Inlines-like arguments as well. The `pandoc.utils.text` function could be written as function pandoc.utils.text (x) assert(type(x) == 'string') return pandoc.Inlines(x) end
2021-11-28Lua: add constructors `pandoc.Blocks` and `pandoc.Inlines`Albert Krewinkel
The functions convert their argument into a list of Block and Inline values, respectively.
2021-11-27Lua: use package pandoc-lua-marshal (#7719)Albert Krewinkel
The marshaling functions for pandoc's AST are extracted into a separate package. The package comes with a number of changes: - Pandoc's List module was rewritten in C, thereby improving error messages. - Lists of `Block` and `Inline` elements are marshaled using the new list types `Blocks` and `Inlines`, respectively. These types currently behave identical to the generic List type, but give better error messages. This also opens up the possibility of adding element-specific methods to these lists in the future. - Elements of type `MetaValue` are no longer pushed as values which have `.t` and `.tag` properties. This was already true for `MetaString` and `MetaBool` values, which are still marshaled as Lua strings and booleans, respectively. Affected values: + `MetaBlocks` values are marshaled as a `Blocks` list; + `MetaInlines` values are marshaled as a `Inlines` list; + `MetaList` values are marshaled as a generic pandoc `List`s. + `MetaMap` values are marshaled as plain tables and no longer given any metatable. - The test suite for marshaled objects and their constructors has been extended and improved. - A bug in Citation objects, where setting a citation's suffix modified it's prefix, has been fixed.
2021-11-24Lua: allow single elements as singleton MetaBlocks/MetaInlinesAlbert Krewinkel
Single elements should always be treated as singleton lists in the Lua subsystem.
2021-11-23Lua: add function `pandoc.utils.text` (#7710)Albert Krewinkel
The function converts a string to `Inlines`, treating interword spaces as `Space`s or `SoftBreak`s. If you want a `Str` with literal spaces, use `pandoc.Str`. Closes: #7709
2021-11-23Lua: split strings into words when treating them as Inline list (#7712)Albert Krewinkel
Using a Lua string where a list of inlines is expected will cause the string to be split into words, replacing spaces and tabs into `pandoc.Space()` elements and newlines into `pandoc.SoftBreak()`. The previous behavior was to treat the string `s` as `{pandoc.Str(s)}`. The old behavior can be recovered by wrapping the string into a table `{s}`.
2021-11-19Lua: fix global module loading (#7701)Albert Krewinkel
2021-11-17Lua: set `lpeg`, `re` as globals; allow shared lib access via requireAlbert Krewinkel
The `lpeg` and `re` modules are loaded into globals of the respective name, but they are not necessarily registered as loaded packages. This ensures that - the built-in library versions are preferred when setting the globals, - a shared library is used if pandoc has been compiled without `lpeg`, and - the `require` mechanism can be used to load the shared library if available, falling back to the internal version if possible and necessary.
2021-11-16Lua: make loading of global LPeg modules more robustAlbert Krewinkel
Ignore errors if the normal package mechanism failed; this not only covers the case of modules being unavailable on the system, but also works if the modules are present, but fail to load for some reason. This makes the built-in package version a true fallback.
2021-11-11Lua: load `re` module available into global of the same nameAlbert Krewinkel
2021-11-09Lua: fix argument order in constructor `pandoc.Cite`.Albert Krewinkel
This restores the old behavior; argument order had been switched accidentally in pandoc 2.15.
2021-11-08Lua: ensure that 're' module is always available.Albert Krewinkel
The module is shipped with LPeg.
2021-11-06Lua: add Pushable instance for ReaderOptionsAlbert Krewinkel
2021-11-06Lua: allow to pass custom reader options to `pandoc.read`Albert Krewinkel
Reader options can now be passed as an optional third argument to `pandoc.read`. The object can either be a table or a ReaderOptions value like `PANDOC_READER_OPTIONS`. Creating new ReaderOptions objects is possible through the new constructor `pandoc.ReaderOptions`. Closes: #7656
2021-11-05Lua: display Pandoc values using their native Haskell representationAlbert Krewinkel
2021-11-05Lua: always load lpeg as global moduleAlbert Krewinkel
2021-11-04Lua: include lpeg module (#7649)Albert Krewinkel
Compiles the 'lpeg' library (Parsing Expression Grammars For Lua) into the program. Package maintainers may choose to rely on package dependencies to make lpeg available, in which case they can compile the with the constraint `lpeg +rely-on-shared-lpeg-library`.
2021-11-03Lua: add missing space in "package not found" messageAlbert Krewinkel
Closes: #7658
2021-11-02Lua: fix typo in SoftBreak constructorAlbert Krewinkel
2021-11-02Lua: re-add `content` property to Strikeout elementsAlbert Krewinkel
Fixes a regression introduced in 2.15.
2021-11-02Lua: be more forgiving when retrieving the Image `caption` propertyAlbert Krewinkel
Fixes a regression introduced in 2.15.
2021-11-02Lua: display Attr values using their native Haskell representationAlbert Krewinkel
2021-11-02Lua: allow omitting the 2nd parameter in pandoc.Code constructorAlbert Krewinkel
Fixes a regression introduced in 2.15 which required users to always specify an Attr value when constructing a Code element.
2021-11-02Lua: allow to compare, show Citation valuesAlbert Krewinkel
Comparisons of Citation values are performed in Haskell; values are equal if they represent the same Haskell value. Converting a Citation value to a string now yields its native Haskell string representation.
2021-11-01Lua: restore `content` property on Header elementsAlbert Krewinkel
2021-10-31Lua: re-add `content` property to Link elementsAlbert Krewinkel
This was a regression introduced in version 2.15. Fixes: #7647