@@ -34,10 +34,11 @@ Base.@kwdef mutable struct Settings
3434 config:: Config = Config (responsive= true )
3535 reuse_preview:: Bool = true
3636 style:: Dict{String,String} = Dict (" display" => " block" , " border" => " none" , " min-height" => " 350px" , " min-width" => " 350px" , " width" => " 100%" , " height" => " 100%" )
37+ inject_head:: Union{Nothing, Node} = nothing
3738end
3839settings:: Settings = Settings ()
3940
40- # -----------------------------------------------------------------------------# utils
41+ # -----------------------------------------------------------------------------# utils/other
4142fix_matrix (x:: Config ) = Config (k => fix_matrix (v) for (k,v) in pairs (x))
4243fix_matrix (x) = x
4344fix_matrix (x:: AbstractMatrix ) = eachrow (x)
@@ -46,6 +47,9 @@ attributes(t::Symbol) = plotly.schema.traces[t].attributes
4647check_attribute (trace, attr:: Symbol ) = haskey (attributes (Symbol (trace)), attr) || @warn (" `$trace ` does not have attribute `$attr `." )
4748check_attributes (trace; kw... ) = foreach (k -> check_attribute (Symbol (trace), k), keys (kw))
4849
50+ mathjax_script = h. script (type= " text/javascript" , id= " MathJax-script" , async= true ,
51+ src= " https://cdnjs.cloudflare.com/ajax/libs/mathjax/3.0.0/es5/latest?tex-mml-chtml.js" )
52+
4953# -----------------------------------------------------------------------------# Plot
5054mutable struct Plot
5155 data:: Vector{Config}
@@ -94,6 +98,7 @@ function html_page(o::Plot)
9498 h. meta (name= " description" , content= " PlotlyLight.jl" ),
9599 h. title (" PlotlyLight.jl" ),
96100 h. style (" html, body { padding: 0px; margin: 0px; } /* remove scrollbar in iframe */" ),
101+ isnothing (settings. inject_head) ? " " : settings. inject_head
97102 ),
98103 h. body (html_div (o))
99104 )
@@ -106,7 +111,7 @@ Base.show(io::IO, ::MIME"juliavscode/html", o::Plot) = show(io, MIME"text/html"(
106111
107112Base. display (:: REPL.REPLDisplay , o:: Plot ) = Cobweb. preview (h. html (h. body (o, style= " margin: 0px;" )), reuse= settings. reuse_preview)
108113
109- mathjax = h. script (type= " text/javascript" , async= true , src= " https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js" )
114+ mathjax_script = h. script (type= " text/javascript" , async= true , src= " https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js" )
110115
111116
112117# -----------------------------------------------------------------------------# preset
0 commit comments