aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Lua
AgeCommit message (Collapse)AuthorFilesLines
2019-05-29pandoc.mediabag module: add function `delete`Albert Krewinkel1-1/+7
Function `pandoc.mediabag.delete` allows to remove a single item of the given name from the media bag.
2019-05-29pandoc.mediabag module: add function `empty`Albert Krewinkel1-0/+6
Function `pandoc.mediabag.empty` was added. It allows to clean-out the media bag, removing all entries.
2019-05-29pandoc.mediabag module: add items function iterating over mediabagAlbert Krewinkel2-1/+82
A new function `pandoc.mediabag.items` was added to Lua module pandoc.mediabag. This allows users to lazily iterate over all media bag items, loading items into Lua one-by-one. Example: for filename, mime_type, content in pandoc.mediabag.items() do -- use media bag item. end This is a convenient alternative to using `mediabag.list` in combination with `mediabag.lookup`.
2019-05-29Lua Version type: shorten "version too old" messageAlbert Krewinkel1-1/+1
2019-05-29Lua: add Version type to simplify comparisonsAlbert Krewinkel6-3/+189
Version specifiers like `PANDOC_VERSION` and `PANDOC_API_VERSION` are turned into `Version` objects. The objects simplify version-appropriate comparisons while maintaining backward-compatibility. A function `pandoc.types.Version` is added as part of the newly introduced module `pandoc.types`, allowing users to create version objects in scripts.
2019-05-04Lua: add `pandoc.system` module (#5468)Albert Krewinkel2-0/+36
The `system` Lua module provides utility functions to interact with the operating- and file system. E.g. print(pandoc.system.get_current_directory()) or pandoc.system.with_temporary_directory('tikz', function (dir) -- write and compile a TikZ file with pdflatex end)
2019-03-01Remove license boilerplate.John MacFarlane8-138/+0
The haddock module header contains essentially the same information, so the boilerplate is redundant and just one more thing to get out of sync.
2019-02-16T.P.Lua: split StackInstances into smaller Marshaling modulesAlbert Krewinkel10-173/+234
2019-02-16T.P.Lua: get CommonState from Lua globalAlbert Krewinkel3-54/+64
This allows more control over the common state from within Lua scripts.
2019-02-09Lua filters: load module `pandoc` before calling `init.lua` (#5287)Albert Krewinkel1-6/+27
The file `init.lua` in pandoc's data directory is run as part of pandoc's Lua initialization process. Previously, the `pandoc` module was loaded in `init.lua`, and the structure for marshaling was set-up after. This allowed simple patching of element marshaling, but made using `init.lua` more difficult: - it encouraged mixing essential initialization with user-defined customization; - upstream changes to init.lua had to be merged manually; - accidentally breaking marshaling by removing required modules was possible; Instead, all required modules are now loaded before calling `init.lua`. The file can be used entirely for user customization. Patching marshaling functions, while discouraged, is still possible via the `debug` module.
2019-02-09T.P.Lua: properly indent module-loading errorAlbert Krewinkel1-1/+1
2019-02-04Add missing copyright notices and remove license boilerplate (#5112)Albert Krewinkel9-24/+24
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 Krewinkel1-3/+15
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 Krewinkel1-2/+9
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 Krewinkel2-2/+21
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 Krewinkel1-3/+3
2018-10-26Text.Pandoc.Lua: move globals handling to separate moduleAlbert Krewinkel2-21/+126
2018-10-25Lua: allow access to pandoc state (#5015)Albert Krewinkel2-6/+95
* 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 Krewinkel1-5/+28
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 Krewinkel1-19/+24
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 Krewinkel2-2/+17
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 MacFarlane1-5/+5
2018-10-01Lua filters: report traceback when an error occursAlbert Krewinkel2-7/+40
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 Krewinkel1-1/+1
2018-09-24Use hslua v1.0.0Albert Krewinkel8-233/+175
2018-09-19Lua filter: cleanup filter execution codeAlbert Krewinkel1-51/+73
2018-08-12Lua: cleanup Lua utils, remove unused functions.Albert Krewinkel3-88/+61
2018-07-30Lua Utils module: add function blocks_to_inlines (#4799)Albert Krewinkel1-0/+10
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 Krotov1-1/+1
2018-03-18Use NoImplicitPrelude and explicitly import Prelude.John MacFarlane8-0/+16
This seems to be necessary if we are to use our custom Prelude with ghci. Closes #4464.
2018-03-17hlint fixes.John MacFarlane1-1/+1
2018-02-24Lua: register script name in global variableAlbert Krewinkel1-1/+7
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 Krewinkel3-3/+29
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 Krewinkel2-13/+17
Change: minor
2018-01-19hlint code improvements.John MacFarlane2-2/+0
2018-01-15Renaming: Json -> JSON in modules and functions.John MacFarlane1-5/+5
2018-01-15Merge pull request #4227 from tarleb/lua-run-json-filterJohn MacFarlane2-4/+28
Run JSON filters from Lua filters
2018-01-13Lua modules: add function pandoc.utils.run_json_filterAlbert Krewinkel2-4/+28
Runs a JSON filter on a Pandoc document.
2018-01-12Lua filters: improve error messagesAlbert Krewinkel3-15/+34
Provide more context about the task which caused an error.
2018-01-12Lua filters: make PANDOC_READER_OPTIONS availableAlbert Krewinkel1-2/+48
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 Krewinkel1-0/+3
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 Krewinkel1-0/+4
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 Krewinkel7-18/+18
2018-01-05data/pandoc.lua: fix attribute names of CitationAlbert Krewinkel1-6/+6
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 Krewinkel4-33/+16
Some helper functions and types have been moved to hslua. Change: minor
2018-01-01Lua.Module.Utils: make stringify work on MetaValues.John MacFarlane1-1/+4
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 Krewinkel2-2/+1
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 Krewinkel2-8/+39
Convert list of Pandoc blocks into (hierarchical) list of Elements.
2017-12-23Lua modules: add function pandoc.utils.normalize_dateAlbert Krewinkel2-2/+14
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 Krewinkel1-1/+9
The function allows conversion of numbers below 4000 into roman numerals.