Age | Commit message (Collapse) | Author | Files | Lines |
|
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.
|
|
|
|
Using the registry directly instead of a custom table is cleaner and
more efficient. The performance improvement is especially noticable when
filtering on frequent elements like Str.
|
|
|
|
Text.Pandoc.App: trap LuaException and issue a PandocFilterError.
|
|
|
|
The implicitly defined global filter (i.e. all element filtering
functions defined in the global lua environment) is used if no filter is
returned from a lua script. This allows to just write top-level
functions in order to define a lua filter. E.g
function Emph(elem) return pandoc.Strong(elem.content) end
|
|
|
|
The return-type parameter for lua filter functions is removed. It only
complicated the code without introducing any additional type safety.
|
|
We want to provide an interface familiar to users of other filtering
libraries.
|
|
Allow to use functions named `SingleQuoted`, `DoubleQuoted`,
`DisplayMath`, and `InlineMath` in filters.
|
|
|
|
Filtering functions take element components as arguments instead of the
whole block elements. This resembles the way elements are handled in
custom writers.
|
|
Pushing values to the lua stack via custom functions is faster and more
flexible.
|
|
|
|
Instead of taking the whole inline element, forcing users to destructure it
themselves, the components of the elements are passed to the filtering
functions.
|
|
Inline elements are no longer pushed and pulled via aeson's Value.
|
|
This is slightly cleaner while keeping performance approximately the
same.
|
|
Plain text readers are exposed to lua scripts via the `pandoc.reader`
submodule, which is further subdivided by format. Converting e.g. a
markdown string into a pandoc document is possible from within lua:
doc = pandoc.reader.markdown.read_doc("Hello, World!")
A `read_block` convenience function is provided for all formats,
although it will still parse the whole string but return only the first
block as the result.
Custom reader options are not supported yet, default options are used
for all parsing operations.
|
|
* Add `--lua-filter` option. This works like `--filter` but takes pathnames of special lua filters and uses the lua interpreter baked into pandoc, so that no external interpreter is needed. Note that lua filters are all applied after regular filters, regardless of their position on the command line.
* Add Text.Pandoc.Lua, exporting `runLuaFilter`. Add `pandoc.lua` to data files.
* Add private module Text.Pandoc.Lua.PandocModule to supply the default lua module.
* Add Tests.Lua to tests.
* Add data/pandoc.lua, the lua module pandoc imports when processing its lua filters.
* Document in MANUAL.txt.
|