@@ -34,10 +34,11 @@ Base.@kwdef mutable struct Settings
34
34
config:: Config = Config (responsive= true )
35
35
reuse_preview:: Bool = true
36
36
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
37
38
end
38
39
settings:: Settings = Settings ()
39
40
40
- # -----------------------------------------------------------------------------# utils
41
+ # -----------------------------------------------------------------------------# utils/other
41
42
fix_matrix (x:: Config ) = Config (k => fix_matrix (v) for (k,v) in pairs (x))
42
43
fix_matrix (x) = x
43
44
fix_matrix (x:: AbstractMatrix ) = eachrow (x)
@@ -46,6 +47,9 @@ attributes(t::Symbol) = plotly.schema.traces[t].attributes
46
47
check_attribute (trace, attr:: Symbol ) = haskey (attributes (Symbol (trace)), attr) || @warn (" `$trace ` does not have attribute `$attr `." )
47
48
check_attributes (trace; kw... ) = foreach (k -> check_attribute (Symbol (trace), k), keys (kw))
48
49
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
+
49
53
# -----------------------------------------------------------------------------# Plot
50
54
mutable struct Plot
51
55
data:: Vector{Config}
@@ -94,6 +98,7 @@ function html_page(o::Plot)
94
98
h. meta (name= " description" , content= " PlotlyLight.jl" ),
95
99
h. title (" PlotlyLight.jl" ),
96
100
h. style (" html, body { padding: 0px; margin: 0px; } /* remove scrollbar in iframe */" ),
101
+ isnothing (settings. inject_head) ? " " : settings. inject_head
97
102
),
98
103
h. body (html_div (o))
99
104
)
@@ -106,7 +111,7 @@ Base.show(io::IO, ::MIME"juliavscode/html", o::Plot) = show(io, MIME"text/html"(
106
111
107
112
Base. display (:: REPL.REPLDisplay , o:: Plot ) = Cobweb. preview (h. html (h. body (o, style= " margin: 0px;" )), reuse= settings. reuse_preview)
108
113
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" )
110
115
111
116
112
117
# -----------------------------------------------------------------------------# preset
0 commit comments