summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile8
-rw-r--r--filters/code.lua13
-rw-r--r--filters/headers.lua9
-rw-r--r--filters/icons.lua11
-rw-r--r--filters/macros.lua57
-rw-r--r--templates/layouts/page.html4
6 files changed, 62 insertions, 40 deletions
diff --git a/Makefile b/Makefile
index 7cdea67..d8dc0db 100644
--- a/Makefile
+++ b/Makefile
@@ -55,7 +55,7 @@ subpages = $(patsubst content/%.md,.cache/meta/%.json, \
55 $(eval NAMESPACE = $(call namespace,$@,.cache/meta)) 55 $(eval NAMESPACE = $(call namespace,$@,.cache/meta))
56 $(if $(PAGES_FILES),jq -s --arg namespace "$(NAMESPACE)" -f scripts/subpages.jq $(PAGES_FILES) > "$@.pages",echo "{}" > "$@.pages") 56 $(if $(PAGES_FILES),jq -s --arg namespace "$(NAMESPACE)" -f scripts/subpages.jq $(PAGES_FILES) > "$@.pages",echo "{}" > "$@.pages")
57 pandoc \ 57 pandoc \
58 -f markdown-citations \ 58 -f markdown-citations-implicit_figures \
59 -t html5 \ 59 -t html5 \
60 --wrap preserve \ 60 --wrap preserve \
61 --no-highlight \ 61 --no-highlight \
@@ -66,7 +66,7 @@ subpages = $(patsubst content/%.md,.cache/meta/%.json, \
66 $(PANDOC_FILTERS) \ 66 $(PANDOC_FILTERS) \
67 -o "$@.meta" "$<" 67 -o "$@.meta" "$<"
68 pandoc \ 68 pandoc \
69 -f markdown-citations \ 69 -f markdown-citations-implicit_figures \
70 -t html5 \ 70 -t html5 \
71 --wrap preserve \ 71 --wrap preserve \
72 --lua-filter scripts/metadata_filter.lua \ 72 --lua-filter scripts/metadata_filter.lua \
@@ -86,7 +86,7 @@ out/%.html: content/%.md .cache/meta/%.json $(CONTENT_TEMPLATES_SRC) metadata/*.
86 86
87 mkdir -p $(@D) 87 mkdir -p $(@D)
88 pandoc \ 88 pandoc \
89 -f markdown-citations \ 89 -f markdown-citations-implicit_figures \
90 -t html5 \ 90 -t html5 \
91 --wrap preserve \ 91 --wrap preserve \
92 --no-highlight \ 92 --no-highlight \
@@ -104,7 +104,7 @@ out/%.xml: content/%.md .cache/meta/%.json $(FEED_TEMPLATES_SRC) metadata/*.yaml
104 104
105 mkdir -p $(@D) 105 mkdir -p $(@D)
106 pandoc \ 106 pandoc \
107 -f markdown-citations \ 107 -f markdown-citations-implicit_figures \
108 -t html5 \ 108 -t html5 \
109 --wrap preserve \ 109 --wrap preserve \
110 --no-highlight \ 110 --no-highlight \
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
diff --git a/templates/layouts/page.html b/templates/layouts/page.html
index a91d6ad..f65a1cf 100644
--- a/templates/layouts/page.html
+++ b/templates/layouts/page.html
@@ -16,8 +16,10 @@
16 <span class="s-headings__primary">$title$</span> 16 <span class="s-headings__primary">$title$</span>
17 </h1> 17 </h1>
18 18
19 <div class="l-container l-container--narrow u-ml-0 s-body s-colored-links s-headings s-blockquotes s-code s-lists s-tables s-alerts e-content" itemprop="articleBody"> 19 <div class="s-body s-colored-links s-headings s-blockquotes s-code s-lists s-tables s-alerts e-content" itemprop="articleBody">
20 <div class="l-container l-container--narrow u-ml-0">
20$body$ 21$body$
22 </div>
21 </div> 23 </div>
22 24
23 $if(references)$ 25 $if(references)$