diff options
| author | Kévin Le Gouguec <kevin.legouguec@gmail.com> | 2020-08-18 22:14:48 +0200 |
|---|---|---|
| committer | Kévin Le Gouguec <kevin.legouguec@gmail.com> | 2020-08-18 22:16:59 +0200 |
| commit | 205b6d12ff5673bd8ae59f827f07b69771b9dfee (patch) | |
| tree | 1d360828ad5485a4c572baae4eba4183ebe467b7 /repo/www/helpers.py | |
| parent | b173c7328dc8ae69880b305216f1196b052f5e03 (diff) | |
| download | memory-leaks-205b6d12ff5673bd8ae59f827f07b69771b9dfee.tar.xz | |
Mutualize pandoc invocations
Will be useful to avoid duplicating changes to Lua filters.
Diffstat (limited to 'repo/www/helpers.py')
| -rw-r--r-- | repo/www/helpers.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/repo/www/helpers.py b/repo/www/helpers.py index 6dc5bad..16cd496 100644 --- a/repo/www/helpers.py +++ b/repo/www/helpers.py @@ -1,6 +1,7 @@ from collections import defaultdict from dataclasses import dataclass, field from os import path +from subprocess import run from typing import Iterator @@ -52,3 +53,17 @@ def deserialize_directories(directories): return { k: Directory.deserialize(v) for k, v in directories.items() } + + +def pandoc(page, output, template, title=None, site_title=None): + cmd = ( + 'pandoc', '-s', page, '-o', output, '--template', template, + '--lua-filter', 'convert-internal-links.lua' + ) + + if title is not None: + cmd += ('-M', f'title={title}') + if site_title is not None: + cmd += ('-T', site_title) + + run(cmd, check=True) |
