Skip to content

Commit 278efd4

Browse files
committed
Add filter for handling several helper classes.
- .btick wraps the text in backticks. - .sup renders the text as superscript. - .sub renders the text as subscript.
1 parent 2436d62 commit 278efd4

File tree

3 files changed

+49
-0
lines changed

3 files changed

+49
-0
lines changed

build.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -771,6 +771,7 @@ do_latex() {
771771
--standalone
772772
--highlight-style=${SYNTAX_HIGHLIGHT_STYLE}
773773
--template=${TEMPLATE_PDF}
774+
--lua-filter=render-helpers.lua
774775
--lua-filter=convert-diagrams.lua
775776
--lua-filter=convert-aasvg.lua
776777
--lua-filter=convert-images.lua
@@ -882,6 +883,7 @@ do_docx() {
882883
cmd=(pandoc
883884
--embed-resources
884885
--standalone
886+
--lua-filter=render-helpers.lua
885887
--lua-filter=convert-diagrams.lua
886888
--lua-filter=convert-aasvg.lua
887889
--lua-filter=convert-images.lua
@@ -926,6 +928,7 @@ do_html() {
926928
--standalone
927929
--template=${TEMPLATE_HTML}
928930
${HTML_STYLESHEET_ARGS}
931+
--lua-filter=render-helpers.lua
929932
--lua-filter=convert-diagrams.lua
930933
--lua-filter=convert-aasvg.lua
931934
--lua-filter=parse-html.lua

filter/render-helpers.lua

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
-- Turn [text]{.btick} into `text`, rendered without changing the font.
2+
-- Turn [text]{.sup} into superscripted text.
3+
-- Turn [text]{.sub} into subscripted text.
4+
5+
backtick_chars =
6+
{
7+
["latex"] = "\\textasciigrave{}",
8+
["default"] = "`"
9+
}
10+
11+
function backtick(el)
12+
local backtick_char = backtick_chars[FORMAT] or backtick_chars["default"]
13+
14+
local new_inlines = {}
15+
16+
table.insert(new_inlines, pandoc.RawInline(FORMAT, backtick_char))
17+
for _, inline_el in ipairs(el.content) do
18+
table.insert(new_inlines, inline_el)
19+
end
20+
table.insert(new_inlines, pandoc.RawInline(FORMAT, backtick_char))
21+
22+
return new_inlines
23+
end
24+
25+
function Span(el)
26+
if el.classes:includes('btick') then
27+
return backtick(el)
28+
elseif el.classes:includes('sup') then
29+
return pandoc.Superscript(el.content)
30+
elseif el.classes:includes('sub') then
31+
return pandoc.Subscript(el.content)
32+
else
33+
return el
34+
end
35+
end

guide.tcg

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1460,6 +1460,17 @@ Carl->>Bob: Goodbye
14601460
Bob->>Alice: Goodbye
14611461
```
14621462

1463+
## Helper classes
1464+
1465+
Several helper classes are available.
1466+
1467+
```md
1468+
[These words]{.btick} are wrapped backticks in normal font.
1469+
[Here's]{.sup} a superscript, and [here's]{.sub} a subscript.
1470+
```
1471+
1472+
[These words]{.btick} are wrapped backticks in normal font. [Here's]{.sup} a superscript, and [here's]{.sub} a subscript.
1473+
14631474
## TCG Storage Workgroup Customizations
14641475

14651476
TCG Storage committee uses command `MethodsOrUID` to render Names of methods and UIDs in \MethodsOrUID{Courier New font}.

0 commit comments

Comments
 (0)