diff options
| author | Albert Krewinkel <[email protected]> | 2024-06-11 15:53:36 +0200 |
|---|---|---|
| committer | Albert Krewinkel <[email protected]> | 2024-07-08 16:30:45 +0200 |
| commit | 790abcf4147fa2a097b1f29c845182675d90ccc3 (patch) | |
| tree | 4acc0956a35af2943edab74d9ed8eddabeaf7bd0 | |
| parent | 73ce302479436d3e2b487e22f6ee5f4325a4cf34 (diff) | |
lua-filters.md: Partially autogenerate docs for module "pandoc"
The documentation system isn't powerful enough to generate the full
documentation automatically.
| -rw-r--r-- | doc/lua-filters.md | 776 | ||||
| -rw-r--r-- | pandoc-lua-engine/src/Text/Pandoc/Lua/Module/Pandoc.hs | 109 | ||||
| -rw-r--r-- | tools/update-lua-module-docs.lua | 79 |
3 files changed, 643 insertions, 321 deletions
diff --git a/doc/lua-filters.md b/doc/lua-filters.md index b90aa01b8..9de10cfbf 100644 --- a/doc/lua-filters.md +++ b/doc/lua-filters.md @@ -2410,23 +2410,14 @@ Usage: 'pandoc-types is too old: expected version %s, got %s' ) -[Alignment]: #type-alignment -[Attr]: #type-attr [Attributes]: #type-attributes -[Block]: #type-block -[Blocks]: #type-blocks -[Caption]: #type-caption -[Cell]: #type-cell [Cells]: #type-cell [Citation]: #type-citation [Citations]: #type-citation [ColSpec]: #type-colspec [CommonState]: #type-commonstate [Div]: #type-div -[Figure]: #type-figure [Image]: #type-image -[Inline]: #type-inline -[Inlines]: #type-inlines [List]: #type-list [ListAttributes]: #type-listattributes [Meta]: #type-meta @@ -2437,13 +2428,8 @@ Usage: [Pandoc]: #type-pandoc [Para]: #type-para [Plain]: #type-plain -[Row]: #type-row [Rows]: #type-row [SimpleTable]: #type-simpletable -[Table]: #type-table -[TableBody]: #type-tablebody -[TableFoot]: #type-tablefoot -[TableHead]: #type-tablehead [Version]: #type-version ## Chunk {#type-chunk} @@ -2509,755 +2495,935 @@ Fields: `toc` : table of contents information (table) +<!-- BEGIN: AUTOGENERATED CONTENT for module pandoc --> + # Module pandoc Fields and functions for pandoc scripts; includes constructors for -document tree elements, functions to parse text in a given -format, and functions to filter and modify a subtree. +document tree elements, functions to parse text in a given format, +and functions to filter and modify a subtree. -## Static Fields {#pandoc.fields} +## Fields {#pandoc-fields} ### readers {#pandoc.readers} Set of formats that pandoc can parse. All keys in this table can -be used as the `format` value in `pandoc.read`. +be used as the `format` value in `pandoc.read`. (table) ### writers {#pandoc.writers} Set of formats that pandoc can generate. All keys in this table -can be used as the `format` value in `pandoc.write`. +can be used as the `format` value in `pandoc.write`. (table) -## Pandoc +## Functions {#pandoc-functions} -### `Pandoc (blocks[, meta])` {#pandoc.pandoc} +### Pandoc {#pandoc.Pandoc} -A complete pandoc document +`Pandoc (blocks[, meta])` Parameters: `blocks` -: document content +: document contents ([Blocks]) `meta` -: document meta data +: document metadata ([Meta]) -Returns: [Pandoc] object +Returns: -## Meta +- new Pandoc document ([Pandoc]) -### `Meta (table)` {#pandoc.meta} +### Meta {#pandoc.Meta} -Create a new Meta object. +`Meta (meta)` Parameters: -`table` -: table containing document meta information +`meta` +: table containing meta information (table) + +Returns: -Returns: [Meta] object +- new Meta table (table) -## MetaValue +### MetaBlocks {#pandoc.MetaBlocks} -### `MetaBlocks (blocks)` {#pandoc.metablocks} +`MetaBlocks (content)` -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. +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. Parameters: -`blocks` -: blocks +`content` +: block content ([Blocks]) + +Returns: -Returns: [Blocks][] +- list of Block elements ([Blocks]) -### `MetaInlines (inlines)` {#pandoc.metainlines} +### MetaBool {#pandoc.MetaBool} -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. +`MetaBool (bool)` Parameters: -`inlines` -: inlines +`bool` +: true or false (boolean) + +Returns: -Returns: [Inlines][] +- input, unchanged (boolean) -### `MetaList (meta_values)` {#pandoc.metalist} +### MetaInlines {#pandoc.MetaInlines} -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. +`MetaInlines (inlines)` + +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. Parameters: -`meta_values` -: list of meta values +`inlines` +: inline elements ([Inlines]) + +Returns: + +- list of Inline elements ([Inlines]) -Returns: [List] +### MetaList {#pandoc.MetaList} -### `MetaMap (key_value_map)` {#pandoc.metamap} +`MetaList (values)` -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. +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. Parameters: -`key_value_map` -: a string-indexed map of meta values +`values` +: value, or list of values ([MetaValue]\|{[MetaValue],\...}) + +Returns: -Returns: table +- list of meta values ([List]{unknown-type="List"}) -### `MetaString (str)` {#pandoc.metastring} +### MetaMap {#pandoc.MetaMap} -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. +`MetaMap (key_value_map)` + +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. Parameters: -`str` -: string value +`key_value_map` +: a string-indexed map of meta values (table) -Returns: string +Returns: -### `MetaBool (bool)` {#pandoc.metabool} +- map of meta values (table) -Creates a value to be used as MetaBool in meta data; this is +### MetaString {#pandoc.MetaString} + +`MetaString (s)` + +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. Parameters: -`bool` -: boolean value +`s` +: string value (string) + +Returns: -Returns: boolean +- unchanged input (string) -## Block +### BlockQuote {#pandoc.BlockQuote} -### `BlockQuote (content)` {#pandoc.blockquote} +`BlockQuote (content)` Creates a block quote element Parameters: `content` -: block content +: block content ([Blocks]) + +Returns: + +- BlockQuote element ([Block]) -Returns: [BlockQuote] object +### BulletList {#pandoc.BulletList} -### `BulletList (items)` {#pandoc.bulletlist} +`BulletList (items)` Creates a bullet list. Parameters: `items` -: list items +: list items ({[Blocks],\...}) + +Returns: -Returns: [BulletList] object +- BulletList element ([Block]) -### `CodeBlock (text[, attr])` {#pandoc.codeblock} +### CodeBlock {#pandoc.CodeBlock} -Creates a code block element +`CodeBlock (text[, attr])` + +Creates a code block element. Parameters: `text` -: code string +: code string (string) `attr` -: element attributes +: element attributes ([Attr]) -Returns: [CodeBlock] object +Returns: -### `DefinitionList (content)` {#pandoc.definitionlist} +- CodeBlock element ([Block]) -Creates a definition list, containing terms and their -explanation. +### DefinitionList {#pandoc.DefinitionList} + +`DefinitionList (content)` + +Creates a definition list, containing terms and their explanation. Parameters: `content` -: list of items +: definition items ([{{Inlines, + {Blocks,\...}},\...}]{unknown-type="{{Inlines, {Blocks,...}},...}"}) -Returns: [DefinitionList] object +Returns: + +- DefinitionList element ([Block]) -### `Div (content[, attr])` {#pandoc.div} +### Div {#pandoc.Div} + +`Div (content[, attr])` Creates a div element Parameters: `content` -: block content +: block content ([Blocks]) `attr` -: element attributes +: element attributes ([Attr]) + +Returns: + +- Div element ([Block]) -Returns: [Div] object +### Figure {#pandoc.Figure} -### `Figure (content[, caption[, attr]])` {#pandoc.figure} +`Figure (content[, caption[, attr]])` -Creates a [Figure][] element. +Creates a [Figure] element. Parameters: `content` -: figure block content +: figure block content ([Blocks]) `caption` -: figure caption +: figure caption ([Caption]) `attr` -: element attributes +: element attributes ([Attr]) + +Returns: + +- Figure object ([Block]) -Returns: [Figure][] object +### Header {#pandoc.Header} -### `Header (level, content[, attr])` {#pandoc.header} +`Header (level, content[, attr])` Creates a header element. Parameters: `level` -: header level +: heading level ([integer]{unknown-type="integer"}) `content` -: inline content +: inline content ([Inlines]) `attr` -: element attributes +: element attributes ([Attr]) + +Returns: -Returns: [Header] object +- Header element ([Block]) -### `HorizontalRule ()` {#pandoc.horizontalrule} +### HorizontalRule {#pandoc.HorizontalRule} + +`HorizontalRule ()` Creates a horizontal rule. -Returns: [HorizontalRule] object +Returns: + +- HorizontalRule element ([Block]) + +### LineBlock {#pandoc.LineBlock} -### `LineBlock (content)` {#pandoc.lineblock} +`LineBlock (content)` Creates a line block element. Parameters: `content` -: inline content +: lines ({[Inlines],\...}) -Returns: [LineBlock] object +Returns: + +- LineBlock element ([Block]) -### `OrderedList (items[, listAttributes])` {#pandoc.orderedlist} +### OrderedList {#pandoc.OrderedList} + +`OrderedList (items[, listAttributes])` Creates an ordered list. Parameters: `items` -: list items +: list items ({[Blocks],\...}) `listAttributes` -: list parameters +: list parameters ([ListAttributes]) -Returns: [OrderedList](#type-orderedlist) object +Returns: + +- OrderedList element ([Block]) -### `Para (content)` {#pandoc.para} +### Para {#pandoc.Para} + +`Para (content)` Creates a para element. Parameters: `content` -: inline content +: inline content ([Inlines]) -Returns: [Para](#type-para) object +Returns: -### `Plain (content)` {#pandoc.plain} +- Para element ([Block]) + +### Plain {#pandoc.Plain} + +`Plain (content)` Creates a plain element. Parameters: `content` -: inline content +: inline content ([Inlines]) -Returns: [Plain](#type-plain) object +Returns: -### `RawBlock (format, text)` {#pandoc.rawblock} +- Plain element ([Block]) + +### RawBlock {#pandoc.RawBlock} + +`RawBlock (format, text)` Creates a raw content block of the specified format. Parameters: `format` -: format of content +: format of content (string) `text` -: string content +: raw content (string) + +Returns: + +- RawBlock element ([Block]) -Returns: [RawBlock](#type-rawblock) object +### Table {#pandoc.Table} -### `Table (caption, colspecs, head, bodies, foot[, attr])` {#pandoc.table} +`Table (caption, colspecs, head, bodies, foot[, attr])` Creates a table element. Parameters: `caption` -: table [caption](#type-caption) +: table caption ([Caption]) `colspecs` -: column alignments and widths (list of [ColSpec](#type-colspec)s) +: column alignments and widths ({[ColSpec],\...}) `head` -: [table head](#type-tablehead) +: table head ([TableHead]) `bodies` -: [table bodies](#type-tablebody) +: table bodies ({[TableBody],\...}) `foot` -: [table foot](#type-tablefoot) +: table foot ([TableFoot]) `attr` -: element attributes +: element attributes ([Attr]) -Returns: [Table](#type-table) object +Returns: + +- Table element ([Block]) -## Blocks +### Blocks {#pandoc.Blocks} -### `Blocks (block_like_elements)` {#pandoc.blocks} +`Blocks (block_like_elements)` -Creates a [Blocks][] list. +Creates a [Blocks] list. Parameters: `block_like_elements` -: List where each element can be treated as a [Block] - value, or a single such value. +: List where each element can be treated as a [Block] value, or + a single such value. ([Blocks]) + +Returns: -Returns: [Blocks][] +- list of block elements ([Blocks]) -## Inline +### Cite {#pandoc.Cite} -### `Cite (content, citations)` {#pandoc.cite} +`Cite (Inlines, citations)` Creates a Cite inline element Parameters: -`content` -: List of inlines +`Inlines` +: placeholder content ([content]{unknown-type="content"}) `citations` -: List of citations +: List of Citations ({[Citation]{unknown-type="Citation"},\...}) + +Returns: -Returns: [Cite](#type-cite) object +- cite element ([Inline]) -### `Code (text[, attr])` {#pandoc.code} +### Code {#pandoc.Code} + +`Code (code[, attr])` Creates a Code inline element Parameters: -`text` -: code string +`code` +: code string (string) `attr` -: additional attributes +: additional attributes ([Attr]) -Returns: [Code](#type-code) object +Returns: -### `Emph (content)` {#pandoc.emph} +- code element ([Inline]) + +### Emph {#pandoc.Emph} + +`Emph (content)` Creates an inline element representing emphasized text. Parameters: `content` -: inline content +: inline content ([Inlines]) + +Returns: -Returns: [Emph](#type-emph) object +- new object ([Inline]) -### `Image (caption, src[, title[, attr]])` {#pandoc.image} +### Image {#pandoc.Image} -Creates a Image inline element +`Image (caption, src[, title[, attr]])` + +Creates an Image element Parameters: `caption` -: text used to describe the image +: text used to describe the image ([Inlines]) `src` -: path to the image file +: path to the image file (string) `title` -: brief image description +: brief image description (string) `attr` -: additional attributes +: image attributes ([Attr]) -Returns: [Image](#type-image) object +Returns: + +- Image element ([Inline]) -### `LineBreak ()` {#pandoc.linebreak} +### LineBreak {#pandoc.LineBreak} + +`LineBreak ()` Create a LineBreak inline element -Returns: [LineBreak](#type-linebreak) object +Returns: -### `Link (content, target[, title[, attr]])` {#pandoc.link} +- line break ([Inline]) + +### Link {#pandoc.Link} + +`Link (content, target[, title[, attr]])` Creates a link inline element, usually a hyperlink. Parameters: `content` -: text for this link +: text for this link ([Inlines]) `target` -: the link target +: the link target (string) `title` -: brief link description +: brief link description (string) `attr` -: additional attributes +: link attributes ([Attr]) + +Returns: + +- link element ([Inline]) -Returns: [Link](#type-link) object +### Math {#pandoc.Math} -### `Math (mathtype, text)` {#pandoc.math} +`Math (mathtype, text)` Creates a Math element, either inline or displayed. Parameters: `mathtype` -: rendering specifier +: rendering specifier ([MathType]{unknown-type="MathType"}) `text` -: Math content +: math content (string) + +Returns: -Returns: [Math](#type-math) object +- math element ([Inline]) -### `Note (content)` {#pandoc.note} +### Note {#pandoc.Note} + +`Note (content)` Creates a Note inline element Parameters: `content` -: footnote block content +: footnote block content ([Blocks]) + +Returns: + +- note ([Inline]) -Returns: [Note](#type-note) object +### Quoted {#pandoc.Quoted} -### `Quoted (quotetype, content)` {#pandoc.quoted} +`Quoted (quotetype, content)` -Creates a Quoted inline element given the quote type and -quoted content. +Creates a Quoted inline element given the quote type and quoted +content. Parameters: `quotetype` -: type of quotes to be used +: type of quotes ([QuoteType]{unknown-type="QuoteType"}) `content` -: inline content +: inlines in quotes ([Inlines]) -Returns: [Quoted](#type-quoted) object +Returns: + +- quoted element ([Inline]) -### `RawInline (format, text)` {#pandoc.rawinline} +### RawInline {#pandoc.RawInline} + +`RawInline (format, text)` Creates a raw inline element Parameters: `format` -: format of the contents +: format of content (string) `text` -: string content +: string content (string) -Returns: [RawInline](#type-rawinline) object +Returns: + +- raw inline element ([Inline]) -### `SmallCaps (content)` {#pandoc.smallcaps} +### SmallCaps {#pandoc.SmallCaps} + +`SmallCaps (content)` Creates text rendered in small caps Parameters: `content` -: inline content +: inline content ([Inlines]) -Returns: [SmallCaps](#type-smallcaps) object +Returns: -### `SoftBreak ()` {#pandoc.softbreak} +- new object ([Inline]) + +### SoftBreak {#pandoc.SoftBreak} + +`SoftBreak ()` Creates a SoftBreak inline element. -Returns: [SoftBreak](#type-softbreak) object +Returns: -### `Space ()` {#pandoc.space} +- soft break ([Inline]) + +### Space {#pandoc.Space} + +`Space ()` Create a Space inline element -Returns: [Space](#type-space) object +Returns: + +- new space ([Inline]) -### `Span (content[, attr])` {#pandoc.span} +### Span {#pandoc.Span} + +`Span (content[, attr])` Creates a Span inline element Parameters: `content` -: inline content +: inline content ([Inlines]) `attr` -: additional attributes +: additional attributes ([Attr]) + +Returns: -Returns: [Span](#type-span) object +- [Span] object ([Inline]) -### `Str (text)` {#pandoc.str} +### Str {#pandoc.Str} + +`Str (text)` Creates a Str inline element Parameters: `text` -: content +: (string) + +Returns: -Returns: [Str](#type-str) object +- [Str] object ([Inline]) -### `Strikeout (content)` {#pandoc.strikeout} +### Strikeout {#pandoc.Strikeout} + +`Strikeout (content)` Creates text which is struck out. Parameters: `content` -: inline content +: inline content ([Inlines]) + +Returns: -Returns: [Strikeout](#type-strikeout) object +- new object ([Inline]) -### `Strong (content)` {#pandoc.strong} +### Strong {#pandoc.Strong} -Creates a Strong element, whose text is usually displayed in -a bold font. +`Strong (content)` + +Creates a Strong element, whose text is usually displayed in a +bold font. Parameters: `content` -: inline content +: inline content ([Inlines]) + +Returns: + +- new object ([Inline]) -Returns: [Strong](#type-strong) object +### Subscript {#pandoc.Subscript} -### `Subscript (content)` {#pandoc.subscript} +`Subscript (content)` Creates a Subscript inline element Parameters: `content` -: inline content +: inline content ([Inlines]) -Returns: [Subscript](#type-subscript) object +Returns: + +- new object ([Inline]) -### `Superscript (content)` {#pandoc.superscript} +### Superscript {#pandoc.Superscript} + +`Superscript (content)` Creates a Superscript inline element Parameters: `content` -: inline content +: inline content ([Inlines]) -Returns: [Superscript](#type-superscript) object +Returns: -### `Underline (content)` {#pandoc.underline} +- new object ([Inline]) + +### Underline {#pandoc.Underline} + +`Underline (content)` Creates an Underline inline element Parameters: `content` -: inline content +: inline content ([Inlines]) + +Returns: -Returns: [Underline](#type-underline) object +- new object ([Inline]) -## Inlines +### Inlines {#pandoc.Inlines} -### `Inlines (inline_like_elements)` {#pandoc.inlines} +`Inlines (inline_like_elements)` -Converts its argument into an [Inlines][] list: +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. +- splits a string into `Str`-wrapped words, treating interword + spaces as `Space`s or `SoftBreak`s. Parameters: `inline_like_elements` -: List where each element can be treated as an [Inline] - values, or just a single such value. +: List where each element can be treated as an [Inline] value, + or just a single such value. ([Inlines]) -Returns: [Inlines][] list +Returns: +- list of inline elements ([Inlines]) -## Element components +### Attr {#pandoc.Attr} -### `Attr ([identifier[, classes[, attributes]]])` {#pandoc.attr} +`Attr ([identifier[, classes[, attributes]]])` -Create a new set of attributes (Attr). +Create a new set of attributes Parameters: `identifier` -: element identifier +: element identifier (string\|table\|[Attr]) `classes` -: element classes +: element classes ({string,\...}) `attributes` : table containing string keys and values + (table\|[AttributeList]) -Returns: [Attr](#type-attr) object +Returns: -### `Cell (blocks[, align[, rowspan[, colspan[, attr]]]])` {#pandoc.cell} +- new Attr object ([Attr]) + +### Cell {#pandoc.Cell} + +`Cell (blocks[, align[, rowspan[, colspan[, attr]]]])` Create a new table cell. Parameters: `blocks` -: cell contents ([Blocks][]) +: cell contents ([Blocks]) `align` -: text alignment; defaults to `AlignDefault` (Alignment) +: text alignment; defaults to `AlignDefault` ([Alignment]) `rowspan` : number of rows occupied by the cell; defaults to `1` - (integer) + ([integer]{unknown-type="integer"}) `colspan` -: number of columns spanned by the cell; defaults to `1` - (integer) +: number of columns occupied by the cell; defaults to `1` + ([integer]{unknown-type="integer"}) `attr` -: cell attributes ([Attr](#type-attr)) +: cell attributes ([Attr]) + +Returns: + +- new Cell object ([Cell]) + +### AttributeList {#pandoc.AttributeList} + +`AttributeList (attribs)` + +Parameters: + +`attribs` +: an attribute list (table\|[AttributeList]) Returns: -- [Cell](#type-cell) object +- new AttributeList object ([AttributeList]) -### `Citation (id, mode[, prefix[, suffix[, note_num[, hash]]]])` {#pandoc.citation} +### Citation {#pandoc.Citation} + +`Citation (id, mode[, prefix[, suffix[, note_num[, hash]]]])` Creates a single citation. Parameters: `id` -: citation identifier (like a bibtex key) +: citation ID (e.g. BibTeX key) (string) `mode` -: citation mode +: citation rendering mode + ([CitationMode]{unknown-type="CitationMode"}) `prefix` -: citation prefix +: ([Inlines]) `suffix` -: citation suffix +: ([Inlines]) `note_num` -: note number +: note number ([integer]{unknown-type="integer"}) `hash` -: hash number +: hash number ([integer]{unknown-type="integer"}) + +Returns: + +- new citation object ([Citation]{unknown-type="Citation"}) -Returns: [Citation](#type-citation) object +### ListAttributes {#pandoc.ListAttributes} -### `ListAttributes ([start[, style[, delimiter]]])` {#pandoc.listattributes} +`ListAttributes ([start[, style[, delimiter]]])` -Creates a set of list attributes. +Creates a new ListAttributes object. Parameters: `start` : number of the first list item + ([integer]{unknown-type="integer"}) `style` -: style used for list numbering +: style used for list numbering (string) `delimiter` -: delimiter of list numbers +: delimiter of list numbers (string) + +Returns: + +- new ListAttributes object ([ListAttributes]) -Returns: [ListAttributes](#type-listattributes) object +### Row {#pandoc.Row} -### `Row ([cells[, attr]])` {#pandoc.row} +`Row ([cells[, attr]])` Creates a table row. Parameters: `cells` -: list of table cells in this row +: list of table cells in this row ({[Cell],\...}) `attr` -: row attributes +: row attributes ([Attr]) -### `TableFoot ([rows[, attr]])` {#pandoc.tablefoot} - -Creates a table foot. - -Parameters: +Returns: -`rows` -: list of table rows +- new Row object ([Row]) -`attr` -: table foot attributes +### TableFoot {#pandoc.TableFoot} -### `TableHead ([rows[, attr]])` {#pandoc.tablehead} +`TableFoot ([rows[, attr]])` -Creates a table head. +Creates a table foot. Parameters: `rows` -: list of table rows +: list of table rows ({[Row],\...}) `attr` -: table head attributes +: table foot attributes ([Attr]) + +Returns: -## Legacy types +- new TableFoot object ([TableFoot]) -### `SimpleTable (caption, aligns, widths, headers, rows)` {#pandoc.simpletable} +### TableHead {#pandoc.TableHead} -Creates a simple table resembling the old (pre pandoc 2.10) -table type. +`TableHead ([rows[, attr]])` + +Creates a table head. Parameters: -`caption` -: [Inlines][] +`rows` +: list of table rows ({[Row],\...}) -`aligns` -: column alignments ([List] of [Alignments](#type-alignment)) +`attr` +: table head attributes ([Attr]) -`widths` -: column widths; a ([List] of numbers) +Returns: -`headers` -: table header row ([List] of [Blocks][]) +- new TableHead object ([TableHead]) -`rows` -: table rows ([List] of rows, where a row is a list - of [Blocks][]) +### SimpleTable {#pandoc.SimpleTable} -Returns: [SimpleTable] object +`SimpleTable (caption, align, widths, header, rows)` Usage: @@ -3278,6 +3444,29 @@ Usage: rows ) +Parameters: + +`caption` +: table caption ([Inlines]) + +`align` +: column alignments ({[Alignment],\...}) + +`widths` +: relative column widths ({number,\...}) + +`header` +: table header row ({[Blocks],\...}) + +`rows` +: table rows ({{[Blocks],\...},\...}) + +Returns: + +- new SimpleTable object ([SimpleTable]) + +<!-- END: AUTOGENERATED CONTENT --> + ## Constants [`AuthorInText`]{#pandoc.authorintext} @@ -6523,13 +6712,29 @@ Returns: <!-- BEGIN: GENERATED REFERENCE LINKS --> - [Block]: #type-block [Blocks]: #type-blocks - [Inline]: #type-inline - [Inlines]: #type-inlines + [Meta]: #type-meta [Pandoc]: #type-pandoc - [Table]: #type-table + [Inlines]: #type-inlines + [MetaValue]: #type-metavalue + [Block]: #type-block + [Attr]: #type-attr + [Figure]: #type-figure + [Caption]: #type-caption + [ListAttributes]: #type-listattributes + [ColSpec]: #type-colspec + [TableHead]: #type-tablehead + [TableBody]: #type-tablebody + [TableFoot]: #type-tablefoot + [Inline]: #type-inline + [Span]: #type-span + [Str]: #type-str + [AttributeList]: #type-attributes + [Alignment]: #type-alignment + [Cell]: #type-cell + [Row]: #type-row [SimpleTable]: #type-simpletable + [Table]: #type-table [Version]: #type-version [`list`]: #pandoc.mediabag.list [WriterOptions]: #type-writeroptions @@ -6538,6 +6743,5 @@ Returns: [ChunkedDoc]: #type-chunkeddoc [Doc]: #type-doc [Template]: #type-template - [Meta]: #type-meta [zip.Entry]: #type-pandoc.zip.Entry [zip.Archive]: #type-pandoc.zip.Archive diff --git a/pandoc-lua-engine/src/Text/Pandoc/Lua/Module/Pandoc.hs b/pandoc-lua-engine/src/Text/Pandoc/Lua/Module/Pandoc.hs index 0b82d35d6..8fdfc3e20 100644 --- a/pandoc-lua-engine/src/Text/Pandoc/Lua/Module/Pandoc.hs +++ b/pandoc-lua-engine/src/Text/Pandoc/Lua/Module/Pandoc.hs @@ -6,12 +6,10 @@ {- | Module : Text.Pandoc.Lua.Module.Pandoc Copyright : Copyright © 2017-2024 Albert Krewinkel - License : GNU GPL, version 2 or above - + License : GPL-2.0-or-later Maintainer : Albert Krewinkel <[email protected]> - Stability : alpha -Pandoc module for lua. +Main @pandoc@ module, containing element constructors and central functions. -} module Text.Pandoc.Lua.Module.Pandoc ( documentedModule @@ -61,19 +59,22 @@ documentedModule :: Module PandocError documentedModule = Module { moduleName = "pandoc" , moduleDescription = T.unlines - [ "Lua functions for pandoc scripts; includes constructors for" - , "document elements, functions to parse text in a given" + [ "Fields and functions for pandoc scripts; includes constructors for" + , "document tree elements, functions to parse text in a given" , "format, and functions to filter and modify a subtree." ] , moduleFields = readersField : writersField : stringConstants ++ [inlineField, blockField] , moduleOperations = [] , moduleFunctions = mconcat - [ functions - , otherConstructors + [ [mkPandoc, mkMeta] + , metaValueConstructors , blockConstructors + , [mkBlocks] , inlineConstructors - , metaValueConstructors + , [mkInlines] + , otherConstructors + , functions ] , moduleTypeInitializers = [ initType typePandoc @@ -144,30 +145,51 @@ pushWithConstructorsSubtable constructors = do otherConstructors :: [DocumentedFunction PandocError] otherConstructors = - [ mkPandoc - , mkMeta - , mkAttr + [ mkAttr + , mkCell , mkAttributeList - , mkBlocks , mkCitation - , mkCell + , mkListAttributes , mkRow - , mkTableHead , mkTableFoot - , mkInlines - , mkListAttributes + , mkTableHead , mkSimpleTable , defun "ReaderOptions" ### liftPure id - <#> parameter peekReaderOptions "ReaderOptions|table" "opts" "reader options" + <#> parameter peekReaderOptions "ReaderOptions|table" "opts" + (T.unlines + [ "Either a table with a subset of the properties of a" + , "[[ReaderOptions]] object, or another ReaderOptions object." + , "Uses the defaults specified in the manual for all" + , "properties that are not explicitly specified. Throws an" + , "error if a table contains properties which are not present" + , "in a ReaderOptions object." + ] + ) =#> functionResult pushReaderOptions "ReaderOptions" "new object" - #? "Creates a new ReaderOptions value." + #? T.unlines + [ "Creates a new ReaderOptions value." + , "" + , "Usage:" + , "" + , " -- copy of the reader options that were defined on the command line." + , " local cli_opts = pandoc.ReaderOptions(PANDOC_READER_OPTIONS)" + , " -- default reader options, but columns set to 66." + , " local short_colums_opts = pandoc.ReaderOptions {columns = 66}" + ] , defun "WriterOptions" ### liftPure id <#> parameter peekWriterOptions "WriterOptions|table" "opts" - "writer options" + (T.unlines + [ "Either a table with a subset of the properties of a" + , "[[WriterOptions]] object, or another WriterOptions object." + , "Uses the defaults specified in the manual for all" + , "properties that are not explicitly specified. Throws an" + , "error if a table contains properties which are not present" + , "in a WriterOptions object." + ]) =#> functionResult pushWriterOptions "WriterOptions" "new object" #? "Creates a new WriterOptions value." ] @@ -260,22 +282,59 @@ functions = (ByteStringWriter w, es) -> Left <$> w writerOpts{ writerExtensions = es } doc) <#> parameter peekPandoc "Pandoc" "doc" "document to convert" - <#> opt (parameter peekFlavoredFormat "string|table" - "formatspec" "format and extensions") - <#> opt (parameter peekWriterOptions "WriterOptions" "writer_options" - "writer options") + <#> opt (parameter peekFlavoredFormat "string|table" "formatspec" + (T.unlines + [ "format specification; defaults to `\"html\"`. See the" + , "documentation of [`pandoc.read`](#pandoc.read) for a complete" + , "description of this parameter." + ])) + <#> opt (parameter peekWriterOptions "WriterOptions|table" "writer_options" + (T.unlines + [ "options passed to the writer; may be a WriterOptions object" + , "or a table with a subset of the keys and values of a" + , "WriterOptions object; defaults to the default values" + , "documented in the manual." + ]) + ) =#> functionResult (either pushLazyByteString pushText) "string" "result document" + #? T.unlines + [ "Converts a document to the given target format." + , "" + , "Usage:" + , "" + , " local doc = pandoc.Pandoc(" + , " {pandoc.Para {pandoc.Strong 'Tea'}}" + , " )" + , " local html = pandoc.write(doc, 'html')" + , " assert(html == '<p><strong>Tea</strong></p>')" + ] , defun "write_classic" ### (\doc mwopts -> runCustom (fromMaybe def mwopts) doc) <#> parameter peekPandoc "Pandoc" "doc" "document to convert" <#> opt (parameter peekWriterOptions "WriterOptions" "writer_options" - "writer options") + (T.unlines + [ "options passed to the writer; may be a WriterOptions object" + , "or a table with a subset of the keys and values of a" + , "WriterOptions object; defaults to the default values" + , "documented in the manual." + ])) =#> functionResult pushText "string" "rendered document" #? (T.unlines [ "Runs a classic custom Lua writer, using the functions defined" , "in the current environment." + , "" + , "Usage:" + , "" + , " -- Adding this function converts a classic writer into a" + , " -- new-style custom writer." + , " function Writer (doc, opts)" + , " PANDOC_DOCUMENT = doc" + , " PANDOC_WRITER_OPTIONS = opts" + , " loadfile(PANDOC_SCRIPT_FILE)()" + , " return pandoc.write_classic(doc, opts)" + , " end" ]) ] where diff --git a/tools/update-lua-module-docs.lua b/tools/update-lua-module-docs.lua index 3680c4640..1491cc7dd 100644 --- a/tools/update-lua-module-docs.lua +++ b/tools/update-lua-module-docs.lua @@ -21,14 +21,21 @@ local BulletList, DefinitionList, Header, Para, Plain, RawBlock = local registry = debug.getregistry() ---- Table containing all known modules -local modules = pandoc - --- Retrieves the documentation object for the given value. local function documentation (value) return registry['HsLua docs'][value] end +--- Table containing all known modules +local modules = {} +for k, v in pairs(pandoc) do + local docs = documentation(v) + if docs and docs.fields then + modules[k] = v + end +end +modules['pandoc'] = pandoc + --- Creates an iterator triple that will return values sorted by key names. -- @param tbl table with string keys -- @return iterator triple to be used in a `for` loop. @@ -66,16 +73,32 @@ end --- Map of all known data types to a heading ID. Used to create hyperlinks. local known_types = { + Alignment = 'type-alignment', + Attr = 'type-attr', + AttributeList = 'type-attributes', Block = 'type-block', Blocks = 'type-blocks', + Caption = 'type-caption', + Cell = 'type-cell', + ColSpec = 'type-colspec', Doc = 'type-doc', ChunkedDoc = 'type-chunkeddoc', + Figure = 'type-figure', Inline = 'type-inline', Inlines = 'type-inlines', + ListAttributes = 'type-listattributes', Meta = 'type-meta', + MetaValue = 'type-metavalue', Pandoc = 'type-pandoc', + ReaderOptions = 'type-readeroptions', + Row = 'type-row', SimpleTable = 'type-simpletable', + Span = 'type-span', + Str = 'type-str', Table = 'type-table', + TableBody = 'type-tablebody', + TableHead = 'type-tablehead', + TableFoot = 'type-tablefoot', Template = 'type-template', WriterOptions = 'type-writeroptions', Version = 'type-version', @@ -264,16 +287,16 @@ local function render_type (name, level, modulename) end end + local type_description = properties .. methods if name == 'Doc' then - local header_id = 'type-' .. nameprefix .. '.' .. name - return {Header(level, name, {header_id})} .. - Blocks{Para {"See the description ", Link("above", "#type-doc"), "."}} + type_description = Blocks{ + Para {"See the description ", Link("above", "#type-doc"), "."} + } end local header_id = 'type-' .. nameprefix .. '.' .. name - known_types[name] = header_id + known_types[name] = known_types[name] or header_id return {Header(level, name, {header_id})} .. - properties .. - methods + type_description end --- Renders module documentation. @@ -314,6 +337,39 @@ local function render_module (doc) typedocs end +--- Renders the documentation of the main "pandoc" module. +-- FIXME: This function shouldn't exist. +local function render_main_pandoc_module (doc) + local constants_section = Blocks{Header(2, "Constants")} + local fields = List{} + for i, field in ipairs(doc.fields) do + if tostring(field.type) == 'string' then + constants_section:extend(render_field(field, 2, "pandoc")) + elseif field.name:match '^[A-Z]' then + -- Ignore (these are the `Block` and `Inline` tables) + else + fields:insert(field) + end + end + local stop_rendering = false + local functions = List{} + for _, fn in ipairs(doc.functions) do + if stop_rendering then + pandoc.log.info("Not rendered in module pandoc: " .. fn.name .. '\n') + else + functions:insert(fn) + end + if fn.name == 'SimpleTable' then + stop_rendering = true + end + end + doc.fields = fields + doc.functions = functions + -- product types don't render well, so we document those manually + doc.types = {} + return render_module(doc) +end + local autogen_start = '\n<!%-%- BEGIN: AUTOGENERATED CONTENT for module ([a-z%.]+) %-%->' local autogen_end = @@ -336,7 +392,10 @@ local function process_document (input, blocks, start) print('Generating docs for module ' .. module_name) blocks:insert(rawmd(input:sub(start, mstop))) local object = modules[module_name] or modules[module_name:gsub('^pandoc%.', '')] - blocks:extend(render_module(documentation(object))) + local docblocks = (object == pandoc) + and render_main_pandoc_module(documentation(object)) + or render_module(documentation(object)) + blocks:extend(docblocks) return process_document(input, blocks, input:find(autogen_end, mstop) or -1) else local reflinks_stop = select(2, input:find(reflinks_marker, start)) |
