From 28527ca2a2336c371966cef441247f11a6805686 Mon Sep 17 00:00:00 2001 From: Volpeon Date: Tue, 16 Nov 2021 17:43:15 +0100 Subject: Make variables accessible from content files --- content/projects/emojis/blobfox/index.md | 9 +++--- content/projects/emojis/bunhd/index.md | 9 +++--- content/projects/emojis/vlpn/index.md | 9 +++--- filters/code.lua | 13 ++++++++ filters/common_actions.lua | 53 -------------------------------- filters/headers.lua | 16 ++++++++++ filters/vars.lua | 38 +++++++++++++++++++++++ 7 files changed, 82 insertions(+), 65 deletions(-) create mode 100644 filters/code.lua delete mode 100644 filters/common_actions.lua create mode 100644 filters/headers.lua create mode 100644 filters/vars.lua diff --git a/content/projects/emojis/blobfox/index.md b/content/projects/emojis/blobfox/index.md index b0029c4..5009575 100644 --- a/content/projects/emojis/blobfox/index.md +++ b/content/projects/emojis/blobfox/index.md @@ -1,12 +1,13 @@ --- -title: Blobfox -category: emojis -preview: preview.jpg +title: Blobfox +category: emojis +last_update: 2020-09-04 +preview: preview.jpg --- ![](screenshot.png) -**Latest release:** v1.6 (2020-09-04 18:02 CEST) +**Latest release:** v1.6 (%last_update.yyyy_mm_dd%) **Download:** [regular version](blobfox.zip), [flipped version](blobfox_flip.zip) To install these emojis on Pleroma, you can run the following commands: diff --git a/content/projects/emojis/bunhd/index.md b/content/projects/emojis/bunhd/index.md index e46c524..e3b24fd 100644 --- a/content/projects/emojis/bunhd/index.md +++ b/content/projects/emojis/bunhd/index.md @@ -1,12 +1,13 @@ --- -title: BunHD -category: emojis -preview: preview.png +title: BunHD +category: emojis +last_update: 2019-09-30 +preview: preview.png --- ![](screenshot.png) -**Latest release:** v1.2.1 (2019-09-30 16:26 CET) +**Latest release:** v1.2.1 (%last_update.yyyy_mm_dd%) **Download:** [regular version](bunhd.zip), [flipped version](bunhd_flip.zip) To install these emojis on Pleroma, you can run the following commands: diff --git a/content/projects/emojis/vlpn/index.md b/content/projects/emojis/vlpn/index.md index e63ccfc..bbc2d5d 100644 --- a/content/projects/emojis/vlpn/index.md +++ b/content/projects/emojis/vlpn/index.md @@ -1,12 +1,13 @@ --- -title: vlpn -category: emojis -preview: preview.png +title: vlpn +category: emojis +last_update: 2021-07-23 +preview: preview.png --- ![](preview.png) -**Latest release:** v1.1 (2021-07-23) +**Latest release:** v1.1 (%last_update.yyyy_mm_dd%) **[Download](vlpn.zip)** To install these emojis on Pleroma, you can run the following command: diff --git a/filters/code.lua b/filters/code.lua new file mode 100644 index 0000000..aca3ce8 --- /dev/null +++ b/filters/code.lua @@ -0,0 +1,13 @@ +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/common_actions.lua b/filters/common_actions.lua deleted file mode 100644 index cfe2d58..0000000 --- a/filters/common_actions.lua +++ /dev/null @@ -1,53 +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 - -function Header(el) - if el.level == 1 then - local newchildren = pandoc.List() - newchildren:insert(pandoc.Span(el.content, { class = 's-headlines__title-inner' })) - el.content = newchildren - end - - if el.level <= 3 and el.identifier ~= '' then - el.content:insert(pandoc.Space()) - el.content:insert(pandoc.Link(pandoc.RawInline('html', - ''), - '#' .. el.identifier, nil, { class = 's-headlines__link' })) - end - - return el -end - -function Div(el) - if el.attributes.macro == nil then return el end - - if el.attributes.macro == 'refs' and el.content[1].tag == 'BulletList' then - local newchildren = pandoc.List() - - newchildren:insert(pandoc.RawBlock('html', '')) - - el.content = newchildren - end - - return el.content -end diff --git a/filters/headers.lua b/filters/headers.lua new file mode 100644 index 0000000..4e3a689 --- /dev/null +++ b/filters/headers.lua @@ -0,0 +1,16 @@ +function Header(el) + if el.level == 1 then + local newchildren = pandoc.List() + newchildren:insert(pandoc.Span(el.content, { class = 's-headlines__title-inner' })) + el.content = newchildren + end + + if el.level <= 3 and el.identifier ~= '' then + el.content:insert(pandoc.Space()) + el.content:insert(pandoc.Link(pandoc.RawInline('html', + ''), + '#' .. el.identifier, nil, { class = 's-headlines__link' })) + end + + return el +end diff --git a/filters/vars.lua b/filters/vars.lua new file mode 100644 index 0000000..e60019e --- /dev/null +++ b/filters/vars.lua @@ -0,0 +1,38 @@ +local vars = {} + +function string.split(str, sep) + sep = sep or '%s' + + local parts = pandoc.List() + + for field, s in str:gmatch("([^" .. sep .. "]*)(" .. sep .. "?)") do + parts:insert(field) + if s == "" then return parts end + end +end + +function meta(meta) vars = meta end + +function str(el) + local prefix, varref, suffix = el.text:match('^(.*)%%(.*)%%(.*)$') + + if varref then + local parts = varref:split(".") + local var = vars + + for i = 1, #parts do + local part = parts[i] + local v = var[part] + + if not v then return el end + + var = v + end + + if var then return pandoc.Str(prefix .. var .. suffix) end + end + + return el +end + +return { { Meta = meta }, { Str = str } } -- cgit v1.2.3-54-g00ecf