|
1
|
|
|
# This Python file uses the following encoding: utf-8 |
|
2
|
|
|
|
|
3
|
|
|
from pandocfilters import Link, Str, Space |
|
4
|
|
|
|
|
5
|
|
|
import pandoc_numbering |
|
6
|
|
|
|
|
7
|
|
|
def init(): |
|
8
|
|
|
pandoc_numbering.count = {} |
|
9
|
|
|
pandoc_numbering.information = {} |
|
10
|
|
|
pandoc_numbering.collections = {} |
|
11
|
|
|
pandoc_numbering.headers = [0, 0, 0, 0, 0, 0] |
|
12
|
|
|
if hasattr(pandoc_numbering.getCiteShortCut, 'value'): |
|
13
|
|
|
delattr(pandoc_numbering.getCiteShortCut, 'value') |
|
14
|
|
|
if hasattr(pandoc_numbering.getDefaultLevels, 'value'): |
|
15
|
|
|
delattr(pandoc_numbering.getDefaultLevels, 'value') |
|
16
|
|
|
if hasattr(pandoc_numbering.getClasses, 'value'): |
|
17
|
|
|
delattr(pandoc_numbering.getClasses, 'value') |
|
18
|
|
|
if hasattr(pandoc_numbering.getFormat, 'value'): |
|
19
|
|
|
delattr(pandoc_numbering.getFormat, 'value') |
|
20
|
|
|
|
|
21
|
|
|
def createLink(attributes, text, reference_title): |
|
22
|
|
|
if pandoc_numbering.pandocVersion() < '1.16': |
|
23
|
|
|
return Link(text, reference_title) |
|
24
|
|
|
else: |
|
25
|
|
|
return Link(attributes, text, reference_title) |
|
26
|
|
|
|
|
27
|
|
|
def createMetaList(data): |
|
28
|
|
|
return {'t': 'MetaList', 'c': data} |
|
29
|
|
|
|
|
30
|
|
|
def createMetaMap(data): |
|
31
|
|
|
return {'t': 'MetaMap', 'c': data} |
|
32
|
|
|
|
|
33
|
|
|
def createMetaInlines(string): |
|
34
|
|
|
return {'t': 'MetaInlines', 'c': createListStr(string)} |
|
35
|
|
|
|
|
36
|
|
|
def createMetaString(string): |
|
37
|
|
|
return {'t': 'MetaString', 'c': string} |
|
38
|
|
|
|
|
39
|
|
|
def createMetaBool(boolean): |
|
40
|
|
|
return {'t': 'MetaBool', 'c': boolean} |
|
41
|
|
|
|
|
42
|
|
|
def createListStr(string): |
|
43
|
|
|
elements = string.split(' ') |
|
44
|
|
|
result = [Str(elements[0])] |
|
45
|
|
|
for elt in elements[1:]: |
|
46
|
|
|
result.append(Space()) |
|
47
|
|
|
result.append(Str(elt)) |
|
48
|
|
|
return result |
|
49
|
|
|
|
|
50
|
|
|
|