Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion scraper/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ indexmap = { version = "2.14.0", optional = true }
precomputed-hash = "0.1.1"
selectors = "0.38.0"
serde = { version = "1.0.228", optional = true }
tendril = "0.5.0"

[dependencies.getopts]
version = "0.2.24"
Expand Down
12 changes: 12 additions & 0 deletions scraper/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,18 @@ let document = tree.finish();
assert_eq!(document.html(), "<html><head></head><body>hello</body></html>");
```

### Using the library across threads
The `html5ever` crate uses the
[`Tendril`](https://docs.rs/html5ever/latest/html5ever/tendril/struct.Tendril.html)
type as their reference counted string. By default, it's thread-local and thus
`!Send`, enabling the `atomic` flag will use the atomic counting version of
[`Tendril`](https://docs.rs/html5ever/latest/html5ever/tendril/struct.Tendril.html),
implementing `Send` and allow their use across threads.
```toml
[dependencies]
scraper = { version = "0.27.0", features = ["atomic"] }
```

## Contributing

Please feel free to open pull requests. If you're planning on implementing
Expand Down
5 changes: 2 additions & 3 deletions scraper/src/html/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use html5ever::serialize::SerializeOpts;
use html5ever::tree_builder::QuirksMode;
use html5ever::{QualName, driver, serialize};
use selectors::matching::SelectorCaches;
use tendril::TendrilSink;
use html5ever::tendril::TendrilSink;

use crate::selector::Selector;
use crate::{ElementRef, Node};
Expand Down Expand Up @@ -65,12 +65,11 @@ impl Html {
/// ```
/// # extern crate html5ever;
/// # extern crate scraper;
/// # extern crate tendril;
/// # fn main() {
/// # let document = "";
/// use html5ever::driver::{self, ParseOpts};
/// use scraper::{Html, HtmlTreeSink};
/// use tendril::TendrilSink;
/// use html5ever::tendril::TendrilSink;
///
/// let parser = driver::parse_document(HtmlTreeSink::new(Html::new_document()), ParseOpts::default());
/// let html = parser.one(document);
Expand Down
Loading