summaryrefslogtreecommitdiffstats
path: root/filters/common_actions.lua
diff options
context:
space:
mode:
authorVolpeon <git@volpeon.ink>2021-01-02 16:47:15 +0100
committerVolpeon <git@volpeon.ink>2021-01-02 16:47:15 +0100
commit14375c5289e84690cacd0ec9b511cefef088f0a5 (patch)
tree6465075e5255be2851a7678d1a629ed23cd810b3 /filters/common_actions.lua
parentSmall design revisions (diff)
downloadvolpeon.ink-14375c5289e84690cacd0ec9b511cefef088f0a5.tar.gz
volpeon.ink-14375c5289e84690cacd0ec9b511cefef088f0a5.tar.bz2
volpeon.ink-14375c5289e84690cacd0ec9b511cefef088f0a5.zip
Use Pygments for syntax highlighting, design adjustments, preload fonts
Diffstat (limited to 'filters/common_actions.lua')
-rw-r--r--filters/common_actions.lua45
1 files changed, 45 insertions, 0 deletions
diff --git a/filters/common_actions.lua b/filters/common_actions.lua
new file mode 100644
index 0000000..1d13e3a
--- /dev/null
+++ b/filters/common_actions.lua
@@ -0,0 +1,45 @@
1function CodeBlock(el)
2 if next(el.classes) == nil then
3 el.classes = el.classes .. {'c-page__prefixed', 'c-page__prefixed--pre'}
4 else
5 local formatted = pandoc.pipe('pygmentize', {'-l', el.classes[1], '-f', 'html', '-O', 'cssclass=c-page__code s-code'}, el.text)
6 el = pandoc.RawBlock('html', formatted)
7 end
8
9 return el
10end
11
12function Header(el)
13 if el.level == 1 then
14 el.classes = el.classes .. {'c-page__prefixed', 'c-page__prefixed--h1'}
15 elseif el.level == 2 then
16 el.classes = el.classes .. {'c-page__prefixed', 'c-page__prefixed--h2'}
17 elseif el.level == 3 then
18 el.classes = el.classes .. {'c-page__prefixed', 'c-page__prefixed--h3'}
19 end
20 return el
21end
22
23function Div(el)
24 if el.attributes.macro == nil then
25 return el
26 end
27
28 if el.attributes.macro == 'refs' and el.content[1].tag == 'BulletList' then
29 local newchildren = pandoc.List()
30
31 newchildren:insert(pandoc.RawBlock('html', '<ul>'))
32
33 for k, children in ipairs(el.content[1].content) do
34 newchildren:insert(pandoc.RawBlock('html', '<li class="c-page__prefixed c-page__prefixed--ref">'))
35 newchildren:extend(children)
36 newchildren:insert(pandoc.RawBlock('html', '</li>'))
37 end
38
39 newchildren:insert(pandoc.RawBlock('html', '</ul>'))
40
41 el.content = newchildren
42 end
43
44 return el.content
45end