From 14375c5289e84690cacd0ec9b511cefef088f0a5 Mon Sep 17 00:00:00 2001 From: Volpeon Date: Sat, 2 Jan 2021 16:47:15 +0100 Subject: Use Pygments for syntax highlighting, design adjustments, preload fonts --- filters/common_actions.lua | 45 +++++++++++++++++++++++++++++++++++++++++++++ filters/element_classes.lua | 15 --------------- filters/macros.lua | 23 ----------------------- 3 files changed, 45 insertions(+), 38 deletions(-) create mode 100644 filters/common_actions.lua delete mode 100644 filters/element_classes.lua delete mode 100644 filters/macros.lua (limited to 'filters') diff --git a/filters/common_actions.lua b/filters/common_actions.lua new file mode 100644 index 0000000..1d13e3a --- /dev/null +++ b/filters/common_actions.lua @@ -0,0 +1,45 @@ +function CodeBlock(el) + if next(el.classes) == nil then + el.classes = el.classes .. {'c-page__prefixed', 'c-page__prefixed--pre'} + else + local formatted = pandoc.pipe('pygmentize', {'-l', el.classes[1], '-f', 'html', '-O', 'cssclass=c-page__code s-code'}, el.text) + el = pandoc.RawBlock('html', formatted) + end + + return el +end + +function Header(el) + if el.level == 1 then + el.classes = el.classes .. {'c-page__prefixed', 'c-page__prefixed--h1'} + elseif el.level == 2 then + el.classes = el.classes .. {'c-page__prefixed', 'c-page__prefixed--h2'} + elseif el.level == 3 then + el.classes = el.classes .. {'c-page__prefixed', 'c-page__prefixed--h3'} + 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/element_classes.lua b/filters/element_classes.lua deleted file mode 100644 index 643ff75..0000000 --- a/filters/element_classes.lua +++ /dev/null @@ -1,15 +0,0 @@ -function CodeBlock(el) - el.attributes.class = 'c-page__prefixed c-page__prefixed--pre' - return el -end - -function Header(el) - if el.level == 1 then - el.attributes.class = 'c-page__prefixed c-page__prefixed--h1' - elseif el.level == 2 then - el.attributes.class = 'c-page__prefixed c-page__prefixed--h2' - elseif el.level == 3 then - el.attributes.class = 'c-page__prefixed c-page__prefixed--h3' - end - return el -end diff --git a/filters/macros.lua b/filters/macros.lua deleted file mode 100644 index 86e94ba..0000000 --- a/filters/macros.lua +++ /dev/null @@ -1,23 +0,0 @@ -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 -- cgit v1.2.3-70-g09d2