diff --git a/src/catala/literate/html.ml b/src/catala/literate/html.ml
index 0661f480..6295dc88 100644
--- a/src/catala/literate/html.ml
+++ b/src/catala/literate/html.ml
@@ -153,11 +153,24 @@ let program_item_to_html (i : A.program_item) (custom_pygments : string option)
| _ -> "#" )
(pre_html (Pos.unmark a.law_article_name))
| A.CodeBlock (_, c) | A.MetadataBlock (_, c) ->
+ let date = "\\d\\d/\\d\\d/\\d\\d\\d\\d" in
+ let syms = R.regexp (date ^ "|!=|<=|>=|--|->|\*|\/") in
+ let syms_subst = function
+ | "!=" -> "≠"
+ | "<=" -> "≤"
+ | ">=" -> "≥"
+ | "--" -> "—"
+ | "->" -> "→"
+ | "*" -> "×"
+ | "/" -> "÷"
+ | s -> s
+ in
+ let pprinted_c = R.substitute ~rex:syms ~subst:syms_subst (Pos.unmark c) in
let formatted_original_code =
P.sprintf "
"
(Pos.get_file (Pos.get_position c))
(pygmentize_code
- (Pos.same_pos_as ("/*" ^ Pos.unmark c ^ "*/") c)
+ (Pos.same_pos_as ("/*" ^ pprinted_c ^ "*/") c)
language custom_pygments)
in
formatted_original_code
diff --git a/src/catala/literate/latex.ml b/src/catala/literate/latex.ml
index b9e857b2..267638f6 100644
--- a/src/catala/literate/latex.ml
+++ b/src/catala/literate/latex.ml
@@ -38,12 +38,20 @@ let wrap_latex (code : string) (source_files : string list) (custom_pygments : s
\\usepackage[%s]{babel}\n\
\\usepackage{lmodern}\n\
\\usepackage{minted}\n\
+ \\usepackage{amssymb}\n\
+ \\usepackage{newunicodechar}\n\
%s\n\
\\usepackage{textcomp}\n\
\\usepackage[hidelinks]{hyperref}\n\
\\usepackage[dvipsnames]{xcolor}\n\
\\usepackage{fullpage}\n\
\\usepackage[many]{tcolorbox}\n\n\
+ \\newunicodechar{÷}{$\\div$}\n\
+ \\newunicodechar{×}{$\\times$}\n\
+ \\newunicodechar{≤}{$\\leqslant$}\n\
+ \\newunicodechar{≥}{$\\geqslant$}\n\
+ \\newunicodechar{→}{$\\rightarrow$}\n\
+ \\newunicodechar{≠}{$\\neq$}\n\n\
\\fvset{\n\
commandchars=\\\\\\{\\},\n\
numbers=left,\n\
@@ -98,6 +106,21 @@ let wrap_latex (code : string) (source_files : string list) (custom_pygments : s
source_files))
code
+let math_syms_replace (c : string) : string =
+ let date = "\\d\\d/\\d\\d/\\d\\d\\d\\d" in
+ let syms = R.regexp (date ^ "|!=|<=|>=|--|->|\*|/") in
+ let syms2cmd = function
+ | "!=" -> "≠"
+ | "<=" -> "≤"
+ | ">=" -> "≥"
+ | "--" -> "—"
+ | "->" -> "→"
+ | "*" -> "×"
+ | "/" -> "÷"
+ | s -> s
+ in
+ R.substitute ~rex:syms ~subst:syms2cmd c
+
let program_item_to_latex (i : A.program_item) (language : C.language_option) : string =
match i with
| A.LawHeading (title, precedence) ->
@@ -114,7 +137,7 @@ let program_item_to_latex (i : A.program_item) (language : C.language_option) :
(pre_latexify (Filename.basename (Pos.get_file (Pos.get_position c))))
(Pos.get_start_line (Pos.get_position c) + 1)
(match language with C.Fr -> "catala_fr" | C.En -> "catala_en")
- (Pos.unmark c)
+ (math_syms_replace (Pos.unmark c))
| A.MetadataBlock (_, c) ->
P.sprintf
"\\begin{tcolorbox}[colframe=OliveGreen, breakable, \
@@ -127,7 +150,7 @@ let program_item_to_latex (i : A.program_item) (language : C.language_option) :
(Pos.get_start_line (Pos.get_position c) + 1)
(pre_latexify (Filename.basename (Pos.get_file (Pos.get_position c))))
(match language with C.Fr -> "catala_fr" | C.En -> "catala_en")
- (Pos.unmark c)
+ (math_syms_replace (Pos.unmark c))
| A.LawInclude (A.PdfFile ((file, _), page)) ->
let label = file ^ match page with None -> "" | Some p -> P.sprintf "_page_%d," p in
P.sprintf