aboutsummaryrefslogtreecommitdiff
path: root/test/lua
AgeCommit message (Collapse)AuthorFilesLines
2021-11-24Lua: allow single elements as singleton MetaBlocks/MetaInlinesAlbert Krewinkel1-1/+19
Single elements should always be treated as singleton lists in the Lua subsystem.
2021-11-23Lua: add function `pandoc.utils.text` (#7710)Albert Krewinkel1-0/+28
The function converts a string to `Inlines`, treating interword spaces as `Space`s or `SoftBreak`s. If you want a `Str` with literal spaces, use `pandoc.Str`. Closes: #7709
2021-11-23Lua: split strings into words when treating them as Inline list (#7712)Albert Krewinkel1-2/+26
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 Krewinkel1-4/+4
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 Krewinkel1-1/+29
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 Krewinkel1-0/+6
2021-11-02Lua tests: ensure Inline elements have all expected propertiesAlbert Krewinkel1-0/+81
2021-11-02Lua: re-add `content` property to Strikeout elementsAlbert Krewinkel1-3/+93
Fixes a regression introduced in 2.15.
2021-11-02Lua: be more forgiving when retrieving the Image `caption` propertyAlbert Krewinkel1-0/+9
Fixes a regression introduced in 2.15.
2021-11-02Lua: display Attr values using their native Haskell representationAlbert Krewinkel1-3/+3
2021-11-02Lua: allow omitting the 2nd parameter in pandoc.Code constructorAlbert Krewinkel1-7/+75
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 Krewinkel1-0/+16
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 Krewinkel1-36/+202
2021-11-01Lua: restore `content` property on Header elementsAlbert Krewinkel1-0/+23
2021-11-01Lua: restore List behavior of MetaListAlbert Krewinkel1-0/+13
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 Krewinkel1-0/+10
This was a regression introduced in version 2.15. Fixes: #7647
2021-10-29Lua: use hslua module abstraction where possibleAlbert Krewinkel1-0/+6
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 Krewinkel1-120/+120
2021-10-27Lua: re-add `t` and `tag` property to Attr valuesAlbert Krewinkel1-0/+7
Removal of these properties from Attr values was a regression.
2021-10-26Lua: marshal SimpleTable values as userdata objectsAlbert Krewinkel1-0/+61
2021-10-26Lua: marshal Block values as userdata objectsAlbert Krewinkel1-0/+120
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 Krewinkel1-0/+2
2021-10-22Lua: marshal Attr values as userdataAlbert Krewinkel1-21/+34
- 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.
2021-10-22Switch to hslua-2.0Albert Krewinkel1-25/+0
The new HsLua version takes a somewhat different approach to marshalling and unmarshalling, relying less on typeclasses and more on specialized types. This allows for better performance and improved error messages. Furthermore, new abstractions allow to document the code and exposed functions.
2021-02-02Add tests for search_path_separatorAlbert Krewinkel1-0/+8
2021-02-02Check that all documented functions are present.Albert Krewinkel1-0/+19
Rely on tests in the module package to check the correctness of each function.
2021-02-02Lua: add module "pandoc.path"Albert Krewinkel1-0/+17
The module allows to work with file paths in a convenient and platform-independent manner. Closes: #6001 Closes: #6565
2020-09-20Lua filters: add SimpleTable for backwards compatibility (#6575)Albert Krewinkel1-0/+66
A new type `SimpleTable` is made available to Lua filters. It is similar to the `Table` type in pandoc versions before 2.10; conversion functions from and to the new Table type are provided. Old filters using tables now require minimal changes and can use, e.g., if PANDOC_VERSION > {2,10,1} then pandoc.Table = pandoc.SimpleTable end and function Table (tbl) tbl = pandoc.utils.to_simple_table(tbl) … return pandoc.utils.from_simple_table(tbl) end to work with the current pandoc version.
2020-05-12Lua: fix regression in package searcherAlbert Krewinkel1-0/+2
This caused `require 'module'` to fail for third party packages. Fixes: #6361
2020-04-17API change: use PandocError for exceptions in Lua subsystemAlbert Krewinkel1-4/+3
The PandocError type is used throughout the Lua subsystem, all Lua functions throw an exception of this type if an error occurs. The `LuaException` type is removed and no longer exported from `Text.Pandoc.Lua`. In its place, a new constructor `PandocLuaError` is added to PandocError.
2020-01-15Lua filters: allow filtering of element lists (#6040)Albert Krewinkel3-0/+33
Lists of Inline and Block elements can now be filtered via `Inlines` and `Blocks` functions, respectively. This is helpful if a filter conversion depends on the order of elements rather than a single element. For example, the following filter can be used to remove all spaces before a citation: function isSpaceBeforeCite (spc, cite) return spc and spc.t == 'Space' and cite and cite.t == 'Cite' end function Inlines (inlines) for i = #inlines-1,1,-1 do if isSpaceBeforeCite(inlines[i], inlines[i+1]) then inlines:remove(i) end end return inlines end Closes: #6038
2020-01-11Lua: add methods `insert`, `remove`, and `sort` to pandoc.ListAlbert Krewinkel1-40/+80
The functions `table.insert`, `table.remove`, and `table.sort` are added to pandoc.List elements. They can be used as methods, e.g. local numbers = pandoc.List {2, 3, 1} numbers:sort() -- numbers is now {1, 2, 3}
2020-01-11pandoc.List.lua: make `pandoc.List` a callable constructorAlbert Krewinkel1-0/+9
It is now possible to construct a new List via `pandoc.List()` instead of `pandoc.List:new()`.
2020-01-11Add tests for pandoc.List moduleAlbert Krewinkel1-0/+111
2019-09-15Lua filters: allow passing of HTML-like tables instead of Attr (#5750)Albert Krewinkel1-0/+41
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-09-08Replace Element and makeHierarchical with makeSections.John MacFarlane1-8/+5
Text.Pandoc.Shared: + Remove `Element` type [API change] + Remove `makeHierarchicalize` [API change] + Add `makeSections` [API change] + Export `deLink` [API change] Now that we have Divs, we can use them to represent the structure of sections, and we don't need a special Element type. `makeSections` reorganizes a block list, adding Divs with class `section` around sections, and adding numbering if needed. This change also fixes some longstanding issues recognizing section structure when the document contains Divs. Closes #3057, see also #997. All writers have been changed to use `makeSections`. Note that in the process we have reverted the change c1d058aeb1c6a331a2cc22786ffaab17f7118ccd made in response to #5168, which I'm not completely sure was a good idea. Lua modules have also been adjusted accordingly. Existing lua filters that use `hierarchicalize` will need to be rewritten to use `make_sections`.
2019-08-16Lua: traverse nested blocks and inlines in correct orderAlbert Krewinkel1-0/+38
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 Krewinkel1-0/+38
Closes: #5568
2019-06-11test/lua/module/pandoc.lua: fix non-determinism in testAlbert Krewinkel1-4/+11
2019-06-11data/pandoc.lua: fix deletion of nonexistent attributesAlbert Krewinkel1-0/+6
Fixes: #5569
2019-06-11Lua pandoc module: better tests for Attr and AttributeListAlbert Krewinkel1-0/+65
2019-05-30Lua modules: test pandoc.mediabagAlbert Krewinkel1-0/+72
2019-05-29Lua Version type: shorten "version too old" messageAlbert Krewinkel1-1/+1
2019-05-29Lua: add Version type to simplify comparisonsAlbert Krewinkel2-0/+112
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-20Improve output of Lua tests (#5499)Albert Krewinkel3-138/+154
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.
2019-01-13data/pandoc.lua: auto-fix nested constructor argumentsAlbert Krewinkel1-0/+10
Incorrect types to pandoc element constructors are automatically converted to the correct types when possible. This was already done for most constructors, but conversions are now also done for nested types (like lists of lists).
2018-07-30Lua Utils module: add function blocks_to_inlines (#4799)Albert Krewinkel1-0/+15
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-05-08Another try at test-pandoc-utils.lua on windows.John MacFarlane1-3/+2
2018-05-08test-pandoc-utils.lua - add diagnostic for windows test.John MacFarlane1-0/+1
2018-05-08More adjustments to test-pandoc-utils.lua.John MacFarlane1-5/+4
We need to find something that will work on windows.