diff --git a/build.sh b/build.sh index 07cb970..0c402f8 100755 --- a/build.sh +++ b/build.sh @@ -771,7 +771,7 @@ do_latex() { --standalone --highlight-style=${SYNTAX_HIGHLIGHT_STYLE} --template=${TEMPLATE_PDF} - --lua-filter=render-helpers.lua + --lua-filter=fix-latex-backticks.lua --lua-filter=convert-diagrams.lua --lua-filter=convert-images.lua --lua-filter=center-images.lua @@ -882,7 +882,6 @@ do_docx() { cmd=(pandoc --embed-resources --standalone - --lua-filter=render-helpers.lua --lua-filter=convert-diagrams.lua --lua-filter=convert-images.lua --lua-filter=parse-html.lua @@ -926,7 +925,6 @@ do_html() { --standalone --template=${TEMPLATE_HTML} ${HTML_STYLESHEET_ARGS} - --lua-filter=render-helpers.lua --lua-filter=convert-diagrams.lua --lua-filter=parse-html.lua --lua-filter=apply-classes-to-tables.lua diff --git a/filter/fix-latex-backticks.lua b/filter/fix-latex-backticks.lua new file mode 100644 index 0000000..9e00f79 --- /dev/null +++ b/filter/fix-latex-backticks.lua @@ -0,0 +1,30 @@ +-- Correct backtick rendering in Latex. Without this, escaped backticks are displayed as curly open single quote marks. + +function Str(el) + local new_inlines = {} + local current_text = "" + + if FORMAT ~= "latex" or not el.text:match("`") then + return el + end + + for i = 1, #el.text do + local char = el.text:sub(i, i) + + if char == "`" then + if current_text ~= "" then + table.insert(new_inlines, pandoc.Str(current_text)) + current_text = "" + end + table.insert(new_inlines, pandoc.RawInline('latex', '\\textasciigrave{}')) + else + current_text = current_text .. char + end + end + + if current_text ~= "" then + table.insert(new_inlines, pandoc.Str(current_text)) + end + + return new_inlines +end diff --git a/filter/render-helpers.lua b/filter/render-helpers.lua deleted file mode 100644 index 3c76ec2..0000000 --- a/filter/render-helpers.lua +++ /dev/null @@ -1,29 +0,0 @@ --- Turn [text]{.btick} into `text`, rendered without changing the font. - -backtick_chars = -{ - ["latex"] = "\\textasciigrave{}", - ["default"] = "`" -} - -function backtick(el) - local backtick_char = backtick_chars[FORMAT] or backtick_chars["default"] - - local new_inlines = {} - - table.insert(new_inlines, pandoc.RawInline(FORMAT, backtick_char)) - for _, inline_el in ipairs(el.content) do - table.insert(new_inlines, inline_el) - end - table.insert(new_inlines, pandoc.RawInline(FORMAT, backtick_char)) - - return new_inlines -end - -function Span(el) - if el.classes:includes('btick') then - return backtick(el) - else - return el - end -end diff --git a/guide.tcg b/guide.tcg index 32393bf..22fd0fc 100644 --- a/guide.tcg +++ b/guide.tcg @@ -1460,16 +1460,6 @@ Carl->>Bob: Goodbye Bob->>Alice: Goodbye ``` -## Helper classes - -To wrap a word in backticks that render as normal text, you can use the following syntax: - -```md -[These words]{.btick} are in backticks. -``` - -[These words]{.btick} are in backticks. - ## TCG Storage Workgroup Customizations TCG Storage committee uses command `MethodsOrUID` to render Names of methods and UIDs in \MethodsOrUID{Courier New font}.