From 9a51c988fedef7624a3f999a8e6c8dab057429b6 Mon Sep 17 00:00:00 2001 From: Volpeon Date: Fri, 17 Jun 2022 12:14:08 +0200 Subject: Make some page elements wide --- Makefile | 8 +++---- filters/code.lua | 13 ----------- filters/headers.lua | 9 ------- filters/icons.lua | 11 --------- filters/macros.lua | 57 +++++++++++++++++++++++++++++++++++++++++++-- templates/layouts/page.html | 4 +++- 6 files changed, 62 insertions(+), 40 deletions(-) delete mode 100644 filters/code.lua delete mode 100644 filters/headers.lua delete mode 100644 filters/icons.lua 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, \ $(eval NAMESPACE = $(call namespace,$@,.cache/meta)) $(if $(PAGES_FILES),jq -s --arg namespace "$(NAMESPACE)" -f scripts/subpages.jq $(PAGES_FILES) > "$@.pages",echo "{}" > "$@.pages") pandoc \ - -f markdown-citations \ + -f markdown-citations-implicit_figures \ -t html5 \ --wrap preserve \ --no-highlight \ @@ -66,7 +66,7 @@ subpages = $(patsubst content/%.md,.cache/meta/%.json, \ $(PANDOC_FILTERS) \ -o "$@.meta" "$<" pandoc \ - -f markdown-citations \ + -f markdown-citations-implicit_figures \ -t html5 \ --wrap preserve \ --lua-filter scripts/metadata_filter.lua \ @@ -86,7 +86,7 @@ out/%.html: content/%.md .cache/meta/%.json $(CONTENT_TEMPLATES_SRC) metadata/*. mkdir -p $(@D) pandoc \ - -f markdown-citations \ + -f markdown-citations-implicit_figures \ -t html5 \ --wrap preserve \ --no-highlight \ @@ -104,7 +104,7 @@ out/%.xml: content/%.md .cache/meta/%.json $(FEED_TEMPLATES_SRC) metadata/*.yaml mkdir -p $(@D) pandoc \ - -f markdown-citations \ + -f markdown-citations-implicit_figures \ -t html5 \ --wrap preserve \ --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 @@ -function CodeBlock(el) - if el.classes[1] == "plain" then - el = pandoc.Div({ el }, { class = 's-code' }) - elseif el.classes[1] then - local formatted = pandoc.pipe('pygmentize', { - '-l', el.classes[1], '-f', 'html', '-O', 'cssclass=s-code s-code--highlight', - }, el.text) - - if formatted then el = pandoc.RawBlock('html', formatted) end - end - - return el -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 @@ -function Header(el) - if el.level <= 3 then - local newchildren = pandoc.List() - newchildren:insert(pandoc.Span(el.content, { class = 's-headings__primary' })) - el.content = newchildren - end - - return el -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 @@ -function Str(el) - local icon = el.text:match('^:(.*):$') - - if icon then - return pandoc.RawInline('html', - '') - end - - return el -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 @@ +function wide(el) + local els = pandoc.List() + + els:insert(pandoc.RawBlock("html", "")) + els:insert(el) + els:insert(pandoc.RawBlock("html", "
")) + + return els +end + function alert(el) el.classes = pandoc.List() el.classes:insert("o-alert") el.classes:insert("o-alert--primary") el.classes:insert("s-alerts__alert") - return el + + return wide(el) end function figure(el) @@ -11,12 +22,14 @@ function figure(el) pandoc.walk_block(el, { Image = function(iel) images:insert(iel) end }) - return pandoc.RawBlock("html", + el = pandoc.RawBlock("html", "
\ \ \ \
") + + return wide(el) end function Div(el) @@ -28,3 +41,43 @@ function Div(el) return el end + +function CodeBlock(el) + if el.classes[1] == "plain" then + el = pandoc.Div({ el }, { class = 's-code' }) + elseif el.classes[1] then + local formatted = pandoc.pipe('pygmentize', { + '-l', el.classes[1], '-f', 'html', '-O', 'cssclass=s-code s-code--highlight', + }, el.text) + + if formatted then el = pandoc.RawBlock('html', formatted) end + end + + return wide(el) +end + +function Header(el) + if el.level <= 3 then + local newchildren = pandoc.List() + newchildren:insert(pandoc.Span(el.content, { class = 's-headings__primary' })) + el.content = newchildren + end + + return el +end + +function Table(el) + return wide(el) +end + +function Str(el) + local icon = el.text:match('^:(.*):$') + + if icon then + return pandoc.RawInline('html', + '') + end + + return el +end 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 @@ $title$ -