pandoc-lua-marshal

GitHub CI Hackage Stackage Lts Stackage Nightly MIT license

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.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, and Pandoc now all have a method walk that 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 definition typeCell and the fuzzy peeker peekCellFuzzy.

  • Added a new module Text.Pandoc.Lua.Marshal.Filter that 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 the Blocks filter 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 the Inlines filter 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.