aboutsummaryrefslogtreecommitdiff
path: root/test/lua/module/pandoc.lua
AgeCommit message (Collapse)Author
2021-12-30Lua: allow binary (byte string) readers to be used with `pandoc.read`Albert Krewinkel
2021-11-28Lua: add constructors `pandoc.Blocks` and `pandoc.Inlines`Albert Krewinkel
The functions convert their argument into a list of Block and Inline values, respectively.
2021-11-27Lua: use package pandoc-lua-marshal (#7719)Albert Krewinkel
The marshaling functions for pandoc's AST are extracted into a separate package. The package comes with a number of changes: - Pandoc's List module was rewritten in C, thereby improving error messages. - Lists of `Block` and `Inline` elements are marshaled using the new list types `Blocks` and `Inlines`, respectively. These types currently behave identical to the generic List type, but give better error messages. This also opens up the possibility of adding element-specific methods to these lists in the future. - Elements of type `MetaValue` are no longer pushed as values which have `.t` and `.tag` properties. This was already true for `MetaString` and `MetaBool` values, which are still marshaled as Lua strings and booleans, respectively. Affected values: + `MetaBlocks` values are marshaled as a `Blocks` list; + `MetaInlines` values are marshaled as a `Inlines` list; + `MetaList` values are marshaled as a generic pandoc `List`s. + `MetaMap` values are marshaled as plain tables and no longer given any metatable. - The test suite for marshaled objects and their constructors has been extended and improved. - A bug in Citation objects, where setting a citation's suffix modified it's prefix, has been fixed.
2021-11-24Lua: allow single elements as singleton MetaBlocks/MetaInlinesAlbert Krewinkel
Single elements should always be treated as singleton lists in the Lua subsystem.
2021-11-23Lua: split strings into words when treating them as Inline list (#7712)Albert Krewinkel
Using a Lua string where a list of inlines is expected will cause the string to be split into words, replacing spaces and tabs into `pandoc.Space()` elements and newlines into `pandoc.SoftBreak()`. The previous behavior was to treat the string `s` as `{pandoc.Str(s)}`. The old behavior can be recovered by wrapping the string into a table `{s}`.
2021-11-09Lua: fix argument order in constructor `pandoc.Cite`.Albert Krewinkel
This restores the old behavior; argument order had been switched accidentally in pandoc 2.15.
2021-11-06Lua: allow to pass custom reader options to `pandoc.read`Albert Krewinkel
Reader options can now be passed as an optional third argument to `pandoc.read`. The object can either be a table or a ReaderOptions value like `PANDOC_READER_OPTIONS`. Creating new ReaderOptions objects is possible through the new constructor `pandoc.ReaderOptions`. Closes: #7656
2021-11-02Lua: fix typo in SoftBreak constructorAlbert Krewinkel
2021-11-02Lua tests: ensure Inline elements have all expected propertiesAlbert Krewinkel
2021-11-02Lua: re-add `content` property to Strikeout elementsAlbert Krewinkel
Fixes a regression introduced in 2.15.
2021-11-02Lua: be more forgiving when retrieving the Image `caption` propertyAlbert Krewinkel
Fixes a regression introduced in 2.15.
2021-11-02Lua: display Attr values using their native Haskell representationAlbert Krewinkel
2021-11-02Lua: allow omitting the 2nd parameter in pandoc.Code constructorAlbert Krewinkel
Fixes a regression introduced in 2.15 which required users to always specify an Attr value when constructing a Code element.
2021-11-02Lua: allow to compare, show Citation valuesAlbert Krewinkel
Comparisons of Citation values are performed in Haskell; values are equal if they represent the same Haskell value. Converting a Citation value to a string now yields its native Haskell string representation.
2021-11-02Lua tests: ensure Block elements have expected propertiesAlbert Krewinkel
2021-11-01Lua: restore `content` property on Header elementsAlbert Krewinkel
2021-11-01Lua: restore List behavior of MetaListAlbert Krewinkel
Fixes a regression introduced in 2.16 which had MetaList elements loose the `pandoc.List` properties. Fixes #7650
2021-10-31Lua: re-add `content` property to Link elementsAlbert Krewinkel
This was a regression introduced in version 2.15. Fixes: #7647
2021-10-29Lua: use hslua module abstraction where possibleAlbert Krewinkel
This will make it easier to generate module documentation in the future.
2021-10-28Lua: fix placement of tests for Block elements in pandoc module testsAlbert Krewinkel
2021-10-27Lua: re-add `t` and `tag` property to Attr valuesAlbert Krewinkel
Removal of these properties from Attr values was a regression.
2021-10-26Lua: marshal SimpleTable values as userdata objectsAlbert Krewinkel
2021-10-26Lua: marshal Block values as userdata objectsAlbert Krewinkel
Properties of Block values are marshalled lazily, which generally improves performance considerably. Script users may also notice the following differences: - Block element properties can no longer be accessed by numerical indexing of the `.c` field. The `.c` property now serves as an alias for `.content`, so some filter that used this undocumented method for property access may continue to work, while others will need to be updated and use proper property names. - The marshalled Block elements now have a `show` method, and a `__tostring` metamethod. Both return the Haskell string representation of the element. - Block values now have the Lua type `userdata` instead of `table`.
2021-10-25Lua: marshal Citation values as userdata objectsAlbert Krewinkel
2021-10-22Lua: marshal Attr values as userdataAlbert Krewinkel
- Adds a new `pandoc.AttributeList()` constructor, which creates the associative attribute list that is used as the third component of `Attr` values. Values of this type can often be passed to constructors instead of `Attr` values. - `AttributeList` values can no longer be indexed numerically.
2019-09-15Lua filters: allow passing of HTML-like tables instead of Attr (#5750)Albert Krewinkel
Attr values can now be given as normal Lua tables; this can be used as a convenient alternative to define Attr values, instead of constructing values with `pandoc.Attr`. Identifiers are taken from the *id* field, classes must be given as space separated words in the *class* field. All remaining fields are included as misc attributes. With this change, the following lines now create equal elements: pandoc.Span('test', {id = 'test', class = 'a b', check = 1}) pandoc.Span('test', pandoc.Attr('test', {'a','b'}, {check = 1})) This also works when using the *attr* setter: local span = pandoc.Span 'text' span.attr = {id = 'test', class = 'a b', check = 1} Furthermore, the *attributes* field of AST elements can now be a plain key-value table even when using the `attributes` accessor: local span = pandoc.Span 'test' span.attributes = {check = 1} -- works as expected now Closes: #5744
2019-08-16Lua: traverse nested blocks and inlines in correct orderAlbert Krewinkel
Traversal methods are updated to use the new Walk module such that sequences with nested Inline (or Block) elements are traversed in the order in which they appear in the linearized document. Fixes: #5667
2019-06-12Lua: add a `clone()` method to all AST elements (#5572)Albert Krewinkel
Closes: #5568
2019-06-11test/lua/module/pandoc.lua: fix non-determinism in testAlbert Krewinkel
2019-06-11data/pandoc.lua: fix deletion of nonexistent attributesAlbert Krewinkel
Fixes: #5569
2019-06-11Lua pandoc module: better tests for Attr and AttributeListAlbert Krewinkel
2019-05-20Improve output of Lua tests (#5499)Albert Krewinkel
This makes use of tasty-lua, a package to write tests in Lua and integrate the results into Tasty output. Test output becomes more informative: individual tests and test groups become visible in test output. Failures are reported with helpful error messages.