From cad8988f8d95f9edff3046575c6fd932249276a7 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Tue, 22 Apr 2025 09:00:47 -0700 Subject: [PATCH] Migrate book_creates_reasonable_search_index to BookTest --- tests/rendered_output.rs | 61 --------------- tests/testsuite/main.rs | 2 + tests/testsuite/search.rs | 78 +++++++++++++++++++ .../reasonable_search_index/expected_index.js | 1 + .../reasonable_search_index/src/SUMMARY.md | 10 +++ .../src/first/duplicate-headers.md | 9 +++ .../src/first/heading-attributes.md | 5 ++ .../src/first/includes.md | 3 + .../src/first/index.md | 5 ++ .../src/first/no-headers.md | 5 ++ .../src/first/unicode.md | 21 +++++ .../reasonable_search_index/src/intro.md | 28 +++++++ 12 files changed, 167 insertions(+), 61 deletions(-) create mode 100644 tests/testsuite/search.rs create mode 100644 tests/testsuite/search/reasonable_search_index/expected_index.js create mode 100644 tests/testsuite/search/reasonable_search_index/src/SUMMARY.md create mode 100644 tests/testsuite/search/reasonable_search_index/src/first/duplicate-headers.md create mode 100644 tests/testsuite/search/reasonable_search_index/src/first/heading-attributes.md create mode 100644 tests/testsuite/search/reasonable_search_index/src/first/includes.md create mode 100644 tests/testsuite/search/reasonable_search_index/src/first/index.md create mode 100644 tests/testsuite/search/reasonable_search_index/src/first/no-headers.md create mode 100644 tests/testsuite/search/reasonable_search_index/src/first/unicode.md create mode 100644 tests/testsuite/search/reasonable_search_index/src/intro.md diff --git a/tests/rendered_output.rs b/tests/rendered_output.rs index d16c7a3f..1418c6bc 100644 --- a/tests/rendered_output.rs +++ b/tests/rendered_output.rs @@ -393,67 +393,6 @@ mod search { serde_json::from_str(&index.replace("\\'", "'").replace("\\\\", "\\")).unwrap() } - #[test] - fn book_creates_reasonable_search_index() { - let temp = DummyBook::new().build().unwrap(); - let md = MDBook::load(temp.path()).unwrap(); - md.build().unwrap(); - - let index = read_book_index(temp.path()); - - let doc_urls = index["doc_urls"].as_array().unwrap(); - eprintln!("doc_urls={doc_urls:#?}",); - let get_doc_ref = - |url: &str| -> String { doc_urls.iter().position(|s| s == url).unwrap().to_string() }; - - let first_chapter = get_doc_ref("first/index.html#first-chapter"); - let introduction = get_doc_ref("intro.html#introduction"); - let some_section = get_doc_ref("first/index.html#some-section"); - let summary = get_doc_ref("first/includes.html#summary"); - let no_headers = get_doc_ref("first/no-headers.html"); - let duplicate_headers_1 = get_doc_ref("first/duplicate-headers.html#header-text-1"); - let conclusion = get_doc_ref("conclusion.html#conclusion"); - let heading_attrs = get_doc_ref("first/heading-attributes.html#both"); - - let bodyidx = &index["index"]["index"]["body"]["root"]; - let textidx = &bodyidx["t"]["e"]["x"]["t"]; - assert_eq!(textidx["df"], 5); - assert_eq!(textidx["docs"][&first_chapter]["tf"], 1.0); - assert_eq!(textidx["docs"][&introduction]["tf"], 1.0); - - let docs = &index["index"]["documentStore"]["docs"]; - assert_eq!(docs[&first_chapter]["body"], "more text."); - assert_eq!(docs[&some_section]["body"], ""); - assert_eq!( - docs[&summary]["body"], - "Dummy Book Introduction First Chapter Nested Chapter Includes Recursive Markdown Unicode No Headers Duplicate Headers Heading Attributes Second Chapter Nested Chapter Conclusion" - ); - assert_eq!( - docs[&summary]["breadcrumbs"], - "First Chapter » Includes » Summary" - ); - // See note about InlineHtml in search.rs. Ideally the `alert()` part - // should not be in the index, but we don't have a way to scrub inline - // html. - assert_eq!(docs[&conclusion]["body"], "I put <HTML> in here! Sneaky inline event alert(\"inline\");. But regular inline is indexed."); - assert_eq!( - docs[&no_headers]["breadcrumbs"], - "First Chapter » No Headers" - ); - assert_eq!( - docs[&duplicate_headers_1]["breadcrumbs"], - "First Chapter » Duplicate Headers » Header Text" - ); - assert_eq!( - docs[&no_headers]["body"], - "Capybara capybara capybara. Capybara capybara capybara. ThisLongWordIsIncludedSoWeCanCheckThatSufficientlyLongWordsAreOmittedFromTheSearchIndex." - ); - assert_eq!( - docs[&heading_attrs]["breadcrumbs"], - "First Chapter » Heading Attributes » Heading with id and classes" - ); - } - #[test] fn can_disable_individual_chapters() { let temp = DummyBook::new().build().unwrap(); diff --git a/tests/testsuite/main.rs b/tests/testsuite/main.rs index 38c60999..95756d51 100644 --- a/tests/testsuite/main.rs +++ b/tests/testsuite/main.rs @@ -15,6 +15,8 @@ mod print; mod redirects; mod renderer; mod rendering; +#[cfg(feature = "search")] +mod search; mod prelude { pub use crate::book_test::BookTest; diff --git a/tests/testsuite/search.rs b/tests/testsuite/search.rs new file mode 100644 index 00000000..2220adc8 --- /dev/null +++ b/tests/testsuite/search.rs @@ -0,0 +1,78 @@ +//! Tests for search support. + +use crate::prelude::*; +use std::path::Path; + +fn read_book_index(root: &Path) -> serde_json::Value { + let index = root.join("book/searchindex.js"); + let index = std::fs::read_to_string(index).unwrap(); + let index = index.trim_start_matches("window.search = JSON.parse('"); + let index = index.trim_end_matches("');"); + // We need unescape the string as it's supposed to be an escaped JS string. + serde_json::from_str(&index.replace("\\'", "'").replace("\\\\", "\\")).unwrap() +} + +// Some spot checks for the generation of the search index. +#[test] +fn reasonable_search_index() { + let mut test = BookTest::from_dir("search/reasonable_search_index"); + test.build(); + let index = read_book_index(&test.dir); + + let doc_urls = index["doc_urls"].as_array().unwrap(); + eprintln!("doc_urls={doc_urls:#?}",); + let get_doc_ref = |url: &str| -> String { + doc_urls + .iter() + .position(|s| s == url) + .unwrap_or_else(|| panic!("failed to find {url}")) + .to_string() + }; + + let first_chapter = get_doc_ref("first/index.html#first-chapter"); + let introduction = get_doc_ref("intro.html#introduction"); + let some_section = get_doc_ref("first/index.html#some-section"); + let summary = get_doc_ref("first/includes.html#summary"); + let no_headers = get_doc_ref("first/no-headers.html"); + let duplicate_headers_1 = get_doc_ref("first/duplicate-headers.html#header-text-1"); + let heading_attrs = get_doc_ref("first/heading-attributes.html#both"); + let sneaky = get_doc_ref("intro.html#sneaky"); + + let bodyidx = &index["index"]["index"]["body"]["root"]; + let textidx = &bodyidx["t"]["e"]["x"]["t"]; + assert_eq!(textidx["df"], 5); + assert_eq!(textidx["docs"][&first_chapter]["tf"], 1.0); + assert_eq!(textidx["docs"][&introduction]["tf"], 1.0); + + let docs = &index["index"]["documentStore"]["docs"]; + assert_eq!(docs[&first_chapter]["body"], "more text."); + assert_eq!(docs[&some_section]["body"], ""); + assert_eq!( + docs[&summary]["body"], + "Introduction First Chapter Includes Unicode No Headers Duplicate Headers Heading Attributes" + ); + assert_eq!( + docs[&summary]["breadcrumbs"], + "First Chapter » Includes » Summary" + ); + // See note about InlineHtml in search.rs. Ideally the `alert()` part + // should not be in the index, but we don't have a way to scrub inline + // html. + assert_eq!(docs[&sneaky]["body"], "I put <HTML> in here! Sneaky inline event alert(\"inline\");. But regular inline is indexed."); + assert_eq!( + docs[&no_headers]["breadcrumbs"], + "First Chapter » No Headers" + ); + assert_eq!( + docs[&duplicate_headers_1]["breadcrumbs"], + "First Chapter » Duplicate Headers » Header Text" + ); + assert_eq!( + docs[&no_headers]["body"], + "Capybara capybara capybara. Capybara capybara capybara. ThisLongWordIsIncludedSoWeCanCheckThatSufficientlyLongWordsAreOmittedFromTheSearchIndex." + ); + assert_eq!( + docs[&heading_attrs]["breadcrumbs"], + "First Chapter » Heading Attributes » Heading with id and classes" + ); +} diff --git a/tests/testsuite/search/reasonable_search_index/expected_index.js b/tests/testsuite/search/reasonable_search_index/expected_index.js new file mode 100644 index 00000000..776cb46d --- /dev/null +++ b/tests/testsuite/search/reasonable_search_index/expected_index.js @@ -0,0 +1 @@ +Object.assign(window.search, {"doc_urls":["intro.html#introduction","intro.html#sneaky","first/index.html#first-chapter","first/index.html#some-section","first/includes.html#includes","first/includes.html#summary","first/unicode.html#unicode-stress-tests","first/no-headers.html","first/duplicate-headers.html#duplicate-headers","first/duplicate-headers.html#header-text","first/duplicate-headers.html#header-text-1","first/duplicate-headers.html#header-text-2","first/heading-attributes.html#attrs","first/heading-attributes.html#heading-with-classes","first/heading-attributes.html#both"],"index":{"documentStore":{"docInfo":{"0":{"body":3,"breadcrumbs":2,"title":1},"1":{"body":10,"breadcrumbs":2,"title":1},"10":{"body":0,"breadcrumbs":6,"title":2},"11":{"body":0,"breadcrumbs":6,"title":2},"12":{"body":0,"breadcrumbs":6,"title":2},"13":{"body":0,"breadcrumbs":6,"title":2},"14":{"body":0,"breadcrumbs":7,"title":3},"2":{"body":2,"breadcrumbs":4,"title":2},"3":{"body":0,"breadcrumbs":3,"title":1},"4":{"body":0,"breadcrumbs":4,"title":1},"5":{"body":10,"breadcrumbs":4,"title":1},"6":{"body":29,"breadcrumbs":6,"title":3},"7":{"body":6,"breadcrumbs":3,"title":2},"8":{"body":5,"breadcrumbs":6,"title":2},"9":{"body":0,"breadcrumbs":6,"title":2}},"docs":{"0":{"body":"Here's some interesting text...","breadcrumbs":"Introduction » Introduction","id":"0","title":"Introduction"},"1":{"body":"I put <HTML> in here! Sneaky inline event alert(/"inline/");. But regular inline is indexed.","breadcrumbs":"Introduction » Sneaky","id":"1","title":"Sneaky"},"10":{"body":"","breadcrumbs":"First Chapter » Duplicate Headers » Header Text","id":"10","title":"Header Text"},"11":{"body":"","breadcrumbs":"First Chapter » Duplicate Headers » header-text","id":"11","title":"header-text"},"12":{"body":"","breadcrumbs":"First Chapter » Heading Attributes » Heading Attributes","id":"12","title":"Heading Attributes"},"13":{"body":"","breadcrumbs":"First Chapter » Heading Attributes » Heading with classes","id":"13","title":"Heading with classes"},"14":{"body":"","breadcrumbs":"First Chapter » Heading Attributes » Heading with id and classes","id":"14","title":"Heading with id and classes"},"2":{"body":"more text.","breadcrumbs":"First Chapter » First Chapter","id":"2","title":"First Chapter"},"3":{"body":"","breadcrumbs":"First Chapter » Some Section","id":"3","title":"Some Section"},"4":{"body":"","breadcrumbs":"First Chapter » Includes » Includes","id":"4","title":"Includes"},"5":{"body":"Introduction First Chapter Includes Unicode No Headers Duplicate Headers Heading Attributes","breadcrumbs":"First Chapter » Includes » Summary","id":"5","title":"Summary"},"6":{"body":"Please be careful editing, this contains carefully crafted characters. Two byte character: spatiëring Combining character: spatiëring Three byte character: 书こんにちは Four byte character: 𐌀‮𐌁‮𐌂‮𐌃‮𐌄‮𐌅‮𐌆‮𐌇‮𐌈‬ Right-to-left: مرحبا Emoticons: 🔊 😍 💜 1️⃣ right-to-left mark: hello באמת!‏ Zalgo: ǫ̛̖̱̗̝͈̋͒͋̏ͥͫ̒̆ͩ̏͌̾͊͐ͪ̾̚","breadcrumbs":"First Chapter » Unicode » Unicode stress tests","id":"6","title":"Unicode stress tests"},"7":{"body":"Capybara capybara capybara. Capybara capybara capybara. ThisLongWordIsIncludedSoWeCanCheckThatSufficientlyLongWordsAreOmittedFromTheSearchIndex.","breadcrumbs":"First Chapter » No Headers","id":"7","title":"First Chapter"},"8":{"body":"This page validates behaviour of duplicate headers.","breadcrumbs":"First Chapter » Duplicate Headers » Duplicate headers","id":"8","title":"Duplicate headers"},"9":{"body":"","breadcrumbs":"First Chapter » Duplicate Headers » Header Text","id":"9","title":"Header Text"}},"length":15,"save":true},"fields":["title","body","breadcrumbs"],"index":{"body":{"root":{"1":{"df":1,"docs":{"6":{"tf":1.0}}},"a":{"df":0,"docs":{},"l":{"df":0,"docs":{},"e":{"df":0,"docs":{},"r":{"df":0,"docs":{},"t":{"(":{"/"":{"df":0,"docs":{},"i":{"df":0,"docs":{},"n":{"df":0,"docs":{},"l":{"df":0,"docs":{},"i":{"df":0,"docs":{},"n":{"df":1,"docs":{"1":{"tf":1.0}}}}}}}},"df":0,"docs":{}},"df":0,"docs":{}}}}},"t":{"df":0,"docs":{},"t":{"df":0,"docs":{},"r":{"df":0,"docs":{},"i":{"b":{"df":0,"docs":{},"u":{"df":0,"docs":{},"t":{"df":2,"docs":{"12":{"tf":1.0},"5":{"tf":1.0}}}}},"df":0,"docs":{}}}}}},"b":{"df":0,"docs":{},"e":{"df":0,"docs":{},"h":{"a":{"df":0,"docs":{},"v":{"df":0,"docs":{},"i":{"df":0,"docs":{},"o":{"df":0,"docs":{},"u":{"df":0,"docs":{},"r":{"df":1,"docs":{"8":{"tf":1.0}}}}}}}},"df":0,"docs":{}}},"y":{"df":0,"docs":{},"t":{"df":0,"docs":{},"e":{"df":1,"docs":{"6":{"tf":1.7320508075688772}}}}}},"c":{"a":{"df":0,"docs":{},"p":{"df":0,"docs":{},"y":{"b":{"a":{"df":0,"docs":{},"r":{"a":{"df":1,"docs":{"7":{"tf":2.449489742783178}}},"df":0,"docs":{}}},"df":0,"docs":{}},"df":0,"docs":{}}},"r":{"df":0,"docs":{},"e":{"df":1,"docs":{"6":{"tf":1.0}},"f":{"df":0,"docs":{},"u":{"df":0,"docs":{},"l":{"df":0,"docs":{},"l":{"df":0,"docs":{},"i":{"df":1,"docs":{"6":{"tf":1.0}}}}}}}}}},"df":0,"docs":{},"h":{"a":{"df":0,"docs":{},"p":{"df":0,"docs":{},"t":{"df":0,"docs":{},"e":{"df":0,"docs":{},"r":{"df":3,"docs":{"2":{"tf":1.0},"5":{"tf":1.0},"7":{"tf":1.0}}}}}},"r":{"a":{"c":{"df":0,"docs":{},"t":{"df":1,"docs":{"6":{"tf":2.23606797749979}}}},"df":0,"docs":{}},"df":0,"docs":{}}},"df":0,"docs":{}},"l":{"a":{"df":0,"docs":{},"s":{"df":0,"docs":{},"s":{"df":2,"docs":{"13":{"tf":1.0},"14":{"tf":1.0}}}}},"df":0,"docs":{}},"o":{"df":0,"docs":{},"m":{"b":{"df":0,"docs":{},"i":{"df":0,"docs":{},"n":{"df":1,"docs":{"6":{"tf":1.0}}}}},"df":0,"docs":{}},"n":{"df":0,"docs":{},"t":{"a":{"df":0,"docs":{},"i":{"df":0,"docs":{},"n":{"df":1,"docs":{"6":{"tf":1.0}}}}},"df":0,"docs":{}}}},"r":{"a":{"df":0,"docs":{},"f":{"df":0,"docs":{},"t":{"df":1,"docs":{"6":{"tf":1.0}}}}},"df":0,"docs":{}}},"d":{"df":0,"docs":{},"u":{"df":0,"docs":{},"p":{"df":0,"docs":{},"l":{"df":0,"docs":{},"i":{"c":{"df":2,"docs":{"5":{"tf":1.0},"8":{"tf":1.4142135623730951}}},"df":0,"docs":{}}}}}},"df":0,"docs":{},"e":{"d":{"df":0,"docs":{},"i":{"df":0,"docs":{},"t":{"df":1,"docs":{"6":{"tf":1.0}}}}},"df":0,"docs":{},"m":{"df":0,"docs":{},"o":{"df":0,"docs":{},"t":{"df":0,"docs":{},"i":{"c":{"df":0,"docs":{},"o":{"df":0,"docs":{},"n":{"df":1,"docs":{"6":{"tf":1.0}}}}},"df":0,"docs":{}}}}},"v":{"df":0,"docs":{},"e":{"df":0,"docs":{},"n":{"df":0,"docs":{},"t":{"df":1,"docs":{"1":{"tf":1.0}}}}}}},"f":{"df":0,"docs":{},"i":{"df":0,"docs":{},"r":{"df":0,"docs":{},"s":{"df":0,"docs":{},"t":{"df":3,"docs":{"2":{"tf":1.0},"5":{"tf":1.0},"7":{"tf":1.0}}}}}},"o":{"df":0,"docs":{},"u":{"df":0,"docs":{},"r":{"df":1,"docs":{"6":{"tf":1.0}}}}}},"h":{"df":0,"docs":{},"e":{"a":{"d":{"df":4,"docs":{"12":{"tf":1.0},"13":{"tf":1.0},"14":{"tf":1.0},"5":{"tf":1.0}},"e":{"df":0,"docs":{},"r":{"df":5,"docs":{"10":{"tf":1.0},"11":{"tf":1.0},"5":{"tf":1.4142135623730951},"8":{"tf":1.4142135623730951},"9":{"tf":1.0}}}}},"df":0,"docs":{}},"df":0,"docs":{},"l":{"df":0,"docs":{},"l":{"df":0,"docs":{},"o":{"df":1,"docs":{"6":{"tf":1.0}}}}},"r":{"df":0,"docs":{},"e":{"'":{"df":1,"docs":{"0":{"tf":1.0}}},"df":1,"docs":{"1":{"tf":1.0}}}}}},"i":{"d":{"df":1,"docs":{"14":{"tf":1.0}}},"df":0,"docs":{},"n":{"c":{"df":0,"docs":{},"l":{"df":0,"docs":{},"u":{"d":{"df":2,"docs":{"4":{"tf":1.0},"5":{"tf":1.0}}},"df":0,"docs":{}}}},"d":{"df":0,"docs":{},"e":{"df":0,"docs":{},"x":{"df":1,"docs":{"1":{"tf":1.0}}}}},"df":0,"docs":{},"l":{"df":0,"docs":{},"i":{"df":0,"docs":{},"n":{"df":1,"docs":{"1":{"tf":1.4142135623730951}}}}},"t":{"df":0,"docs":{},"e":{"df":0,"docs":{},"r":{"df":0,"docs":{},"e":{"df":0,"docs":{},"s":{"df":0,"docs":{},"t":{"df":1,"docs":{"0":{"tf":1.0}}}}}}},"r":{"df":0,"docs":{},"o":{"d":{"df":0,"docs":{},"u":{"c":{"df":0,"docs":{},"t":{"df":2,"docs":{"0":{"tf":1.0},"5":{"tf":1.0}}}},"df":0,"docs":{}}},"df":0,"docs":{}}}}}},"l":{"df":0,"docs":{},"e":{"df":0,"docs":{},"f":{"df":0,"docs":{},"t":{"df":1,"docs":{"6":{"tf":1.4142135623730951}}}}},"t":{";":{"df":0,"docs":{},"h":{"df":0,"docs":{},"t":{"df":0,"docs":{},"m":{"df":0,"docs":{},"l":{"&":{"df":0,"docs":{},"g":{"df":0,"docs":{},"t":{"df":1,"docs":{"1":{"tf":1.0}}}}},"df":0,"docs":{}}}}}},"df":0,"docs":{}}},"m":{"a":{"df":0,"docs":{},"r":{"df":0,"docs":{},"k":{"df":1,"docs":{"6":{"tf":1.0}}}}},"df":0,"docs":{},"o":{"df":0,"docs":{},"r":{"df":0,"docs":{},"e":{"df":1,"docs":{"2":{"tf":1.0}}}}}},"p":{"a":{"df":0,"docs":{},"g":{"df":0,"docs":{},"e":{"df":1,"docs":{"8":{"tf":1.0}}}}},"df":0,"docs":{},"l":{"df":0,"docs":{},"e":{"a":{"df":0,"docs":{},"s":{"df":1,"docs":{"6":{"tf":1.0}}}},"df":0,"docs":{}}},"u":{"df":0,"docs":{},"t":{"df":1,"docs":{"1":{"tf":1.0}}}}},"r":{"df":0,"docs":{},"e":{"df":0,"docs":{},"g":{"df":0,"docs":{},"u":{"df":0,"docs":{},"l":{"a":{"df":0,"docs":{},"r":{"df":1,"docs":{"1":{"tf":1.0}}}},"df":0,"docs":{}}}}},"i":{"df":0,"docs":{},"g":{"df":0,"docs":{},"h":{"df":0,"docs":{},"t":{"df":1,"docs":{"6":{"tf":1.4142135623730951}}}}}}},"s":{"df":0,"docs":{},"e":{"c":{"df":0,"docs":{},"t":{"df":0,"docs":{},"i":{"df":0,"docs":{},"o":{"df":0,"docs":{},"n":{"df":1,"docs":{"3":{"tf":1.0}}}}}}},"df":0,"docs":{}},"n":{"df":0,"docs":{},"e":{"a":{"df":0,"docs":{},"k":{"df":0,"docs":{},"i":{"df":1,"docs":{"1":{"tf":1.4142135623730951}}}}},"df":0,"docs":{}}},"p":{"a":{"df":0,"docs":{},"t":{"df":0,"docs":{},"i":{"df":0,"docs":{},"e":{"df":0,"docs":{},"̈":{"df":0,"docs":{},"r":{"df":1,"docs":{"6":{"tf":1.0}}}}},"ë":{"df":0,"docs":{},"r":{"df":1,"docs":{"6":{"tf":1.0}}}}}}},"df":0,"docs":{}},"t":{"df":0,"docs":{},"r":{"df":0,"docs":{},"e":{"df":0,"docs":{},"s":{"df":0,"docs":{},"s":{"df":1,"docs":{"6":{"tf":1.0}}}}}}},"u":{"df":0,"docs":{},"m":{"df":0,"docs":{},"m":{"a":{"df":0,"docs":{},"r":{"df":0,"docs":{},"i":{"df":1,"docs":{"5":{"tf":1.0}}}}},"df":0,"docs":{}}}}},"t":{"df":0,"docs":{},"e":{"df":0,"docs":{},"s":{"df":0,"docs":{},"t":{"df":1,"docs":{"6":{"tf":1.0}}}},"x":{"df":0,"docs":{},"t":{"df":5,"docs":{"0":{"tf":1.0},"10":{"tf":1.0},"11":{"tf":1.0},"2":{"tf":1.0},"9":{"tf":1.0}}}}},"h":{"df":0,"docs":{},"r":{"df":0,"docs":{},"e":{"df":0,"docs":{},"e":{"df":1,"docs":{"6":{"tf":1.0}}}}}},"w":{"df":0,"docs":{},"o":{"df":1,"docs":{"6":{"tf":1.0}}}}},"u":{"df":0,"docs":{},"n":{"df":0,"docs":{},"i":{"c":{"df":0,"docs":{},"o":{"d":{"df":2,"docs":{"5":{"tf":1.0},"6":{"tf":1.0}}},"df":0,"docs":{}}},"df":0,"docs":{}}}},"v":{"a":{"df":0,"docs":{},"l":{"df":0,"docs":{},"i":{"d":{"df":1,"docs":{"8":{"tf":1.0}}},"df":0,"docs":{}}}},"df":0,"docs":{}},"z":{"a":{"df":0,"docs":{},"l":{"df":0,"docs":{},"g":{"df":0,"docs":{},"o":{"df":1,"docs":{"6":{"tf":1.0}}}}}},"df":0,"docs":{}}}},"breadcrumbs":{"root":{"1":{"df":1,"docs":{"6":{"tf":1.0}}},"a":{"df":0,"docs":{},"l":{"df":0,"docs":{},"e":{"df":0,"docs":{},"r":{"df":0,"docs":{},"t":{"(":{"/"":{"df":0,"docs":{},"i":{"df":0,"docs":{},"n":{"df":0,"docs":{},"l":{"df":0,"docs":{},"i":{"df":0,"docs":{},"n":{"df":1,"docs":{"1":{"tf":1.0}}}}}}}},"df":0,"docs":{}},"df":0,"docs":{}}}}},"t":{"df":0,"docs":{},"t":{"df":0,"docs":{},"r":{"df":0,"docs":{},"i":{"b":{"df":0,"docs":{},"u":{"df":0,"docs":{},"t":{"df":4,"docs":{"12":{"tf":1.7320508075688772},"13":{"tf":1.0},"14":{"tf":1.0},"5":{"tf":1.0}}}}},"df":0,"docs":{}}}}}},"b":{"df":0,"docs":{},"e":{"df":0,"docs":{},"h":{"a":{"df":0,"docs":{},"v":{"df":0,"docs":{},"i":{"df":0,"docs":{},"o":{"df":0,"docs":{},"u":{"df":0,"docs":{},"r":{"df":1,"docs":{"8":{"tf":1.0}}}}}}}},"df":0,"docs":{}}},"y":{"df":0,"docs":{},"t":{"df":0,"docs":{},"e":{"df":1,"docs":{"6":{"tf":1.7320508075688772}}}}}},"c":{"a":{"df":0,"docs":{},"p":{"df":0,"docs":{},"y":{"b":{"a":{"df":0,"docs":{},"r":{"a":{"df":1,"docs":{"7":{"tf":2.449489742783178}}},"df":0,"docs":{}}},"df":0,"docs":{}},"df":0,"docs":{}}},"r":{"df":0,"docs":{},"e":{"df":1,"docs":{"6":{"tf":1.0}},"f":{"df":0,"docs":{},"u":{"df":0,"docs":{},"l":{"df":0,"docs":{},"l":{"df":0,"docs":{},"i":{"df":1,"docs":{"6":{"tf":1.0}}}}}}}}}},"df":0,"docs":{},"h":{"a":{"df":0,"docs":{},"p":{"df":0,"docs":{},"t":{"df":0,"docs":{},"e":{"df":0,"docs":{},"r":{"df":13,"docs":{"10":{"tf":1.0},"11":{"tf":1.0},"12":{"tf":1.0},"13":{"tf":1.0},"14":{"tf":1.0},"2":{"tf":1.7320508075688772},"3":{"tf":1.0},"4":{"tf":1.0},"5":{"tf":1.4142135623730951},"6":{"tf":1.0},"7":{"tf":1.4142135623730951},"8":{"tf":1.0},"9":{"tf":1.0}}}}}},"r":{"a":{"c":{"df":0,"docs":{},"t":{"df":1,"docs":{"6":{"tf":2.23606797749979}}}},"df":0,"docs":{}},"df":0,"docs":{}}},"df":0,"docs":{}},"l":{"a":{"df":0,"docs":{},"s":{"df":0,"docs":{},"s":{"df":2,"docs":{"13":{"tf":1.4142135623730951},"14":{"tf":1.4142135623730951}}}}},"df":0,"docs":{}},"o":{"df":0,"docs":{},"m":{"b":{"df":0,"docs":{},"i":{"df":0,"docs":{},"n":{"df":1,"docs":{"6":{"tf":1.0}}}}},"df":0,"docs":{}},"n":{"df":0,"docs":{},"t":{"a":{"df":0,"docs":{},"i":{"df":0,"docs":{},"n":{"df":1,"docs":{"6":{"tf":1.0}}}}},"df":0,"docs":{}}}},"r":{"a":{"df":0,"docs":{},"f":{"df":0,"docs":{},"t":{"df":1,"docs":{"6":{"tf":1.0}}}}},"df":0,"docs":{}}},"d":{"df":0,"docs":{},"u":{"df":0,"docs":{},"p":{"df":0,"docs":{},"l":{"df":0,"docs":{},"i":{"c":{"df":5,"docs":{"10":{"tf":1.0},"11":{"tf":1.0},"5":{"tf":1.0},"8":{"tf":2.0},"9":{"tf":1.0}}},"df":0,"docs":{}}}}}},"df":0,"docs":{},"e":{"d":{"df":0,"docs":{},"i":{"df":0,"docs":{},"t":{"df":1,"docs":{"6":{"tf":1.0}}}}},"df":0,"docs":{},"m":{"df":0,"docs":{},"o":{"df":0,"docs":{},"t":{"df":0,"docs":{},"i":{"c":{"df":0,"docs":{},"o":{"df":0,"docs":{},"n":{"df":1,"docs":{"6":{"tf":1.0}}}}},"df":0,"docs":{}}}}},"v":{"df":0,"docs":{},"e":{"df":0,"docs":{},"n":{"df":0,"docs":{},"t":{"df":1,"docs":{"1":{"tf":1.0}}}}}}},"f":{"df":0,"docs":{},"i":{"df":0,"docs":{},"r":{"df":0,"docs":{},"s":{"df":0,"docs":{},"t":{"df":13,"docs":{"10":{"tf":1.0},"11":{"tf":1.0},"12":{"tf":1.0},"13":{"tf":1.0},"14":{"tf":1.0},"2":{"tf":1.7320508075688772},"3":{"tf":1.0},"4":{"tf":1.0},"5":{"tf":1.4142135623730951},"6":{"tf":1.0},"7":{"tf":1.4142135623730951},"8":{"tf":1.0},"9":{"tf":1.0}}}}}},"o":{"df":0,"docs":{},"u":{"df":0,"docs":{},"r":{"df":1,"docs":{"6":{"tf":1.0}}}}}},"h":{"df":0,"docs":{},"e":{"a":{"d":{"df":4,"docs":{"12":{"tf":1.7320508075688772},"13":{"tf":1.7320508075688772},"14":{"tf":1.7320508075688772},"5":{"tf":1.0}},"e":{"df":0,"docs":{},"r":{"df":6,"docs":{"10":{"tf":1.7320508075688772},"11":{"tf":1.7320508075688772},"5":{"tf":1.4142135623730951},"7":{"tf":1.0},"8":{"tf":2.0},"9":{"tf":1.7320508075688772}}}}},"df":0,"docs":{}},"df":0,"docs":{},"l":{"df":0,"docs":{},"l":{"df":0,"docs":{},"o":{"df":1,"docs":{"6":{"tf":1.0}}}}},"r":{"df":0,"docs":{},"e":{"'":{"df":1,"docs":{"0":{"tf":1.0}}},"df":1,"docs":{"1":{"tf":1.0}}}}}},"i":{"d":{"df":1,"docs":{"14":{"tf":1.4142135623730951}}},"df":0,"docs":{},"n":{"c":{"df":0,"docs":{},"l":{"df":0,"docs":{},"u":{"d":{"df":2,"docs":{"4":{"tf":1.7320508075688772},"5":{"tf":1.4142135623730951}}},"df":0,"docs":{}}}},"d":{"df":0,"docs":{},"e":{"df":0,"docs":{},"x":{"df":1,"docs":{"1":{"tf":1.0}}}}},"df":0,"docs":{},"l":{"df":0,"docs":{},"i":{"df":0,"docs":{},"n":{"df":1,"docs":{"1":{"tf":1.4142135623730951}}}}},"t":{"df":0,"docs":{},"e":{"df":0,"docs":{},"r":{"df":0,"docs":{},"e":{"df":0,"docs":{},"s":{"df":0,"docs":{},"t":{"df":1,"docs":{"0":{"tf":1.0}}}}}}},"r":{"df":0,"docs":{},"o":{"d":{"df":0,"docs":{},"u":{"c":{"df":0,"docs":{},"t":{"df":3,"docs":{"0":{"tf":1.7320508075688772},"1":{"tf":1.0},"5":{"tf":1.0}}}},"df":0,"docs":{}}},"df":0,"docs":{}}}}}},"l":{"df":0,"docs":{},"e":{"df":0,"docs":{},"f":{"df":0,"docs":{},"t":{"df":1,"docs":{"6":{"tf":1.4142135623730951}}}}},"t":{";":{"df":0,"docs":{},"h":{"df":0,"docs":{},"t":{"df":0,"docs":{},"m":{"df":0,"docs":{},"l":{"&":{"df":0,"docs":{},"g":{"df":0,"docs":{},"t":{"df":1,"docs":{"1":{"tf":1.0}}}}},"df":0,"docs":{}}}}}},"df":0,"docs":{}}},"m":{"a":{"df":0,"docs":{},"r":{"df":0,"docs":{},"k":{"df":1,"docs":{"6":{"tf":1.0}}}}},"df":0,"docs":{},"o":{"df":0,"docs":{},"r":{"df":0,"docs":{},"e":{"df":1,"docs":{"2":{"tf":1.0}}}}}},"p":{"a":{"df":0,"docs":{},"g":{"df":0,"docs":{},"e":{"df":1,"docs":{"8":{"tf":1.0}}}}},"df":0,"docs":{},"l":{"df":0,"docs":{},"e":{"a":{"df":0,"docs":{},"s":{"df":1,"docs":{"6":{"tf":1.0}}}},"df":0,"docs":{}}},"u":{"df":0,"docs":{},"t":{"df":1,"docs":{"1":{"tf":1.0}}}}},"r":{"df":0,"docs":{},"e":{"df":0,"docs":{},"g":{"df":0,"docs":{},"u":{"df":0,"docs":{},"l":{"a":{"df":0,"docs":{},"r":{"df":1,"docs":{"1":{"tf":1.0}}}},"df":0,"docs":{}}}}},"i":{"df":0,"docs":{},"g":{"df":0,"docs":{},"h":{"df":0,"docs":{},"t":{"df":1,"docs":{"6":{"tf":1.4142135623730951}}}}}}},"s":{"df":0,"docs":{},"e":{"c":{"df":0,"docs":{},"t":{"df":0,"docs":{},"i":{"df":0,"docs":{},"o":{"df":0,"docs":{},"n":{"df":1,"docs":{"3":{"tf":1.4142135623730951}}}}}}},"df":0,"docs":{}},"n":{"df":0,"docs":{},"e":{"a":{"df":0,"docs":{},"k":{"df":0,"docs":{},"i":{"df":1,"docs":{"1":{"tf":1.7320508075688772}}}}},"df":0,"docs":{}}},"p":{"a":{"df":0,"docs":{},"t":{"df":0,"docs":{},"i":{"df":0,"docs":{},"e":{"df":0,"docs":{},"̈":{"df":0,"docs":{},"r":{"df":1,"docs":{"6":{"tf":1.0}}}}},"ë":{"df":0,"docs":{},"r":{"df":1,"docs":{"6":{"tf":1.0}}}}}}},"df":0,"docs":{}},"t":{"df":0,"docs":{},"r":{"df":0,"docs":{},"e":{"df":0,"docs":{},"s":{"df":0,"docs":{},"s":{"df":1,"docs":{"6":{"tf":1.4142135623730951}}}}}}},"u":{"df":0,"docs":{},"m":{"df":0,"docs":{},"m":{"a":{"df":0,"docs":{},"r":{"df":0,"docs":{},"i":{"df":1,"docs":{"5":{"tf":1.4142135623730951}}}}},"df":0,"docs":{}}}}},"t":{"df":0,"docs":{},"e":{"df":0,"docs":{},"s":{"df":0,"docs":{},"t":{"df":1,"docs":{"6":{"tf":1.4142135623730951}}}},"x":{"df":0,"docs":{},"t":{"df":5,"docs":{"0":{"tf":1.0},"10":{"tf":1.4142135623730951},"11":{"tf":1.4142135623730951},"2":{"tf":1.0},"9":{"tf":1.4142135623730951}}}}},"h":{"df":0,"docs":{},"r":{"df":0,"docs":{},"e":{"df":0,"docs":{},"e":{"df":1,"docs":{"6":{"tf":1.0}}}}}},"w":{"df":0,"docs":{},"o":{"df":1,"docs":{"6":{"tf":1.0}}}}},"u":{"df":0,"docs":{},"n":{"df":0,"docs":{},"i":{"c":{"df":0,"docs":{},"o":{"d":{"df":2,"docs":{"5":{"tf":1.0},"6":{"tf":1.7320508075688772}}},"df":0,"docs":{}}},"df":0,"docs":{}}}},"v":{"a":{"df":0,"docs":{},"l":{"df":0,"docs":{},"i":{"d":{"df":1,"docs":{"8":{"tf":1.0}}},"df":0,"docs":{}}}},"df":0,"docs":{}},"z":{"a":{"df":0,"docs":{},"l":{"df":0,"docs":{},"g":{"df":0,"docs":{},"o":{"df":1,"docs":{"6":{"tf":1.0}}}}}},"df":0,"docs":{}}}},"title":{"root":{"a":{"df":0,"docs":{},"t":{"df":0,"docs":{},"t":{"df":0,"docs":{},"r":{"df":0,"docs":{},"i":{"b":{"df":0,"docs":{},"u":{"df":0,"docs":{},"t":{"df":1,"docs":{"12":{"tf":1.0}}}}},"df":0,"docs":{}}}}}},"c":{"df":0,"docs":{},"h":{"a":{"df":0,"docs":{},"p":{"df":0,"docs":{},"t":{"df":0,"docs":{},"e":{"df":0,"docs":{},"r":{"df":2,"docs":{"2":{"tf":1.0},"7":{"tf":1.0}}}}}}},"df":0,"docs":{}},"l":{"a":{"df":0,"docs":{},"s":{"df":0,"docs":{},"s":{"df":2,"docs":{"13":{"tf":1.0},"14":{"tf":1.0}}}}},"df":0,"docs":{}}},"d":{"df":0,"docs":{},"u":{"df":0,"docs":{},"p":{"df":0,"docs":{},"l":{"df":0,"docs":{},"i":{"c":{"df":1,"docs":{"8":{"tf":1.0}}},"df":0,"docs":{}}}}}},"df":0,"docs":{},"f":{"df":0,"docs":{},"i":{"df":0,"docs":{},"r":{"df":0,"docs":{},"s":{"df":0,"docs":{},"t":{"df":2,"docs":{"2":{"tf":1.0},"7":{"tf":1.0}}}}}}},"h":{"df":0,"docs":{},"e":{"a":{"d":{"df":3,"docs":{"12":{"tf":1.0},"13":{"tf":1.0},"14":{"tf":1.0}},"e":{"df":0,"docs":{},"r":{"df":4,"docs":{"10":{"tf":1.0},"11":{"tf":1.0},"8":{"tf":1.0},"9":{"tf":1.0}}}}},"df":0,"docs":{}},"df":0,"docs":{}}},"i":{"d":{"df":1,"docs":{"14":{"tf":1.0}}},"df":0,"docs":{},"n":{"c":{"df":0,"docs":{},"l":{"df":0,"docs":{},"u":{"d":{"df":1,"docs":{"4":{"tf":1.0}}},"df":0,"docs":{}}}},"df":0,"docs":{},"t":{"df":0,"docs":{},"r":{"df":0,"docs":{},"o":{"d":{"df":0,"docs":{},"u":{"c":{"df":0,"docs":{},"t":{"df":1,"docs":{"0":{"tf":1.0}}}},"df":0,"docs":{}}},"df":0,"docs":{}}}}}},"s":{"df":0,"docs":{},"e":{"c":{"df":0,"docs":{},"t":{"df":0,"docs":{},"i":{"df":0,"docs":{},"o":{"df":0,"docs":{},"n":{"df":1,"docs":{"3":{"tf":1.0}}}}}}},"df":0,"docs":{}},"n":{"df":0,"docs":{},"e":{"a":{"df":0,"docs":{},"k":{"df":0,"docs":{},"i":{"df":1,"docs":{"1":{"tf":1.0}}}}},"df":0,"docs":{}}},"t":{"df":0,"docs":{},"r":{"df":0,"docs":{},"e":{"df":0,"docs":{},"s":{"df":0,"docs":{},"s":{"df":1,"docs":{"6":{"tf":1.0}}}}}}},"u":{"df":0,"docs":{},"m":{"df":0,"docs":{},"m":{"a":{"df":0,"docs":{},"r":{"df":0,"docs":{},"i":{"df":1,"docs":{"5":{"tf":1.0}}}}},"df":0,"docs":{}}}}},"t":{"df":0,"docs":{},"e":{"df":0,"docs":{},"s":{"df":0,"docs":{},"t":{"df":1,"docs":{"6":{"tf":1.0}}}},"x":{"df":0,"docs":{},"t":{"df":3,"docs":{"10":{"tf":1.0},"11":{"tf":1.0},"9":{"tf":1.0}}}}}},"u":{"df":0,"docs":{},"n":{"df":0,"docs":{},"i":{"c":{"df":0,"docs":{},"o":{"d":{"df":1,"docs":{"6":{"tf":1.0}}},"df":0,"docs":{}}},"df":0,"docs":{}}}}}}},"lang":"English","pipeline":["trimmer","stopWordFilter","stemmer"],"ref":"id","version":"0.9.5"},"results_options":{"limit_results":30,"teaser_word_count":30},"search_options":{"bool":"OR","expand":true,"fields":{"body":{"boost":1},"breadcrumbs":{"boost":1},"title":{"boost":2}}}}); \ No newline at end of file diff --git a/tests/testsuite/search/reasonable_search_index/src/SUMMARY.md b/tests/testsuite/search/reasonable_search_index/src/SUMMARY.md new file mode 100644 index 00000000..c4fe0838 --- /dev/null +++ b/tests/testsuite/search/reasonable_search_index/src/SUMMARY.md @@ -0,0 +1,10 @@ +# Summary + +[Introduction](intro.md) + +- [First Chapter](first/index.md) + - [Includes](first/includes.md) + - [Unicode](first/unicode.md) + - [No Headers](first/no-headers.md) + - [Duplicate Headers](first/duplicate-headers.md) + - [Heading Attributes](first/heading-attributes.md) diff --git a/tests/testsuite/search/reasonable_search_index/src/first/duplicate-headers.md b/tests/testsuite/search/reasonable_search_index/src/first/duplicate-headers.md new file mode 100644 index 00000000..83522b44 --- /dev/null +++ b/tests/testsuite/search/reasonable_search_index/src/first/duplicate-headers.md @@ -0,0 +1,9 @@ +# Duplicate headers + +This page validates behaviour of duplicate headers. + +# Header Text + +# Header Text + +# header-text diff --git a/tests/testsuite/search/reasonable_search_index/src/first/heading-attributes.md b/tests/testsuite/search/reasonable_search_index/src/first/heading-attributes.md new file mode 100644 index 00000000..a09a22b6 --- /dev/null +++ b/tests/testsuite/search/reasonable_search_index/src/first/heading-attributes.md @@ -0,0 +1,5 @@ +# Heading Attributes {#attrs} + +## Heading with classes {.class1 .class2} + +## Heading with id and classes {#both .class1 .class2} diff --git a/tests/testsuite/search/reasonable_search_index/src/first/includes.md b/tests/testsuite/search/reasonable_search_index/src/first/includes.md new file mode 100644 index 00000000..93ce0721 --- /dev/null +++ b/tests/testsuite/search/reasonable_search_index/src/first/includes.md @@ -0,0 +1,3 @@ +# Includes + +{{#include ../SUMMARY.md::}} diff --git a/tests/testsuite/search/reasonable_search_index/src/first/index.md b/tests/testsuite/search/reasonable_search_index/src/first/index.md new file mode 100644 index 00000000..200672b9 --- /dev/null +++ b/tests/testsuite/search/reasonable_search_index/src/first/index.md @@ -0,0 +1,5 @@ +# First Chapter + +more text. + +## Some Section diff --git a/tests/testsuite/search/reasonable_search_index/src/first/no-headers.md b/tests/testsuite/search/reasonable_search_index/src/first/no-headers.md new file mode 100644 index 00000000..5d799aa6 --- /dev/null +++ b/tests/testsuite/search/reasonable_search_index/src/first/no-headers.md @@ -0,0 +1,5 @@ +Capybara capybara capybara. + +Capybara capybara capybara. + +ThisLongWordIsIncludedSoWeCanCheckThatSufficientlyLongWordsAreOmittedFromTheSearchIndex. diff --git a/tests/testsuite/search/reasonable_search_index/src/first/unicode.md b/tests/testsuite/search/reasonable_search_index/src/first/unicode.md new file mode 100644 index 00000000..160cc367 --- /dev/null +++ b/tests/testsuite/search/reasonable_search_index/src/first/unicode.md @@ -0,0 +1,21 @@ +# Unicode stress tests + +Please be careful editing, this contains carefully crafted characters. + +Two byte character: spatiëring + +Combining character: spatiëring + +Three byte character: 书こんにちは + +Four byte character: 𐌀‮𐌁‮𐌂‮𐌃‮𐌄‮𐌅‮𐌆‮𐌇‮𐌈‬ + +Right-to-left: مرحبا + +Emoticons: 🔊 😍 💜 1️⃣ + +right-to-left mark: hello באמת!‏ + + +Zalgo: ǫ̛̖̱̗̝͈̋͒͋̏ͥͫ̒̆ͩ̏͌̾͊͐ͪ̾̚ + diff --git a/tests/testsuite/search/reasonable_search_index/src/intro.md b/tests/testsuite/search/reasonable_search_index/src/intro.md new file mode 100644 index 00000000..93dbcb82 --- /dev/null +++ b/tests/testsuite/search/reasonable_search_index/src/intro.md @@ -0,0 +1,28 @@ +# Introduction + +Here's some interesting text... + +## Sneaky + +

+ +I put <HTML> in here!
+

+ + + +Sneaky inline event . + +But regular inline is indexed.