aboutsummaryrefslogtreecommitdiff
path: root/test/Tests/Lua.hs
AgeCommit message (Collapse)AuthorFilesLines
2021-02-07Avoid unnecessary use of NoImplicitPrelude pragma (#7089)Albert Krewinkel1-2/+0
2021-01-08Update copyright notices for 2021 (#7012)Albert Krewinkel1-1/+1
2020-10-14Fix remaining typos in testsAlbert Krewinkel1-1/+1
See: #6738
2020-05-12Lua: fix regression in package searcherAlbert Krewinkel1-0/+6
This caused `require 'module'` to fail for third party packages. Fixes: #6361
2020-04-17API change: use PandocError for exceptions in Lua subsystemAlbert Krewinkel1-7/+8
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-03-13Update copyright year (#6186)Albert Krewinkel1-1/+1
* Update copyright year * Copyright: add notes for Lua and Jira modules
2020-01-15Lua filters: allow filtering of element lists (#6040)Albert Krewinkel1-1/+24
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
2019-11-12Switch to new pandoc-types and use Text instead of String [API change].despresc1-3/+4
PR #5884. + Use pandoc-types 1.20 and texmath 0.12. + Text is now used instead of String, with a few exceptions. + In the MediaBag module, some of the types using Strings were switched to use FilePath instead (not Text). + In the Parsing module, new parsers `manyChar`, `many1Char`, `manyTillChar`, `many1TillChar`, `many1Till`, `manyUntil`, `mantyUntilChar` have been added: these are like their unsuffixed counterparts but pack some or all of their output. + `glob` in Text.Pandoc.Class still takes String since it seems to be intended as an interface to Glob, which uses strings. It seems to be used only once in the package, in the EPUB writer, so that is not hard to change.
2019-07-02Fix redundant constraint warnings. (#5625)Pete Ryland1-1/+1
2019-05-29Lua: add Version type to simplify comparisonsAlbert Krewinkel1-8/+5
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 Krewinkel1-26/+10
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-05-04Lua: add `pandoc.system` module (#5468)Albert Krewinkel1-0/+5
The `system` Lua module provides utility functions to interact with the operating- and file system. E.g. print(pandoc.system.get_current_directory()) or pandoc.system.with_temporary_directory('tikz', function (dir) -- write and compile a TikZ file with pdflatex end)
2019-02-04Add missing copyright notices and remove license boilerplate (#5112)Albert Krewinkel1-0/+11
Quite a few modules were missing copyright notices. This commit adds copyright notices everywhere via haddock module headers. The old license boilerplate comment is redundant with this and has been removed. Update copyright years to 2019. Closes #4592.
2019-01-13data/pandoc.lua: auto-fix nested constructor argumentsAlbert Krewinkel1-4/+15
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-10-28T.P.Lua: rename `runPandocLua` to `runLua` (API change)Albert Krewinkel1-10/+10
2018-10-28T.P.Lua: merge runLuaFilter into T.P.Filter.Lua (API change)Albert Krewinkel1-8/+7
The function `runLuaFilter` was only used in Text.Pandoc.Filter.Lua, use apply from the that module instead.
2018-09-24Use hslua v1.0.0Albert Krewinkel1-5/+5
2018-09-19Lua filter tests: produce better error on test failureAlbert Krewinkel1-2/+2
2018-07-30Lua Utils module: add function blocks_to_inlines (#4799)Albert Krewinkel1-1/+2
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-07-02More spellcheckAlexander Krotov1-1/+1
2018-04-29Test Lua filter converting display math to inline mathAlexander Krotov1-1/+8
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-03-17Removed redundant import of <>John MacFarlane1-1/+1
2018-02-25Tests/Lua: fix tests on windowsAlbert Krewinkel1-1/+1
2018-02-24Lua: register script name in global variableAlbert Krewinkel1-0/+6
The name of the Lua script which is executed is made available in the global Lua variable `PANDOC_SCRIPT_FILE`, both for Lua filters and custom writers. Closes: #4393
2018-01-13data/pandoc.lua: add attr, listAttributes accessorsAlbert Krewinkel1-2/+9
Elements with attributes got an additional `attr` accessor. Attributes were accessible only via the `identifier`, `classes`, and `attributes`, which was in conflict with the documentation, which indirectly states that such elements have the an `attr` property.
2018-01-13data/pandoc.lua: accept single block as singleton listAlbert Krewinkel1-4/+14
Every constructor which accepts a list of blocks now also accepts a single block element for convenience. Furthermore, strings are accepted as shorthand for `{pandoc.Str "text"}` in constructors.
2018-01-13data/pandoc.lua: accept singleton inline as a listAlbert Krewinkel1-1/+6
Every constructor which accepts a list of inlines now also accepts a single inline element for convenience.
2018-01-12Lua filters: improve error messagesAlbert Krewinkel1-0/+10
Provide more context about the task which caused an error.
2018-01-12Lua filters: make PANDOC_READER_OPTIONS availableAlbert Krewinkel1-1/+2
The options which were used to read the document are made available to Lua filters via the `PANDOC_READER_OPTIONS` global.
2018-01-08data/pandoc.lua: cleanup code, remove cruftAlbert Krewinkel1-2/+2
2018-01-07Lua: make pandoc-types version available as PANDOC_API_VERSIONAlbert Krewinkel1-1/+8
The current pandoc-types version is made available to Lua programs in the global PANDOC_API_VERSION. It contains the version as a list of numbers.
2018-01-07Lua: make pandoc version available as PANDOC_VERSIONAlbert Krewinkel1-13/+25
The current pandoc version is made available to Lua programs in the global PANDOC_VERSION. It contains the version as a list of numbers.
2017-12-23Lua modules: add function pandoc.utils.hierarchicalizeAlbert Krewinkel1-1/+2
Convert list of Pandoc blocks into (hierarchical) list of Elements.
2017-12-23Lua modules: add function pandoc.utils.normalize_dateAlbert Krewinkel1-1/+2
The function parses a date and converts it (if possible) to "YYYY-MM-DD" format.
2017-12-23Lua modules: add function pandoc.utils.to_roman_numeralAlbert Krewinkel1-0/+1
The function allows conversion of numbers below 4000 into roman numerals.
2017-12-22Lua modules: add stringify function to pandoc.utilsAlbert Krewinkel1-0/+1
The new function `pandoc.utils.stringify` converts any AST element to a string with formatting removed.
2017-12-20Test more pandoc Lua module functionsAlbert Krewinkel1-0/+11
The functions `sha1`, `read`, and `pipe` are now tested. Change: minor
2017-12-13Custom writer: use init file to setup Lua interpreterAlbert Krewinkel1-13/+18
The same init file (`data/init`) that is used to setup the Lua interpreter for Lua filters is also used to setup the interpreter of custom writers.lua.
2017-12-02Lua filters: refactor lua module handlingAlbert Krewinkel1-13/+11
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-11-20data/pandoc.lua: enable table-like behavior of attributes (#4080)Albert Krewinkel1-3/+11
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-11-18Lua filters: preload text module (#4077)Albert Krewinkel1-3/+9
The `text` module is preloaded in lua. The module contains some UTF-8 aware string functions, implemented in Haskell. The module is loaded on request only, e.g.: text = require 'text' function Str (s) s.text = text.upper(s.text) return s end
2017-10-27Automatic reformating by stylish-haskell.John MacFarlane1-8/+8
2017-09-30Text.Pandoc.Lua: add mediabag submoduleAlbert Krewinkel1-3/+7
2017-08-22Text.Pandoc.Lua: support Inline and Block catch-allsAlbert Krewinkel1-0/+6
Try function `Inline`/`Block` if no other filter function of the respective type matches an element. Closes: #3859
2017-08-22Text.Pandoc.Lua: respect metatable when getting filtersAlbert Krewinkel1-0/+6
This change makes it possible to define a catch-all function using lua's metatable lookup functionality. function catch_all(el) … end return { setmetatable({}, {__index = function(_) return catch_all end}) } A further effect of this change is that the map with filter functions now only contains functions corresponding to AST element constructors.
2017-08-14Test fixes so we can find data files.John MacFarlane1-2/+2
In old tests & command tests, we now set the environment variable pandoc_datadir. In lua tests, we set the datadir explicitly.
2017-08-13Use hslua >= 0.7, update Lua codeAlbert Krewinkel1-17/+14
2017-06-29Added parameter for user data directory to runLuaFilter.John MacFarlane1-2/+2
in Text.Pandoc.Lua. Also to pushPandocModule. This change allows users to override pandoc.lua with a file in their local data directory, adding custom functions, etc. @tarleb, if you think this is a bad idea, you can revert this. But in general our data files are all overridable.
2017-05-07Use fewer quickcheck tests for lua tests, to speed things up.John MacFarlane1-3/+3