HypertextLiteral.jl icon indicating copy to clipboard operation
HypertextLiteral.jl copied to clipboard

FR: Support `<!doctype>`

Open fonsp opened this issue 3 years ago • 4 comments

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 :)

fonsp avatar Nov 22 '21 17:11 fonsp

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.

clarkevans avatar Dec 25 '21 12:12 clarkevans

is there a workaround for now?

schlichtanders avatar Feb 16 '23 14:02 schlichtanders

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

clarkevans avatar Feb 16 '23 15:02 clarkevans

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

fonsp avatar Mar 13 '23 14:03 fonsp