"
# remove possible 's on the title because of markdown conversion
- echo "$title" | sed 's/<\/*p>//g'
+ title=${title//
/}
+ title=${title//<\/p>/}
+ echo "$title"
echo '
'
if [[ -z $timestamp ]]; then
echo "$template_tags_title
" echo "- "
- for i in ./$prefix_tags*.html; do
+ for i in $prefix_tags*.html; do
[[ -f "$i" ]] || break
echo -n "." 1>&3
nposts=$(grep -c "<\!-- text begin -->" "$i")
- tagname=$(echo "$i" | cut -c "$((${#prefix_tags}+3))-" | sed 's/\.html//g')
- i=$(clean_filename "$i")
- word=$template_tags_posts_singular
- (($nposts > 1)) && word=$template_tags_posts
+ tagname=${i#"$prefix_tags"}
+ tagname=${tagname%.html}
+ ((nposts > 1)) && word=$template_tags_posts || word=$template_tags_posts_singular
echo "
- $tagname — $nposts $word " done echo "" 1>&3 @@ -810,7 +803,8 @@ rebuild_tags() { rm "$tmpfile" # Now generate the tag files with headers, footers, etc while IFS='' read -r i; do - tagname=$(echo "$i" | cut -c "$((${#prefix_tags}+3))-" | sed 's/\.tmp\.html//g') + tagname=${i#./"$prefix_tags"} + tagname=${tagname%.tmp.html} create_html_page "$i" "$prefix_tags$tagname.html" yes "$global_title — $template_tag_title \"$tagname\"" rm "$i" done < <(ls -t ./"$prefix_tags"*.tmp.html 2>/dev/null) @@ -828,24 +822,23 @@ get_post_title() { # # $2 if "-n", tags will be sorted by number of posts list_tags() { - if [[ $2 ]] && [[ $2 == -n ]]; then do_sort=1; else do_sort=0; fi + if [[ $2 == -n ]]; then do_sort=1; else do_sort=0; fi ls ./$prefix_tags*.html &> /dev/null (($? != 0)) && echo "No posts yet. Use 'bb.sh post' to create one" && return lines="" - for i in ./$prefix_tags*.html; do + for i in $prefix_tags*.html; do [[ -f "$i" ]] || break nposts=$(grep -c "<\!-- text begin -->" "$i") - tagname=$(echo "$i" | cut -c "$((${#prefix_tags}+3))-" | sed 's/\.html//g') - i=$(clean_filename "$i") - word=$template_tags_posts_singular - (($nposts > 1)) && word=$template_tags_posts + tagname=${i#"$prefix_tags"} + tagname=${tagname#.html} + ((nposts > 1)) && word=$template_tags_posts || word=$template_tags_posts_singular line="$tagname # $nposts # $word" lines+=$line\\n done - if (( $do_sort == 1 )); then + if (( do_sort == 1 )); then echo -e "$lines" | column -t -s "#" | sort -nrk 2 else echo -e "$lines" | column -t -s "#" @@ -895,7 +888,7 @@ make_rss() { get_post_title "$i" echo '