From 81f35db25ab6f634b24d4f66b9ff80d3fa9dc5b9 Mon Sep 17 00:00:00 2001 From: dualfroz Date: Fri, 4 Sep 2026 07:54:24 +0200 Subject: [PATCH] feat: add NewDocumentFromReaderWithOptions goquery calls html.Parse, so callers cannot reach the parse options that golang.org/x/net/html has since grown. The one that matters is ParseOptionEnableScripting(false): with scripting assumed enabled the contents of a noscript element are parsed as raw text and no selector can reach inside it. Add a constructor taking html.ParseOption values. Existing constructors are untouched. Refs #139 --- type.go | 18 ++++++++++++++++++ type_test.go | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) diff --git a/type.go b/type.go index dd3778d..7f34170 100644 --- a/type.go +++ b/type.go @@ -56,6 +56,24 @@ func NewDocumentFromReader(r io.Reader) (*Document, error) { return newDocument(root, nil), nil } +// NewDocumentFromReaderWithOptions is like NewDocumentFromReader, with the +// parse options of the html package. +// +// The option that usually matters is html.ParseOptionEnableScripting(false), +// which makes