aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Lua/StackInstances.hs
AgeCommit message (Collapse)AuthorFilesLines
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 Krewinkel1-2/+16
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-09-24Use hslua v1.0.0Albert Krewinkel1-112/+82
2018-08-12Lua: cleanup Lua utils, remove unused functions.Albert Krewinkel1-28/+28
2018-03-18Use NoImplicitPrelude and explicitly import Prelude.John MacFarlane1-0/+2
This seems to be necessary if we are to use our custom Prelude with ghci. Closes #4464.
2018-01-23Lua: move getTag from StackInstances to UtilAlbert Krewinkel1-10/+1
Change: minor
2018-01-19hlint code improvements.John MacFarlane1-1/+0
2018-01-12Lua filters: improve error messagesAlbert Krewinkel1-13/+19
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-05Update copyright notices to include 2018Albert Krewinkel1-4/+4
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
2017-12-23Lua modules: add function pandoc.utils.hierarchicalizeAlbert Krewinkel1-1/+27
Convert list of Pandoc blocks into (hierarchical) list of Elements.
2017-12-01Lua/StackInstances: push Pandoc and Meta via constructorAlbert Krewinkel1-7/+5
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-10-27hlint suggestions.John MacFarlane1-10/+10
2017-10-27Automatic reformating by stylish-haskell.John MacFarlane1-5/+6
2017-09-24Allow lua filters to return lists of elementsAlbert Krewinkel1-15/+15
Closes: #3918
2017-08-16Update to hslua-0.8.0Albert Krewinkel1-2/+12
hslua no longer provides lua stack instances for Int and Double, the necessary instances are added to the Custom writer and the lua filtering system.
2017-08-13Delete Text.Pandoc.Lua.SharedInstancesAlbert Krewinkel1-1/+0
Stack instances for common data types are now provides by hslua. The instance for Either was useful only for a very specific case; the function that was using the `ToLuaStack Either` instance was rewritten to work without it. Closes: #3805
2017-08-13Text.Pandoc.Lua: Optimize performance by using raw table accessAlbert Krewinkel1-6/+21
Raw table accessing functions never call back into haskell, which allows the compiler to use more aggressive optimizations. This improves lua filter performance considerably (⪆5% speedup).
2017-08-13Use hslua >= 0.7, update Lua codeAlbert Krewinkel1-203/+204
2017-06-03Improve code style in lua and org modulesAlbert Krewinkel1-6/+6
2017-05-13Update dates in copyright noticesAlbert Krewinkel1-2/+2
This follows the suggestions given by the FSF for GPL licensed software. <https://www.gnu.org/prep/maintain/html_node/Copyright-Notices.html>
2017-04-30Lua module: simplify Attributes, rename to AttrAlbert Krewinkel1-1/+1
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-1/+1
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-26Lua filter: allow natural access to meta elementsAlbert Krewinkel1-1/+1
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 filter: use Attributes constructor for AttrsAlbert Krewinkel1-14/+26
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-14Lua filter: Re-order code of stack value instancesAlbert Krewinkel1-106/+122
2017-04-14Lua filter: use lua strings for nullary constructorsAlbert Krewinkel1-80/+19
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-14Avoid repeating StackValue instances definitionsAlbert Krewinkel1-125/+3
The lua filters and custom lua writer system defined very similar StackValue instances for strings and tuples. These instance definitions are extracted to a separate module to enable sharing.
2017-04-14Extract lua helper functions into Lua.Util moduleAlbert Krewinkel1-103/+56
2017-04-14Use lua bools and strings for MetaBool, MetaStringAlbert Krewinkel1-2/+2
Native lua booleans and strings are used to represent MetaBool and MetaString values. This is more natural than the previous table-based representation. The old lua representation can still be read back to haskell, ensuring compatibility with the `pandoc.MetaBool` and `pandoc.MetaString` lua constructors.
2017-04-14Drop dependency on hslua-aesonAlbert Krewinkel1-1/+0
Pushing values to the lua stack via custom functions is faster and more flexible.
2017-04-14Push blocks via lua constructors and constantsAlbert Krewinkel1-37/+102
All element creation tasks are handled by lua functions defined in the pandoc module.
2017-04-14Push inlines via lua constructors and constantsAlbert Krewinkel1-41/+29
All element creation tasks are handled in the lua module.
2017-04-13Use lua constructors to push meta valuesAlbert Krewinkel1-30/+148
2017-04-11Lua filter: use custom StackValue Inline instanceAlbert Krewinkel1-24/+151
Inline elements are no longer pushed and pulled via aeson's Value.
2017-04-07Lua filter: improve doc filter performanceAlbert Krewinkel1-36/+47
Pandoc elements are pushed and pulled from the lua stack via custom instances.
2017-04-06Lua filter: Improve block filter performanceAlbert Krewinkel1-7/+44
Reading of simple block values from the lua stack is handled manually, but most block constructors are still handled via instances of aeson's Value type.
2017-04-06Lua filter: Improve inline filter performanceAlbert Krewinkel1-7/+73
Getting inline instances from the lua stack is handled manually for some simple inline constructors, including the `Str` constructor. This avoids the indirect route through aeson's Value type and improves performance considerably (approx. 30% speedup for some filters).
2017-04-02Lua module: add readers submoduleAlbert Krewinkel1-0/+75
Plain text readers are exposed to lua scripts via the `pandoc.reader` submodule, which is further subdivided by format. Converting e.g. a markdown string into a pandoc document is possible from within lua: doc = pandoc.reader.markdown.read_doc("Hello, World!") A `read_block` convenience function is provided for all formats, although it will still parse the whole string but return only the first block as the result. Custom reader options are not supported yet, default options are used for all parsing operations.