diff options
| author | Volpeon <git@volpeon.ink> | 2021-01-02 16:47:15 +0100 |
|---|---|---|
| committer | Volpeon <git@volpeon.ink> | 2021-01-02 16:47:15 +0100 |
| commit | 14375c5289e84690cacd0ec9b511cefef088f0a5 (patch) | |
| tree | 6465075e5255be2851a7678d1a629ed23cd810b3 /filters | |
| parent | Small design revisions (diff) | |
| download | volpeon.ink-14375c5289e84690cacd0ec9b511cefef088f0a5.tar.gz volpeon.ink-14375c5289e84690cacd0ec9b511cefef088f0a5.tar.bz2 volpeon.ink-14375c5289e84690cacd0ec9b511cefef088f0a5.zip | |
Use Pygments for syntax highlighting, design adjustments, preload fonts
Diffstat (limited to 'filters')
| -rw-r--r-- | filters/common_actions.lua | 45 | ||||
| -rw-r--r-- | filters/element_classes.lua | 15 | ||||
| -rw-r--r-- | filters/macros.lua | 23 |
3 files changed, 45 insertions, 38 deletions
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 @@ | |||
| 1 | function CodeBlock(el) | ||
| 2 | if next(el.classes) == nil then | ||
| 3 | el.classes = el.classes .. {'c-page__prefixed', 'c-page__prefixed--pre'} | ||
| 4 | else | ||
| 5 | local formatted = pandoc.pipe('pygmentize', {'-l', el.classes[1], '-f', 'html', '-O', 'cssclass=c-page__code s-code'}, el.text) | ||
| 6 | el = pandoc.RawBlock('html', formatted) | ||
| 7 | end | ||
| 8 | |||
| 9 | return el | ||
| 10 | end | ||
| 11 | |||
| 12 | function Header(el) | ||
| 13 | if el.level == 1 then | ||
| 14 | el.classes = el.classes .. {'c-page__prefixed', 'c-page__prefixed--h1'} | ||
| 15 | elseif el.level == 2 then | ||
| 16 | el.classes = el.classes .. {'c-page__prefixed', 'c-page__prefixed--h2'} | ||
| 17 | elseif el.level == 3 then | ||
| 18 | el.classes = el.classes .. {'c-page__prefixed', 'c-page__prefixed--h3'} | ||
| 19 | end | ||
| 20 | return el | ||
| 21 | end | ||
| 22 | |||
| 23 | function Div(el) | ||
| 24 | if el.attributes.macro == nil then | ||
| 25 | return el | ||
| 26 | end | ||
| 27 | |||
| 28 | if el.attributes.macro == 'refs' and el.content[1].tag == 'BulletList' then | ||
| 29 | local newchildren = pandoc.List() | ||
| 30 | |||
| 31 | newchildren:insert(pandoc.RawBlock('html', '<ul>')) | ||
| 32 | |||
| 33 | for k, children in ipairs(el.content[1].content) do | ||
| 34 | newchildren:insert(pandoc.RawBlock('html', '<li class="c-page__prefixed c-page__prefixed--ref">')) | ||
| 35 | newchildren:extend(children) | ||
| 36 | newchildren:insert(pandoc.RawBlock('html', '</li>')) | ||
| 37 | end | ||
| 38 | |||
| 39 | newchildren:insert(pandoc.RawBlock('html', '</ul>')) | ||
| 40 | |||
| 41 | el.content = newchildren | ||
| 42 | end | ||
| 43 | |||
| 44 | return el.content | ||
| 45 | 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 @@ | |||
| 1 | function CodeBlock(el) | ||
| 2 | el.attributes.class = 'c-page__prefixed c-page__prefixed--pre' | ||
| 3 | return el | ||
| 4 | end | ||
| 5 | |||
| 6 | function Header(el) | ||
| 7 | if el.level == 1 then | ||
| 8 | el.attributes.class = 'c-page__prefixed c-page__prefixed--h1' | ||
| 9 | elseif el.level == 2 then | ||
| 10 | el.attributes.class = 'c-page__prefixed c-page__prefixed--h2' | ||
| 11 | elseif el.level == 3 then | ||
| 12 | el.attributes.class = 'c-page__prefixed c-page__prefixed--h3' | ||
| 13 | end | ||
| 14 | return el | ||
| 15 | 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 @@ | |||
| 1 | function Div(el) | ||
| 2 | if el.attributes.macro == nil then | ||
| 3 | return el | ||
| 4 | end | ||
| 5 | |||
| 6 | if el.attributes.macro == 'refs' and el.content[1].tag == 'BulletList' then | ||
| 7 | local newchildren = pandoc.List() | ||
| 8 | |||
| 9 | newchildren:insert(pandoc.RawBlock('html', '<ul>')) | ||
| 10 | |||
| 11 | for k, children in ipairs(el.content[1].content) do | ||
| 12 | newchildren:insert(pandoc.RawBlock('html', '<li class="c-page__prefixed c-page__prefixed--ref">')) | ||
| 13 | newchildren:extend(children) | ||
| 14 | newchildren:insert(pandoc.RawBlock('html', '</li>')) | ||
| 15 | end | ||
| 16 | |||
| 17 | newchildren:insert(pandoc.RawBlock('html', '</ul>')) | ||
| 18 | |||
| 19 | el.content = newchildren | ||
| 20 | end | ||
| 21 | |||
| 22 | return el.content | ||
| 23 | end | ||
