28 Commits
Author SHA1 Message Date
sean0407 e61532997e Clarify Single matcher selection scope 2026-10-12 21:30:24 +08:00
Martin Angers 0ac714270a Small tweak to the new constructor documentation 2026-09-30 13:43:55 -04:00
DualFroz 0a624966d3 Apply the document's parse options to HTML added to it later 2026-09-23 07:01:09 +02:00
dualfroz 81f35db25a 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
2026-09-06 01:24:56 +02:00
jvoisin df88dce547 Refactor first-match optimization into singleMatcher
Move the "stop at first match" optimization out of HasMatcher and into
singleMatcher, where it can be reused elsewhere.

singleMatcher now implements MatchFirst, which calls the underlying
Matcher's MatchFirst if it provides one (cascadia-compiled matchers all
do), otherwise falls back to MatchAll and returns its first element.
singleMatcher.MatchAll wraps MatchFirst's result in a single-item slice
to respect the Matcher interface, so external SingleMatcher() users get
the slice signature while internal callers can avoid that allocation.

HasMatcher now constructs a singleMatcher directly to call MatchFirst
without a type assertion, removing the duplicated probe branch.
2026-06-02 14:15:45 +02:00
Martin Angers b3953ef42a Finalize documentation 2021-06-14 09:06:47 -04:00
Martin Angers ee8a7e0a3a Test and benchmark the Single[Matcher] funcs 2021-06-13 15:02:43 -04:00
Martin Angers 0126a1fd88 Implement Single and SingleMatcher 2021-06-13 14:34:32 -04:00
Martin Angers 106fcbf95a deprecate NewDocument and NewDocumentFromResponse 2018-03-24 11:50:21 -04:00
Martin Angers 2ab590df05 use a failing matcher if selector fails to compile, adjust tests 2016-06-15 09:27:17 -04:00
Martin Angers 417cce822c return error if response`s request is nil on NewDocumentFromResponse 2015-09-27 16:28:20 -04:00
Baptiste Fontaine 2d28dba982 Typo in NewDocumentFromResponse doc 2015-04-09 19:33:38 +02:00
Martin Angers 1ff3f2a033 rename NewDocumentFromDocument to CloneDocument 2014-11-07 09:23:27 -05:00
Martin Angers 251095afb5 start adding matcher functions 2014-11-06 21:43:08 -05:00
Martin Angers cc9b6f8c6f Merge branch 'master' into manipulation 2014-11-06 20:46:11 -05:00
Martin Angers 040cf98281 change paths to golang.org/x/, fails to build because cascadia has to switch too 2014-11-05 20:30:33 -05:00
Andrew Stone 0e970f1f85 manipulation: Add Append*() functions 2014-10-24 11:49:01 -04:00
Noyb Cybot e7f5b65573 gofmt 2014-04-22 20:11:15 +02:00
Noyb Cybot 21918f0808 Check if response is nil pointer in NewDocumentFromResponse 2014-04-22 20:09:53 +02:00
Martin Angers 2c6687f6d3 lint 2014-04-11 12:00:17 -04:00
Martin Angers f065786d41 add NewDocumentFromReader, closes #20 2013-09-07 10:57:54 -04:00
Martin Angers e8c0a63721 document new constructor, rename to NewDocumentFromResponse 2013-07-24 08:49:11 -04:00
tesla.peng 2d2b626f0d add another method to get html document 2013-07-24 18:29:10 +08:00
Dobrosław Żybort 474b169363 Update exp/html import paths 2013-02-12 20:32:16 +01:00
Martin Angers 6669ef001f remove Document.Root, Document is itself a Selection (using embedded struct) 2012-10-14 12:28:27 -04:00
Martin Angers 6e1e76af6b refactor Document to make Root a Selection, with all API available 2012-09-02 14:45:50 -04:00
Martin Angers 505516529b finalize type.go documentation 2012-09-01 11:03:02 -04:00
Martin Angers de74d0bf97 reorganize code in what seems like a sane structure 2012-08-30 17:35:41 -04:00