summaryrefslogtreecommitdiffstats
path: root/filters
diff options
context:
space:
mode:
Diffstat (limited to 'filters')
-rw-r--r--filters/common_actions.lua45
-rw-r--r--filters/element_classes.lua15
-rw-r--r--filters/macros.lua23
3 files changed, 45 insertions, 38 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
diff --git a/filters/element_classes.lua b/filters/element_classes.lua
deleted file mode 100644
index 643ff75..0000000
--- a/filters/element_classes.lua
+++ /dev/null
@@ -1,15 +0,0 @@
1function CodeBlock(el)
2 el.attributes.class = 'c-page__prefixed c-page__prefixed--pre'
3 return el
4end
5
6function Header(el)
7 if el.level == 1 then
8 el.attributes.class = 'c-page__prefixed c-page__prefixed--h1'
9 elseif el.level == 2 then
10 el.attributes.class = 'c-page__prefixed c-page__prefixed--h2'
11 elseif el.level == 3 then
12 el.attributes.class = 'c-page__prefixed c-page__prefixed--h3'
13 end
14 return el
15end
diff --git a/filters/macros.lua b/filters/macros.lua
deleted file mode 100644
index 86e94ba..0000000
--- a/filters/macros.lua
+++ /dev/null
@@ -1,23 +0,0 @@
1function Div(el)
2 if el.attributes.macro == nil then
3 return el
4 end
5
6 if el.attributes.macro == 'refs' and el.content[1].tag == 'BulletList' then
7 local newchildren = pandoc.List()
8
9 newchildren:insert(pandoc.RawBlock('html', '<ul>'))
10
11 for k, children in ipairs(el.content[1].content) do
12 newchildren:insert(pandoc.RawBlock('html', '<li class="c-page__prefixed c-page__prefixed--ref">'))
13 newchildren:extend(children)
14 newchildren:insert(pandoc.RawBlock('html', '</li>'))
15 end
16
17 newchildren:insert(pandoc.RawBlock('html', '</ul>'))
18
19 el.content = newchildren
20 end
21
22 return el.content
23end