Skip to content

Commit 055a110

Browse files
authored
fix handling of script content, bump html5gum (#181)
* scriptdata bad testcase * bump html5gum
1 parent df88a08 commit 055a110

File tree

3 files changed

+26
-3
lines changed

3 files changed

+26
-3
lines changed

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ rayon = "1.5.1"
2121
pulldown-cmark = "0.12.2"
2222
blake3 = "1.0.0"
2323

24-
html5gum = "0.6.0"
24+
html5gum = "0.6.1"
2525
jwalk = "0.8.1"
2626
bumpalo = { version = "3.11.1", features = ["collections"] }
2727
percent-encoding = "2.1.0"

src/html/mod.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,3 +570,26 @@ fn test_document_join_bare_html() {
570570
Href("locations/oslo#grünerløkka")
571571
);
572572
}
573+
574+
#[test]
575+
fn test_json_script() {
576+
use crate::paragraph::ParagraphHasher;
577+
578+
let doc = Document::new(
579+
Path::new("/"),
580+
Path::new("/html5gum/struct.Tokenizer.html"),
581+
);
582+
583+
let html = r#"<script type="text/json" id="notable-traits-data">{"InfallibleTokenizer<R, E>":"<h3>Notable traits for <code><a class=\"struct\" href=\"struct.InfallibleTokenizer.html\" title=\"struct html5gum::InfallibleTokenizer\">InfallibleTokenizer</a>&lt;R, E&gt;</code></h3><pre><code><div class=\"where\">impl&lt;R: <a class=\"trait\" href=\"trait.Reader.html\" title=\"trait html5gum::Reader\">Reader</a>&lt;Error = <a class=\"enum\" href=\"https://doc.rust-lang.org/1.82.0/core/convert/enum.Infallible.html\" title=\"enum core::convert::Infallible\">Infallible</a>&gt;, E: <a class=\"trait\" href=\"emitters/trait.Emitter.html\" title=\"trait html5gum::emitters::Emitter\">Emitter</a>&gt; <a class=\"trait\" href=\"https://doc.rust-lang.org/1.82.0/core/iter/traits/iterator/trait.Iterator.html\" title=\"trait core::iter::traits::iterator::Iterator\">Iterator</a> for <a class=\"struct\" href=\"struct.InfallibleTokenizer.html\" title=\"struct html5gum::InfallibleTokenizer\">InfallibleTokenizer</a>&lt;R, E&gt;</div><div class=\"where\"> type <a href=\"https://doc.rust-lang.org/1.82.0/core/iter/traits/iterator/trait.Iterator.html#associatedtype.Item\" class=\"associatedtype\">Item</a> = E::<a class=\"associatedtype\" href=\"emitters/trait.Emitter.html#associatedtype.Token\" title=\"type html5gum::emitters::Emitter::Token\">Token</a>;</div>"}</script>"#;
584+
585+
let mut doc_buf = DocumentBuffers::default();
586+
587+
let links = doc
588+
.links_from_read::<_, ParagraphHasher>(&mut doc_buf, html.as_bytes(), false)
589+
.unwrap();
590+
591+
assert_eq!(
592+
links.collect::<Vec<_>>(),
593+
&[]
594+
);
595+
}

0 commit comments

Comments
 (0)