summaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Lua.hs
AgeCommit message (Collapse)Author
2022-09-30[API Change] Extract Lua code into new package pandoc-lua-engineAlbert Krewinkel
The flag 'lua53` must now be used with that package if pandoc is to be compiled against Lua 5.3.
2022-09-30[API Change] Lua: export new function T.P.Lua.getEngineAlbert Krewinkel
The function returns the Lua scripting engine.
2022-09-27pandoc-cli: support `-E` flag in pandoc-luaAlbert Krewinkel
2022-09-23Use hslua-cli package for pandoc-lua interfaceAlbert Krewinkel
2022-09-22Make pandoc behave like a Lua interpreter when called as `pandoc-lua`. (#8311)Albert Krewinkel
2022-09-20Export `applyFilter` from T.P.Lua.Filter.John MacFarlane
Motivation: now we need not have any logic referring to hslua types (LuaE) in T.P.Filter.Lua. This restricts the parts of Pandoc that deal directly with hslua to T.P.Lua (and in tests, Tests.Lua). [API changes] T.P.Lua now exports `applyFilter`, `readCustom`, and `writeCustom`. The lower-level function `runFilterFile` is no longer exported.
2022-01-02Copyright notices: update for 2022Albert Krewinkel
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-01-08Update copyright notices for 2021 (#7012)Albert Krewinkel
2020-04-17API change: use PandocError for exceptions in Lua subsystemAlbert Krewinkel
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-15Use implicit Prelude (#6187)Albert Krewinkel
* Use implicit Prelude The previous behavior was introduced as a fix for #4464. It seems that this change alone did not fix the issue, and `stack ghci` and `cabal repl` only work with GHC 8.4.1 or newer, as no custom Prelude is loaded for these versions. Given this, it seems cleaner to revert to the implicit Prelude. * PandocMonad: remove outdated check for base version Only base versions 4.9 and later are supported, the check for `MIN_VERSION_base(4,8,0)` is therefore unnecessary. * Always use custom prelude Previously, the custom prelude was used only with older GHC versions, as a workaround for problems with ghci. The ghci problems are resolved by replacing package `base` with `base-noprelude`, allowing for consistent use of the custom prelude across all GHC versions.
2020-03-13Update copyright year (#6186)Albert Krewinkel
* Update copyright year * Copyright: add notes for Lua and Jira modules
2020-02-07Apply linter suggestions. Add fix_spacing to lint target in Makefile.John MacFarlane
2019-03-01Remove license boilerplate.John MacFarlane
The haddock module header contains essentially the same information, so the boilerplate is redundant and just one more thing to get out of sync.
2019-02-16T.P.Lua: split StackInstances into smaller Marshaling modulesAlbert Krewinkel
2019-02-04Add missing copyright notices and remove license boilerplate (#5112)Albert Krewinkel
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.
2018-10-28T.P.Lua: expose more useful internals (API change)Albert Krewinkel
Newly exported from Text.Pandoc.Lua: - `runFilterFile` to run a Lua filter from file; - data type `Global` and its constructors; and - `setGlobals` to add globals to a Lua environment. This module also contains `Pushable` and `Peekable` instances required to get pandoc's data types to and from Lua. Low-level Lua operation remain hidden in Text.Pandoc.Lua.
2018-10-28T.P.Lua: rename `runPandocLua` to `runLua` (API change)Albert Krewinkel
2018-10-28T.P.Lua: merge runLuaFilter into T.P.Filter.Lua (API change)Albert Krewinkel
The function `runLuaFilter` was only used in Text.Pandoc.Filter.Lua, use apply from the that module instead.
2018-10-26Text.Pandoc.Lua: move globals handling to separate moduleAlbert Krewinkel
2018-10-01Lua filters: report traceback when an error occursAlbert Krewinkel
A proper Lua traceback is added if either loading of a file or execution of a filter function fails. This should be of help to authors of Lua filters who need to debug their code.
2018-09-24Use hslua v1.0.0Albert Krewinkel
2018-08-12Lua: cleanup Lua utils, remove unused functions.Albert Krewinkel
2018-03-18Use NoImplicitPrelude and explicitly import Prelude.John MacFarlane
This seems to be necessary if we are to use our custom Prelude with ghci. Closes #4464.
2018-02-24Lua: register script name in global variableAlbert Krewinkel
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-19hlint code improvements.John MacFarlane
2018-01-12Lua filters: make PANDOC_READER_OPTIONS availableAlbert Krewinkel
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 Krewinkel
2017-12-29Lua filters: stop exporting pushPandocModuleAlbert Krewinkel
The function `pushPandocModule` was exported by Text.Pandoc.Lua to enable simpler testing. The introduction of `runPandocLua` renders direct use of this function obsolete. (API change)
2017-12-29data/pandoc.lua: drop function pandoc.global_filterAlbert Krewinkel
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-21Lua modules: move to dedicated submoduleAlbert Krewinkel
The Haskell module defining the Lua `pandoc` module is moved to Text.Pandoc.Lua.Module.Pandoc. Change: minor
2017-12-13Custom writer: use init file to setup Lua interpreterAlbert Krewinkel
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-13Lua filters: drop unused code, language extensionsAlbert Krewinkel
2017-12-06Lua filters: use script to initialize the interpreterAlbert Krewinkel
The file `init.lua` is used to initialize the Lua interpreter which is used in Lua filters. This gives users the option to require libraries which they want to use in all of their filters, and to extend default modules.
2017-12-02Lua filters: refactor lua module handlingAlbert Krewinkel
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-18Lua filters: preload text module (#4077)Albert Krewinkel
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-11-11Add lua filter functions to walk inline and block elements.John MacFarlane
Refactored some code from Text.Pandoc.Lua.PandocModule into new internal module Text.Pandoc.Lua.Filter. Add `walk_inline` and `walk_block` in pandoc lua module.
2017-10-27Automatic reformating by stylish-haskell.John MacFarlane
2017-10-05pandoc.lua: throw better error when pipe command failsAlbert Krewinkel
A table containing the error code, command, and command output is thrown instead of just a string error message.
2017-09-30Lua filters: make sure whole CommonState is passed through...John MacFarlane
to insertResource (`fetch`).
2017-09-30Text.Pandoc.Lua: add mediabag submoduleAlbert Krewinkel
2017-09-26Lua filters: set global FORMAT instead of args.John MacFarlane
This changes the type of runLuaFilter.
2017-09-26Lua: set "arg" instead of "PandocParameters".John MacFarlane
This is standard for lua scripts, and I see no reason to depart from the standard here. Also, "arg" is now pushed onto the stack before the script is loaded. Previously it was not, and thus "PandocParameters" was not available at the top level.
2017-09-24Allow lua filters to return lists of elementsAlbert Krewinkel
Closes: #3918
2017-08-23Text.Pandoc.Lua: fix fallback functions with GHC 7.8Albert Krewinkel
2017-08-22Text.Pandoc.Lua: support Inline and Block catch-allsAlbert Krewinkel
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 Krewinkel
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-13Delete Text.Pandoc.Lua.SharedInstancesAlbert Krewinkel
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: cleanup element walking codeAlbert Krewinkel
WalkM is general enough to work in any monad, not just IO. Also get rid of the LuaException type, sufficient to use the one defined in hslua.
2017-08-13Use hslua >= 0.7, update Lua codeAlbert Krewinkel