Skip to content

Commit c7c192b

Browse files
committed
Wrap HTML heatmap in paragraph
1 parent 6a1204c commit c7c192b

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

src/heatmap.jl

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ const DEFAULT_COLORSCHEME = seismic
22
const DEFAULT_RANGESCALE = :centered
33

44
"""
5-
heatmap(values, words; kwargs...)
6-
heatmap(values, words, colors)
5+
heatmap(values, words)
76
87
Create a heatmap of words where the background color of each word is determined by its corresponding value.
98
Arguments `values` and `words` (and optionally `colors`) must have the same size.
@@ -81,16 +80,13 @@ luma(c::RGB) = 0.2126 * c.r + 0.7152 * c.g + 0.0722 * c.b # using BT. 709 coeffi
8180

8281
# Used e.g. in Pluto notebooks
8382
function Base.show(io::IO, ::MIME"text/html", h::TextHeatmap)
83+
print(io, "<p><heatmap>")
8484
for (word, color) in zip(h.words, h.colors)
8585
bg = hex(color)
8686
fg = is_background_bright(color) ? "black" : "white"
8787

88-
style = """
89-
background-color: #$bg;
90-
color: $fg;
91-
padding: 0.2em;
92-
margin: 0.2em;
93-
"""
94-
print(io, """<heatmap style="$style">$word</heatmap>""")
88+
style = "background-color: #$bg; color: $fg; padding: 0.2em; margin: 0.2em;"
89+
print(io, """<heatmap-word style="$style">$word</heatmap-word>""")
9590
end
91+
print(io, "</heatmap></p>")
9692
end

0 commit comments

Comments
 (0)