diff options
Diffstat (limited to 'util/weaver.lua')
| -rw-r--r-- | util/weaver.lua | 34 |
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 @@ | |||
| 1 | if 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 | ||
| 34 | end | ||
