diff options
| author | Alasdair Armstrong | 2020-09-30 13:15:21 +0100 |
|---|---|---|
| committer | GitHub | 2020-09-30 13:15:21 +0100 |
| commit | 36cd0d8a7a146f8d51ef920212be768428680dac (patch) | |
| tree | 7e5225b6f819d44de504c65fc91f046959e0ecea /src | |
| parent | 1609552d3ff34bd887755c163eb27eb98b72837f (diff) | |
| parent | 38341beb186e5ac871d0e3446e5a98a25a806667 (diff) | |
Merge pull request #100 from arichardson/add-more-latex-tests-and-fix-escaping
Add more latex tests and fix underscore escaping
Diffstat (limited to 'src')
| -rw-r--r-- | src/latex.ml | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/latex.ml b/src/latex.ml index c2c61078..9cb0b4d8 100644 --- a/src/latex.ml +++ b/src/latex.ml @@ -242,7 +242,7 @@ let latex_of_markdown str = | Paragraph elems -> let prepend = if state.noindent then (state.noindent <- false; "\\noindent ") else "" in prepend ^ format elems ^ "\n\n" - | Text str -> Str.global_replace (Str.regexp_string "_") "\\_" str + | Text str -> text_code str | Emph elems -> sprintf "\\emph{%s}" (format elems) | Bold elems -> sprintf "\\textbf{%s}" (format elems) | Ref (r, "THIS", alt, _) -> @@ -441,7 +441,12 @@ let tdef_id = function let defs { defs; _ } = reset_state state; - let preamble = string "\\providecommand\\saildoclabelled[2]{\\phantomsection\\label{#1}#2}" ^^ twice hardline in + let preamble = string ("\\providecommand\\saildoclabelled[2]{\\phantomsection\\label{#1}#2}\n" ^ + "\\providecommand\\saildocval[2]{#1 #2}\n" ^ + "\\providecommand\\saildocfcl[2]{#1 #2}\n" ^ + "\\providecommand\\saildoctype[2]{#1 #2}\n" ^ + "\\providecommand\\saildocfn[2]{#1 #2}\n" ^ + "\\providecommand\\saildocoverload[2]{#1 #2}\n\n") in let overload_counter = ref 0 in @@ -501,7 +506,7 @@ let defs { defs; _ } = identifiers then outputs the correct mangled command. *) let id_command cat ids = sprintf "\\newcommand{\\%s%s}[1]{\n " !opt_prefix (category_name cat) - ^ Util.string_of_list "%\n " (fun id -> sprintf "\\ifstrequal{#1}{%s}{\\%s}{}" (string_of_id id) (latex_cat_id cat id)) + ^ Util.string_of_list "%\n " (fun id -> sprintf "\\ifstrequal{#1}{%s}{\\%s}{}" (text_code (string_of_id id)) (latex_cat_id cat id)) (IdSet.elements ids) ^ "}" |> string |
