summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArun Isaac2022-06-29 11:48:03 +0530
committerArun Isaac2022-06-29 11:48:03 +0530
commitefec16853cce7a497010a2da42844a7bc0bd704f (patch)
tree0da87961fe22c6442990533e2d432de7fd0f9e5c
parent983fc85243a5b914cc2fbfaee60e0e1e6ef0b614 (diff)
downloadtissue-efec16853cce7a497010a2da42844a7bc0bd704f.tar.gz
tissue-efec16853cce7a497010a2da42844a7bc0bd704f.tar.lz
tissue-efec16853cce7a497010a2da42844a7bc0bd704f.zip
document: Abstract out HTML snippet generation.
* tissue/document.scm (document-html-snippet): New function. (document-snippet, document-sxml-snippet): Use document-html-snippet.
-rw-r--r--tissue/document.scm32
1 files changed, 16 insertions, 16 deletions
diff --git a/tissue/document.scm b/tissue/document.scm
index 2806f3b..b549f2d 100644
--- a/tissue/document.scm
+++ b/tissue/document.scm
@@ -173,17 +173,22 @@ and further text, increase-termpos! must be called before indexing."
(index-text! term-generator (file-document-path document))
term-generator))
+(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
+ (document-text document)
+ #:length 200
+ #:highlight-start "<b>"
+ #:highlight-end "</b>"
+ #:stemmer (make-stem "en")))
+
(define (document-snippet document mset)
"Return snippet for DOCUMENT. MSET is the xapian MSet object
representing a list of search results."
- ;; mset-snippet returns serialized HTML. So, we reverse it with
- ;; html->sxml.
- (match (html->sxml (mset-snippet mset
- (document-text document)
- #:length 200
- #:highlight-start "<b>"
- #:highlight-end "</b>"
- #:stemmer (make-stem "en")))
+ ;; mset-snippet, and thus document-html-snippet, returns serialized
+ ;; HTML. So, we reverse it with html->sxml.
+ (match (html->sxml (document-html-snippet document mset))
(('*TOP* children ...)
(string-join
(map (match-lambda
@@ -211,14 +216,9 @@ MSet object representing a list of search results."
(define (document-sxml-snippet document mset)
"Return snippet in SXML form for DOCUMENT. MSET is the xapian MSet
object representing a list of search results."
- ;; mset-snippet returns serialized HTML. So, we reverse it with
- ;; html->sxml.
- (match (html->sxml (mset-snippet mset
- (document-text document)
- #:length 200
- #:highlight-start "<b>"
- #:highlight-end "</b>"
- #:stemmer (make-stem "en")))
+ ;; mset-snippet, and thus document-html-snippet, returns serialized
+ ;; HTML. So, we reverse it with html->sxml.
+ (match (html->sxml (document-html-snippet document mset))
(('*TOP* children ...)
(append-map (lambda (child)
(cond