Skip to content

Commit

Permalink
Use context extraction for 'search'
Browse files Browse the repository at this point in the history
Context extraction already supports dealing with Markdown lists which
works better than outputting a full Markdown list which adds to noise
in search results.
  • Loading branch information
msp301 committed Jun 22, 2023
1 parent 1fa79ae commit d1e7959
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions notebook/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"github.com/lithammer/fuzzysearch/fuzzy"
"github.com/msp301/zb/graph"
"github.com/msp301/zb/parser"
"github.com/msp301/zb/util"
"regexp"
"strings"
)
Expand All @@ -30,8 +31,14 @@ func (book *Notebook) Search(query ...string) []Result {
continue PARAGRAPH
}

context = append(context, paragraph)
matched = true
for _, term := range query {
extracted, ok := util.Context(paragraph, term)
if ok {
context = append(context, extracted...)
matched = true
break
}
}
break
}

Expand Down

0 comments on commit d1e7959

Please sign in to comment.