summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArun Isaac2022-07-09 15:34:31 +0530
committerArun Isaac2022-07-09 16:41:02 +0530
commitb0cf99385a73b7461789aae2d71f7ad23ab5c56f (patch)
tree5456a487dddcff6a2a10e78c6546d9cc119e99a9
parent94ceb9d5a66ecc67088874855771141240b76bc4 (diff)
downloadtissue-b0cf99385a73b7461789aae2d71f7ad23ab5c56f.tar.gz
tissue-b0cf99385a73b7461789aae2d71f7ad23ab5c56f.tar.lz
tissue-b0cf99385a73b7461789aae2d71f7ad23ab5c56f.zip
document: Make snippet source text extraction a generic function.
* tissue/document.scm (document-snippet-source-text): New generic method. (document-html-snippet): Use document-snippet-source-text.
-rw-r--r--tissue/document.scm17
1 files changed, 12 insertions, 5 deletions
diff --git a/tissue/document.scm b/tissue/document.scm
index 983a1f2..e40c80e 100644
--- a/tissue/document.scm
+++ b/tissue/document.scm
@@ -40,6 +40,7 @@
document-id-term
document-text
document-term-generator
+ document-snippet-source-text
document-snippet
print
document-sxml-snippet
@@ -178,15 +179,21 @@ and further text, increase-termpos! must be called before indexing."
(index-text! term-generator (file-document-path document))
term-generator))
+(define-method (document-snippet-source-text (document <document>))
+ "Return the source text for DOCUMENT from which to extract a search
+result snippet."
+ ;; Remove blank lines from document text.
+ (string-join
+ (remove (cut string-every char-set:whitespace <>)
+ (string-split (document-text document)
+ #\newline))
+ "\n"))
+
(define (document-html-snippet document mset)
"Return snippet for DOCUMENT. MSET is the xapian MSet object
representing a list of search results."
(mset-snippet mset
- (string-join
- (remove (cut string-every char-set:whitespace <>)
- (string-split (document-text document)
- #\newline))
- "\n")
+ (document-snippet-source-text document)
#:length 200
#:highlight-start "<b>"
#:highlight-end "</b>"