aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Lua/Module/Pandoc.hs
AgeCommit message (Collapse)Author
2022-09-30[API Change] Extract Lua code into new package pandoc-lua-engineAlbert Krewinkel
The flag 'lua53` must now be used with that package if pandoc is to be compiled against Lua 5.3.
2022-07-12Lua: add fields `pandoc.readers` and `pandoc.writers`. (#8177)Albert Krewinkel
The set of supported input and output formats is made available to Lua users.
2022-03-30Lua: allow to pass Sources to pandoc.read (#8002)Albert Krewinkel
Sources, the data type passed to the `Reader` function in custom readers, are now accepted as input to `pandoc.read`.
2022-01-29Switch to hslua-2.1Albert Krewinkel
This allows for some code simplification and improves stability.
2022-01-04Lua: add `pandoc.template` moduleAlbert Krewinkel
The module provides a `compile` function to use strings as templates.
2022-01-04Lua: add `pandoc.WriterOptions` constructorAlbert Krewinkel
2022-01-04Lua: add function `pandoc.write`Albert Krewinkel
2022-01-02Copyright notices: update for 2022Albert Krewinkel
2021-12-31Lua: use global state when parsing documents in `pandoc.read`Albert Krewinkel
The function `pandoc.read` is updated to use the same state that was used while parsing the main input files. This ensures that log messages are preserved and that images embedded in the input are added to the mediabag.
2021-12-30Lua: allow binary (byte string) readers to be used with `pandoc.read`Albert Krewinkel
2021-12-19Lua: fixup, should have been part of previous commitAlbert Krewinkel
2021-12-10Switch to released pandoc-lua-marshal-0.1.2Albert Krewinkel
Cell values are now marshaled as userdata objects; a constructor function for table cells is provided as `pandoc.Cell`.
2021-12-09Lua: update to latest pandoc-lua-marshal (0.1.1)Albert Krewinkel
- `walk` methods are added to `Block` and `Inline` values; the methods are similar to `pandoc.utils.walk_block` and `pandoc.utils.walk_inline`, but apply to filter also to the element itself, and therefore return a list of element instead of a single element. - Functions of name `Doc` are no longer accepted as alternatives for `Pandoc` filter functions. This functionality was undocumented.
2021-11-28Lua: add constructors `pandoc.Blocks` and `pandoc.Inlines`Albert Krewinkel
The functions convert their argument into a list of Block and Inline values, respectively.
2021-11-27Lua: use package pandoc-lua-marshal (#7719)Albert Krewinkel
The marshaling functions for pandoc's AST are extracted into a separate package. The package comes with a number of changes: - Pandoc's List module was rewritten in C, thereby improving error messages. - Lists of `Block` and `Inline` elements are marshaled using the new list types `Blocks` and `Inlines`, respectively. These types currently behave identical to the generic List type, but give better error messages. This also opens up the possibility of adding element-specific methods to these lists in the future. - Elements of type `MetaValue` are no longer pushed as values which have `.t` and `.tag` properties. This was already true for `MetaString` and `MetaBool` values, which are still marshaled as Lua strings and booleans, respectively. Affected values: + `MetaBlocks` values are marshaled as a `Blocks` list; + `MetaInlines` values are marshaled as a `Inlines` list; + `MetaList` values are marshaled as a generic pandoc `List`s. + `MetaMap` values are marshaled as plain tables and no longer given any metatable. - The test suite for marshaled objects and their constructors has been extended and improved. - A bug in Citation objects, where setting a citation's suffix modified it's prefix, has been fixed.
2021-11-09Lua: fix argument order in constructor `pandoc.Cite`.Albert Krewinkel
This restores the old behavior; argument order had been switched accidentally in pandoc 2.15.
2021-11-06Lua: allow to pass custom reader options to `pandoc.read`Albert Krewinkel
Reader options can now be passed as an optional third argument to `pandoc.read`. The object can either be a table or a ReaderOptions value like `PANDOC_READER_OPTIONS`. Creating new ReaderOptions objects is possible through the new constructor `pandoc.ReaderOptions`. Closes: #7656
2021-11-02Lua: fix typo in SoftBreak constructorAlbert Krewinkel
2021-11-02Lua: allow omitting the 2nd parameter in pandoc.Code constructorAlbert Krewinkel
Fixes a regression introduced in 2.15 which required users to always specify an Attr value when constructing a Code element.
2021-10-29Lua: use hslua module abstraction where possibleAlbert Krewinkel
This will make it easier to generate module documentation in the future.
2021-10-26Lua: marshal SimpleTable values as userdata objectsAlbert Krewinkel
2021-10-26Lua: generate constants in module pandoc programmaticallyAlbert Krewinkel
2021-10-26Lua: marshal ListAttributes values as userdata objectsAlbert Krewinkel
2021-10-26Lua: marshal Block values as userdata objectsAlbert Krewinkel
Properties of Block values are marshalled lazily, which generally improves performance considerably. Script users may also notice the following differences: - Block element properties can no longer be accessed by numerical indexing of the `.c` field. The `.c` property now serves as an alias for `.content`, so some filter that used this undocumented method for property access may continue to work, while others will need to be updated and use proper property names. - The marshalled Block elements now have a `show` method, and a `__tostring` metamethod. Both return the Haskell string representation of the element. - Block values now have the Lua type `userdata` instead of `table`.
2021-10-25Lua: marshal Citation values as userdata objectsAlbert Krewinkel
2021-10-23Lua: convert IOErrors to PandocErrors in pandoc.pipe functionAlbert Krewinkel
Fixes: #7523
2021-10-22Lua: marshal Inline elements as userdataAlbert Krewinkel
This includes the following user-facing changes: - Deprecated inline constructors are removed. These are `DoubleQuoted`, `SingleQuoted`, `DisplayMath`, and `InlineMath`. - Attr values are no longer normalized when assigned to an Inline element property. - It's no longer possible to access parts of Inline elements via numerical indexes. E.g., `pandoc.Span('test')[2]` used to give `pandoc.Str 'test'`, but yields `nil` now. This was undocumented behavior not intended to be used in user scripts. Use named properties instead. - Accessing `.c` to get a JSON-like tuple of all components no longer works. This was undocumented behavior. - Only known properties can be set on an element value. Trying to set a different property will now raise an error.
2021-10-22Lua: marshal Attr values as userdataAlbert Krewinkel
- Adds a new `pandoc.AttributeList()` constructor, which creates the associative attribute list that is used as the third component of `Attr` values. Values of this type can often be passed to constructors instead of `Attr` values. - `AttributeList` values can no longer be indexed numerically.
2021-10-22Lua: marshal Pandoc values as userdataAlbert Krewinkel
2021-10-22Switch to hslua-2.0Albert Krewinkel
The new HsLua version takes a somewhat different approach to marshalling and unmarshalling, relying less on typeclasses and more on specialized types. This allows for better performance and improved error messages. Furthermore, new abstractions allow to document the code and exposed functions.
2021-04-08Lua filter: respect Inlines/Blocks filter functions in pandoc.walk_*Albert Krewinkel
2021-02-04Lua filters: use same function names in Haskell and LuaAlbert Krewinkel
2021-01-26Lua: always load built-in Lua scripts from default data-dirAlbert Krewinkel
The Lua modules `pandoc` and `pandoc.List` are now always loaded from the system's default data directory. Loading from a different directory by overriding the default path, e.g. via `--data-dir`, is no longer supported to avoid unexpected behavior and to address security concerns.
2021-01-08Update copyright notices for 2021 (#7012)Albert Krewinkel
2020-04-17API change: use new type PandocLua for all pandoc Lua operationsAlbert Krewinkel
The new type `PandocLua` is an instance of the `PandocMonad` typeclass and can thus be used in a way similar to `PandocIO`.
2020-03-22Finer grained imports of Text.Pandoc.Class submodules (#6203)Albert Krewinkel
This should speed-up recompilation after changes in `Text.Pandoc.Class`, as the number of modules affected by a change will be smaller in general. It also offers faster insights into the parts of `T.P.Class` used within a module.
2020-03-15Use implicit Prelude (#6187)Albert Krewinkel
* 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.
2020-03-13Update copyright year (#6186)Albert Krewinkel
* Update copyright year * Copyright: add notes for Lua and Jira modules
2020-02-07Resolve HLint warningsAlbert Krewinkel
All warnings are either fixed or, if more appropriate, HLint is configured to ignore them. HLint suggestions remain. * Ignore "Use camelCase" warnings in Lua and legacy code * Fix or ignore remaining HLint warnings * Remove redundant brackets * Remove redundant `return`s * Remove redundant as-pattern * Fuse mapM_/map * Use `.` to shorten code * Remove redundant `fmap` * Remove unused LANGUAGE pragmas * Hoist `not` in Text.Pandoc.App * Use fewer imports for `Text.DocTemplates` * Remove redundant `do`s * Remove redundant `$`s * Jira reader: remove unnecessary parentheses
2019-11-12Switch to new pandoc-types and use Text instead of String [API change].despresc
PR #5884. + Use pandoc-types 1.20 and texmath 0.12. + Text is now used instead of String, with a few exceptions. + In the MediaBag module, some of the types using Strings were switched to use FilePath instead (not Text). + In the Parsing module, new parsers `manyChar`, `many1Char`, `manyTillChar`, `many1TillChar`, `many1Till`, `manyUntil`, `mantyUntilChar` have been added: these are like their unsuffixed counterparts but pack some or all of their output. + `glob` in Text.Pandoc.Class still takes String since it seems to be intended as an interface to Glob, which uses strings. It seems to be used only once in the package, in the EPUB writer, so that is not hard to change.
2019-09-29Raise error on unsupported extensions. Closes #4338.John MacFarlane
+ An error is now raised if you try to specify (enable or disable) an extension that does not affect the given format, e.g. `docx+pipe_tables`. + The `--list-extensions[=FORMAT]` option now lists only extensions that affect the given FORMAT. + Text.Pandoc.Error: Add constructors `PandocUnknownReaderError`, `PandocUnknownWriterError`, `PandocUnsupportedExtensionError`. [API change] + Text.Pandoc.Extensions now exports `getAllExtensions`, which returns the extensions that affect a given format (whether enabled by default or not). [API change] + Text.Pandoc.Extensions: change type of `parseFormatSpec` from `Either ParseError (String, Extensions -> Extensions)` to `Either ParseError (String, [Extension], [Extension])` [API change]. + Text.Pandoc.Readers: change type of `getReader` so it returns a value in the PandocMonad instance rather than an Either [API change]. Exceptions for unknown formats and unsupported extensions are now raised by this function and need not be handled by the calling function. + Text.Pandoc.Writers: change type of `getWriter` so it returns a value in the PandocMonad instance rather than an Either [API change]. Exceptions for unknown formats and unsupported extensions are now raised by this function and need not be handled by the calling function.
2019-08-16Lua: traverse nested blocks and inlines in correct orderAlbert Krewinkel
Traversal methods are updated to use the new Walk module such that sequences with nested Inline (or Block) elements are traversed in the order in which they appear in the linearized document. Fixes: #5667
2019-07-02Fix redundant constraint warnings. (#5625)Pete Ryland
2019-03-01Remove license boilerplate.John MacFarlane
The haddock module header contains essentially the same information, so the boilerplate is redundant and just one more thing to get out of sync.
2019-02-16T.P.Lua: split StackInstances into smaller Marshaling modulesAlbert Krewinkel
2019-02-04Add missing copyright notices and remove license boilerplate (#5112)Albert Krewinkel
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.
2018-09-24Use hslua v1.0.0Albert Krewinkel
2018-08-12Lua: cleanup Lua utils, remove unused functions.Albert Krewinkel
2018-03-18Use NoImplicitPrelude and explicitly import Prelude.John MacFarlane
This seems to be necessary if we are to use our custom Prelude with ghci. Closes #4464.
2018-01-23Lua filters: store constructors in registryAlbert Krewinkel
Lua functions used to construct AST element values are stored in the Lua registry for quicker access. Getting a value from the registry is much faster than getting a global value (partly to idiosyncrasies of hslua); this change results in a considerable performance boost.