summaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Lua
AgeCommit message (Collapse)Author
2019-02-04Add missing copyright notices and remove license boilerplate (#5112)Albert Krewinkel
Quite a few modules were missing copyright notices. This commit adds copyright notices everywhere via haddock module headers. The old license boilerplate comment is redundant with this and has been removed. Update copyright years to 2019. Closes #4592.
2018-11-19Lua filters: test AST object equality via HaskellAlbert Krewinkel
Equality of Lua objects representing pandoc AST elements is tested by unmarshalling the objects and comparing the result in Haskell. A new function `equals` which performs this test has been added to the `pandoc.utils` module. Closes: #5092
2018-11-17Lua Utils module: improve stringifyAlbert Krewinkel
Meta value strings (MetaString) and booleans (MetaBool) are now converted to the literal string and the lowercase boolean name, respectively. Previously, all values of these types were converted to the empty string.
2018-10-28T.P.Lua: expose more useful internals (API change)Albert Krewinkel
Newly exported from Text.Pandoc.Lua: - `runFilterFile` to run a Lua filter from file; - data type `Global` and its constructors; and - `setGlobals` to add globals to a Lua environment. This module also contains `Pushable` and `Peekable` instances required to get pandoc's data types to and from Lua. Low-level Lua operation remain hidden in Text.Pandoc.Lua.
2018-10-28T.P.Lua: rename `runPandocLua` to `runLua` (API change)Albert Krewinkel
2018-10-26Text.Pandoc.Lua: move globals handling to separate moduleAlbert Krewinkel
2018-10-25Lua: allow access to pandoc state (#5015)Albert Krewinkel
* Lua: allow access to pandoc state Lua filters and custom writers now have read-only access to most fields of pandoc's internal state via the global variable `PANDOC_STATE`. * Lua: allow iterating through fields of PANDOC_STATE * Lua filters doc: describe CommonState * Lua filters doc: mention global variable PANDOC_STATE * Lua: add access to logs Log messages can currently only be printed, but not decomposed.
2018-10-15Lua filters: rename ReaderOptions fields, use snake_caseAlbert Krewinkel
Snake case is used in most variable names, using camelCase for these fields was an oversight. A metatable is added to ensure that the old field names remain functional.
2018-10-13Lua filter internals: push Shared.Element as userdataAlbert Krewinkel
Hierarchical Elements were pushed to Lua as plain tables. This is simple, but has the disadvantage that marshaling is eager: all child elements will be marshaled as part of the object. Using a Lua userdata object instead allows lazy access to fields, causing content marshaling just (but also each time) when a field is accessed. Filters which do not traverse the full element contents tree become faster as a result.
2018-10-12Lua filters: push ListAttributes via constructorAlbert Krewinkel
This ensures that ListAttributes, as present in OrderedList elements, have additional accessors (viz. *start*, *style*, and *delimiter*).
2018-10-02T.P.Lua.StackInstances - moved pragmas to top of file.John MacFarlane
2018-10-01Lua filters: report traceback when an error occursAlbert Krewinkel
A proper Lua traceback is added if either loading of a file or execution of a filter function fails. This should be of help to authors of Lua filters who need to debug their code.
2018-10-01Lua Util: add missing docstring to defineHowToAlbert Krewinkel
2018-09-24Use hslua v1.0.0Albert Krewinkel
2018-09-19Lua filter: cleanup filter execution codeAlbert Krewinkel
2018-08-12Lua: cleanup Lua utils, remove unused functions.Albert Krewinkel
2018-07-30Lua Utils module: add function blocks_to_inlines (#4799)Albert Krewinkel
Exposes a function converting which flattenes a list of blocks into a list of inlines. An example use case would be the conversion of Note elements into other inlines.
2018-07-02Spellcheck commentsAlexander Krotov
2018-03-18Use NoImplicitPrelude and explicitly import Prelude.John MacFarlane
This seems to be necessary if we are to use our custom Prelude with ghci. Closes #4464.
2018-03-17hlint fixes.John MacFarlane
2018-02-24Lua: register script name in global variableAlbert Krewinkel
The name of the Lua script which is executed is made available in the global Lua variable `PANDOC_SCRIPT_FILE`, both for Lua filters and custom writers. Closes: #4393
2018-01-23Lua filters: store constructors in registryAlbert Krewinkel
Lua functions used to construct AST element values are stored in the Lua registry for quicker access. Getting a value from the registry is much faster than getting a global value (partly to idiosyncrasies of hslua); this change results in a considerable performance boost.
2018-01-23Lua: move getTag from StackInstances to UtilAlbert Krewinkel
Change: minor
2018-01-19hlint code improvements.John MacFarlane
2018-01-15Renaming: Json -> JSON in modules and functions.John MacFarlane
2018-01-15Merge pull request #4227 from tarleb/lua-run-json-filterJohn MacFarlane
Run JSON filters from Lua filters
2018-01-13Lua modules: add function pandoc.utils.run_json_filterAlbert Krewinkel
Runs a JSON filter on a Pandoc document.
2018-01-12Lua filters: improve error messagesAlbert Krewinkel
Provide more context about the task which caused an error.
2018-01-12Lua filters: make PANDOC_READER_OPTIONS availableAlbert Krewinkel
The options which were used to read the document are made available to Lua filters via the `PANDOC_READER_OPTIONS` global.
2018-01-07Lua: make pandoc-types version available as PANDOC_API_VERSIONAlbert Krewinkel
The current pandoc-types version is made available to Lua programs in the global PANDOC_API_VERSION. It contains the version as a list of numbers.
2018-01-07Lua: make pandoc version available as PANDOC_VERSIONAlbert Krewinkel
The current pandoc version is made available to Lua programs in the global PANDOC_VERSION. It contains the version as a list of numbers.
2018-01-05Update copyright notices to include 2018Albert Krewinkel
2018-01-05data/pandoc.lua: fix attribute names of CitationAlbert Krewinkel
The fields were named like the Haskell fields, not like the documented, shorter version. The names are changed to match the documentation and Citations are given a shared metatable to enable simple extensibility. Fixes: #4222
2018-01-04Use hslua utils where possibleAlbert Krewinkel
Some helper functions and types have been moved to hslua. Change: minor
2018-01-01Lua.Module.Utils: make stringify work on MetaValues.John MacFarlane
I'm sure this was intended in the first place, but currently only Meta is supported.
2017-12-29data/pandoc.lua: drop function pandoc.global_filterAlbert Krewinkel
The function `global_filter` was used internally to get the implicitly defined global filter. It was of little value to end-users, but caused unnecessary code duplication in pandoc. The function has hence been dropped. Internally, the global filter is now received by interpreting the global table as lua filter. This is a Lua API change.
2017-12-23Lua modules: add function pandoc.utils.hierarchicalizeAlbert Krewinkel
Convert list of Pandoc blocks into (hierarchical) list of Elements.
2017-12-23Lua modules: add function pandoc.utils.normalize_dateAlbert Krewinkel
The function parses a date and converts it (if possible) to "YYYY-MM-DD" format.
2017-12-23Lua modules: add function pandoc.utils.to_roman_numeralAlbert Krewinkel
The function allows conversion of numbers below 4000 into roman numerals.
2017-12-22Lua modules: add stringify function to pandoc.utilsAlbert Krewinkel
The new function `pandoc.utils.stringify` converts any AST element to a string with formatting removed.
2017-12-22Lua.Util: avoid altering the stack if peeking failsAlbert Krewinkel
The stack now remains unaltered if `getRawInt` or `getTable` fail. This is important when those functions are used in an operation that is part of an Alternative. Change: minor
2017-12-21Lua modules: added pandoc.utils moduleAlbert Krewinkel
A new module `pandoc.utils` has been created. It holds utility functions like `sha1`, which was moved from the main `pandoc` module.
2017-12-21Lua modules: make a Haskell module for each Lua moduleAlbert Krewinkel
Definitions for the `pandoc.mediabag` modules are moved to a separate Haskell module. Change: minor
2017-12-21Lua modules: move to dedicated submoduleAlbert Krewinkel
The Haskell module defining the Lua `pandoc` module is moved to Text.Pandoc.Lua.Module.Pandoc. Change: minor
2017-12-20Lua modules: turn pipe, read into full Haskell functionsAlbert Krewinkel
The `pipe` and `read` utility functions are converted from hybrid lua/haskell functions into full Haskell functions. This avoids the need for intermediate `_pipe`/`_read` helper functions, which have dropped.
2017-12-18Lua filters: perform minor code clean-upAlbert Krewinkel
Change: minor
2017-12-13Custom writer: use init file to setup Lua interpreterAlbert Krewinkel
The same init file (`data/init`) that is used to setup the Lua interpreter for Lua filters is also used to setup the interpreter of custom writers.lua.
2017-12-10Lua filters: fix package loading for Lua 5.1Albert Krewinkel
The list of package searchers is named `package.loaders` in Lua 5.1 and LuaJIT, and `package.searchers` in Lua 5.2 and later.
2017-12-06Lua filters: use script to initialize the interpreterAlbert Krewinkel
The file `init.lua` is used to initialize the Lua interpreter which is used in Lua filters. This gives users the option to require libraries which they want to use in all of their filters, and to extend default modules.
2017-12-02Lua filters: refactor lua module handlingAlbert Krewinkel
The integration with Lua's package/module system is improved: A pandoc-specific package searcher is prepended to the searchers in `package.searchers`. The modules `pandoc` and `pandoc.mediabag` can now be loaded via `require`.