Skip to content

Commit 73e19f4

Browse files
authored
Add filter for handling helper classes. (#248)
- .btick wraps the text in backticks, without changing the font. Compatible with both HTML and PDF output.
1 parent 288b301 commit 73e19f4

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-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-images.lua
776777
--lua-filter=center-images.lua
@@ -881,6 +882,7 @@ do_docx() {
881882
cmd=(pandoc
882883
--embed-resources
883884
--standalone
885+
--lua-filter=render-helpers.lua
884886
--lua-filter=convert-diagrams.lua
885887
--lua-filter=convert-images.lua
886888
--lua-filter=parse-html.lua
@@ -924,6 +926,7 @@ do_html() {
924926
--standalone
925927
--template=${TEMPLATE_HTML}
926928
${HTML_STYLESHEET_ARGS}
929+
--lua-filter=render-helpers.lua
927930
--lua-filter=convert-diagrams.lua
928931
--lua-filter=parse-html.lua
929932
--lua-filter=apply-classes-to-tables.lua

filter/render-helpers.lua

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

guide.tcg

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

1463+
## Helper classes
1464+
1465+
To wrap a word in backticks that render as normal text, you can use the following syntax:
1466+
1467+
```md
1468+
[These words]{.btick} are in backticks.
1469+
```
1470+
1471+
[These words]{.btick} are in backticks.
1472+
14631473
## TCG Storage Workgroup Customizations
14641474

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

0 commit comments

Comments
 (0)