From 18ec4b3dd35972b709dedce0a1e4fe5aa88c7965 Mon Sep 17 00:00:00 2001 From: Louis Gesbert Date: Thu, 15 Feb 2024 17:02:24 +0100 Subject: [PATCH] LaTeX backend: fix module name escaping --- compiler/literate/latex.ml | 12 +++++++----- tests/literate/good/test_grave_char_en.catala_en | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/compiler/literate/latex.ml b/compiler/literate/latex.ml index f389e2a1..d4c9b134 100644 --- a/compiler/literate/latex.ml +++ b/compiler/literate/latex.ml @@ -271,17 +271,19 @@ let rec law_structure_to_latex file label | A.LawInclude (A.CatalaFile _ | A.LegislativeText _) -> () | A.ModuleDef (id, extern) -> - Format.fprintf fmt "\n\\textbf{This defines the %s module \\textsc{%s}}" + Format.fprintf fmt + "\n\\textbf{This defines the \\texttt{%s} module \\texttt{%s}}" (if extern then "external" else "catala") - (Mark.remove id) + (pre_latexify (Mark.remove id)) | A.ModuleUse (id, alias) -> ( Format.fprintf fmt - "\n\\textbf{The following makes use of the module \\textsc{%s}" - (Mark.remove id); + "\n\\textbf{The following makes use of the module \\texttt{%s}" + (pre_latexify (Mark.remove id)); match alias with | None -> Format.fprintf fmt "}" | Some al -> - Format.fprintf fmt " under the name \\textsc{%s}" (Mark.remove al)) + Format.fprintf fmt " under the name \texttt{%s}" + (pre_latexify (Mark.remove al))) | A.LawText t -> Format.fprintf fmt "%s" (pre_latexify t) | A.CodeBlock (_, c, false) when not print_only_law -> let start_line = Pos.get_start_line (Mark.get c) - 1 in diff --git a/tests/literate/good/test_grave_char_en.catala_en b/tests/literate/good/test_grave_char_en.catala_en index a351f3d5..b735d2ed 100644 --- a/tests/literate/good/test_grave_char_en.catala_en +++ b/tests/literate/good/test_grave_char_en.catala_en @@ -52,7 +52,7 @@ $ catala Interpret -s A ```catala-test-inline $ catala latex -\textbf{This defines the catala module \textsc{Test_grave_char_en}} +\textbf{This defines the \texttt{catala} module \texttt{Test\_grave\_char\_en}} \subsection{Law text should be able to contain grave accent ``'.}