aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Lua/PandocModule.hs
AgeCommit message (Collapse)AuthorFilesLines
2017-11-11Add lua filter functions to walk inline and block elements.John MacFarlane1-1/+21
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 MacFarlane1-9/+9
2017-10-05Use hslua v0.9.0Albert Krewinkel1-12/+1
2017-10-03pandoc.lua: use wrapper funciton for pipe commandAlbert Krewinkel1-1/+1
The pipe command is wrapped in a lua function, throwing a lua error if the command returns with an error. A wrapper is needed as Haskell functions exposed to lua may not throw lua errors due to limitations of hslua. The error handling is written such that a table can be returned as an error object in the future. This is potentially useful when finer control is required while catching the error in lua code. Current limitations of hslua require error objects to be strings.
2017-10-03Lua.PandocModule: promote addFunction to top levelAlbert Krewinkel1-14/+10
This reduces some boilerplate.
2017-10-01Lua: added 'pipe', which encapsulates Text.Pandoc.Process.pipeProcess.John MacFarlane1-0/+17
This is hard to do in lua, so it's helpful to provide this.
2017-10-01Lua: move sha1 from pandoc.mediabag to pandoc.John MacFarlane1-1/+3
2017-09-30Lua: use sha1 instead of hashname.John MacFarlane1-13/+5
Better to leave control over the extension to the user.
2017-09-30Lua: make fetch return mime type first and then content.John MacFarlane1-1/+1
2017-09-30Lua: simply mediabag module.John MacFarlane1-15/+31
Now 'fetch' simply fetches content and mime type. A new 'hashname' function is provided to get a filename based on the sha1 hash of the contents and the mime type.
2017-09-30Lua: make lua.mediabag.fetch return filename and mime type.John MacFarlane1-0/+4
This is necessary because you may need to insert the filename into an image or link element.
2017-09-30Lua filters: make sure whole CommonState is passed through...John MacFarlane1-9/+14
to insertResource (`fetch`).
2017-09-30Removed writerSourceURL, add source URL to common state.John MacFarlane1-4/+2
Removed `writerSourceURL` from `WriterOptions` (API change). Added `stSourceURL` to `CommonState`. It is set automatically by `setInputFiles`. Text.Pandoc.Class now exports `setInputFiles`, `setOutputFile`. The type of `getInputFiles` has changed; it now returns `[FilePath]` instead of `Maybe [FilePath]`. Functions in Class that formerly took the source URL as a parameter now have one fewer parameter (`fetchItem`, `downloadOrRead`, `setMediaResource`, `fillMediaBag`). Removed `WriterOptions` parameter from `makeSelfContained` in `SelfContained`.
2017-09-30Text.Pandoc.Lua: add mediabag submoduleAlbert Krewinkel1-14/+111
2017-08-13Delete Text.Pandoc.Lua.SharedInstancesAlbert Krewinkel1-11/+11
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-13Use hslua >= 0.7, update Lua codeAlbert Krewinkel1-12/+12
2017-08-11Added support for translations (localization) (see #3559).John MacFarlane1-3/+3
* readDataFile, readDefaultDataFile, getReferenceDocx, getReferenceODT have been removed from Shared and moved into Class. They are now defined in terms of PandocMonad primitives, rather than being primitve methods of the class. * toLang has been moved from BCP47 to Class. * NoTranslation and CouldNotLoudTranslations have been added to LogMessage. * New module, Text.Pandoc.Translations, exporting Term, Translations, readTranslations. * New functions in Class: translateTerm, setTranslations. Note that nothing is loaded from data files until translateTerm is used; setTranslation just sets the language to be used. * Added two translation data files in data/translations. * LaTeX reader: Support `\setmainlanguage` or `\setdefaultlanguage` (polyglossia) and `\figurename`.
2017-06-29Added parameter for user data directory to runLuaFilter.John MacFarlane1-5/+5
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-06-24Readers.getReader, Writers.getWriter API change.John MacFarlane1-2/+3
Now these functions return a pair of a reader/writer and an Extensions, instead of building the extensions into the reader/writer. The calling code must explicitly set readerExtensions or writerExtensions using the Extensions returned. The point of the change is to make it possible for the calling code to determine what extensions are being used. See #3659.
2017-06-10Changed all readers to take Text instead of String.John MacFarlane1-2/+3
Readers: Renamed StringReader -> TextReader. Updated tests. API change.
2017-06-03Improve code style in lua and org modulesAlbert Krewinkel1-14/+12
2017-04-26Lua module: provide simple `read` format parserAlbert Krewinkel1-67/+18
A single `read` function parsing pandoc-supported formats is added to the module. This is simpler and more convenient than the previous method of exposing all reader functions individually.
2017-04-02Lua module: add readers submoduleAlbert Krewinkel1-2/+72
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.
2017-03-24Ensure compatibility with hslua 0.5.*Albert Krewinkel1-2/+3
The 0.5.0 release of hslua fixes problems with lua C modules on linux. The signature of the `loadstring` function changed, so a compatibility wrapper is introduced to allow both 0.4.* and 0.5.* versions to be used.
2017-03-20Lua filters (#3514)Albert Krewinkel1-0/+47
* 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.