From 988a1b1926ac67c89e5672a60ff358c62b4a3a55 Mon Sep 17 00:00:00 2001 From: Mirek Kratochvil Date: Mon, 15 Jan 2024 09:48:18 +0100 Subject: [PATCH] HTMLWriter: allow extra attributes for external links, default to no-referrer policy --- src/html/HTMLWriter.jl | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/html/HTMLWriter.jl b/src/html/HTMLWriter.jl index f5226a5d58..0bd35078da 100644 --- a/src/html/HTMLWriter.jl +++ b/src/html/HTMLWriter.jl @@ -619,11 +619,13 @@ mutable struct HTMLContext search_index_js :: String search_navnode :: Documenter.NavNode atexample_warnings::Vector{AtExampleFallbackWarning} + external_link_attribs :: Vector{Pair{Symbol,String}} HTMLContext(doc, settings=nothing) = new( doc, settings, [], "", "", "", [], "", Documenter.NavNode("search", "Search", nothing), AtExampleFallbackWarning[], + [:referrerpolicy => "no-referrer"] ) end @@ -958,13 +960,19 @@ function render_head(ctx, navnode) # Stylesheets. map(css_links) do each - link[:href => each, :rel => "stylesheet", :type => "text/css"] + link[ + :href => each, + :rel => "stylesheet", + :type => "text/css", + ctx.external_link_attribs... + ] end, script("documenterBaseURL=\"$(relhref(src, "."))\""), script[ :src => RD.requirejs_cdn, - Symbol("data-main") => relhref(src, ctx.documenter_js) + Symbol("data-main") => relhref(src, ctx.documenter_js), + ctx.external_link_attribs... ], script[:src => relhref(src, ctx.search_index_js)],