summaryrefslogtreecommitdiff
path: root/data/pandoc.lua
Commit message (Collapse)AuthorAge
* Lua modules: added pandoc.utils moduleAlbert Krewinkel2017-12-21
| | | | | A new module `pandoc.utils` has been created. It holds utility functions like `sha1`, which was moved from the main `pandoc` module.
* Lua modules: turn pipe, read into full Haskell functionsAlbert Krewinkel2017-12-20
| | | | | | 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.
* pandoc.lua: re-add missing MetaMap functionAlbert Krewinkel2017-12-19
| | | | | This was a bug introduced in version 2.0.4 (commit 3f1f9536d4817bbdd797c01050a887fe4cdf347c).
* Lua filters: refactor lua module handlingAlbert Krewinkel2017-12-02
| | | | | | | 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`.
* pandoc.lua: set metatable on List MetaValuesAlbert Krewinkel2017-12-01
| | | | | | | The `List` metatable is assigned to the tables which get passed to the constructors `MetaBlocks`, `MetaInline`, and `MetaList`. This enables the use of the resulting objects as lists. This is part of the changes discussed in #4081.
* Lua/StackInstances: push Pandoc and Meta via constructorAlbert Krewinkel2017-12-01
| | | | | | | Pandoc and Meta elements are now pushed by calling the respective constructor functions of the pandoc Lua module. This makes serialization consistent with the way blocks and inlines are pushed to lua and allows to use List methods with the `blocks` value.
* List.lua: add missing fixes as discussed in #4099Albert Krewinkel2017-12-01
| | | | The changes were missing due to an error while using git.
* Add basic lua List module (#4099)Albert Krewinkel2017-11-28
| | | | | | | | | | | | | | | | | | The List module is automatically loaded, but not assigned to a global variable. It can be included in filters by calling `List = require 'List'`. Lists of blocks, lists of inlines, and lists of classes are now given `List` as a metatable, making working with them more convenient. E.g., it is now possible to concatenate lists of inlines using Lua's concatenation operator `..` (requires at least one of the operants to have `List` as a metatable): function Emph (emph) local s = {pandoc.Space(), pandoc.Str 'emphasized'} return pandoc.Span(emph.content .. s) end Closes: #4081
* data/pandoc.lua: enable table-like behavior of attributes (#4080)Albert Krewinkel2017-11-20
| | | | | | | | | | | | | | | | | | | | | | Attribute lists are represented as associative lists in Lua. Pure associative lists are awkward to work with. A metatable is attached to attribute lists, allowing to access and use the associative list as if the attributes were stored in as normal key-value pair in table. Note that this changes the way `pairs` works on attribute lists. Instead of producing integer keys and two-element tables, the resulting iterator function now returns the key and value of those pairs. Use `ipairs` to get the old behavior. Warning: the new iteration mechanism only works if pandoc has been compiled with Lua 5.2 or later (current default: 5.3). The `pandoc.Attr` function is altered to allow passing attributes as key-values in a normal table. This is more convenient than having to construct the associative list which is used internally. Closes #4071
* pandoc.lua: define default list attributesAlbert Krewinkel2017-10-25
| | | | | | The second argument of the OrderedList constructor, which should define the list's attributes, is made optional. Default attributes are used if the parameter is omitted.
* pandoc.lua: destructure attr for Link and ImageAlbert Krewinkel2017-10-17
| | | | | | Make Attr values accessible through through the keys `identifier`, `classes` and `attributes`. This is already used in other elements with attributes and is now fixed for Link and Image.
* pandoc.lua: throw better error when pipe command failsAlbert Krewinkel2017-10-05
| | | | | A table containing the error code, command, and command output is thrown instead of just a string error message.
* pandoc.lua: use wrapper funciton for pipe commandAlbert Krewinkel2017-10-03
| | | | | | | | | | | | The pipe command is wrapped in a lua function, throwing a lua error if the command returns with an error. A wrapper is needed as Haskell functions exposed to lua may not throw lua errors due to limitations of hslua. The error handling is written such that a table can be returned as an error object in the future. This is potentially useful when finer control is required while catching the error in lua code. Current limitations of hslua require error objects to be strings.
* Lua.PandocModule: promote addFunction to top levelAlbert Krewinkel2017-10-03
| | | | This reduces some boilerplate.
* data/pandoc.lua: fix typos in documentationAlbert Krewinkel2017-08-31
|
* Text.Pandoc.Lua: support Inline and Block catch-allsAlbert Krewinkel2017-08-22
| | | | | | | Try function `Inline`/`Block` if no other filter function of the respective type matches an element. Closes: #3859
* data/pandoc.lua: fix documentationAlbert Krewinkel2017-08-21
| | | | Multiple documentation mistakes were fixed.
* data/pandoc.lua: Include Pandoc, Meta in implicit filtersAlbert Krewinkel2017-08-21
| | | | | | Functions with a name that corresponds to an AST element are included in implicit pandoc filter, but both `Meta` and `Pandoc` were wrongly ignored till now.
* data/pandoc.lua: regularize constructors.John MacFarlane2017-06-29
| | | | | | We now use Pandoc instead of Doc (though Doc remains a deprecated Synonym), and we deprecate DoubleQuoted, SingleQuoted, InlineMath, and DisplayMath.
* data/pandoc.lua: add accessors to Table elementsAlbert Krewinkel2017-06-27
|
* Lua module: allow omitting Attr in element constructorsAlbert Krewinkel2017-05-18
| | | | | | | The Attr argument is made optional for all pandoc element constructors which take such a parameter. The attr param is always the last argument of the constructor functions, so the option to omit them makes it easier to construct new pandoc elements by hand.
* Lua filter: fall-back to global filters when none is returnedAlbert Krewinkel2017-04-30
| | | | | | | | | The implicitly defined global filter (i.e. all element filtering functions defined in the global lua environment) is used if no filter is returned from a lua script. This allows to just write top-level functions in order to define a lua filter. E.g function Emph(elem) return pandoc.Strong(elem.content) end
* Lua module: simplify Attributes, rename to AttrAlbert Krewinkel2017-04-30
| | | | | | | Attributes was written to behave much like a normal table, in order to simplify working with it. However, all Attr containing elements were changed to provide panflute-like accessors to Attr components, rendering the previous approach unnecessary.
* Lua module: make Header argument order consistentAlbert Krewinkel2017-04-30
| | | | | Attributes are always passed as the last element, making it possible to omit this argument. Argument order for `Header` was wrong and is fixed.
* Lua module: add example for usage of `read`Albert Krewinkel2017-04-30
|
* Lua module: provide simple `read` format parserAlbert Krewinkel2017-04-26
| | | | | | A single `read` function parsing pandoc-supported formats is added to the module. This is simpler and more convenient than the previous method of exposing all reader functions individually.
* Lua filter: allow natural access to meta elementsAlbert Krewinkel2017-04-26
| | | | | | | | Meta elements that are treated as lua tables (i.e. MetaList, MetaInlines, MetaBlocks, and MetaMap), are no longer wrapped in an additional table but simply marked via a metatable. This allows treating those meta values just like normal tables, while still making empty elements of those values distinguishable.
* Lua module: provide accessors to element propertiesAlbert Krewinkel2017-04-15
|
* Lua filter: use Attributes constructor for AttrsAlbert Krewinkel2017-04-15
| | | | | | Element attributes are pushed to the stack via the `Attributes` function. `Attributes` creates an Attr like triple, but the triple also allows table-like access to key-value pairs.
* Lua module: fix doc generation, reorder codeAlbert Krewinkel2017-04-15
| | | | Ensure that documentation generated with `ldoc` is readable and correct.
* Lua module: provide builder functions for math and quotedAlbert Krewinkel2017-04-15
| | | | | | Provide functions `pandoc.SingleQuoted`, `pandoc.DoubleQuoted`, `pandoc.DisplayMath`, and `pandoc.InlineMath` to allow simple building of Math and Quoted elements.
* Lua filter: use lua strings for nullary constructorsAlbert Krewinkel2017-04-14
| | | | | | | Lua string are used to represent nullary data constructors. The previous table-based representation was based on the JSON serialization, but can be simplified. This also matches the way those arguments are passed to custom writers.
* Push blocks via lua constructors and constantsAlbert Krewinkel2017-04-14
| | | | | All element creation tasks are handled by lua functions defined in the pandoc module.
* Use lua constructors to push meta valuesAlbert Krewinkel2017-04-13
|
* Improve lua module documentationAlbert Krewinkel2017-04-13
|
* Lua module: provide multi-param Inline constructorsAlbert Krewinkel2017-04-12
| | | | | | Instead of taking only a single argument containing the pre-packed element contents, `Inline` constructors now take the same arguments as the respective filter and `Custom` writer function
* Lua filter: use custom StackValue Inline instanceAlbert Krewinkel2017-04-11
| | | | Inline elements are no longer pushed and pulled via aeson's Value.
* Lua filters (#3514)Albert Krewinkel2017-03-20
* Add `--lua-filter` option. This works like `--filter` but takes pathnames of special lua filters and uses the lua interpreter baked into pandoc, so that no external interpreter is needed. Note that lua filters are all applied after regular filters, regardless of their position on the command line. * Add Text.Pandoc.Lua, exporting `runLuaFilter`. Add `pandoc.lua` to data files. * Add private module Text.Pandoc.Lua.PandocModule to supply the default lua module. * Add Tests.Lua to tests. * Add data/pandoc.lua, the lua module pandoc imports when processing its lua filters. * Document in MANUAL.txt.