tildelog/lib/tags_in_post.sh

10 lines
369 B
Bash
Raw Normal View History

2020-12-19 19:43:21 +00:00
#!/usr/bin/env bash
# Finds all tags referenced in one post.
# Accepts either filename as first argument, or post content at stdin
# Prints one line with space-separated tags to stdout
2021-03-12 09:13:56 +00:00
declare template_tags_line_header
2020-12-19 19:43:21 +00:00
tags_in_post() {
sed -n "/^<p>$template_tags_line_header/{s/^<p>$template_tags_line_header//;s/<[^>]*>//g;s/[ ,]\+/ /g;p;}" "$1" | tr ', ' ' '
}