Support fast tags by trimming the key binding.
This commit is contained in:
parent
9995b3cdad
commit
aff78bc23d
1 changed files with 18 additions and 1 deletions
|
@ -47,7 +47,9 @@ func (d *Document) parseHeadline(i int, parentStop stopFn) (int, Node) {
|
||||||
headline.Index = d.addHeadline(&headline)
|
headline.Index = d.addHeadline(&headline)
|
||||||
|
|
||||||
text := t.content
|
text := t.content
|
||||||
todoKeywords := strings.FieldsFunc(d.Get("TODO"), func(r rune) bool { return unicode.IsSpace(r) || r == '|' })
|
todoKeywords := trimFastTags(
|
||||||
|
strings.FieldsFunc(d.Get("TODO"), func(r rune) bool { return unicode.IsSpace(r) || r == '|' }),
|
||||||
|
)
|
||||||
for _, k := range todoKeywords {
|
for _, k := range todoKeywords {
|
||||||
if strings.HasPrefix(text, k) && len(text) > len(k) && unicode.IsSpace(rune(text[len(k)])) {
|
if strings.HasPrefix(text, k) && len(text) > len(k) && unicode.IsSpace(rune(text[len(k)])) {
|
||||||
headline.Status = k
|
headline.Status = k
|
||||||
|
@ -82,6 +84,21 @@ func (d *Document) parseHeadline(i int, parentStop stopFn) (int, Node) {
|
||||||
return consumed + 1, headline
|
return consumed + 1, headline
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func trimFastTags(tags []string) []string {
|
||||||
|
trimmedTags := make([]string, len(tags))
|
||||||
|
for i, t := range tags {
|
||||||
|
lParen := strings.LastIndex(t, "(")
|
||||||
|
rParen := strings.LastIndex(t, ")")
|
||||||
|
end := len(t) - 1
|
||||||
|
if lParen == end-2 && rParen == end {
|
||||||
|
trimmedTags[i] = t[:end-2]
|
||||||
|
} else {
|
||||||
|
trimmedTags[i] = t
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return trimmedTags
|
||||||
|
}
|
||||||
|
|
||||||
func (h Headline) ID() string {
|
func (h Headline) ID() string {
|
||||||
if customID, ok := h.Properties.Get("CUSTOM_ID"); ok {
|
if customID, ok := h.Properties.Get("CUSTOM_ID"); ok {
|
||||||
return customID
|
return customID
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue