git.iko.soy/typeable/pandoc
on da72d0f help sign in
typeable/pandoc/data/pandoc.lua
922 lines 27 kB history raw
1--[[
2pandoc.lua
4Copyright © 2017–2018 Albert Krewinkel
6Permission to use, copy, modify, and/or distribute this software for any purpose
7with or without fee is hereby granted, provided that the above copyright notice
8and this permission notice appear in all copies.
10THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
11REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
12FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
13INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
14OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
16THIS SOFTWARE.
17]]
19---
20-- Lua functions for pandoc scripts.
21--
22-- @author Albert Krewinkel
23-- @copyright © 2017–2018 Albert Krewinkel
24-- @license MIT
25local M = {
26 _VERSION = "0.4.0"
29local List = require 'pandoc.List'
31------------------------------------------------------------------------
32-- Accessor objects
33--
34-- Create metatables which allow to access numerical indices via accessor
35-- methods.
36-- @section
37-- @local
39--- Create a new indexing function.
40-- @param template function template
41-- @param indices list of indices, starting with the most deeply nested
42-- @return newly created function
43-- @local
44function make_indexing_function(template, indices)
45 local loadstring = loadstring or load
46 local bracketed = {}
47 for i = 1, #indices do
48 bracketed[i] = string.format('[%d]', indices[#indices - i + 1])
49 end
50 local fnstr = string.format('return ' .. template, table.concat(bracketed))
51 return assert(loadstring(fnstr))()
52end
54--- Create accessor functions using a function template.
55-- @param fn_template function template in which '%s' is replacd with indices
56-- @param accessors list of accessors
57-- @return mapping from accessor names to accessor functions
58-- @local
59local function create_accessor_functions (fn_template, accessors)
60 local res = {}
61 function add_accessors(acc, ...)
62 if type(acc) == "string" then
63 res[acc] = make_indexing_function(fn_template, {...})
64 else
65 for i = 1, #(acc or {}) do
66 add_accessors(acc[i], i, ...)
67 end
68 end
69 end
70 add_accessors(accessors)
71 return res
72end
74--- Create a new table which allows to access numerical indices via accessor
75-- functions.
76-- @local
77local function create_accessor_behavior (tag, accessors)
78 local behavior = {tag = tag}
79 behavior.getters = create_accessor_functions(
80 'function (x) return x.c%s end',
81 accessors
82 )
83 behavior.setters = create_accessor_functions(
84 'function (x, v) x.c%s = v end',
85 accessors
86 )
87 behavior.__index = function(t, k)
88 if getmetatable(t).getters[k] then
89 return getmetatable(t).getters[k](t)
90 elseif k == "t" then
91 return getmetatable(t)["tag"]
92 else
93 return getmetatable(t)[k]
94 end
95 end
96 behavior.__newindex = function(t, k, v)
97 if getmetatable(t).setters[k] then
98 getmetatable(t).setters[k](t, v)
99 else
100 rawset(t, k, v)
101 end
102 end
103 return behavior
104end
107------------------------------------------------------------------------
108-- The base class for types
109-- @type Type
110-- @local
111local Type = {}
112Type.name = 'Type'
113Type.__index = Type
114Type.behavior = {
115 __type = Type,
116 new = function (obj)
117 obj = obj or {}
118 setmetatable(obj, self)
119 return obj
120 end
122Type.behavior.__index = Type.behavior
124--- Set a new behavior for the type, inheriting that of the parent type if none
125--- is specified explicitely
126-- @param behavior the behavior object for this type.
127-- @local
128function Type:set_behavior (behavior)
129 behavior = behavior or {}
130 behavior.__index = rawget(behavior, '__index') or behavior
131 behavior.__type = self
132 if not getmetatable(behavior) and getmetatable(self) then
133 setmetatable(behavior, getmetatable(self).behavior)
134 end
135 self.behavior = behavior
136end
138--- Create a new subtype, using the given table as base.
139-- @param name name of the new type
140-- @param[opt] behavior behavioral object for the new type.
141-- @return a new type
142-- @local
143function Type:make_subtype(name, behavior)
144 local newtype = setmetatable({}, self)
145 newtype.name = name
146 newtype.__index = newtype
147 newtype:set_behavior(behavior)
148 return newtype
149end
152------------------------------------------------------------------------
153-- The base class for pandoc's AST elements.
154-- @type AstElement
155-- @local
156local AstElement = Type:make_subtype 'AstElement'
157AstElement.__call = function(t, ...)
158 local success, ret = pcall(t.new, t, ...)
159 if success then
160 return setmetatable(ret, t.behavior)
161 else
162 error(string.format('Constructor for %s failed: %s\n', t.name, ret))
163 end
164end
166--- Make a new subtype which constructs a new value when called.
167-- @local
168function AstElement:make_subtype(...)
169 local newtype = Type.make_subtype(self, ...)
170 newtype.__call = self.__call
171 return newtype
172end
174--- Create a new constructor
175-- @local
176-- @param tag Tag used to identify the constructor
177-- @param fn Function to be called when constructing a new element
178-- @param accessors names to use as accessors for numerical fields
179-- @return function that constructs a new element
180function AstElement:create_constructor(tag, fn, accessors)
181 local constr = self:make_subtype(tag, create_accessor_behavior(tag, accessors))
182 function constr:new(...)
183 return setmetatable(fn(...), self.behavior)
184 end
185 self.constructor = self.constructor or {}
186 self.constructor[tag] = constr
187 return constr
188end
190------------------------------------------------------------------------
191--- Pandoc Document
192-- @section document
194--- A complete pandoc document
195-- @function Pandoc
196-- @tparam {Block,...} blocks document content
197-- @tparam[opt] Meta meta document meta data
198M.Pandoc = AstElement:make_subtype'Pandoc'
199function M.Pandoc:new (blocks, meta)
200 return {
201 blocks = List:new(blocks),
202 meta = meta or {},
203 }
204end
206-- DEPRECATED synonym:
207M.Doc = M.Pandoc
209------------------------------------------------------------------------
210-- Meta
211-- @section Meta
213--- Create a new Meta object. It sets the metatable of the given table to
214--- `Meta`.
215-- @function Meta
216-- @tparam meta table table containing document meta information
217M.Meta = AstElement:make_subtype'Meta'
218function M.Meta:new (meta) return meta end
221------------------------------------------------------------------------
222-- MetaValue
223-- @section MetaValue
224M.MetaValue = AstElement:make_subtype('MetaValue')
226--- Meta blocks
227-- @function MetaBlocks
228-- @tparam {Block,...} blocks blocks
229M.MetaBlocks = M.MetaValue:create_constructor(
230 'MetaBlocks',
231 function (content) return List:new(content) end
234--- Meta inlines
235-- @function MetaInlines
236-- @tparam {Inline,...} inlines inlines
237M.MetaInlines = M.MetaValue:create_constructor(
238 'MetaInlines',
239 function (content) return List:new(content) end
242--- Meta list
243-- @function MetaList
244-- @tparam {MetaValue,...} meta_values list of meta values
245M.MetaList = M.MetaValue:create_constructor(
246 'MetaList',
247 function (content) return List:new(content) end
250--- Meta map
251-- @function MetaMap
252-- @tparam table key_value_map a string-indexed map of meta values
253M.MetaMap = M.MetaValue:create_constructor(
254 "MetaMap",
255 function (mm) return mm end
258--- Creates string to be used in meta data.
259-- Does nothing, lua strings are meta strings.
260-- @function MetaString
261-- @tparam string str string value
262function M.MetaString(str)
263 return str
264end
266--- Creates boolean to be used in meta data.
267-- Does nothing, lua booleans are meta booleans.
268-- @function MetaBool
269-- @tparam boolean bool boolean value
270function M.MetaBool(bool)
271 return bool
272end
274------------------------------------------------------------------------
275-- Blocks
276-- @section Block
278--- Block elements
279M.Block = AstElement:make_subtype'Block'
281--- Creates a block quote element
282-- @function BlockQuote
283-- @tparam {Block,...} content block content
284-- @treturn Block block quote element
285M.BlockQuote = M.Block:create_constructor(
286 "BlockQuote",
287 function(content) return {c = content} end,
288 "content"
291--- Creates a bullet (i.e. unordered) list.
292-- @function BulletList
293-- @tparam {{Block,...},...} content list of items
294-- @treturn Block bullet list element
295M.BulletList = M.Block:create_constructor(
296 "BulletList",
297 function(content) return {c = content} end,
298 "content"
301--- Creates a code block element
302-- @function CodeBlock
303-- @tparam string text code string
304-- @tparam[opt] Attr attr element attributes
305-- @treturn Block code block element
306M.CodeBlock = M.Block:create_constructor(
307 "CodeBlock",
308 function(text, attr) return {c = {attr or M.Attr(), text}} end,
309 {{"identifier", "classes", "attributes"}, "text"}
312--- Creates a definition list, containing terms and their explanation.
313-- @function DefinitionList
314-- @tparam {{{Inline,...},{Block,...}},...} content list of items
315-- @treturn Block definition list element
316M.DefinitionList = M.Block:create_constructor(
317 "DefinitionList",
318 function(content) return {c = List:new(content)} end,
319 "content"
322--- Creates a div element
323-- @function Div
324-- @tparam {Block,...} content block content
325-- @tparam[opt] Attr attr element attributes
326-- @treturn Block div element
327M.Div = M.Block:create_constructor(
328 "Div",
329 function(content, attr)
330 return {c = {attr or M.Attr(), List:new(content)}}
331 end,
332 {{"identifier", "classes", "attributes"}, "content"}
335--- Creates a header element.
336-- @function Header
337-- @tparam int level header level
338-- @tparam {Inline,...} content inline content
339-- @tparam[opt] Attr attr element attributes
340-- @treturn Block header element
341M.Header = M.Block:create_constructor(
342 "Header",
343 function(level, content, attr)
344 return {c = {level, attr or M.Attr(), content}}
345 end,
346 {"level", {"identifier", "classes", "attributes"}, "content"}
349--- Creates a horizontal rule.
350-- @function HorizontalRule
351-- @treturn Block horizontal rule
352M.HorizontalRule = M.Block:create_constructor(
353 "HorizontalRule",
354 function() return {} end
357--- Creates a line block element.
358-- @function LineBlock
359-- @tparam {{Inline,...},...} content inline content
360-- @treturn Block line block element
361M.LineBlock = M.Block:create_constructor(
362 "LineBlock",
363 function(content) return {c = List:new(content)} end,
364 "content"
367--- Creates a null element.
368-- @function Null
369-- @treturn Block null element
370M.Null = M.Block:create_constructor(
371 "Null",
372 function() return {} end
375--- Creates an ordered list.
376-- @function OrderedList
377-- @tparam {{Block,...},...} items list items
378-- @param[opt] listAttributes list parameters
379-- @treturn Block ordered list element
380M.OrderedList = M.Block:create_constructor(
381 "OrderedList",
382 function(items, listAttributes)
383 listAttributes = listAttributes or {1, M.DefaultStyle, M.DefaultDelim}
384 return {c = {listAttributes, List:new(items)}}
385 end,
386 {{"start", "style", "delimiter"}, "content"}
389--- Creates a para element.
390-- @function Para
391-- @tparam {Inline,...} content inline content
392-- @treturn Block paragraph element
393M.Para = M.Block:create_constructor(
394 "Para",
395 function(content) return {c = List:new(content)} end,
396 "content"
399--- Creates a plain element.
400-- @function Plain
401-- @tparam {Inline,...} content inline content
402-- @treturn Block plain element
403M.Plain = M.Block:create_constructor(
404 "Plain",
405 function(content) return {c = List:new(content)} end,
406 "content"
409--- Creates a raw content block of the specified format.
410-- @function RawBlock
411-- @tparam string format format of content
412-- @tparam string text string content
413-- @treturn Block raw block element
414M.RawBlock = M.Block:create_constructor(
415 "RawBlock",
416 function(format, text) return {c = {format, text}} end,
417 {"format", "text"}
420--- Creates a table element.
421-- @function Table
422-- @tparam {Inline,...} caption table caption
423-- @tparam {AlignDefault|AlignLeft|AlignRight|AlignCenter,...} aligns alignments
424-- @tparam {int,...} widths column widths
425-- @tparam {Block,...} headers header row
426-- @tparam {{Block,...}} rows table rows
427-- @treturn Block table element
428M.Table = M.Block:create_constructor(
429 "Table",
430 function(caption, aligns, widths, headers, rows)
431 return {
432 c = {
433 List:new(caption),
434 List:new(aligns),
435 List:new(widths),
436 List:new(headers),
437 List:new(rows)
438 }
439 }
440 end,
441 {"caption", "aligns", "widths", "headers", "rows"}
445------------------------------------------------------------------------
446-- Inline
447-- @section Inline
449--- Inline element class
450M.Inline = AstElement:make_subtype'Inline'
452--- Creates a Cite inline element
453-- @function Cite
454-- @tparam {Inline,...} content List of inlines
455-- @tparam {Citation,...} citations List of citations
456-- @treturn Inline citations element
457M.Cite = M.Inline:create_constructor(
458 "Cite",
459 function(content, citations)
460 return {c = {List:new(citations), List:new(content)}}
461 end,
462 {"citations", "content"}
465--- Creates a Code inline element
466-- @function Code
467-- @tparam string text brief image description
468-- @tparam[opt] Attr attr additional attributes
469-- @treturn Inline code element
470M.Code = M.Inline:create_constructor(
471 "Code",
472 function(text, attr) return {c = {attr or M.Attr(), text}} end,
473 {{"identifier", "classes", "attributes"}, "text"}
476--- Creates an inline element representing emphasised text.
477-- @function Emph
478-- @tparam {Inline,..} content inline content
479-- @treturn Inline emphasis element
480M.Emph = M.Inline:create_constructor(
481 "Emph",
482 function(content) return {c = List:new(content)} end,
483 "content"
486--- Creates a Image inline element
487-- @function Image
488-- @tparam {Inline,..} caption text used to describe the image
489-- @tparam string src path to the image file
490-- @tparam[opt] string title brief image description
491-- @tparam[opt] Attr attr additional attributes
492-- @treturn Inline image element
493M.Image = M.Inline:create_constructor(
494 "Image",
495 function(caption, src, title, attr)
496 title = title or ""
497 attr = attr or M.Attr()
498 return {c = {attr, List:new(caption), {src, title}}}
499 end,
500 {{"identifier", "classes", "attributes"}, "caption", {"src", "title"}}
503--- Create a LineBreak inline element
504-- @function LineBreak
505-- @treturn Inline linebreak element
506M.LineBreak = M.Inline:create_constructor(
507 "LineBreak",
508 function() return {} end
511--- Creates a link inline element, usually a hyperlink.
512-- @function Link
513-- @tparam {Inline,..} content text for this link
514-- @tparam string target the link target
515-- @tparam[opt] string title brief link description
516-- @tparam[opt] Attr attr additional attributes
517-- @treturn Inline image element
518M.Link = M.Inline:create_constructor(
519 "Link",
520 function(content, target, title, attr)
521 title = title or ""
522 attr = attr or M.Attr()
523 return {c = {attr, List:new(content), {target, title}}}
524 end,
525 {{"identifier", "classes", "attributes"}, "content", {"target", "title"}}
528--- Creates a Math element, either inline or displayed.
529-- @function Math
530-- @tparam "InlineMath"|"DisplayMath" mathtype rendering specifier
531-- @tparam string text Math content
532-- @treturn Inline Math element
533M.Math = M.Inline:create_constructor(
534 "Math",
535 function(mathtype, text)
536 return {c = {mathtype, text}}
537 end,
538 {"mathtype", "text"}
540--- Creates a DisplayMath element (DEPRECATED).
541-- @function DisplayMath
542-- @tparam string text Math content
543-- @treturn Inline Math element
544M.DisplayMath = M.Inline:create_constructor(
545 "DisplayMath",
546 function(text) return M.Math("DisplayMath", text) end,
547 {"mathtype", "text"}
549--- Creates an InlineMath inline element (DEPRECATED).
550-- @function InlineMath
551-- @tparam string text Math content
552-- @treturn Inline Math element
553M.InlineMath = M.Inline:create_constructor(
554 "InlineMath",
555 function(text) return M.Math("InlineMath", text) end,
556 {"mathtype", "text"}
559--- Creates a Note inline element
560-- @function Note
561-- @tparam {Block,...} content footnote block content
562M.Note = M.Inline:create_constructor(
563 "Note",
564 function(content) return {c = List:new(content)} end,
565 "content"
568--- Creates a Quoted inline element given the quote type and quoted content.
569-- @function Quoted
570-- @tparam "DoubleQuote"|"SingleQuote" quotetype type of quotes to be used
571-- @tparam {Inline,..} content inline content
572-- @treturn Inline quoted element
573M.Quoted = M.Inline:create_constructor(
574 "Quoted",
575 function(quotetype, content) return {c = {quotetype, List:new(content)}} end,
576 {"quotetype", "content"}
578--- Creates a single-quoted inline element (DEPRECATED).
579-- @function SingleQuoted
580-- @tparam {Inline,..} content inline content
581-- @treturn Inline quoted element
582-- @see Quoted
583M.SingleQuoted = M.Inline:create_constructor(
584 "SingleQuoted",
585 function(content) return M.Quoted(M.SingleQuote, content) end,
586 {"quotetype", "content"}
588--- Creates a single-quoted inline element (DEPRECATED).
589-- @function DoubleQuoted
590-- @tparam {Inline,..} content inline content
591-- @treturn Inline quoted element
592-- @see Quoted
593M.DoubleQuoted = M.Inline:create_constructor(
594 "DoubleQuoted",
595 function(content) return M.Quoted("DoubleQuote", content) end,
596 {"quotetype", "content"}
599--- Creates a RawInline inline element
600-- @function RawInline
601-- @tparam string format format of the contents
602-- @tparam string text string content
603-- @treturn Inline raw inline element
604M.RawInline = M.Inline:create_constructor(
605 "RawInline",
606 function(format, text) return {c = {format, text}} end,
607 {"format", "text"}
610--- Creates text rendered in small caps
611-- @function SmallCaps
612-- @tparam {Inline,..} content inline content
613-- @treturn Inline smallcaps element
614M.SmallCaps = M.Inline:create_constructor(
615 "SmallCaps",
616 function(content) return {c = List:new(content)} end,
617 "content"
620--- Creates a SoftBreak inline element.
621-- @function SoftBreak
622-- @treturn Inline softbreak element
623M.SoftBreak = M.Inline:create_constructor(
624 "SoftBreak",
625 function() return {} end
628--- Create a Space inline element
629-- @function Space
630-- @treturn Inline space element
631M.Space = M.Inline:create_constructor(
632 "Space",
633 function() return {} end
636--- Creates a Span inline element
637-- @function Span
638-- @tparam {Inline,..} content inline content
639-- @tparam[opt] Attr attr additional attributes
640-- @treturn Inline span element
641M.Span = M.Inline:create_constructor(
642 "Span",
643 function(content, attr)
644 return {c = {attr or M.Attr(), List:new(content)}}
645 end,
646 {{"identifier", "classes", "attributes"}, "content"}
649--- Creates a Str inline element
650-- @function Str
651-- @tparam string text content
652-- @treturn Inline string element
653M.Str = M.Inline:create_constructor(
654 "Str",
655 function(text) return {c = text} end,
656 "text"
659--- Creates text which is striked out.
660-- @function Strikeout
661-- @tparam {Inline,..} content inline content
662-- @treturn Inline strikeout element
663M.Strikeout = M.Inline:create_constructor(
664 "Strikeout",
665 function(content) return {c = List:new(content)} end,
666 "content"
669--- Creates a Strong element, whose text is usually displayed in a bold font.
670-- @function Strong
671-- @tparam {Inline,..} content inline content
672-- @treturn Inline strong element
673M.Strong = M.Inline:create_constructor(
674 "Strong",
675 function(content) return {c = List:new(content)} end,
676 "content"
679--- Creates a Subscript inline element
680-- @function Subscript
681-- @tparam {Inline,..} content inline content
682-- @treturn Inline subscript element
683M.Subscript = M.Inline:create_constructor(
684 "Subscript",
685 function(content) return {c = List:new(content)} end,
686 "content"
689--- Creates a Superscript inline element
690-- @function Superscript
691-- @tparam {Inline,..} content inline content
692-- @treturn Inline strong element
693M.Superscript = M.Inline:create_constructor(
694 "Superscript",
695 function(content) return {c = List:new(content)} end,
696 "content"
700------------------------------------------------------------------------
701-- Element components
702-- @section components
704--- Check if the first element of a pair matches the given value.
705-- @param x key value to be checked
706-- @return function returning true iff first element of its argument matches x
707-- @local
708local function assoc_key_equals (x)
709 return function (y) return y[1] == x end
710end
712--- Lookup a value in an associative list
713-- @function lookup
714-- @local
715-- @tparam {{key, value},...} alist associative list
716-- @param key key for which the associated value is to be looked up
717local function lookup(alist, key)
718 return (List.find_if(alist, assoc_key_equals(key)) or {})[2]
719end
721--- Return an iterator which returns key-value pairs of an associative list.
722-- @function apairs
723-- @local
724-- @tparam {{key, value},...} alist associative list
725local apairs = function (alist)
726 local i = 1
727 local cur
728 function nxt ()
729 cur = rawget(alist, i)
730 if cur then
731 i = i + 1
732 return cur[1], cur[2]
733 end
734 return nil
735 end
736 return nxt, nil, nil
737end
739--- AttributeList, a metatable to allow table-like access to attribute lists
740-- represented by associative lists.
741-- @local
742local AttributeList = {
743 __index = function (t, k)
744 if type(k) == "number" then
745 return rawget(t, k)
746 else
747 return lookup(t, k)
748 end
749 end,
751 __newindex = function (t, k, v)
752 local cur, idx = List.find_if(t, assoc_key_equals(k))
753 if v == nil then
754 table.remove(t, idx)
755 elseif cur then
756 cur[2] = v
757 elseif type(k) == "number" then
758 rawset(t, k, v)
759 else
760 rawset(t, #t + 1, {k, v})
761 end
762 end,
764 __pairs = apairs
767--- Convert a table to an associative list. The order of key-value pairs in the
768-- alist is undefined. The table should either contain no numeric keys or
769-- already be an associative list.
770-- @local
771-- @tparam table tbl associative list or table without numeric keys.
772-- @treturn table associative list
773local to_alist = function (tbl)
774 if #tbl ~= 0 or next(tbl) == nil then
775 -- probably already an alist
776 return tbl
777 end
778 local alist = {}
779 local i = 1
780 for k, v in pairs(tbl) do
781 alist[i] = {k, v}
782 i = i + 1
783 end
784 return alist
785end
787-- Attr
789--- Create a new set of attributes (Attr).
790-- @function Attr
791-- @tparam[opt] string identifier element identifier
792-- @tparam[opt] {string,...} classes element classes
793-- @tparam[opt] table attributes table containing string keys and values
794-- @return element attributes
795M.Attr = AstElement:make_subtype'Attr'
796function M.Attr:new (identifier, classes, attributes)
797 identifier = identifier or ''
798 classes = List:new(classes or {})
799 attributes = setmetatable(to_alist(attributes or {}), AttributeList)
800 return {identifier, classes, attributes}
801end
802M.Attr.behavior._field_names = {identifier = 1, classes = 2, attributes = 3}
803M.Attr.behavior.__index = function(t, k)
804 return rawget(t, getmetatable(t)._field_names[k]) or
805 getmetatable(t)[k]
806end
807M.Attr.behavior.__newindex = function(t, k, v)
808 if getmetatable(t)._field_names[k] then
809 rawset(t, getmetatable(t)._field_names[k], v)
810 else
811 rawset(t, k, v)
812 end
813end
815-- Citation
816M.Citation = AstElement:make_subtype'Citation'
818--- Creates a single citation.
819-- @function Citation
820-- @tparam string id citation identifier (like a bibtex key)
821-- @tparam AuthorInText|SuppressAuthor|NormalCitation mode citation mode
822-- @tparam[opt] {Inline,...} prefix citation prefix
823-- @tparam[opt] {Inline,...} suffix citation suffix
824-- @tparam[opt] int note_num note number
825-- @tparam[opt] int hash hash number
826function M.Citation:new (id, mode, prefix, suffix, note_num, hash)
827 return {
828 id = id,
829 mode = mode,
830 prefix = prefix or {},
831 suffix = suffix or {},
832 note_num = note_num or 0,
833 hash = hash or 0,
834 }
835end
838------------------------------------------------------------------------
839-- Constants
840-- @section constants
842--- Author name is mentioned in the text.
843-- @see Citation
844-- @see Cite
845M.AuthorInText = "AuthorInText"
847--- Author name is suppressed.
848-- @see Citation
849-- @see Cite
850M.SuppressAuthor = "SuppressAuthor"
852--- Default citation style is used.
853-- @see Citation
854-- @see Cite
855M.NormalCitation = "NormalCitation"
857--- Table cells aligned left.
858-- @see Table
859M.AlignLeft = "AlignLeft"
861--- Table cells right-aligned.
862-- @see Table
863M.AlignRight = "AlignRight"
865--- Table cell content is centered.
866-- @see Table
867M.AlignCenter = "AlignCenter"
869--- Table cells are alignment is unaltered.
870-- @see Table
871M.AlignDefault = "AlignDefault"
873--- Default list number delimiters are used.
874-- @see OrderedList
875M.DefaultDelim = "DefaultDelim"
877--- List numbers are delimited by a period.
878-- @see OrderedList
879M.Period = "Period"
881--- List numbers are delimited by a single parenthesis.
882-- @see OrderedList
883M.OneParen = "OneParen"
885--- List numbers are delimited by a double parentheses.
886-- @see OrderedList
887M.TwoParens = "TwoParens"
889--- List are numbered in the default style
890-- @see OrderedList
891M.DefaultStyle = "DefaultStyle"
893--- List items are numbered as examples.
894-- @see OrderedList
895M.Example = "Example"
897--- List are numbered using decimal integers.
898-- @see OrderedList
899M.Decimal = "Decimal"
901--- List are numbered using lower-case roman numerals.
902-- @see OrderedList
903M.LowerRoman = "LowerRoman"
905--- List are numbered using upper-case roman numerals
906-- @see OrderedList
907M.UpperRoman = "UpperRoman"
909--- List are numbered using lower-case alphabetic characters.
910-- @see OrderedList
911M.LowerAlpha = "LowerAlpha"
913--- List are numbered using upper-case alphabetic characters.
914-- @see OrderedList
915M.UpperAlpha = "UpperAlpha"
917------------------------------------------------------------------------
918-- Functions which have moved to different modules
919local utils = require 'pandoc.utils'
920M.sha1 = utils.sha1
922return M