diff options
author | Albert Krewinkel <albert@zeitkraut.de> | 2017-12-23 22:39:05 +0100 |
---|---|---|
committer | Albert Krewinkel <albert@zeitkraut.de> | 2017-12-23 23:29:24 +0100 |
commit | 59a47454574d9eab424ef3d6d9ef6b238515f479 (patch) | |
tree | 68f755bcaba5e013966357e972ff9d11779c8fdd /doc | |
parent | 790dc2546b965853dbcaa8db1a36dd05b147ef85 (diff) | |
download | pandoc-59a47454574d9eab424ef3d6d9ef6b238515f479.tar.gz |
Lua modules: add function pandoc.utils.hierarchicalize
Convert list of Pandoc blocks into (hierarchical) list of Elements.
Diffstat (limited to 'doc')
-rw-r--r-- | doc/lua-filters.md | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/doc/lua-filters.md b/doc/lua-filters.md index 7c0e83ee8..6ab6d3718 100644 --- a/doc/lua-filters.md +++ b/doc/lua-filters.md @@ -1433,6 +1433,34 @@ Lua functions for pandoc scripts. This module exposes internal pandoc functions and utility functions. +[`hierarchicalize (blocks)`]{#utils-hierarchicalize} + +: Convert list of blocks into an hierarchical list. An + hierarchical elements is either a normal block (but no + Header), or a `Sec` element. The latter has the following + fields: + + - level: level in the document hierarchy; + - numbering: list of integers of length `level`, + specifying the absolute position of the section in the + document; + - attr: section attributes (see [Attr](#Attr)); + - contents: nested list of hierarchical elements. + + Returns: + + - List of hierarchical elements + + Usage: + + local blocks = { + pandoc.Header(2, pandoc.Str 'first'), + pandoc.Header(2, pandoc.Str 'second'), + } + local elements = pandoc.utils.hierarchicalize(blocks) + print(table.concat(elements[1].numbering, '.')) -- 0.1 + print(table.concat(elements[2].numbering, '.')) -- 0.2 + [`normalize_date (date_string)`]{#utils-normalize_date} : Parse a date and convert (if possible) to "YYYY-MM-DD" |