JuliaPluto / HypertextLiteral.jl

Julia library for the string interpolation of HTML and SVG
https://juliapluto.github.io/HypertextLiteral.jl/stable/
ISC License
64 stars 10 forks source link

FR: Support `<!doctype>` #21

Open fonsp opened 2 years ago

fonsp commented 2 years ago

I am using HypertextLiteral to generate the entire contents of an HTML file, but HypertextLiteral.jl won't let me write <!doctype html> or <!DOCTYPE html> on the first line:

Schermafbeelding 2021-11-22 om 18 34 40 Schermafbeelding 2021-11-22 om 18 34 53

This is not a bug, but a nice-to-have :)

clarkevans commented 2 years ago

This shouldn't be difficult, but it's likely to be tedious. It's a non-breaking change to add this feature, so, I don't think there is any urgency to it. We're open to pull requests.

schlichtanders commented 1 year ago

is there a workaround for now?

clarkevans commented 1 year ago

Hmm. I'll see if I can make progress on it.

fonsp commented 1 year ago

One workaround is:

import Base

struct WithDoctype
x
end

function Base.show(io::IO, m::MIME"text/html", wd::WithDoctype)
    write(io, "<!doctype html>\n")
    show(io, m, wd.x)
end

mypage = @htl("""
<html>
...
</html>
""") |> WithDoctype