File tree Expand file tree Collapse file tree 1 file changed +17
-5
lines changed
Expand file tree Collapse file tree 1 file changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -18,17 +18,29 @@ TYPE_TAG=1
1818category_count=0
1919tag_count=0
2020
21+
22+ _read_yaml () {
23+ local _endline=$( grep -n " \-\-\-" $1 | cut -d: -f 1 | sed -n ' 2p' )
24+ head -$_endline $1
25+ }
26+
27+
2128read_categories () {
22- if [[ $( grep " categories:" $1 ) ]]; then
23- grep " categories:" $1 | head -1 | sed ' s/categories: *//;s/\[//;s/\]//;s/, */,/g;s/"//g'
24- elif [[ $( grep " category:" $1 ) ]]; then
25- grep " category:" $1 | head -1 | sed ' s/category: *//;s/\[//;s/\]//;s/, */,/g;s/"//g'
29+ local _yaml=$( _read_yaml $1 )
30+ local _categories=$( echo " $_yaml " | grep " ^categories:" )
31+ local _category=$( echo " $_yaml " | grep " ^category:" )
32+
33+ if [[ ! -z " $_categories " ]]; then
34+ echo " $_categories " | sed " s/categories: *//;s/\[//;s/\]//;s/, */,/g;s/\" //g;s/'//g"
35+ elif [[ ! -z " _category" ]]; then
36+ echo " $_category " | sed " s/category: *//;s/\[//;s/\]//;s/, */,/g;s/\" //g;s/'//g"
2637 fi
2738}
2839
2940
3041read_tags () {
31- grep " tags:" $1 | head -1 | sed ' s/tags: *//;s/\[//;s/\]//;s/, */,/g;s/"//g'
42+ local _yaml=$( _read_yaml $1 )
43+ echo " $_yaml " | grep " ^tags:" | sed " s/tags: *//;s/\[//;s/\]//;s/, */,/g;s/\" //g;s/'//g"
3244}
3345
3446
You can’t perform that action at this time.
0 commit comments