Skip to content

proposal: x/net/html: Option to not add <html><head></head><body> ... </body></head></html> tags #71321

@pjebs

Description

@pjebs

Proposal Details

If I try and parse:

		<strong>
			<!-- comment 1 . -->
			<h1 class="jump">Title with <strong>BOLD</strong></h1>
			<script>
				console.log('sgasdg');
			</script>
			<script>
				console.log('2222');
			</script>
			<!-- commebsdg 2. -->
			<h3 style="text-color:red, width:50px" class="big top" data-good custom="ddd" onclick="alert('dasdg')">Subject</h3>
			<![CDATA[
Within this Character Data block I can
use double dashes as much as I want (along with <, &, ', and ")
*and* %MyParamEntity; will be expanded to the text
"Has been expanded" ... however, I can't use
the CEND sequence. If I need to use CEND I must escape one of the
brackets or the greater-than sign using concatenated CDATA sections.
]]>
		</strong>

using html.Parse.

It adds <html><head> </head><body> ... </body></head></html> tags at the start and the end.
There should be an option to disable adding these tags that don't exist in source html.

func ParseFragment(r io.Reader, context *Node) ([]*Node, error) requires a context which I can't provide.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions