Open allefeld opened 3 years ago
document is a thin wrapper that's pretty much just for quick prototyping. If you want more control, I would suggest just using tags.html
as your root element instead of document
. Other simple things you could do is just removing doc.title_node
or doing doc.children.insert(0, meta_node)
.
If this is more of a feature request than a bug report, adding an automatic meta
tag to document
(in the right place) could be a good idea.
Honestly not sure whether this is a bug report or a feature request. ;) But I agree, document
could be more than just for prototyping, but a convenience function which makes sure that things like <meta charset="">
are there.
I wasn't aware that I could use tags.html
instead of document
, thanks! But then, how do I get the <!DOCTYPE html>
? Just write it myself?
I have a similar issue trying to set the doc rendered opening html tag to html lang="en" using dominate.tags.html I guess it is rather a feature request though.. Edit : as a workaround I am using beautiful soup to modify the opening html tag..
In HTML5 it is recommended to explicitly specify the character encoding with a
meta
element in thehead
:To make sure this encoding is also applied to the title of the document, it should come before the
title
element. However, if I try to do so with the codethe result is
i.e. I get two
title
elements. If I specify the title instead as an argument ofdominate.document
, there is only onetitle
element, but it is before themeta
element.I see two ways around this:
1) The
title
attribute ofdominate.document
is only used to generate atitle
element if none has been added manually.2)
dominate.document
gets an additionalcharset
argument.My preference would be (1).