;; Extension — highlight + snippet over document text. ;; Text: "the quick brown fox jumps" (define hl-cases (list (list "highlight two terms" "highlight [\"quick\", \"fox\"] \"the quick brown fox jumps\"" "the [quick] brown [fox] jumps") (list "highlight none" "highlight [] \"the quick brown fox jumps\"" "the quick brown fox jumps") (list "highlight absent term" "highlight [\"zzz\"] \"the quick brown fox jumps\"" "the quick brown fox jumps") (list "highlight first token" "highlight [\"the\"] \"the quick brown fox jumps\"" "[the] quick brown fox jumps") (list "highlight normalizes text" "highlight [\"quick\"] \"The Quick, brown!\"" "the [quick] brown") (list "snippet around middle" "snippet 1 [\"brown\"] \"the quick brown fox jumps\"" "quick [brown] fox") (list "snippet at start" "snippet 1 [\"the\"] \"the quick brown fox jumps\"" "[the] quick brown") (list "snippet near end" "snippet 1 [\"fox\"] \"the quick brown fox jumps\"" "brown [fox] jumps") (list "snippet ctx zero" "snippet 0 [\"brown\"] \"the quick brown fox jumps\"" "[brown]") (list "snippet clamps at end" "snippet 2 [\"jumps\"] \"the quick brown fox jumps\"" "brown fox [jumps]") (list "snippet no match shows head" "snippet 1 [\"zzz\"] \"the quick brown fox jumps\"" "the quick brown") (list "snippet wide window" "snippet 5 [\"brown\"] \"the quick brown fox jumps\"" "the quick [brown] fox jumps"))) (define hl-results (search-batch "" (map (fn (c) (nth c 1)) hl-cases))) (map-indexed (fn (i c) (hk-test (nth c 0) (nth hl-results i) (nth c 2))) hl-cases) {:fail hk-test-fail :pass hk-test-pass :fails hk-test-fails}