@@ -95,7 +95,8 @@ Aggregates multiple Documenter.jl-based documentation pages `docs` into `outdir`
9595- `brand_image` is a `BrandImage(path, imgpath)`, which is rendered as the leftmost
9696 item in the global navigation
9797- `custom_stylesheets` is a `Vector{String}` of relative stylesheet URLs injected into each page.
98- - `custom_scripts` is a `Vector{String}` of relative script URLs injected into each page.
98+ - `custom_scripts` is a `Vector{Union{String, Docs.HTML}}`. Strings can be relative or absolute URLs, while
99+ `Docs.HTML` objects are inserted as the content of inline scripts.
99100- `search_engine` inserts a global search bar if not `false`. See [`SearchConfig`](@ref) for more details.
100101- `prettyurls` removes all `index.html` suffixes from links in the global navigation.
101102"""
@@ -253,19 +254,34 @@ function make_global_scripts(custom_scripts, path)
253254 out = []
254255
255256 for script in custom_scripts
256- script = startswith (script, r" https?://" ) ?
257- script :
258- replace (joinpath (path, script), raw " \\ " => " /" )
259- js = Gumbo. HTMLElement {:script} (
260- [],
261- Gumbo. NullNode (),
262- Dict (
263- " src" => script,
264- " type" => " text/javascript" ,
265- " charset" => " utf-8" ,
266- ),
267- )
268- push! (out, js)
257+ if script isa Docs. HTML
258+ js = Gumbo. HTMLElement {:script} (
259+ [],
260+ Gumbo. NullNode (),
261+ Dict (
262+ " type" => " text/javascript" ,
263+ " charset" => " utf-8" ,
264+ ),
265+ )
266+ push! (js, Gumbo. HTMLText (js, script. content))
267+ push! (out, js)
268+ elseif script isa AbstractString
269+ script = startswith (script, r" https?://" ) ?
270+ script :
271+ replace (joinpath (path, script), raw " \\ " => " /" )
272+ js = Gumbo. HTMLElement {:script} (
273+ [],
274+ Gumbo. NullNode (),
275+ Dict (
276+ " src" => script,
277+ " type" => " text/javascript" ,
278+ " charset" => " utf-8" ,
279+ ),
280+ )
281+ push! (out, js)
282+ else
283+ throw (ArgumentError (" `custom_scripts` may only contain elements of type `AbstractString` or `Docs.HTML`." ))
284+ end
269285 end
270286
271287 return out
0 commit comments