diff options
| author | Alex Richardson | 2020-09-25 16:21:57 +0100 |
|---|---|---|
| committer | Alex Richardson | 2020-09-25 16:43:10 +0100 |
| commit | cd32009738e05e4eb7f7e0e25ccf700525a7badb (patch) | |
| tree | 9601d70612d61b1144bc0c41106eee01e9beecf0 /src | |
| parent | f22136def93656ebe8c4c6e49214983365ecd6e2 (diff) | |
Saildoc: do not mangle links targets enclosed in <>
This can be useful to reference things that aren't defined by sail.
Diffstat (limited to 'src')
| -rw-r--r-- | src/latex.ml | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/latex.ml b/src/latex.ml index 2bb38bd7..6d479a52 100644 --- a/src/latex.ml +++ b/src/latex.ml @@ -237,10 +237,14 @@ let latex_of_markdown str = | Ref (r, name, alt, _) -> (* special case for [id] (format as code) *) let format_fn = if name = alt then inline_code else replace_this in - begin match r#get_ref name with - | None -> sprintf "\\hyperref[%s]{%s}" (refcode_string name) (format_fn alt) - | Some (link, _) -> sprintf "\\hyperref[%s]{%s}" (refcode_string link) (format_fn alt) - end + (* Do not attempt to escape link destinations wrapped in <> *) + if Str.string_match (Str.regexp "<.+>") name 0 then + sprintf "\\hyperref[%s]{%s}" (String.sub name 1 ((String.length name) - 2)) (format_fn alt) + else + begin match r#get_ref name with + | None -> sprintf "\\hyperref[%s]{%s}" (refcode_string name) (format_fn alt) + | Some (link, _) -> sprintf "\\hyperref[%s]{%s}" (refcode_string link) (format_fn alt) + end | Url (href, text, "") -> sprintf "\\href{%s}{%s}" href (format text) | Url (href, text, reference) -> |
