Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 26s
highlight marks query-matching (normalized) tokens with [..]; snippet extracts a context window around the first match. 178/178. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
67 lines
1.8 KiB
Plaintext
67 lines
1.8 KiB
Plaintext
;; 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}
|