Skip to content

Commit 804841b

Browse files
authored
Fix native escaped backtick rendering. (#249)
Instead of having a dedicated class, we can just fix the AST when processing escaped backticks.
1 parent 73e19f4 commit 804841b

File tree

4 files changed

+31
-42
lines changed

4 files changed

+31
-42
lines changed

build.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -771,7 +771,7 @@ do_latex() {
771771
--standalone
772772
--highlight-style=${SYNTAX_HIGHLIGHT_STYLE}
773773
--template=${TEMPLATE_PDF}
774-
--lua-filter=render-helpers.lua
774+
--lua-filter=fix-latex-backticks.lua
775775
--lua-filter=convert-diagrams.lua
776776
--lua-filter=convert-images.lua
777777
--lua-filter=center-images.lua
@@ -882,7 +882,6 @@ do_docx() {
882882
cmd=(pandoc
883883
--embed-resources
884884
--standalone
885-
--lua-filter=render-helpers.lua
886885
--lua-filter=convert-diagrams.lua
887886
--lua-filter=convert-images.lua
888887
--lua-filter=parse-html.lua
@@ -926,7 +925,6 @@ do_html() {
926925
--standalone
927926
--template=${TEMPLATE_HTML}
928927
${HTML_STYLESHEET_ARGS}
929-
--lua-filter=render-helpers.lua
930928
--lua-filter=convert-diagrams.lua
931929
--lua-filter=parse-html.lua
932930
--lua-filter=apply-classes-to-tables.lua

filter/fix-latex-backticks.lua

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
-- Correct backtick rendering in Latex. Without this, escaped backticks are displayed as curly open single quote marks.
2+
3+
function Str(el)
4+
local new_inlines = {}
5+
local current_text = ""
6+
7+
if FORMAT ~= "latex" or not el.text:match("`") then
8+
return el
9+
end
10+
11+
for i = 1, #el.text do
12+
local char = el.text:sub(i, i)
13+
14+
if char == "`" then
15+
if current_text ~= "" then
16+
table.insert(new_inlines, pandoc.Str(current_text))
17+
current_text = ""
18+
end
19+
table.insert(new_inlines, pandoc.RawInline('latex', '\\textasciigrave{}'))
20+
else
21+
current_text = current_text .. char
22+
end
23+
end
24+
25+
if current_text ~= "" then
26+
table.insert(new_inlines, pandoc.Str(current_text))
27+
end
28+
29+
return new_inlines
30+
end

filter/render-helpers.lua

Lines changed: 0 additions & 29 deletions
This file was deleted.

guide.tcg

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1460,16 +1460,6 @@ 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-
14731463
## TCG Storage Workgroup Customizations
14741464

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

0 commit comments

Comments
 (0)