summaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Lua
Commit message (Collapse)AuthorAge
* Use hslua v0.9.0Albert Krewinkel2017-10-05
|
* pandoc.lua: use wrapper funciton for pipe commandAlbert Krewinkel2017-10-03
| | | | | | | | | | | | 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.
* Lua.PandocModule: promote addFunction to top levelAlbert Krewinkel2017-10-03
| | | | This reduces some boilerplate.
* Lua: added 'pipe', which encapsulates Text.Pandoc.Process.pipeProcess.John MacFarlane2017-10-01
| | | | This is hard to do in lua, so it's helpful to provide this.
* Lua: move sha1 from pandoc.mediabag to pandoc.John MacFarlane2017-10-01
|
* Lua: use sha1 instead of hashname.John MacFarlane2017-09-30
| | | | Better to leave control over the extension to the user.
* Lua: make fetch return mime type first and then content.John MacFarlane2017-09-30
|
* Lua: simply mediabag module.John MacFarlane2017-09-30
| | | | | | 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.
* Lua: make lua.mediabag.fetch return filename and mime type.John MacFarlane2017-09-30
| | | | | This is necessary because you may need to insert the filename into an image or link element.
* Lua filters: make sure whole CommonState is passed through...John MacFarlane2017-09-30
| | | | to insertResource (`fetch`).
* Removed writerSourceURL, add source URL to common state.John MacFarlane2017-09-30
| | | | | | | | | | | | | | | | | | 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`.
* Text.Pandoc.Lua: add mediabag submoduleAlbert Krewinkel2017-09-30
|
* Allow lua filters to return lists of elementsAlbert Krewinkel2017-09-24
| | | | Closes: #3918
* Update to hslua-0.8.0Albert Krewinkel2017-08-16
| | | | | | hslua no longer provides lua stack instances for Int and Double, the necessary instances are added to the Custom writer and the lua filtering system.
* Delete Text.Pandoc.Lua.SharedInstancesAlbert Krewinkel2017-08-13
| | | | | | | | | 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
* Text.Pandoc.Lua: Optimize performance by using raw table accessAlbert Krewinkel2017-08-13
| | | | | | Raw table accessing functions never call back into haskell, which allows the compiler to use more aggressive optimizations. This improves lua filter performance considerably (⪆5% speedup).
* Use hslua >= 0.7, update Lua codeAlbert Krewinkel2017-08-13
|
* Added support for translations (localization) (see #3559).John MacFarlane2017-08-11
| | | | | | | | | | | | | | | | | | | | | | | | | | * 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`.
* Added parameter for user data directory to runLuaFilter.John MacFarlane2017-06-29
| | | | | | | | | | 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.
* Readers.getReader, Writers.getWriter API change.John MacFarlane2017-06-24
| | | | | | | | | | | | | 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.
* Changed all readers to take Text instead of String.John MacFarlane2017-06-10
| | | | | | | | Readers: Renamed StringReader -> TextReader. Updated tests. API change.
* Improve code style in lua and org modulesAlbert Krewinkel2017-06-03
|
* Update dates in copyright noticesAlbert Krewinkel2017-05-13
| | | | | This follows the suggestions given by the FSF for GPL licensed software. <https://www.gnu.org/prep/maintain/html_node/Copyright-Notices.html>
* Lua module: simplify Attributes, rename to AttrAlbert Krewinkel2017-04-30
| | | | | | | Attributes was written to behave much like a normal table, in order to simplify working with it. However, all Attr containing elements were changed to provide panflute-like accessors to Attr components, rendering the previous approach unnecessary.
* Lua module: make Header argument order consistentAlbert Krewinkel2017-04-30
| | | | | Attributes are always passed as the last element, making it possible to omit this argument. Argument order for `Header` was wrong and is fixed.
* Lua module: provide simple `read` format parserAlbert Krewinkel2017-04-26
| | | | | | 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.
* Lua filter: allow natural access to meta elementsAlbert Krewinkel2017-04-26
| | | | | | | | Meta elements that are treated as lua tables (i.e. MetaList, MetaInlines, MetaBlocks, and MetaMap), are no longer wrapped in an additional table but simply marked via a metatable. This allows treating those meta values just like normal tables, while still making empty elements of those values distinguishable.
* Lua filter: use Attributes constructor for AttrsAlbert Krewinkel2017-04-15
| | | | | | Element attributes are pushed to the stack via the `Attributes` function. `Attributes` creates an Attr like triple, but the triple also allows table-like access to key-value pairs.
* Lua filter: Re-order code of stack value instancesAlbert Krewinkel2017-04-14
|
* Lua filter: use lua strings for nullary constructorsAlbert Krewinkel2017-04-14
| | | | | | | Lua string are used to represent nullary data constructors. The previous table-based representation was based on the JSON serialization, but can be simplified. This also matches the way those arguments are passed to custom writers.
* Avoid repeating StackValue instances definitionsAlbert Krewinkel2017-04-14
| | | | | | The lua filters and custom lua writer system defined very similar StackValue instances for strings and tuples. These instance definitions are extracted to a separate module to enable sharing.
* Extract lua helper functions into Lua.Util moduleAlbert Krewinkel2017-04-14
|
* Use lua bools and strings for MetaBool, MetaStringAlbert Krewinkel2017-04-14
| | | | | | | | Native lua booleans and strings are used to represent MetaBool and MetaString values. This is more natural than the previous table-based representation. The old lua representation can still be read back to haskell, ensuring compatibility with the `pandoc.MetaBool` and `pandoc.MetaString` lua constructors.
* Drop dependency on hslua-aesonAlbert Krewinkel2017-04-14
| | | | | Pushing values to the lua stack via custom functions is faster and more flexible.
* Push blocks via lua constructors and constantsAlbert Krewinkel2017-04-14
| | | | | All element creation tasks are handled by lua functions defined in the pandoc module.
* Push inlines via lua constructors and constantsAlbert Krewinkel2017-04-14
| | | | All element creation tasks are handled in the lua module.
* Use lua constructors to push meta valuesAlbert Krewinkel2017-04-13
|
* Lua filter: use custom StackValue Inline instanceAlbert Krewinkel2017-04-11
| | | | Inline elements are no longer pushed and pulled via aeson's Value.
* Lua filter: improve doc filter performanceAlbert Krewinkel2017-04-07
| | | | | Pandoc elements are pushed and pulled from the lua stack via custom instances.
* Lua filter: Improve block filter performanceAlbert Krewinkel2017-04-06
| | | | | | Reading of simple block values from the lua stack is handled manually, but most block constructors are still handled via instances of aeson's Value type.
* Lua filter: Improve inline filter performanceAlbert Krewinkel2017-04-06
| | | | | | | Getting inline instances from the lua stack is handled manually for some simple inline constructors, including the `Str` constructor. This avoids the indirect route through aeson's Value type and improves performance considerably (approx. 30% speedup for some filters).
* Lua module: add readers submoduleAlbert Krewinkel2017-04-02
| | | | | | | | | | | | | | | 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.
* Ensure compatibility with hslua 0.5.*Albert Krewinkel2017-03-24
| | | | | | 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.
* Lua filters (#3514)Albert Krewinkel2017-03-20
* 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.