Is there an HTML string type in Julia?


#1

When working in IJulia I find myself using this code:

struct HtmlString
    s::String
end

Base.show(io::IO, ::MIME"text/html", s::HtmlString) =
           print(io, s.s)
           
HtmlString("Result: <b>123.4</b")

I can then easily output tables of results as HTML etc. I can build up functions that return lumps of HTML for reports that appear inline in the notebook.

This feels fundamental - is there an HTML string type elsewhere that I’m missing please?

We have LatexStrings.jl, perhaps we should have HtmlStrings.jl?

Perhaps I’m missing a more idiomatic approach? Any wisdom appreciated please.


#2

HTML("Result: <b>123.4</b") in Base.

You can also call display("text/html", "Result: <b>123.4</b") if you just want to show something without constructing a new object.


#3

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.