Age | Commit message (Collapse) | Author | Files | Lines |
|
|
|
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.
|
|
* 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.
|
|
* Update copyright year
* Copyright: add notes for Lua and Jira modules
|
|
|
|
The haddock module header contains essentially the
same information, so the boilerplate is redundant and
just one more thing to get out of sync.
|
|
|
|
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.
|
|
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.
|
|
|
|
The function `runLuaFilter` was only used in Text.Pandoc.Filter.Lua, use
apply from the that module instead.
|
|
|
|
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.
|
|
|
|
|
|
This seems to be necessary if we are to use our custom Prelude
with ghci.
Closes #4464.
|
|
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
|
|
|
|
The options which were used to read the document are made available to
Lua filters via the `PANDOC_READER_OPTIONS` global.
|
|
|
|
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)
|
|
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.
|
|
The Haskell module defining the Lua `pandoc` module is moved to
Text.Pandoc.Lua.Module.Pandoc.
Change: minor
|
|
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.
|
|
|
|
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.
|
|
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`.
|
|
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
|
|
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.
|
|
|
|
A table containing the error code, command, and command output is thrown
instead of just a string error message.
|
|
to insertResource (`fetch`).
|
|
|
|
This changes the type of runLuaFilter.
|
|
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.
|
|
Closes: #3918
|
|
|
|
Try function `Inline`/`Block` if no other filter function of the
respective type matches an element.
Closes: #3859
|
|
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.
|
|
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
|
|
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.
|
|
|
|
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.
|
|
Also, now we check before running walkM that the function
table actually does contain something relevant. E.g. if
your filter just defines Str, there's no need to run walkM
for blocks, meta, or the whole document. This should
help performance a bit (and it does, in my tests).
|
|
No more SingleQuoted, DoubleQuoted, InlineMath, DisplayMath.
This makes everything uniform and predictable, though it does
open up a difference btw lua filters and custom writers.
|
|
|
|
I tested this with the str.lua filter on MANUAL.txt, and
I could see no significant performance degradation.
Doing things this way will ease maintenance, as we won't
have to manually modify this module when types change.
@tarleb, do we really need special cases for things like
DoubleQuoted and InlineMath?
|
|
Replace lua errors with `LuaException`s.
|
|
This was suggested by jgm and is consistent with the behavior of other
filtering libraries.
|
|
The code still allowed to pass an arbitrary number of arguments to the
filter function, as element properties were passed as function arguments
at some point. Now we only pass the element as the single arg, so the
code to handle multiple arguments is no longer necessary.
|