pandoc-lua-marshal
Use pandoc types in Lua
https://github.com/pandoc/pandoc-lua-marshal
| LTS Haskell 24.67: | 0.3.3 |
| Stackage Nightly 2026-11-15: | 0.3.3 |
| Latest on Hackage: | 0.3.3 |
pandoc-lua-marshal-0.3.3@sha256:6fd91360ebf40725fe6a829cf23fe70327cbae2fff8520c7fe24c9f25f8d870e,5475Module documentation for 0.3.3
- Text
- Text.Pandoc
- Text.Pandoc.Lua
- Text.Pandoc.Lua.Marshal
- Text.Pandoc.Lua.Marshal.AST
- Text.Pandoc.Lua.Marshal.Alignment
- Text.Pandoc.Lua.Marshal.Attr
- Text.Pandoc.Lua.Marshal.Block
- Text.Pandoc.Lua.Marshal.Caption
- Text.Pandoc.Lua.Marshal.Cell
- Text.Pandoc.Lua.Marshal.Citation
- Text.Pandoc.Lua.Marshal.CitationMode
- Text.Pandoc.Lua.Marshal.Content
- Text.Pandoc.Lua.Marshal.Filter
- Text.Pandoc.Lua.Marshal.Format
- Text.Pandoc.Lua.Marshal.Inline
- Text.Pandoc.Lua.Marshal.List
- Text.Pandoc.Lua.Marshal.ListAttributes
- Text.Pandoc.Lua.Marshal.MathType
- Text.Pandoc.Lua.Marshal.MetaValue
- Text.Pandoc.Lua.Marshal.Pandoc
- Text.Pandoc.Lua.Marshal.QuoteType
- Text.Pandoc.Lua.Marshal.Row
- Text.Pandoc.Lua.Marshal.SimpleTable
- Text.Pandoc.Lua.Marshal.TableBody
- Text.Pandoc.Lua.Marshal.TableFoot
- Text.Pandoc.Lua.Marshal.TableHead
- Text.Pandoc.Lua.Marshal.TableParts
- Text.Pandoc.Lua.Marshal
- Text.Pandoc.Lua
- Text.Pandoc
pandoc-lua-marshal
Use pandoc types in Lua.
Description
This package provides functions to marshal and unmarshal pandoc document types to and from Lua.
The values of most types are pushed to pandoc as “userdata” objects that wrap a stable pointer to the Haskell value; these objects come with methods to access and modify their properties.
Sequences are pushed as normal Lua tables, but are augmented with convenience functions.
Changes
Changelog
pandoc-lua-marshal uses PVP Versioning.
0.3.3
Released 2026-11-11.
-
Allow singleton TableBody as list of table bodies.
It’s now possible to pass a bare TableBody value whenever a list of TableBody elements is expected. This should simplify the construction of table values.
-
Allow rows to be given as simple lists of cells instead of always having to use the
Rowconstructor function. -
Fixed the failure method in
peekAttr: peeking failures are now kept within the Peek monad. Previously, this function would raise Lua exceptions in certain cases. The change un-breaks the use of this function within the Peek monad and will result in better error messages in some cases. -
Raise upper bound for aeson, QuickCheck
0.3.2.1
Released 2026-01-09.
- Added missing entry
test/test-table.luato extra-source-files in cabal file.
0.3.2
Released 2026-01-08.
-
Added a docstring to the
Pandoc.normalizemethod. -
Added
TableBodyconstructor. (Sean Soon) -
Fixed comments in files
TableFoot.hsandTableHead.hs(Sean Soon). -
Allow hslua-2.5 and containers-0.8.*.
0.3.1
Released 2025-06-23.
-
Fix docs of the
Citeconstructor function -
Relax upper bounds for hslua and QuickCheck.
-
Dropped support for GHC 8.6.
0.3.0
Released 2024-12-07.
-
Add method
normalizeto Pandoc objects. This returns a normalized document by merging adjacent spaces in inlines and by modifying tables. -
Push Captions as userdata, move code to separate module.
-
Add tests for RawInline and its properties
-
Allow treatment of custom elements as singleton lists.
-
Remove
pandocprefix on table components (jgm/pandoc#8574).
0.2.9
Released 2024-10-01.
-
Update list module, thereby introducing a new method
iter; the function returns an iterator that steps through list values on each call. -
Added support for
__toinlineand__toblockmetamethods. If the metamethods are available on a Lua object and return an appropriate value, then that returned value will be used during unmarshalling.
0.2.8
Released 2024-09-21.
- Update list module, thereby introducing a new method
atand an extended constructor for List types.
0.2.7.1
Released 2024-07-02.
-
Relaxed the upper bound of tasty-quickcheck, used in tests. Now allows version 0.11.
-
Update documentation on constructors; the descriptions now match those in the pandoc docs.
0.2.7
Released 2024-05-06.
-
Let the behavior of
contentattributes on BulletList and OrderedList elements match that of the constructor by treating a list of Block elements as a list of single-block items. The following assertion now holds true:local content = {pandoc.Plain "one", pandoc.Plain "two"} local bl = pandoc.BulletList{} bl.content = content assert(bl == pandoc.BulletList(content))
0.2.6
Released 2024-03-29.
- Fixed a bug that caused problems with empty Block lists in
the
contentattributes of Div, Figure, and BlockQuote elements.
0.2.5
Released 2024-03-04.
- The
clonemethod on Blocks and Inlines elements now creates deep copies of the lists.
0.2.4
Released 2024-01-19.
- Relaxed upper bound for aeson, allowing aeson-2.2.*.
0.2.3
Released 2024-01-19.
- Relaxed upper bound for text, containers, and bytestring, allowing text-2.1, containers-0.7, and bytestring-0.12.
0.2.2
Released 2023-03-15.
- Add
__tostringmetamethods to Blocks and Inlines.
0.2.1.1
Released 2023-03-13.
- The version constraints for hslua packages have been relaxed; other changes in hslua 2.3.* do not affect this package.
0.2.1
Released 2023-02-11.
- All userdata types have been given a
__tojsonmetamethod. The methods return the default JSON representations of AST objects.
0.2.0
Released 2023-01-18.
-
Depend on pandoc-types 1.23: the
NullBlock constructor has been removed, and aFigureconstructor has been added. -
Support for Lua 5.3 has been dropped; the package now requires hslua 2.2 or later.
-
The implementation for
Listhas been moved to the separatehslua-listmodule. This module no longer contains C code.
0.1.7
Released 2022-07-16.
-
Allow Blocks to be passed as Caption value. The resulting caption has the Blocks as its long version and no short version.
-
Add
clonemethod to Pandoc elements.
0.1.6.1
Released 2022-06-10.
-
Provide better error messages when fuzzy retrieval of Inlines or Blocks fails.
-
Relax upper bound for text, allow text-2.0.
0.1.6
Released 2022-06-03.
-
Fix
applyFully: the function always traversed the document type-wise, never topdown. -
Avoid shadowing of a function name that was added in hslua-2.2.
-
Support concatenating of Pandoc values with the
..operator.
0.1.5.1
Released 2022-02-19.
- Relax upper bound for lua and hslua.
0.1.5
Released 2022-02-17.
-
Allow any type of callable object as argument to List functions
filter,map, andfind_if. These previously required the argument to be of typefunction, which was too restrictive. -
Inline: the type of Image captions is now
Inlinesinstead ofList.
0.1.4
Released 2022-01-29.
-
Export AttributeList type and marshaling functions from
Text.Pandoc.Marshal.Attr, namelytypeAttributeList,peekAttributeList, andpushAttributeList. -
Update to hslua 2.1, making use of the new utility functions.
0.1.3.1
Released 2022-01-14.
- Fixed a bug in
List.includethat was causing the Lua stack to overflow when the function was applied to long lists.
0.1.3
Released 2021-12-23.
Lua changes
-
The traversal order of filters can now be selected by setting the key
traverseto either'topdown'or'typewise'; the default remains'typewise'.Topdown traversals can be cut short by returning
falseas a second value from the filter function. No child-element of the returned element is processed in that case. -
All types can be compared. Previously, comparing values of different types would lead to errors in a number of cases.
-
Lists now have an
__eqmetamethod. List equality is checked by comparing both lists element-wise. Two lists are equal if they have the same type and have equal elements. -
If start indices in
List:findandList:find_ifare negative the start index is relative to the list length. -
TableFoot, TableHead, and Row values are marshaled as userdata objects.
Haskell code
-
Text.Pandoc.Lua.Marshal.Filter exports the new type
WalkingOrder. The typeFilternow contains the the traversal specifier as a field. -
New modules for TableFoot, TableHead, and Row, defining the usual marshaling methods and constructor functions for these types.
0.1.2
Released 2021-12-10.
- Restored backward compatible retrieval of Rows. Cells can be either a userdata value or a table.
0.1.1
Released 2021-12-10.
Behavior of Lua objects
-
Lists of Inline values and lists of Block values are now pushed with their own metatables (named “Inlines” and “Blocks”).
-
The types
Block,Blocks,Inline,Inlines, andPandocnow all have a methodwalkthat applies a filter to the document subtree. -
Changed behavior for Cell values: these are now pushed as userdata; the old table-based structure is still accepted when retrieving a Cell from the stack.
Haskell code
-
Module Text.Pandoc.Lua.Marshal.Cell exports the constructor function
mkCell, the type definitiontypeCelland the fuzzy peekerpeekCellFuzzy. -
Added a new module
Text.Pandoc.Lua.Marshal.Filterthat handles Lua filters. -
Added functions for filtering:
-
Module Text.Pandoc.Lua.Marshal.Block:
walkBlockSplicing: walk an AST element, applying a filter on each Block and splicing the result back into the list.walkBlocks: walk an AST element, modifying lists of Block elements by applying theBlocksfilter function.
-
Module Text.Pandoc.Lua.Marshal.Inline:
walkInlineSplicing: walk an AST element, applying a filter on each Inline and splicing the result back into the list.walkInlines: walk an AST element, modifying lists of Inline elements by applying theInlinesfilter function.
-
Module Text.Pandoc.Lua.Marshal.Pandoc:
applyFully: fully apply a filter on a Pandoc document.
-
-
New internal modules:
-
Text.Pandoc.Lua.SpliceList: defines a helper type used to walk a list of elements in a way that replaces the element by splicing the function result back into the list.
The module is a slight rewrite of pandoc’s
SingletonsList. -
Text.Pandoc.Lua.Walk: handles walking of the document tree while modifying elements via filter functions. This is a re-implementation of large parts of pandoc’s T.P.Lua.Filter module.
-
Text.Pandoc.Lua.Marshal.Shared: provides helper functions used in multiple Lua type definitions.
-
0.1.0.1
Released 2021-11-28.
- Added test-simpletable.lua to the list of extra-source-files.
0.1.0
Released 2021-11-28.
- Released into the wild. May it live long and prosper.