aboutsummaryrefslogtreecommitdiff
path: root/util/weaver.lua
diff options
context:
space:
mode:
authorFederico Igne <git@federicoigne.com>2022-06-08 20:58:43 +0100
committerFederico Igne <git@federicoigne.com>2022-06-08 20:58:43 +0100
commit7fb232b502e0ad06c139b64c1f2d541b79ab96df (patch)
tree9bad58e23b58101562f641c7ed37c77ce516a90b /util/weaver.lua
parent24a2f4c09901863a3d4fbbda7f85eaebbf29c95f (diff)
downloadpangler-7fb232b502e0ad06c139b64c1f2d541b79ab96df.tar.gz
pangler-7fb232b502e0ad06c139b64c1f2d541b79ab96df.zip
feat: add literate version of pangler
Diffstat (limited to 'util/weaver.lua')
-rw-r--r--util/weaver.lua34
1 files changed, 34 insertions, 0 deletions
diff --git a/util/weaver.lua b/util/weaver.lua
new file mode 100644
index 0000000..1159988
--- /dev/null
+++ b/util/weaver.lua
@@ -0,0 +1,34 @@
1if FORMAT:match 'latex' then
2 -- Setting custom `listings` style
3 function Meta(m)
4 m["header-includes"] = pandoc.MetaBlocks({pandoc.RawBlock("latex",[[
5 \lstdefinestyle{weaver}{
6 basicstyle=\small\ttfamily,
7 backgroundcolor=\color{gray!10},
8 xleftmargin=0.5cm,
9 numbers=left,
10 numbersep=5pt,
11 numberstyle=\tiny\color{gray},
12 captionpos=b
13 }
14 \lstset{style=weaver}
15 ]])})
16 return m
17 end
18 function CodeBlock(b)
19 -- Remove `path` attribute and merge it with `id`
20 if b.attributes.path and b.identifier then
21 b.identifier = b.attributes.path .. b.identifier
22 b.attributes.path = nil
23 end
24 -- Add ID to caption
25 if b.identifier then
26 if b.attributes.caption then
27 b.attributes.caption = b.identifier .. ": " .. b.attributes.caption
28 else
29 b.attributes.caption = b.identifier
30 end
31 end
32 return b
33 end
34end