diff --git a/Artifacts.toml b/Artifacts.toml index e72885f..ca24981 100644 --- a/Artifacts.toml +++ b/Artifacts.toml @@ -1,6 +1,6 @@ [plotly_artifacts] -git-tree-sha1 = "0482d05aeb45f0389a9f2ec9919f430d6dfd454d" +git-tree-sha1 = "cb3112c4d60b522ef0302c35516aee1a5b2eb711" [[plotly_artifacts.download]] - sha256 = "a3b7b176230c3c49c8fb4866a845e133d0afe4f58b23b941f9b3059e907d913e" - url = "https://gist.github.com/joshday/c62001c14794e2f28c8f6ab6937b3e94/raw/0482d05aeb45f0389a9f2ec9919f430d6dfd454d.tar.gz" + sha256 = "44265cd24ac7acc3d2b21527d0326e2c131a1b4fe9266f5661b5ecb783aff4bb" + url = "https://gist.github.com/joshday/30654755d769aa794fb8f84bc36d882c/raw/cb3112c4d60b522ef0302c35516aee1a5b2eb711.tar.gz" diff --git a/deps/artifacts.jl b/deps/artifacts.jl index ce4116f..9bd4c6a 100644 --- a/deps/artifacts.jl +++ b/deps/artifacts.jl @@ -1,5 +1,6 @@ using Pkg Pkg.activate(@__DIR__) +Pkg.instantiate() using ArtifactUtils, JSON3 diff --git a/docs/src/settings.md b/docs/src/settings.md index 22804c3..0870b0e 100644 --- a/docs/src/settings.md +++ b/docs/src/settings.md @@ -9,7 +9,7 @@ PlotlyLight.settings.layout::EasyConfig.Config # default `layout` for all plots PlotlyLight.settings.config::EasyConfig.Config # default `config` for all plots PlotlyLight.settings.reuse_preview::Bool # In the REPL, open plots in same page (true, the default) or different pages. PlotlyLight.settings.style::Dict{String,String} # CSS styles for the plot
+PlotlyLight.settings.inject_head::Cobweb.Node # Code to inject at the bottom the ``` Check out e.g. `PlotlyLight.Settings().src` to examine default values. - diff --git a/src/PlotlyLight.jl b/src/PlotlyLight.jl index 4d74a71..ac6de63 100644 --- a/src/PlotlyLight.jl +++ b/src/PlotlyLight.jl @@ -34,10 +34,11 @@ Base.@kwdef mutable struct Settings config::Config = Config(responsive=true) reuse_preview::Bool = true style::Dict{String,String} = Dict("display" => "block", "border" => "none", "min-height" => "350px", "min-width" => "350px", "width" => "100%", "height" => "100%") + inject_head::Union{Nothing, Node} = nothing end settings::Settings = Settings() -#-----------------------------------------------------------------------------# utils +#-----------------------------------------------------------------------------# utils/other fix_matrix(x::Config) = Config(k => fix_matrix(v) for (k,v) in pairs(x)) fix_matrix(x) = x fix_matrix(x::AbstractMatrix) = eachrow(x) @@ -46,6 +47,9 @@ attributes(t::Symbol) = plotly.schema.traces[t].attributes check_attribute(trace, attr::Symbol) = haskey(attributes(Symbol(trace)), attr) || @warn("`$trace` does not have attribute `$attr`.") check_attributes(trace; kw...) = foreach(k -> check_attribute(Symbol(trace), k), keys(kw)) +mathjax_script = h.script(type="text/javascript", id="MathJax-script", async=true, + src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/3.0.0/es5/latest?tex-mml-chtml.js") + #-----------------------------------------------------------------------------# Plot mutable struct Plot data::Vector{Config} @@ -94,6 +98,7 @@ function html_page(o::Plot) h.meta(name="description", content="PlotlyLight.jl"), h.title("PlotlyLight.jl"), h.style("html, body { padding: 0px; margin: 0px; } /* remove scrollbar in iframe */"), + isnothing(settings.inject_head) ? "" : settings.inject_head ), h.body(html_div(o)) ) @@ -106,7 +111,7 @@ Base.show(io::IO, ::MIME"juliavscode/html", o::Plot) = show(io, MIME"text/html"( Base.display(::REPL.REPLDisplay, o::Plot) = Cobweb.preview(h.html(h.body(o, style="margin: 0px;")), reuse=settings.reuse_preview) -mathjax = h.script(type="text/javascript", async=true, src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js") +mathjax_script = h.script(type="text/javascript", async=true, src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js") #-----------------------------------------------------------------------------# preset