aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Lua
AgeCommit message (Collapse)AuthorFilesLines
2017-08-13Use hslua >= 0.7, update Lua codeAlbert Krewinkel5-395/+260
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 Krewinkel5-32/+28
2017-05-13Update dates in copyright noticesAlbert Krewinkel3-4/+4
This follows the suggestions given by the FSF for GPL licensed software. <https://www.gnu.org/prep/maintain/html_node/Copyright-Notices.html>
2017-04-30Lua module: simplify Attributes, rename to AttrAlbert Krewinkel1-1/+1
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.
2017-04-30Lua module: make Header argument order consistentAlbert Krewinkel1-1/+1
Attributes are always passed as the last element, making it possible to omit this argument. Argument order for `Header` was wrong and is fixed.
2017-04-26Lua module: provide simple `read` format parserAlbert Krewinkel2-67/+28
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-26Lua filter: allow natural access to meta elementsAlbert Krewinkel1-1/+1
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.
2017-04-15Lua filter: use Attributes constructor for AttrsAlbert Krewinkel1-14/+26
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.
2017-04-14Lua filter: Re-order code of stack value instancesAlbert Krewinkel1-106/+122
2017-04-14Lua filter: use lua strings for nullary constructorsAlbert Krewinkel1-80/+19
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.
2017-04-14Avoid repeating StackValue instances definitionsAlbert Krewinkel3-126/+164
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.
2017-04-14Extract lua helper functions into Lua.Util moduleAlbert Krewinkel2-103/+142
2017-04-14Use lua bools and strings for MetaBool, MetaStringAlbert Krewinkel1-2/+2
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.
2017-04-14Drop dependency on hslua-aesonAlbert Krewinkel1-1/+0
Pushing values to the lua stack via custom functions is faster and more flexible.
2017-04-14Push blocks via lua constructors and constantsAlbert Krewinkel1-37/+102
All element creation tasks are handled by lua functions defined in the pandoc module.
2017-04-14Push inlines via lua constructors and constantsAlbert Krewinkel1-41/+29
All element creation tasks are handled in the lua module.
2017-04-13Use lua constructors to push meta valuesAlbert Krewinkel1-30/+148
2017-04-11Lua filter: use custom StackValue Inline instanceAlbert Krewinkel1-24/+151
Inline elements are no longer pushed and pulled via aeson's Value.
2017-04-07Lua filter: improve doc filter performanceAlbert Krewinkel1-36/+47
Pandoc elements are pushed and pulled from the lua stack via custom instances.
2017-04-06Lua filter: Improve block filter performanceAlbert Krewinkel1-7/+44
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.
2017-04-06Lua filter: Improve inline filter performanceAlbert Krewinkel1-7/+73
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).
2017-04-02Lua module: add readers submoduleAlbert Krewinkel2-2/+147
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 Krewinkel2-2/+43
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.