diff options
author | Volpeon <git@volpeon.ink> | 2022-06-17 12:14:08 +0200 |
---|---|---|
committer | Volpeon <git@volpeon.ink> | 2022-06-17 12:14:08 +0200 |
commit | 9a51c988fedef7624a3f999a8e6c8dab057429b6 (patch) | |
tree | 31415f41b87b547e9d830cdd922ce1fcacc18821 /filters | |
parent | Update (diff) | |
download | volpeon.ink-9a51c988fedef7624a3f999a8e6c8dab057429b6.tar.gz volpeon.ink-9a51c988fedef7624a3f999a8e6c8dab057429b6.tar.bz2 volpeon.ink-9a51c988fedef7624a3f999a8e6c8dab057429b6.zip |
Make some page elements wide
Diffstat (limited to 'filters')
-rw-r--r-- | filters/code.lua | 13 | ||||
-rw-r--r-- | filters/headers.lua | 9 | ||||
-rw-r--r-- | filters/icons.lua | 11 | ||||
-rw-r--r-- | filters/macros.lua | 57 |
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 @@ | |||
1 | function 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 | ||
13 | end | ||
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 @@ | |||
1 | function 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 | ||
9 | end | ||
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 @@ | |||
1 | function 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 | ||
11 | end | ||
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 @@ | |||
1 | function 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 | ||
9 | end | ||
10 | |||
1 | function alert(el) | 11 | function 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) | ||
7 | end | 18 | end |
8 | 19 | ||
9 | function figure(el) | 20 | function 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) | ||
20 | end | 33 | end |
21 | 34 | ||
22 | function Div(el) | 35 | function Div(el) |
@@ -28,3 +41,43 @@ function Div(el) | |||
28 | 41 | ||
29 | return el | 42 | return el |
30 | end | 43 | end |
44 | |||
45 | function 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) | ||
57 | end | ||
58 | |||
59 | function 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 | ||
67 | end | ||
68 | |||
69 | function Table(el) | ||
70 | return wide(el) | ||
71 | end | ||
72 | |||
73 | function 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 | ||
83 | end | ||