Fix looking for mentions of a note with a title containing double quotes

pull/14/head
Mickaël Menu 3 years ago
parent 29a01c793a
commit 01b85c55e8
No known key found for this signature in database
GPG Key ID: 53D73664CD359895

@ -407,6 +407,11 @@ func (d *NoteDAO) expandMentionsIntoMatch(opts note.FinderOpts) (note.FinderOpts
defer rows.Close()
titles := []string{}
appendTitle := func(t string) {
titles = append(titles, `"`+strings.ReplaceAll(t, `"`, "")+`"`)
}
for rows.Next() {
var title, metadataJSON string
err := rows.Scan(&title, &metadataJSON)
@ -414,7 +419,7 @@ func (d *NoteDAO) expandMentionsIntoMatch(opts note.FinderOpts) (note.FinderOpts
return opts, err
}
titles = append(titles, `"`+title+`"`)
appendTitle(title)
// Support `aliases` key in the YAML frontmatter, like Obsidian:
// https://publish.obsidian.md/help/How+to/Add+aliases+to+note
@ -426,10 +431,10 @@ func (d *NoteDAO) expandMentionsIntoMatch(opts note.FinderOpts) (note.FinderOpts
switch aliases := aliases.(type) {
case []interface{}:
for _, alias := range aliases {
titles = append(titles, `"`+fmt.Sprint(alias)+`"`)
appendTitle(fmt.Sprint(alias))
}
case string:
titles = append(titles, `"`+aliases+`"`)
appendTitle(aliases)
}
}
}

@ -18,5 +18,6 @@ keywords: [writing, essay, practice]
| `date` | Creation date takes precedence over the file date |
| `tags` | List of tags attached to this note |
| `keywords` | Alias for `tags` |
| `aliases` | Alternative titles for this note, used by `--mention` |
All metadata are indexed and can be printed in `zk list` output, using the template variable `{{metadata.<key>}}`, e.g. `{{metadata.description}}`. The keys are normalized to lower case.

Loading…
Cancel
Save