14 Commits
Author SHA1 Message Date
Chris (ChrisJr404) 91ed06d7c5 Add top-level Text function for BeautifulSoup-style text extraction
Adds goquery.Text(s, *TextOptions), a package-level counterpart to the
Selection.Text method that gives control over how the text of distinct
text nodes is joined (Separator), whether each node is trimmed of
surrounding whitespace (Trim), and which text nodes are included (Keep).
This covers the common need to extract clean, readable text from a
document - for example joining fragments with a space and dropping the
text of script/style elements - without hand-rolling a node walk.

Passing a nil TextOptions keeps the behaviour identical to Selection.Text.
Includes tests and a runnable example.
2026-08-18 08:54:59 -04:00
Martin Angers 0126a1fd88 Implement Single and SingleMatcher 2021-06-13 14:34:32 -04:00
Martin Angers 7757e27950 add examples for NewDocumentFromReader (#254) 2018-06-07 11:04:59 -04:00
Martin Angers dd77530fdb update examples to use the preferred NewDocumentFromReader approach 2018-03-24 12:12:09 -04:00
Martin Angers f0d75731e0 fix example, closes #120 2016-06-29 08:59:28 -04:00
Martin Angers 5cc721859e edit example to follow Go conventions 2016-04-08 07:39:02 -04:00
Martin Angers 1e5417b3db make example easier to understand (used from outside the goquery package) 2014-08-18 19:57:23 -04:00
Martin Angers bc0c11b086 update doc, example 2014-04-11 11:32:03 -04: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 f0e21587c8 start work on benchmarks 2012-09-11 11:00:14 -04:00
Martin Angers eea8ab69ed add PrevUntilSelection() and PrevUntilNodes() with tests 2012-09-06 10:57:54 -04:00
Martin Angers a9c4ad4c8f start work on PrevUntil() and NextUntil() 2012-09-06 10:27:42 -04:00
Martin Angers e952587198 little more idiomatic code in the example 2012-09-06 07:55:07 -04:00
Martin Angers 5aae70d501 add example 2012-09-05 10:40:16 -04:00