packages feed

pandoc-lua-marshal 0.2.7 → 0.2.7.1

raw patch · 13 files changed

+174/−49 lines, 13 filesdep ~tasty-quickcheckPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: tasty-quickcheck

API changes (from Hackage documentation)

Files

CHANGELOG.md view
@@ -2,6 +2,16 @@  `pandoc-lua-marshal` uses [PVP Versioning][]. +## 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.
pandoc-lua-marshal.cabal view
@@ -1,6 +1,6 @@ cabal-version:       2.4 name:                pandoc-lua-marshal-version:             0.2.7+version:             0.2.7.1 synopsis:            Use pandoc types in Lua description:         This package provides functions to marshal and unmarshal                      pandoc document types to and from Lua.@@ -113,7 +113,7 @@                      , tasty                >= 0.11                      , tasty-hunit          >= 0.9                      , tasty-lua            >= 1.0-                     , tasty-quickcheck     >= 0.8     && < 0.11+                     , tasty-quickcheck     >= 0.8     && < 0.12   ghc-options:         -threaded                        -rtsopts                        -with-rtsopts=-N
src/Text/Pandoc/Lua/Marshal/Attr.hs view
@@ -229,7 +229,8 @@ -- | Constructor for 'Attr'. mkAttr :: LuaError e => DocumentedFunction e mkAttr = defun "Attr"-  ### (ltype (nthBottom 1) >>= \case+  ### (\_ _ _ ->+        ltype (nthBottom 1) >>= \case           TypeString -> forcePeek $ do             mident <- optional (peekText (nthBottom 1))             mclass <- optional (peekList peekText (nthBottom 2))@@ -244,7 +245,12 @@           TypeNil    -> pure nullAttr           TypeNone   -> pure nullAttr           x          -> failLua $ "Cannot create Attr from " ++ show x)+  <#> opt (parameter pure "string|table|Attr" "identifier" "element identifier")+  <#> opt (parameter pure "{string,...}" "classes" "element classes")+  <#> opt (parameter pure "table|AttributeList" "attributes"+           "table containing string keys and values")   =#> functionResult pushAttr "Attr" "new Attr object"+  #? "Create a new set of attributes"  -- | Constructor for 'AttributeList'. mkAttributeList :: LuaError e => DocumentedFunction e
src/Text/Pandoc/Lua/Marshal/Block.hs view
@@ -332,17 +332,20 @@     ### liftPure BlockQuote     <#> blocksParam     =#> blockResult "BlockQuote element"+    #? "Creates a block quote element"    , defun "BulletList"     ### liftPure BulletList     <#> blockItemsParam "list items"     =#> blockResult "BulletList element"+    #? "Creates a bullet list."    , defun "CodeBlock"     ### liftPure2 (\code mattr -> CodeBlock (fromMaybe nullAttr mattr) code)-    <#> textParam "text" "code block content"+    <#> textParam "text" "code string"     <#> optAttrParam     =#> blockResult "CodeBlock element"+    #? "Creates a code block element."    , defun "DefinitionList"     ### liftPure DefinitionList@@ -353,22 +356,25 @@                   "{{Inlines, {Blocks,...}},...}"                   "content" "definition items"     =#> blockResult "DefinitionList element"+    #? "Creates a definition list, containing terms and their explanation."    , defun "Div"     ### liftPure2 (\content mattr -> Div (fromMaybe nullAttr mattr) content)     <#> blocksParam     <#> optAttrParam     =#> blockResult "Div element"+    #? "Creates a div element"    , defun "Figure"     ### liftPure3 (\content mcapt mattr ->                      let attr = fromMaybe nullAttr mattr                          capt = fromMaybe (Caption mempty mempty) mcapt                      in Figure attr capt content)-    <#> parameter peekBlocksFuzzy "Blocks" "content" "figure content"+    <#> parameter peekBlocksFuzzy "Blocks" "content" "figure block content"     <#> opt (parameter peekCaptionFuzzy "Caption" "caption" "figure caption")     <#> optAttrParam-    =#> blockResult "Figure element"+    =#> blockResult "Figure object"+    #? "Creates a [[Figure]] element."    , defun "Header"     ### liftPure3 (\lvl content mattr ->@@ -377,40 +383,47 @@     <#> parameter peekInlinesFuzzy "Inlines" "content" "inline content"     <#> optAttrParam     =#> blockResult "Header element"+    #? "Creates a header element."    , defun "HorizontalRule"     ### return HorizontalRule     =#> blockResult "HorizontalRule element"+    #? "Creates a horizontal rule."    , defun "LineBlock"     ### liftPure LineBlock     <#> parameter (peekList peekInlinesFuzzy) "{Inlines,...}" "content" "lines"     =#> blockResult "LineBlock element"+    #? "Creates a line block element."    , defun "OrderedList"     ### liftPure2 (\items mListAttrib ->                      let defListAttrib = (1, DefaultStyle, DefaultDelim)                      in OrderedList (fromMaybe defListAttrib mListAttrib) items)-    <#> blockItemsParam "ordered list items"+    <#> blockItemsParam "list items"     <#> opt (parameter peekListAttributes "ListAttributes" "listAttributes"-                       "specifier for the list's numbering")+                       "list parameters")     =#> blockResult "OrderedList element"+    #? "Creates an ordered list."    , defun "Para"     ### liftPure Para-    <#> parameter peekInlinesFuzzy "Inlines" "content" "paragraph content"+    <#> parameter peekInlinesFuzzy "Inlines" "content" "inline content"     =#> blockResult "Para element"+    #? "Creates a para element."    , defun "Plain"     ### liftPure Plain-    <#> parameter peekInlinesFuzzy "Inlines" "content" "paragraph content"+    <#> parameter peekInlinesFuzzy "Inlines" "content" "inline content"     =#> blockResult "Plain element"+    #? "Creates a plain element."    , defun "RawBlock"     ### liftPure2 RawBlock-    <#> parameter peekFormat "Format" "format" "format of content"+    <#> parameter peekFormat "string" "format" "format of content"     <#> textParam "text" "raw content"     =#> blockResult "RawBlock element"+    #? "Creates a raw content block of the specified format."    , defun "Table"     ### (\capt colspecs thead tbodies tfoot mattr ->@@ -426,23 +439,27 @@     <#> parameter peekTableFoot "TableFoot" "foot" "table foot"     <#> optAttrParam     =#> blockResult "Table element"+    #? "Creates a table element."   ]  where   blockResult = functionResult pushBlock "Block"   blocksParam = parameter peekBlocksFuzzy "Blocks" "content" "block content"-  blockItemsParam = parameter peekItemsFuzzy "List of Blocks" "content"+  blockItemsParam = parameter peekItemsFuzzy "{Blocks,...}" "items"   peekItemsFuzzy idx = peekList peekBlocksFuzzy idx     <|> ((:[]) <$!> peekBlocksFuzzy idx) -  optAttrParam = opt (parameter peekAttr "Attr" "attr" "additional attributes")+  optAttrParam = opt (parameter peekAttr "Attr" "attr" "element attributes")   -- | Constructor for a list of `Block` values. mkBlocks :: LuaError e => DocumentedFunction e mkBlocks = defun "Blocks"   ### liftPure id-  <#> parameter peekBlocksFuzzy "Blocks" "blocks" "block elements"+  <#> parameter peekBlocksFuzzy "Blocks" "block_like_elements"+      ("List where each element can be treated as a [[Block]] value, " <>+       "or a single such value.")   =#> functionResult pushBlocks "Blocks" "list of block elements"+  #? "Creates a [[Blocks]] list."  -- -- walk
src/Text/Pandoc/Lua/Marshal/Cell.hs view
@@ -111,9 +111,13 @@                   (maybe 1 RowSpan mRowSpan)                   (maybe 1 ColSpan mColSpan)                   blocks)-  <#> parameter peekBlocksFuzzy "Blocks" "blocks" "document contents"-  <#> opt (parameter peekAlignment "integer" "align" "cell alignment")-  <#> opt (parameter peekIntegral "integer" "row_span" "rows to span")-  <#> opt (parameter peekIntegral "integer" "col_span" "columns to span")+  <#> parameter peekBlocksFuzzy "Blocks" "blocks" "cell contents"+  <#> opt (parameter peekAlignment "Alignment" "align"+           "text alignment; defaults to `AlignDefault`")+  <#> opt (parameter peekIntegral "integer" "rowspan"+           "number of rows occupied by the cell; defaults to `1`")+  <#> opt (parameter peekIntegral "integer" "colspan"+           "number of columns occupied by the cell; defaults to `1`")   <#> opt (parameter peekAttr "Attr" "attr" "cell attributes")   =#> functionResult pushCell "Cell" "new Cell object"+  #? "Create a new table cell."
src/Text/Pandoc/Lua/Marshal/Citation.hs view
@@ -92,10 +92,10 @@            , citationNoteNum = fromMaybe 0 mnote_num            , citationHash = fromMaybe 0 mhash            })-  <#> textParam "cid" "citation ID (e.g. bibtex key)"+  <#> textParam "id" "citation ID (e.g. BibTeX key)"   <#> parameter peekCitationMode "CitationMode" "mode" "citation rendering mode"-  <#> opt (parameter peekInlinesFuzzy "prefix" "Inlines" "")-  <#> opt (parameter peekInlinesFuzzy "suffix" "Inlines" "")+  <#> opt (parameter peekInlinesFuzzy "Inlines" "prefix" "")+  <#> opt (parameter peekInlinesFuzzy "Inlines" "suffix" "")   <#> opt (integralParam "note_num" "note number")   <#> opt (integralParam "hash"     "hash number")   =#> functionResult pushCitation "Citation" "new citation object"
src/Text/Pandoc/Lua/Marshal/Inline.hs view
@@ -47,6 +47,7 @@ import Text.Pandoc.Lua.Marshal.QuoteType (peekQuoteType, pushQuoteType) import Text.Pandoc.Lua.Marshal.Shared (walkBlocksAndInlines) import Text.Pandoc.Lua.Walk (SpliceList, Walkable, walkSplicing, walkStraight)+import qualified Data.Text as T import qualified Text.Pandoc.Builder as B  -- | Pushes an Inline value as userdata object.@@ -313,28 +314,35 @@ inlineConstructors =   [ defun "Cite"     ### liftPure2 (flip Cite)-    <#> parameter peekInlinesFuzzy "content" "Inline" "placeholder content"-    <#> parameter (peekList peekCitation) "citations" "list of Citations" ""+    <#> parameter peekInlinesFuzzy "content" "Inlines" "placeholder content"+    <#> parameter (peekList peekCitation) "{Citation,...}" "citations"+        "List of Citations"     =#> functionResult pushInline "Inline" "cite element"+    #? "Creates a Cite inline element"   , defun "Code"     ### liftPure2 (\text mattr -> Code (fromMaybe nullAttr mattr) text)     <#> textParam "code" "code string"     <#> opt (parameter peekAttr "Attr" "attr" "additional attributes")     =#> functionResult pushInline "Inline" "code element"+    #? "Creates a Code inline element"   , mkInlinesConstr "Emph" Emph+    #? "Creates an inline element representing emphasized text."   , defun "Image"     ### liftPure4 (\caption src mtitle mattr ->                      let attr = fromMaybe nullAttr mattr                          title = fromMaybe mempty mtitle                      in Image attr caption (src, title))-    <#> parameter peekInlinesFuzzy "Inlines" "caption" "image caption / alt"-    <#> textParam "src" "path/URL of the image file"+    <#> parameter peekInlinesFuzzy "Inlines" "caption"+        "text used to describe the image"+    <#> textParam "src" "path to the image file"     <#> opt (textParam "title" "brief image description")     <#> opt (parameter peekAttr "Attr" "attr" "image attributes")-    =#> functionResult pushInline "Inline" "image element"+    =#> functionResult pushInline "Inline" "Image element"+    #? "Creates an Image element"   , defun "LineBreak"     ### return LineBreak     =#> functionResult pushInline "Inline" "line break"+    #? "Create a LineBreak inline element"   , defun "Link"     ### liftPure4 (\content target mtitle mattr ->                      let attr = fromMaybe nullAttr mattr@@ -345,59 +353,87 @@     <#> opt (textParam "title" "brief link description")     <#> opt (parameter peekAttr "Attr" "attr" "link attributes")     =#> functionResult pushInline "Inline" "link element"+    #? "Creates a link inline element, usually a hyperlink."   , defun "Math"     ### liftPure2 Math-    <#> parameter peekMathType "quotetype" "Math" "rendering method"+    <#> parameter peekMathType "MathType" "mathtype" "rendering specifier"     <#> textParam "text" "math content"     =#> functionResult pushInline "Inline" "math element"+    #? "Creates a Math element, either inline or displayed."   , defun "Note"     ### liftPure Note-    <#> parameter peekBlocksFuzzy "content" "Blocks" "note content"+    <#> parameter peekBlocksFuzzy "Blocks" "content" "footnote block content"     =#> functionResult pushInline "Inline" "note"+    #? "Creates a Note inline element"   , defun "Quoted"     ### liftPure2 Quoted-    <#> parameter peekQuoteType "quotetype" "QuoteType" "type of quotes"-    <#> parameter peekInlinesFuzzy "content" "Inlines" "inlines in quotes"+    <#> parameter peekQuoteType "QuoteType" "quotetype" "type of quotes"+    <#> parameter peekInlinesFuzzy "Inlines" "content" "inlines in quotes"     =#> functionResult pushInline "Inline" "quoted element"+    #? ("Creates a Quoted inline element given the quote type and " <>+        "quoted content.")   , defun "RawInline"     ### liftPure2 RawInline-    <#> parameter peekFormat "format" "Format" "format of content"+    <#> parameter peekFormat "string" "format" "format of content"     <#> textParam "text" "string content"     =#> functionResult pushInline "Inline" "raw inline element"+    #? "Creates a raw inline element"   , mkInlinesConstr "SmallCaps" SmallCaps+    #? "Creates text rendered in small caps"   , defun "SoftBreak"     ### return SoftBreak     =#> functionResult pushInline "Inline" "soft break"+    #? "Creates a SoftBreak inline element."   , defun "Space"     ### return Space     =#> functionResult pushInline "Inline" "new space"+    #? "Create a Space inline element"   , defun "Span"     ### liftPure2 (\inlns mattr -> Span (fromMaybe nullAttr mattr) inlns)-    <#> parameter peekInlinesFuzzy "content" "Inlines" "inline content"+    <#> parameter peekInlinesFuzzy "Inlines" "content" "inline content"     <#> opt (parameter peekAttr "Attr" "attr" "additional attributes")-    =#> functionResult pushInline "Inline" "span element"+    =#> functionResult pushInline "Inline" "[[Span]] object"+    #? "Creates a Span inline element"   , defun "Str"     ### liftPure Str     <#> textParam "text" ""-    =#> functionResult pushInline "Inline" "new Str object"-  , mkInlinesConstr "Strong" Strong+    =#> functionResult pushInline "Inline" "[[Str]] object"+    #? "Creates a Str inline element"   , mkInlinesConstr "Strikeout" Strikeout+    #? "Creates text which is struck out."+  , mkInlinesConstr "Strong" Strong+    #? ("Creates a Strong element, whose text is usually displayed in " <>+        "a bold font.")   , mkInlinesConstr "Subscript" Subscript+    #? "Creates a Subscript inline element"   , mkInlinesConstr "Superscript" Superscript+    #? "Creates a Superscript inline element"   , mkInlinesConstr "Underline" Underline+    #? "Creates an Underline inline element"   ]  where    mkInlinesConstr name constr = defun name      ### liftPure (\x -> x `seq` constr x)-     <#> parameter peekInlinesFuzzy "Inlines" "content" ""+     <#> parameter peekInlinesFuzzy "Inlines" "content" "inline content"      =#> functionResult pushInline "Inline" "new object"  -- | Constructor for a list of `Inline` values. mkInlines :: LuaError e => DocumentedFunction e mkInlines = defun "Inlines"   ### liftPure id-  <#> parameter peekInlinesFuzzy "Inlines" "inlines" "inline elements"+  <#> parameter peekInlinesFuzzy "Inlines" "inline_like_elements"+      ("List where each element can be treated as an [[Inline]] " <>+       "value, or just a single such value.")   =#> functionResult pushInlines "Inlines" "list of inline elements"+  #? T.unlines+  [ "Converts its argument into an [[Inlines]] list:"+  , ""+  , "-   copies a list of [[Inline]] elements into a fresh list; any"+  , "    string `s` within the list is treated as `pandoc.Str(s)`;"+  , "-   turns a single [[Inline]] into a singleton list;"+  , "-   splits a string into `Str`-wrapped words, treating"+  , "    interword spaces as `Space`s or `SoftBreak`s."+  ]  -- | Walks an element of type @a@ and applies the filter to all 'Inline' -- elements.  The filter result is spliced back into the list.
src/Text/Pandoc/Lua/Marshal/ListAttributes.hs view
@@ -75,10 +75,10 @@                    , fromMaybe DefaultStyle mstyle                    , fromMaybe DefaultDelim mdelim                    ))-  <#> opt (integralParam "start" "number of first item")-  <#> opt (parameter peekRead "string" "style" "list numbering style")-  <#> opt (parameter peekRead "string" "delimiter" "list number delimiter")-  =#> udresult typeListAttributes "new ListAttributes"+  <#> opt (integralParam "start" "number of the first list item")+  <#> opt (parameter peekRead "string" "style" "style used for list numbering")+  <#> opt (parameter peekRead "string" "delimiter" "delimiter of list numbers")+  =#> udresult typeListAttributes "new ListAttributes object"   #? "Creates a new ListAttributes object."  -- | Pushes a 'ListNumberDelim' value as string.
src/Text/Pandoc/Lua/Marshal/MetaValue.hs view
@@ -83,6 +83,11 @@     ### liftPure MetaBlocks     <#> parameter peekBlocksFuzzy "Blocks" "content" "block content"     =#> functionResult pushMetaValue "Blocks" "list of Block elements"+    #? T.unlines+    [ "Creates a value to be used as a MetaBlocks value in meta"+    , "data; creates a copy of the input list via `pandoc.Blocks`,"+    , "discarding all non-list keys."+    ]    , defun "MetaBool"     ### liftPure MetaBool@@ -93,21 +98,41 @@     ### liftPure MetaInlines     <#> parameter peekInlinesFuzzy "Inlines" "inlines" "inline elements"     =#> functionResult pushMetaValue "Inlines" "list of Inline elements"+    #? T.unlines+    [ "Creates a value to be used as a MetaInlines value in meta"+    , "data; creates a copy of the input list via `pandoc.Inlines`,"+    , "discarding all non-list keys."+    ]    , defun "MetaList"     ### liftPure MetaList     <#> parameter (peekList peekMetaValue) "MetaValue|{MetaValue,...}"           "values" "value, or list of values"     =#> functionResult pushMetaValue "List" "list of meta values"+    #? T.unlines+    [ "Creates a value to be used as a MetaList in meta data;"+    , "creates a copy of the input list via `pandoc.List`,"+    , "discarding all non-list keys."+    ]    , defun "MetaMap"     ### liftPure MetaMap-    <#> parameter (peekMap peekText peekMetaValue) "table" "map"-          "string-indexed table"+    <#> parameter (peekMap peekText peekMetaValue) "table" "key_value_map"+          "a string-indexed map of meta values"     =#> functionResult pushMetaValue "table" "map of meta values"+    #? T.unlines+    [ "Creates a value to be used as a MetaMap in meta data; creates"+    , "a copy of the input table, keeping only pairs with string"+    , "keys and discards all other keys."+    ]    , defun "MetaString"     ### liftPure MetaString     <#> textParam "s" "string value"     =#> functionResult pushMetaValue "string" "unchanged input"+    #? T.unlines+    [ "Creates a value to be used as a MetaString in meta data; this"+    , "is the identity function for boolean values and exists only"+    , "for completeness."+    ]   ]
src/Text/Pandoc/Lua/Marshal/Row.hs view
@@ -93,6 +93,8 @@   ### liftPure2 (\mCells mAttr -> Row                   (fromMaybe nullAttr mAttr)                   (fromMaybe [] mCells))-  <#> opt (parameter (peekList peekCellFuzzy) "{Cell,...}" "cells" "row cells")-  <#> opt (parameter peekAttr "Attr" "attr" "cell attributes")+  <#> opt (parameter (peekList peekCellFuzzy) "{Cell,...}" "cells"+           "list of table cells in this row")+  <#> opt (parameter peekAttr "Attr" "attr" "row attributes")   =#> functionResult pushRow "Row" "new Row object"+  #? "Creates a table row."
src/Text/Pandoc/Lua/Marshal/SimpleTable.hs view
@@ -25,6 +25,7 @@ import Text.Pandoc.Lua.Marshal.Inline (peekInlinesFuzzy, pushInlines) import Text.Pandoc.Lua.Marshal.List (pushPandocList) import Text.Pandoc.Definition+import qualified Data.Text as T  -- | A simple (legacy-style) table. data SimpleTable = SimpleTable@@ -95,6 +96,26 @@         "relative column widths"   <#> parameter peekRow "{Blocks,...}" "header"         "table header row"-  <#> parameter (peekList peekRow) "{{Blocks,...},...}" "body"-        "table body rows"+  <#> parameter (peekList peekRow) "{{Blocks,...},...}" "rows"+        "table rows"   =#> functionResult pushSimpleTable "SimpleTable" "new SimpleTable object"+  #? T.unlines+  [ "Usage:"+  , " "+  , "    local caption = \"Overview\""+  , "    local aligns = {pandoc.AlignDefault, pandoc.AlignDefault}"+  , "    local widths = {0, 0} -- let pandoc determine col widths"+  , "    local headers = {{pandoc.Plain({pandoc.Str \"Language\"})},"+  , "                     {pandoc.Plain({pandoc.Str \"Typing\"})}}"+  , "    local rows = {"+  , "      {{pandoc.Plain \"Haskell\"}, {pandoc.Plain \"static\"}},"+  , "      {{pandoc.Plain \"Lua\"}, {pandoc.Plain \"Dynamic\"}},"+  , "    }"+  , "    simple_table = pandoc.SimpleTable("+  , "      caption,"+  , "      aligns,"+  , "      widths,"+  , "      headers,"+  , "      rows"+  , "    )"+  ]
src/Text/Pandoc/Lua/Marshal/TableFoot.hs view
@@ -72,6 +72,8 @@   ### liftPure2 (\mCells mAttr -> TableFoot                   (fromMaybe nullAttr mAttr)                   (fromMaybe [] mCells))-  <#> opt (parameter (peekList peekRowFuzzy) "{Row,...}" "rows" "footer rows")+  <#> opt (parameter (peekList peekRowFuzzy) "{Row,...}" "rows"+           "list of table rows")   <#> opt (parameter peekAttr "Attr" "attr" "table foot attributes")   =#> functionResult pushTableFoot "TableFoot" "new TableFoot object"+  #? "Creates a table foot."
src/Text/Pandoc/Lua/Marshal/TableHead.hs view
@@ -72,6 +72,8 @@   ### liftPure2 (\mRows mAttr -> TableHead                   (fromMaybe nullAttr mAttr)                   (fromMaybe [] mRows))-  <#> opt (parameter (peekList peekRowFuzzy) "{Row,...}" "rows" "header rows")+  <#> opt (parameter (peekList peekRowFuzzy) "{Row,...}" "rows"+           "list of table rows")   <#> opt (parameter peekAttr "Attr" "attr" "table head attributes")   =#> functionResult pushTableHead "TableHead" "new TableHead object"+  #? "Creates a table head."