@@ -26,60 +26,6 @@ local M = {
2626 _VERSION = "0.2.0"
2727}
2828
29−--- Attributes
30−-- @type Attributes
31−M.Attributes = {}
32−setmetatable(M.Attributes, M.Attributes)
33−
34−M.Attributes.__index = function(t, k)
35− if k == "id" then
36− return t[1]
37− elseif k == "class" then
38− return table.concat(t[2], ' ')
39− else
40− return t.kv[k]
41− end
42−end
43−
44−--- Create a new set of attributes (Attr).
45−-- @function Attributes
46−M.Attributes.__call = function(t, key_values, id, classes)
47− local kv = {}
48− for i = 1, #key_values do
49− kv[key_values[i][1]] = key_values[i][2]
50− end
51− id = id or ''
52− classes = classes or {}
53− local attr = {id, classes, key_values, kv = kv}
54− setmetatable(attr, t)
55− return attr
56−end
57−M.Attributes.empty = M.Attributes('', {}, {})
58−
59−
60−--- Creates a single citation.
61−-- @function Citation
62−-- @tparam string id citation identifier (like a bibtex key)
63−-- @tparam AuthorInText|SuppressAuthor|NormalCitation mode citation mode
64−-- @tparam[opt] {Inline,...} prefix citation prefix
65−-- @tparam[opt] {Inline,...} suffix citation suffix
66−-- @tparam[opt] int note_num note number
67−-- @tparam[opt] int note_num hash number
68−M.Citation = function(id, mode, prefix, suffix, note_num, hash)
69− prefix = prefix or {}
70− suffix = suffix or {}
71− note_num = note_num or 0
72− hash = hash or 0
73− return {
74− citationId = id,
75− citationPrefix = prefix,
76− citationSuffix = suffix,
77− citationMode = mode,
78− citationNoteNum = note_num,
79− citationHash = hash,
80− }
81−end
82−
8329------------------------------------------------------------------------
8430-- The base class for pandoc's AST elements.
8531-- @type Element
@@ -211,9 +157,10 @@ for i = 1, #M.meta_value_types do
211157end
212158
213159------------------------------------------------------------------------
214−-- Block
160+-- Blocks
215161-- @section Block
216162
163+--- Block elements
217164M.Block = Element:make_subtype{}
218165M.Block.__call = function (t, ...)
219166 return t:new(...)
@@ -598,23 +545,67 @@ M.Superscript = M.Inline:create_constructor(
598545
599546
600547------------------------------------------------------------------------
601−-- Constants
602−-- @section constants
548+-- Helpers
549+-- @section helpers
603550
604−--- Math content is to be displayed on a separate line.
605−-- @see Math
606−M.DisplayMath = "DisplayMath"
607−--- Math content is to be displayed inline within the paragraph
608−-- @see Math
609−M.InlineMath = "InlineMath"
551+-- Attributes
552+M.Attributes = {}
553+setmetatable(M.Attributes, M.Attributes)
554+M.Attributes.__index = function(t, k)
555+ if k == "id" then
556+ return t[1]
557+ elseif k == "class" then
558+ return table.concat(t[2], ' ')
559+ else
560+ return t.kv[k]
561+ end
562+end
563+--- Create a new set of attributes (Attr).
564+-- @function Attributes
565+-- @tparam table key_values table containing string keys and values
566+-- @tparam[opt] string id element identifier
567+-- @tparam[opt] {string,...} classes element classes
568+-- @return element attributes
569+M.Attributes.__call = function(t, key_values, id, classes)
570+ local kv = {}
571+ for i = 1, #key_values do
572+ kv[key_values[i][1]] = key_values[i][2]
573+ end
574+ id = id or ''
575+ classes = classes or {}
576+ local attr = {id, classes, key_values, kv = kv}
577+ setmetatable(attr, t)
578+ return attr
579+end
580+M.Attributes.empty = M.Attributes('', {}, {})
610581
611−--- Double quoted content.
612−-- @see Quoted
613−M.DoubleQuote = "DoubleQuote"
582+--- Creates a single citation.
583+-- @function Citation
584+-- @tparam string id citation identifier (like a bibtex key)
585+-- @tparam AuthorInText|SuppressAuthor|NormalCitation mode citation mode
586+-- @tparam[opt] {Inline,...} prefix citation prefix
587+-- @tparam[opt] {Inline,...} suffix citation suffix
588+-- @tparam[opt] int note_num note number
589+-- @tparam[opt] int note_num hash number
590+M.Citation = function(id, mode, prefix, suffix, note_num, hash)
591+ prefix = prefix or {}
592+ suffix = suffix or {}
593+ note_num = note_num or 0
594+ hash = hash or 0
595+ return {
596+ citationId = id,
597+ citationPrefix = prefix,
598+ citationSuffix = suffix,
599+ citationMode = mode,
600+ citationNoteNum = note_num,
601+ citationHash = hash,
602+ }
603+end
614604
615−--- Single quoted content.
616−-- @see Quoted
617−M.SingleQuote = "SingleQuote"
605+
606+------------------------------------------------------------------------
607+-- Constants
608+-- @section constants
618609
619610--- Author name is mentioned in the text.
620611-- @see Citation