aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Lua
AgeCommit message (Collapse)Author
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.
2022-09-30Change imports in Lua code to only use exported pandoc modulesAlbert Krewinkel
2022-09-30[API Change] Change type of Text.Pandoc.Lua.applyFilterAlbert Krewinkel
The module Text.Pandoc.Filter.Lua has been merged into Text.Pandoc.Lua. The function `applyFilter` now has type ``` haskell applyFilter :: (PandocMonad m, MonadIO m) => Environment-> [String]-> FilePath-> Pandoc-> m Pandoc ``` where `Environment` is defined in Text.Pandoc.Filter.Environment.
2022-09-30[API Change] Rename `pandocVersion` to `pandocVersionText`...Albert Krewinkel
and add a new `pandocVersion` value with type `Version`. This is consistent with the type used for `pandocTypesVersion` and allows to use the value where a Version type is required.
2022-09-27Fix small whitespace things.John MacFarlane
2022-09-27pandoc-cli: support `-E` flag in pandoc-luaAlbert Krewinkel
2022-09-20Export `applyFilter` from T.P.Lua.Filter.John MacFarlane
Motivation: now we need not have any logic referring to hslua types (LuaE) in T.P.Filter.Lua. This restricts the parts of Pandoc that deal directly with hslua to T.P.Lua (and in tests, Tests.Lua). [API changes] T.P.Lua now exports `applyFilter`, `readCustom`, and `writeCustom`. The lower-level function `runFilterFile` is no longer exported.
2022-09-20Add T.P.Lua.Reader, T.P.Lua.Writer.John MacFarlane
(Unexported modules, presently.) These contain the definitions of `readCustom` and `writeCustom` that were previously in T.P.Readers.Custom and T.P.Writers.Custom. Motivation is to ensure that all of the Lua-related code is under the T.P.Lua tree. This will make it easier to make pandoc-lua a separate package or put lua support under a flag, if we decide to do that.
2022-08-13Lua: add function `pandoc.utils.citeproc`Albert Krewinkel
The function runs the *citeproc* processor on a Pandoc document. Exposing this functionality to Lua allows to make citation processing part of a filter or writer, simplifies the creation of multiple bibliographies, and enables the use of varying citation styles in different parts of a document.
2022-07-15Lua: extend pandoc.system module. (#8184)Albert Krewinkel
The module now has the additional functions `list_directory`, `make_directory`, and `remove_directory`. This makes it easier to write cross-platform scripts that need to inspect or modify the file system.
2022-07-12Lua: add fields `pandoc.readers` and `pandoc.writers`. (#8177)Albert Krewinkel
The set of supported input and output formats is made available to Lua users.
2022-06-23Lua: ensure that tables marshaled via JSON arrays behave like Lists.Albert Krewinkel
This allows to invoke methods like `map` and `includes` on lists like `PANDOC_WRITER_OPTIONS.extensions`.
2022-06-19Lua: do not reset foreign encoding before running LuaAlbert Krewinkel
This was a leftover from previous hslua versions that relied heavily on `Foreign.C.withCString` and the like. However, hslua 2 and later use bytestring functions to retrieve string values, so this is no longer needed.
2022-06-15Use dev version of citeproc.John MacFarlane
2022-06-09Lua: use only old ByteString functions.Albert Krewinkel
The function `takeWhileEnd` was added with bytestring-0.11.3.0, but older versions should be supported as well. Fixes the previous commit.
2022-06-08Lua: Simplify module loading code.Albert Krewinkel
Modules are now loaded directly; the special pandoc Lua package searcher is no longer necessary and has been removed.
2022-06-06Lua: add function pandoc.mediabag.fill (#8104)Albert Krewinkel
The function allows to fill the mediabag with all images in a given document. Images that cannot be fetched are replaced with a Span containing the image description.
2022-03-30Lua: allow to pass Sources to pandoc.read (#8002)Albert Krewinkel
Sources, the data type passed to the `Reader` function in custom readers, are now accepted as input to `pandoc.read`.
2022-03-29Remove redundant dependency on hslua-marshalling.Albert Krewinkel
The package is a dependency of hslua; all important modules are re-exported.
2022-02-22Fix typos (#7934)Dimitris Apostolou
2022-02-19Relax upper bound for hslua, allow hslua-2.2. (#7929)Albert Krewinkel
Lua 5.4 is used by default after this is merged. Packagers may still include Lua 5.3 instead by building pandoc with `--constraint='hslua <2.2'`. Differences between 5.3 and 5.4 should not generally affect pandoc Lua filters. See list of incompatible changes here <https://www.lua.org/manual/5.4/manual.html#8.1>
2022-02-06Lua: move custom writer code into Lua hierarchy.Albert Krewinkel
2022-02-06Lua: add module `pandoc.layout` to format and layout textAlbert Krewinkel
2022-02-05Lua: set module name before pushingAlbert Krewinkel
Using the correct module name is relevant when auto-generating documentation.
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.