summaryrefslogtreecommitdiffstats
path: root/filters
diff options
context:
space:
mode:
Diffstat (limited to 'filters')
-rw-r--r--filters/common_actions.lua23
1 files changed, 13 insertions, 10 deletions
diff --git a/filters/common_actions.lua b/filters/common_actions.lua
index 5b6c86b..8383ada 100644
--- a/filters/common_actions.lua
+++ b/filters/common_actions.lua
@@ -1,15 +1,12 @@
1function CodeBlock(el) 1function CodeBlock(el)
2 if el.classes[1] == "plain" then 2 if el.classes[1] == "plain" then
3 el = pandoc.Div({el}, {class = 's-code'}) 3 el = pandoc.Div({ el }, { class = 's-code' })
4 elseif el.classes[1] then 4 elseif el.classes[1] then
5 local formatted = pandoc.pipe('pygmentize', { 5 local formatted = pandoc.pipe('pygmentize', {
6 '-l', el.classes[1], '-f', 'html', '-O', 6 '-l', el.classes[1], '-f', 'html', '-O', 'cssclass=s-code s-code--highlight',
7 'cssclass=s-code s-code--highlight'
8 }, el.text) 7 }, el.text)
9 8
10 if formatted then 9 if formatted then el = pandoc.RawBlock('html', formatted) end
11 el = pandoc.RawBlock('html', formatted)
12 end
13 end 10 end
14 11
15 return el 12 return el
@@ -18,11 +15,17 @@ end
18function Header(el) 15function Header(el)
19 if el.level == 1 then 16 if el.level == 1 then
20 local newchildren = pandoc.List() 17 local newchildren = pandoc.List()
21 18 newchildren:insert(pandoc.Span(el.content, { class = 's-headlines__title-inner' }))
22 newchildren:insert(pandoc.Span(el.content, {class = 's-headlines__title-inner'}))
23
24 el.content = newchildren 19 el.content = newchildren
25 end 20 end
21
22 if el.level <= 3 and el.identifier ~= '' then
23 el.content:insert(pandoc.Space())
24 el.content:insert(pandoc.Link(pandoc.RawInline('html',
25 '<svg class="o-icon"><use href="/symbols.svg#icon-link"></use></svg>'),
26 '#' .. el.identifier, nil, { class = 's-headlines__link' }))
27 end
28
26 return el 29 return el
27end 30end
28 31
@@ -36,7 +39,7 @@ function Div(el)
36 39
37 for _, children in ipairs(el.content[1].content) do 40 for _, children in ipairs(el.content[1].content) do
38 newchildren:insert(pandoc.RawBlock('html', 41 newchildren:insert(pandoc.RawBlock('html',
39 '<li class="c-page__prefixed c-page__prefixed--ref">')) 42 '<li class="c-page__prefixed c-page__prefixed--ref">'))
40 newchildren:extend(children) 43 newchildren:extend(children)
41 newchildren:insert(pandoc.RawBlock('html', '</li>')) 44 newchildren:insert(pandoc.RawBlock('html', '</li>'))
42 end 45 end