summaryrefslogtreecommitdiffstats
path: root/filters
diff options
context:
space:
mode:
Diffstat (limited to 'filters')
-rw-r--r--filters/code.lua13
-rw-r--r--filters/headers.lua9
-rw-r--r--filters/icons.lua11
-rw-r--r--filters/macros.lua57
4 files changed, 55 insertions, 35 deletions
diff --git a/filters/code.lua b/filters/code.lua
deleted file mode 100644
index aca3ce8..0000000
--- a/filters/code.lua
+++ /dev/null
@@ -1,13 +0,0 @@
1function CodeBlock(el)
2 if el.classes[1] == "plain" then
3 el = pandoc.Div({ el }, { class = 's-code' })
4 elseif el.classes[1] then
5 local formatted = pandoc.pipe('pygmentize', {
6 '-l', el.classes[1], '-f', 'html', '-O', 'cssclass=s-code s-code--highlight',
7 }, el.text)
8
9 if formatted then el = pandoc.RawBlock('html', formatted) end
10 end
11
12 return el
13end
diff --git a/filters/headers.lua b/filters/headers.lua
deleted file mode 100644
index ea9cde6..0000000
--- a/filters/headers.lua
+++ /dev/null
@@ -1,9 +0,0 @@
1function Header(el)
2 if el.level <= 3 then
3 local newchildren = pandoc.List()
4 newchildren:insert(pandoc.Span(el.content, { class = 's-headings__primary' }))
5 el.content = newchildren
6 end
7
8 return el
9end
diff --git a/filters/icons.lua b/filters/icons.lua
deleted file mode 100644
index 3f8cb64..0000000
--- a/filters/icons.lua
+++ /dev/null
@@ -1,11 +0,0 @@
1function Str(el)
2 local icon = el.text:match('^:(.*):$')
3
4 if icon then
5 return pandoc.RawInline('html',
6 '<svg class="o-icon o-icon--inline" width="1em" height="1em" aria-hidden="true"><use href="/icons.svg#' ..
7 icon .. '"></use></svg>')
8 end
9
10 return el
11end
diff --git a/filters/macros.lua b/filters/macros.lua
index ca0b487..df08676 100644
--- a/filters/macros.lua
+++ b/filters/macros.lua
@@ -1,9 +1,20 @@
1function wide(el)
2 local els = pandoc.List()
3
4 els:insert(pandoc.RawBlock("html", "</div>"))
5 els:insert(el)
6 els:insert(pandoc.RawBlock("html", "<div class=\"l-container l-container--narrow u-ml-0\">"))
7
8 return els
9end
10
1function alert(el) 11function alert(el)
2 el.classes = pandoc.List() 12 el.classes = pandoc.List()
3 el.classes:insert("o-alert") 13 el.classes:insert("o-alert")
4 el.classes:insert("o-alert--primary") 14 el.classes:insert("o-alert--primary")
5 el.classes:insert("s-alerts__alert") 15 el.classes:insert("s-alerts__alert")
6 return el 16
17 return wide(el)
7end 18end
8 19
9function figure(el) 20function figure(el)
@@ -11,12 +22,14 @@ function figure(el)
11 22
12 pandoc.walk_block(el, { Image = function(iel) images:insert(iel) end }) 23 pandoc.walk_block(el, { Image = function(iel) images:insert(iel) end })
13 24
14 return pandoc.RawBlock("html", 25 el = pandoc.RawBlock("html",
15 "<figure class=\"c-figure\">\ 26 "<figure class=\"c-figure\">\
16 <a class=\"c-figure__link\" href=\"" .. images[1].src .. "\">\ 27 <a class=\"c-figure__link\" href=\"" .. images[1].src .. "\">\
17 <img class=\"c-figure__image\" src=\"" .. images[1].src .. "\" title=\"" .. images[1].title .. "\" />\ 28 <img class=\"c-figure__image\" src=\"" .. images[1].src .. "\" title=\"" .. images[1].title .. "\" />\
18 </a>\ 29 </a>\
19 </figure>") 30 </figure>")
31
32 return wide(el)
20end 33end
21 34
22function Div(el) 35function Div(el)
@@ -28,3 +41,43 @@ function Div(el)
28 41
29 return el 42 return el
30end 43end
44
45function CodeBlock(el)
46 if el.classes[1] == "plain" then
47 el = pandoc.Div({ el }, { class = 's-code' })
48 elseif el.classes[1] then
49 local formatted = pandoc.pipe('pygmentize', {
50 '-l', el.classes[1], '-f', 'html', '-O', 'cssclass=s-code s-code--highlight',
51 }, el.text)
52
53 if formatted then el = pandoc.RawBlock('html', formatted) end
54 end
55
56 return wide(el)
57end
58
59function Header(el)
60 if el.level <= 3 then
61 local newchildren = pandoc.List()
62 newchildren:insert(pandoc.Span(el.content, { class = 's-headings__primary' }))
63 el.content = newchildren
64 end
65
66 return el
67end
68
69function Table(el)
70 return wide(el)
71end
72
73function Str(el)
74 local icon = el.text:match('^:(.*):$')
75
76 if icon then
77 return pandoc.RawInline('html',
78 '<svg class="o-icon o-icon--inline" width="1em" height="1em" aria-hidden="true"><use href="/icons.svg#' ..
79 icon .. '"></use></svg>')
80 end
81
82 return el
83end