pandoc.structure
make_sections
function pandoc.structure.make_sections(blocks: pandoc.Blocks, opts?: table)
-> pandoc.Blocks[]
Puts Blocks into a hierarchical structure: a list of sections (each a Div with class “section” and first element a Header).
The optional opts argument can be a table; two settings are recognized: If number_sections is true, a number attribute containing the section number will be added to each Header. If base_level is an integer, then Header levels will be reorganized so that there are no gaps, with numbering levels shifted by the given value. Finally, an integer slide_level value triggers the creation of slides at that heading level.
Note that a WriterOptions object can be passed as the opts table; this will set the number_section and slide_level values to those defined on the command line.
Usage:
local blocks = {
pandoc.Header(2, pandoc.Str 'first'),
pandoc.Header(2, pandoc.Str 'second'),
}
local opts = PANDOC_WRITER_OPTIONS
local newblocks = pandoc.structure.make_sections(blocks, opts)
slide_level
function pandoc.structure.slide_level(blocks: pandoc.Blocks|pandoc.Pandoc)
-> integer
Find level of header that starts slides (defined as the least header level that occurs before a non-header/non-hrule in the blocks).
split_into_chunks
function pandoc.structure.split_into_chunks(doc: pandoc.Pandoc, opts?: { path_template: string, number_sections: boolean, chunk_level: integer, base_heading_level: integer|nil })
-> pandoc.ChunkedDoc
Converts a Pandoc document into a ChunkedDoc.
The following option fields are supported:
`path_template`
: template used to generate the chunks' filepaths
`%n` will be replaced with the chunk number (padded with
leading 0s to 3 digits), `%s` with the section number of
the heading, `%h` with the (stringified) heading text,
`%i` with the section identifier. For example,
`"section-%s-%i.html"` might be resolved to
`"section-1.2-introduction.html"`.
Default is `"chunk-%n"` (string)
`number_sections`
: whether sections should be numbered; default is `false`
(boolean)
`chunk_level`
: The heading level the document should be split into
chunks. The default is to split at the top-level, i.e.,
`1`. (integer)
`base_heading_level`
: The base level to be used for numbering. Default is `nil`
(integer|nil)
table_of_contents
function pandoc.structure.table_of_contents(toc_source: pandoc.Blocks|pandoc.ChunkedDoc|pandoc.Pandoc, opts?: pandoc.WriterOptions)
-> pandoc.Block
Generates a table of contents for the given object.