aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Lua/Init.hs
AgeCommit message (Collapse)AuthorFilesLines
2021-08-24Lua subsystem and custom writers: generalize types from PandocIO...John MacFarlane1-3/+2
to any instance of PandocMonad and MonadIO. This involves an API change, since the type of runLua is now (PandocMonad m, MonadIO m) => Lua a -> m (Either PandocError a)
2021-01-26Lua: always load built-in Lua scripts from default data-dirAlbert Krewinkel1-4/+14
The Lua modules `pandoc` and `pandoc.List` are now always loaded from the system's default data directory. Loading from a different directory by overriding the default path, e.g. via `--data-dir`, is no longer supported to avoid unexpected behavior and to address security concerns.
2021-01-08Update copyright notices for 2021 (#7012)Albert Krewinkel1-1/+1
2020-09-20Lua filters: add SimpleTable for backwards compatibility (#6575)Albert Krewinkel1-0/+1
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-04-17API change: use new type PandocLua for all pandoc Lua operationsAlbert Krewinkel1-60/+23
The new type `PandocLua` is an instance of the `PandocMonad` typeclass and can thus be used in a way similar to `PandocIO`.
2020-04-17API change: use PandocError for exceptions in Lua subsystemAlbert Krewinkel1-9/+7
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-22Finer grained imports of Text.Pandoc.Class submodules (#6203)Albert Krewinkel1-2/+3
This should speed-up recompilation after changes in `Text.Pandoc.Class`, as the number of modules affected by a change will be smaller in general. It also offers faster insights into the parts of `T.P.Class` used within a module.
2020-03-15Use implicit Prelude (#6187)Albert Krewinkel1-2/+0
* 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 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-0/+1
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-2/+3
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-03-01Remove license boilerplate.John MacFarlane1-17/+0
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: get CommonState from Lua globalAlbert Krewinkel1-15/+15
This allows more control over the common state from within Lua scripts.
2019-02-09Lua filters: load module `pandoc` before calling `init.lua` (#5287)Albert Krewinkel1-6/+27
The file `init.lua` in pandoc's data directory is run as part of pandoc's Lua initialization process. Previously, the `pandoc` module was loaded in `init.lua`, and the structure for marshaling was set-up after. This allowed simple patching of element marshaling, but made using `init.lua` more difficult: - it encouraged mixing essential initialization with user-defined customization; - upstream changes to init.lua had to be merged manually; - accidentally breaking marshaling by removing required modules was possible; Instead, all required modules are now loaded before calling `init.lua`. The file can be used entirely for user customization. Patching marshaling functions, while discouraged, is still possible via the `debug` module.
2019-02-04Add missing copyright notices and remove license boilerplate (#5112)Albert Krewinkel1-2/+2
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 Krewinkel1-2/+1
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 Krewinkel1-3/+3
2018-10-26Text.Pandoc.Lua: move globals handling to separate moduleAlbert Krewinkel1-21/+18
2018-10-25Lua: allow access to pandoc state (#5015)Albert Krewinkel1-5/+10
* Lua: allow access to pandoc state Lua filters and custom writers now have read-only access to most fields of pandoc's internal state via the global variable `PANDOC_STATE`. * Lua: allow iterating through fields of PANDOC_STATE * Lua filters doc: describe CommonState * Lua filters doc: mention global variable PANDOC_STATE * Lua: add access to logs Log messages can currently only be printed, but not decomposed.
2018-10-12Lua filters: push ListAttributes via constructorAlbert Krewinkel1-0/+1
This ensures that ListAttributes, as present in OrderedList elements, have additional accessors (viz. *start*, *style*, and *delimiter*).
2018-09-24Use hslua v1.0.0Albert Krewinkel1-4/+9
2018-07-02Spellcheck commentsAlexander Krotov1-1/+1
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-02-24Lua: register script name in global variableAlbert Krewinkel1-1/+7
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-23Lua filters: store constructors in registryAlbert Krewinkel1-0/+25
Lua functions used to construct AST element values are stored in the Lua registry for quicker access. Getting a value from the registry is much faster than getting a global value (partly to idiosyncrasies of hslua); this change results in a considerable performance boost.
2018-01-07Lua: make pandoc-types version available as PANDOC_API_VERSIONAlbert Krewinkel1-0/+3
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-0/+4
The current pandoc version is made available to Lua programs in the global PANDOC_VERSION. It contains the version as a list of numbers.
2018-01-05Update copyright notices to include 2018Albert Krewinkel1-2/+2
2017-12-18Lua filters: perform minor code clean-upAlbert Krewinkel1-4/+4
Change: minor
2017-12-13Custom writer: use init file to setup Lua interpreterAlbert Krewinkel1-0/+79
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.