aboutsummaryrefslogtreecommitdiff
path: root/data/pandoc.lua
AgeCommit message (Collapse)AuthorFilesLines
2018-01-13data/pandoc.lua: drop _VERSIONAlbert Krewinkel1-3/+0
Having a _VERSION became superfluous, as this module is closely tied to the pandoc version, which is available via PANDOC_VERSION.
2018-01-09data/pandoc.lua: fix access to Attr componentsAlbert Krewinkel1-6/+4
Accessing an Attr value (e.g., ` Attr().classes`) was broken; the more common case of accessing it via an Inline or Block element was unaffected by this.
2018-01-09data/pandoc.lua: slightly de-complicate accessor codeAlbert Krewinkel1-20/+20
Change: minor
2018-01-08data/pandoc.lua: cleanup code, remove cruftAlbert Krewinkel1-81/+90
2018-01-07data/pandoc.lua: fix docstringsAlbert Krewinkel1-9/+18
Change: minor
2018-01-07data/pandoc.lua: make Attr an AstElementAlbert Krewinkel1-9/+7
Attr is an AST element, which is now reflected in the type hierarchy.
2018-01-07data/pandoc.lua: drop 'pandoc-api-version' from Pandoc objectsAlbert Krewinkel1-4/+2
This attribute was out-of-sync with the actual version as is mostly irrelevant in the context Lua filters and custom writers. Use the global `PANDOC_API_VERSION` instead.
2018-01-07data/pandoc.lua: make all types subtypes of AstElementAlbert Krewinkel1-25/+28
*Pandoc*, *Meta*, and *Citation* were just plain functions and did not set a metatable on the returned value, which made it difficult to amend objects of these types with new behavior. They are now subtypes of AstElement, meaning that all their objects can gain new features when a method is added to the behavior object (e.g., `pandoc.Pandoc.behavior`).
2018-01-06data/pandoc.lua: split type and behavior tablesAlbert Krewinkel1-51/+83
Clearly distinguish between a type and the behavioral properties of an instance of that type. The behavior of a type (and all its subtypes) can now be amended by adding methods to that types `behavior` object, without exposing the type objects internals. E.g.: pandoc.Inline.behavior.frob = function () print'42' end local str = pandoc.Str'hello' str.frob() -- outputs '42'
2018-01-06data/pandoc.lua: rename Element to AstElementAlbert Krewinkel1-9/+9
This avoids confusion with the Element type from Text.Pandoc.Shared. Change: minor
2018-01-06data/pandoc.lua: remove dead codeAlbert Krewinkel1-6/+2
A `Element:new` method was a left-over was never called. Change: minor
2018-01-06data/pandoc.lua: fix Element inheritanceAlbert Krewinkel1-2/+3
Extending all elements of a given type (e.g., all inline elements) was difficult, as the table used to lookup unknown methods would be reset every time a new element of that type was created, preventing recursive property lookup. This is was changed in that all methods and attributes of supertypes are now available to their subtypes.
2018-01-05Update copyright notices to include 2018Albert Krewinkel1-2/+2
2018-01-05data/pandoc.lua: fix attribute names of CitationAlbert Krewinkel1-13/+15
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
2017-12-29data/pandoc.lua: drop function pandoc.global_filterAlbert Krewinkel1-36/+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-29data/pandoc.lua: fix documentation for global_filterAlbert Krewinkel1-5/+5
2017-12-28Fixed some doc comments in data/pandoc.lua.John MacFarlane1-10/+10
2017-12-21Lua modules: added pandoc.utils moduleAlbert Krewinkel1-0/+5
A new module `pandoc.utils` has been created. It holds utility functions like `sha1`, which was moved from the main `pandoc` module.
2017-12-20Lua modules: turn pipe, read into full Haskell functionsAlbert Krewinkel1-47/+0
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-19pandoc.lua: re-add missing MetaMap functionAlbert Krewinkel1-1/+4
This was a bug introduced in version 2.0.4 (commit 3f1f9536d4817bbdd797c01050a887fe4cdf347c).
2017-12-02Lua filters: refactor lua module handlingAlbert Krewinkel1-1/+1
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`.
2017-12-01pandoc.lua: set metatable on List MetaValuesAlbert Krewinkel1-10/+10
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.
2017-12-01Lua/StackInstances: push Pandoc and Meta via constructorAlbert Krewinkel1-0/+15
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.
2017-12-01List.lua: add missing fixes as discussed in #4099Albert Krewinkel1-1/+1
The changes were missing due to an error while using git.
2017-11-28Add basic lua List module (#4099)Albert Krewinkel1-41/+39
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
2017-11-20data/pandoc.lua: enable table-like behavior of attributes (#4080)Albert Krewinkel1-1/+92
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
2017-10-25pandoc.lua: define default list attributesAlbert Krewinkel1-1/+2
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.
2017-10-17pandoc.lua: destructure attr for Link and ImageAlbert Krewinkel1-2/+2
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.
2017-10-05pandoc.lua: throw better error when pipe command failsAlbert Krewinkel1-3/+3
A table containing the error code, command, and command output is thrown instead of just a string error message.
2017-10-03pandoc.lua: use wrapper funciton for pipe commandAlbert Krewinkel1-0/+23
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.
2017-10-03Lua.PandocModule: promote addFunction to top levelAlbert Krewinkel1-1/+1
This reduces some boilerplate.
2017-08-31data/pandoc.lua: fix typos in documentationAlbert Krewinkel1-2/+2
2017-08-22Text.Pandoc.Lua: support Inline and Block catch-allsAlbert Krewinkel1-1/+2
Try function `Inline`/`Block` if no other filter function of the respective type matches an element. Closes: #3859
2017-08-21data/pandoc.lua: fix documentationAlbert Krewinkel1-3/+4
Multiple documentation mistakes were fixed.
2017-08-21data/pandoc.lua: Include Pandoc, Meta in implicit filtersAlbert Krewinkel1-1/+6
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.
2017-06-29data/pandoc.lua: regularize constructors.John MacFarlane1-11/+10
We now use Pandoc instead of Doc (though Doc remains a deprecated Synonym), and we deprecate DoubleQuoted, SingleQuoted, InlineMath, and DisplayMath.
2017-06-27data/pandoc.lua: add accessors to Table elementsAlbert Krewinkel1-1/+2
2017-05-18Lua module: allow omitting Attr in element constructorsAlbert Krewinkel1-19/+21
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.
2017-04-30Lua filter: fall-back to global filters when none is returnedAlbert Krewinkel1-1/+1
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
2017-04-30Lua module: simplify Attributes, rename to AttrAlbert Krewinkel1-59/+26
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.
2017-04-30Lua module: make Header argument order consistentAlbert Krewinkel1-2/+2
Attributes are always passed as the last element, making it possible to omit this argument. Argument order for `Header` was wrong and is fixed.
2017-04-30Lua module: add example for usage of `read`Albert Krewinkel1-1/+11
2017-04-26Lua module: provide simple `read` format parserAlbert Krewinkel1-0/+14
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.
2017-04-26Lua filter: allow natural access to meta elementsAlbert Krewinkel1-13/+18
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.
2017-04-15Lua module: provide accessors to element propertiesAlbert Krewinkel1-39/+109
2017-04-15Lua filter: use Attributes constructor for AttrsAlbert Krewinkel1-16/+50
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.
2017-04-15Lua module: fix doc generation, reorder codeAlbert Krewinkel1-69/+60
Ensure that documentation generated with `ldoc` is readable and correct.
2017-04-15Lua module: provide builder functions for math and quotedAlbert Krewinkel1-4/+42
Provide functions `pandoc.SingleQuoted`, `pandoc.DoubleQuoted`, `pandoc.DisplayMath`, and `pandoc.InlineMath` to allow simple building of Math and Quoted elements.
2017-04-14Lua filter: use lua strings for nullary constructorsAlbert Krewinkel1-44/+22
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.
2017-04-14Push blocks via lua constructors and constantsAlbert Krewinkel1-41/+234
All element creation tasks are handled by lua functions defined in the pandoc module.