From bcf88bac9a65668db425ecdc6f7c742bf3c4fac2 Mon Sep 17 00:00:00 2001 From: Paul-Elliot Date: Thu, 28 Oct 2021 10:52:22 +0200 Subject: [PATCH] adding a font-awesome icon for external links Signed-off-by: Paul-Elliot --- src/html/generator.ml | 5 ++++- src/odoc/etc/odoc.css | 11 +++++++++- test/generators/html/Bugs.html | 4 ++-- test/generators/html/Bugs_pre_410.html | 3 ++- test/generators/html/Markup.html | 28 +++++++++++++++----------- test/generators/html/Module.html | 4 ++-- test/generators/html/Ocamlary.html | 8 +++++--- 7 files changed, 41 insertions(+), 22 deletions(-) diff --git a/src/html/generator.ml b/src/html/generator.ml index a1870592e4..578ec692e1 100644 --- a/src/html/generator.ml +++ b/src/html/generator.ml @@ -113,7 +113,10 @@ and inline ?(emph_level = 0) ~resolve (l : Inline.t) : phrasing Html.elt list = let emph_level, app_style = styled style ~emph_level in [ app_style @@ inline ~emph_level ~resolve c ] | Link (href, c) -> - let a = (a :> Html_types.a_attrib Html.attrib list) in + let a = + (class_ ("external-link" :: t.attr) + :> Html_types.a_attrib Html.attrib list) + in let content = inline_nolink ~emph_level c in [ Html.a ~a:(Html.a_href href :: a) content ] | InternalLink c -> internallink ~emph_level ~resolve ~a c diff --git a/src/odoc/etc/odoc.css b/src/odoc/etc/odoc.css index cc5625ed77..9c833a3e57 100644 --- a/src/odoc/etc/odoc.css +++ b/src/odoc/etc/odoc.css @@ -298,7 +298,16 @@ a.anchor { .xref-unresolved:hover { box-shadow: 0 1px 0 0 var(--xref-shadow); } - +.external-link::after { + display: inline-block; + content: ""; + mask-image: url("data:image/svg+xml;utf8,"); + -webkit-mask-image: url("data:image/svg+xml;utf8,"); + width: 0.75em; + height: 0.75em; + background-color: currentColor; + margin-left: 0.1em; +} /* Section and document divisions. Until at least 4.03 many of the modules of the stdlib start at .h7, we restart the sequence there like h2 */ diff --git a/test/generators/html/Bugs.html b/test/generators/html/Bugs.html index dc716de80f..72f4eced4f 100644 --- a/test/generators/html/Bugs.html +++ b/test/generators/html/Bugs.html @@ -33,8 +33,8 @@

Module Bugs

diff --git a/test/generators/html/Bugs_pre_410.html b/test/generators/html/Bugs_pre_410.html index 5078379897..8d296cb8b3 100644 --- a/test/generators/html/Bugs_pre_410.html +++ b/test/generators/html/Bugs_pre_410.html @@ -37,7 +37,8 @@

Module Bugs_pre_410

Similar to Bugs, but the printed type of ~bar should be int, not 'a . This probably requires fixing in the compiler. See - + https://github.com/ocaml/odoc/pull/230#issuecomment-433226807 .

diff --git a/test/generators/html/Markup.html b/test/generators/html/Markup.html index c8d3d2c841..5b51f52f36 100644 --- a/test/generators/html/Markup.html +++ b/test/generators/html/Markup.html @@ -78,7 +78,7 @@
italics. It also work the same in - links in italics with + links in italics with emphasis in emphasis. @@ -101,16 +101,20 @@
-

This is a link. It sends you to the top of this - page. Links can have markup inside them: bold - , italics, emphasis - , superscript, - subscript, and - code. Links can also be nested - inside markup. Links cannot be nested inside - each other. This link has no replacement text: # - . The text is filled in by odoc. This is a shorthand link: - #. The text is also filled in by odoc in this case. +

This is a link. It sends + you to the top of this page. Links can have markup inside them: + bold, + italics, + emphasis, + superscript, + subscript, and + code. Links can + also be nested inside + markup. Links cannot be nested inside each other. This link has + no replacement text: #. The + text is filled in by odoc. This is a shorthand link: + #. The text is also filled + in by odoc in this case.

This is a reference to foo. References can have replacement text: @@ -209,7 +213,7 @@

Modules