@@ -95,7 +95,8 @@ Aggregates multiple Documenter.jl-based documentation pages `docs` into `outdir`
95
95
- `brand_image` is a `BrandImage(path, imgpath)`, which is rendered as the leftmost
96
96
item in the global navigation
97
97
- `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.
99
100
- `search_engine` inserts a global search bar if not `false`. See [`SearchConfig`](@ref) for more details.
100
101
- `prettyurls` removes all `index.html` suffixes from links in the global navigation.
101
102
"""
@@ -253,19 +254,34 @@ function make_global_scripts(custom_scripts, path)
253
254
out = []
254
255
255
256
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
269
285
end
270
286
271
287
return out
0 commit comments