- Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathithelp.lua
More file actions
Latest commit
187 lines (155 loc) · 4.14 KB
/
Copy pathithelp.lua
File metadata and controls
187 lines (155 loc) · 4.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
-- Invoke with: pandoc -t ithelp.lua XXXXXXXX.md -o XXXXXXXX.txt
-- Original scirpt from Gist https://gist.github.com/lilydjwg/5812009
-- Inline HTML
functionRawInline(s, s2)
returns2..'\n'
end
-- Blocksep is used to separate block elements.
functionBlocksep()
return"\n\n"
end
-- This function is called once for the whole document. Parameters:
-- body, title, date are strings; authors is an array of strings;
-- variables is a table. One could use some kind of templating
-- system here; this just gives you a simple standalone HTML file.
functionDoc(body, title, authors, date, variables)
returnbody..'\n'
end
-- The functions that follow render corresponding pandoc elements.
-- s is always a string, attr is always a table of attributes, and
-- items is always an array of strings (the items in a list).
-- Comments indicate the types of other variables.
functionStr(s)
returns
end
functionSpace()
return""
end
functionLineBreak()
return"\n"
end
functionEmph(s)
return"[em]" ..s.."[/em]"
end
functionStrong(s)
return"[b]" ..s.."[/b]"
end
functionSubscript(s)
error("Subscript isn't supported")
end
functionSuperscript(s)
error("Superscript isn't supported")
end
functionSmallCaps(s)
error("SmallCaps isn't supported")
end
functionStrikeout(s)
return'[del]' ..s..'[/del]'
end
functionLink(s, src, tit)
localret='[url'
ifsthen
ret=ret..'=' ..src
else
s=src
end
ret=ret.."]" ..s.."[/url]"
returnret
end
-- Fix Me
functionCaptionedImage(s, src, tit)
-- return "[img=" .. tit .. "]" .. src .. "[/img]"
ifstring.len(tit) >0then
return"[img]" ..s.."[/img]" .."\n" .."(" ..tit..")"
else
return"[img]" ..s.."[/img]"
end
end
functionImage(s, src, tit)
return"[img=" ..tit.."]" ..src.."[/img]"
end
functionCode(s, attr)
return"[u]" ..s.."[/u]"
end
functionInlineMath(s)
error("InlineMath isn't supported")
end
functionDisplayMath(s)
error("DisplayMath isn't supported")
end
functionNote(s)
error("Note isn't supported")
end
functionPlain(s)
returns
end
functionPara(s)
returns
end
-- lev is an integer, the header level.
functionHeader(lev, s, attr)
return"[size=20px][color=blue][font=Sans Serif]" ..s.."[/font][/color][/size]"
end
functionBlockQuote(s)
return"[quote]\n" ..s.."\n[/quote]"
end
functionHorizontalRule()
return"--------------------------------------------------------------------------------"
end
functionCodeBlock(s, attr)
return"[code]\n" ..s..'\n[/code]'
end
functionBulletList(items)
localbuffer= {}
for_, iteminipairs(items) do
table.insert(buffer, " * " ..item)
end
returntable.concat(buffer, "\n")
end
functionOrderedList(items)
localbuffer= {}
for_, iteminipairs(items) do
table.insert(buffer, " * " ..item)
end
returntable.concat(buffer, "\n")
end
-- Revisit association list STackValue instance.
functionDefinitionList(items)
localbuffer= {}
for_, iteminpairs(items) do
fork, vinpairs(item) do
table.insert(buffer, "[b]" ..k.."[/b]:\n" ..
table.concat(v, "\n"))
end
end
returntable.concat(buffer, "\n")
end
-- Convert pandoc alignment to something HTML can use.
-- align is AlignLeft, AlignRight, AlignCenter, or AlignDefault.
functionhtml_align(align)
ifalign=='AlignLeft' then
return'left'
elseifalign=='AlignRight' then
return'right'
elseifalign=='AlignCenter' then
return'center'
else
return'left'
end
end
-- Caption is a string, aligns is an array of strings,
-- widths is an array of floats, headers is an array of
-- strings, rows is an array of arrays of strings.
functionTable(caption, aligns, widths, headers, rows)
error("Table isn't supported")
end
-- The following code will produce runtime warnings when you haven't defined
-- all of the functions you need for the custom writer, so it's useful
-- to include when you're working on a writer.
localmeta= {}
meta.__index=
function(_, key)
io.stderr:write(string.format("WARNING: Undefined function '%s'\n",key))
returnfunction() return"" end
end
setmetatable(_G, meta)