summaryrefslogtreecommitdiff
path: root/repo/www/helpers.py
diff options
context:
space:
mode:
authorKévin Le Gouguec <kevin.legouguec@gmail.com>2020-08-18 22:14:48 +0200
committerKévin Le Gouguec <kevin.legouguec@gmail.com>2020-08-18 22:16:59 +0200
commit205b6d12ff5673bd8ae59f827f07b69771b9dfee (patch)
tree1d360828ad5485a4c572baae4eba4183ebe467b7 /repo/www/helpers.py
parentb173c7328dc8ae69880b305216f1196b052f5e03 (diff)
downloadmemory-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.py15
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)