diff options
| author | Alasdair Armstrong | 2020-09-27 02:10:52 +0100 |
|---|---|---|
| committer | GitHub | 2020-09-27 02:10:52 +0100 |
| commit | 882850db49cffef75e11eef8cf00364611e54e19 (patch) | |
| tree | 9601d70612d61b1144bc0c41106eee01e9beecf0 /src | |
| parent | b73aaf6d7209d693e295abcc499fa2f759cb877e (diff) | |
| parent | cd32009738e05e4eb7f7e0e25ccf700525a7badb (diff) | |
Merge pull request #96 from arichardson/add-latex-tests-and-allow-external-links
Add latex tests and allow external links
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) -> |
