diff options
Diffstat (limited to 'document/utils.go')
-rw-r--r-- | document/utils.go | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/document/utils.go b/document/utils.go new file mode 100644 index 0000000..c6593c4 --- /dev/null +++ b/document/utils.go @@ -0,0 +1,30 @@ +package document + +import ( + "github.com/scrotadamus/ghligh/go-poppler" + + "encoding/json" +) + +func unmarshallHighlights(jsonData string) (AnnotsMap, error) { + var annotsMap AnnotsMap + + err := json.Unmarshal([]byte(jsonData), &struct { + Highlights *AnnotsMap `json:"highlights"` + }{ + Highlights: &annotsMap, + }) + + return annotsMap, err +} + +func isInPage(a *poppler.Annot, p *poppler.Page) bool { + annots := p.GetAnnots() + for _, annot := range annots { + if popplerAnnotsMatch(a, annot) { + return true + } + } + + return false +} |