Skip to content

Commit

Permalink
Support non-ascii [:alnum:] characters in search --tags.
Browse files Browse the repository at this point in the history
refs gh-328
refs gh-329
  • Loading branch information
xwmx committed Jul 13, 2024
1 parent 825d043 commit eee91d8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions nb
Original file line number Diff line number Diff line change
Expand Up @@ -16987,15 +16987,15 @@ _search() {
"-I"
"--ignore-case"
"--only-matching"
-e '(^|[[:space:]])#[A-Za-z0-9_-]+'
-e '(^|[[:space:]])#[[:alnum:]_-]+'
)
else
local _grep_arguments=(
"--extended-regexp"
"-I"
"--ignore-case"
"--only-matching"
-e '[[:space:]]#[A-Za-z0-9_-]+'
-e '[[:space:]]#[[:alnum:]_-]+'
-e '^#[A-Za-z0-9_-]+'
)
fi
Expand Down
24 changes: 12 additions & 12 deletions test/search-list-tags.bats
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Example Content Two #tag3 Example #tag1 Phrase.
More content.
#low-tag
#lõw-tag
## Content
Expand Down Expand Up @@ -81,7 +81,7 @@ HEREDOC
[[ "${output}" =~ \#tag1 ]]
[[ "${output}" =~ \#tag2 ]]
[[ "${output}" =~ \#tag3 ]]
[[ "${output}" =~ \#low-tag ]]
[[ "${output}" =~ \#lõw-tag ]]
}

# _GIT_ENABLED=0 ##############################################################
Expand All @@ -104,7 +104,7 @@ HEREDOC
[[ "${output}" =~ \#tag1 ]]
[[ "${output}" =~ \#tag2 ]]
[[ "${output}" =~ \#tag3 ]]
[[ "${output}" =~ \#low-tag ]]
[[ "${output}" =~ \#lõw-tag ]]
}

# edge cases ##################################################################
Expand Down Expand Up @@ -225,7 +225,7 @@ HEREDOC

[[ "${lines[0]}" =~ \#tag3 ]]
[[ "${lines[1]}" =~ \#tag1 ]]
[[ "${lines[2]}" =~ \#low-tag ]]
[[ "${lines[2]}" =~ \#lõw-tag ]]
}

@test "'<folder>/ --tags' lists all unique tags in <folder>." {
Expand Down Expand Up @@ -263,7 +263,7 @@ HEREDOC
[[ "${lines[2]}" =~ \#tag1 ]]
[[ "${lines[3]}" =~ \#tag2 ]]
[[ "${lines[4]}" =~ \#tag3 ]]
[[ "${lines[5]}" =~ \#low-tag ]]
[[ "${lines[5]}" =~ \#lõw-tag ]]
}

@test "'--tags --all' lists all unique tags in all notebooks." {
Expand All @@ -284,7 +284,7 @@ HEREDOC
[[ "${lines[2]}" =~ \#nested-tag2 ]]
[[ "${lines[3]}" =~ \#tag1 ]]
[[ "${lines[4]}" =~ \#tag2 ]]
[[ "${lines[6]}" =~ \#low-tag ]]
[[ "${lines[6]}" =~ \#lõw-tag ]]
[[ "${lines[5]}" =~ \#tag3 ]]
}

Expand All @@ -305,7 +305,7 @@ HEREDOC

[[ "${lines[0]}" =~ \#tag3 ]]
[[ "${lines[1]}" =~ \#tag1 ]]
[[ "${lines[2]}" =~ \#low-tag ]]
[[ "${lines[2]}" =~ \#lõw-tag ]]
}

@test "'list <folder>/ --tags' lists all unique tags in <folder>." {
Expand Down Expand Up @@ -343,7 +343,7 @@ HEREDOC
[[ "${lines[2]}" =~ \#tag1 ]]
[[ "${lines[3]}" =~ \#tag2 ]]
[[ "${lines[4]}" =~ \#tag3 ]]
[[ "${lines[5]}" =~ \#low-tag ]]
[[ "${lines[5]}" =~ \#lõw-tag ]]
}

@test "'list --tags --all' lists all unique tags in all notebooks." {
Expand All @@ -365,7 +365,7 @@ HEREDOC
[[ "${lines[3]}" =~ \#tag1 ]]
[[ "${lines[4]}" =~ \#tag2 ]]
[[ "${lines[5]}" =~ \#tag3 ]]
[[ "${lines[6]}" =~ \#low-tag ]]
[[ "${lines[6]}" =~ \#lõw-tag ]]
}

# `search` ####################################################################
Expand All @@ -385,7 +385,7 @@ HEREDOC

[[ "${lines[0]}" =~ \#tag3 ]]
[[ "${lines[1]}" =~ \#tag1 ]]
[[ "${lines[2]}" =~ \#low-tag ]]
[[ "${lines[2]}" =~ \#lõw-tag ]]
}

@test "'search <folder>/ --tags' lists all unique tags in <folder>." {
Expand Down Expand Up @@ -423,7 +423,7 @@ HEREDOC
[[ "${lines[2]}" =~ \#tag1 ]]
[[ "${lines[3]}" =~ \#tag2 ]]
[[ "${lines[4]}" =~ \#tag3 ]]
[[ "${lines[5]}" =~ \#low-tag ]]
[[ "${lines[5]}" =~ \#lõw-tag ]]
}

@test "'search --tags --all' lists all unique tags in all notebooks." {
Expand All @@ -445,5 +445,5 @@ HEREDOC
[[ "${lines[3]}" =~ \#tag1 ]]
[[ "${lines[4]}" =~ \#tag2 ]]
[[ "${lines[5]}" =~ \#tag3 ]]
[[ "${lines[6]}" =~ \#low-tag ]]
[[ "${lines[6]}" =~ \#lõw-tag ]]
}

0 comments on commit eee91d8

Please sign in to comment.