diff options
| -rwxr-xr-x | gemtexter | 1 | ||||
| -rw-r--r-- | lib/atomfeed.source.sh | 6 | ||||
| -rw-r--r-- | lib/generate.source.sh | 10 |
3 files changed, 13 insertions, 4 deletions
@@ -137,6 +137,7 @@ main () { --test) LOG_VERBOSE=yes assert::shellcheck + generate::test template::test html::test md::test diff --git a/lib/atomfeed.source.sh b/lib/atomfeed.source.sh index 53e54d5..9392e95 100644 --- a/lib/atomfeed.source.sh +++ b/lib/atomfeed.source.sh @@ -92,11 +92,11 @@ ATOMFOOTER } atomfeed::verify () { - if [ $(find $CONTENT_BASE_DIR -name \*.xml.tmp | wc -l) -ge 1 ]; then - find $CONTENT_BASE_DIR -name \*.xml.tmp + if [ "$(find "$CONTENT_BASE_DIR" -name \*.xml.tmp | wc -l)" -ge 1 ]; then + find "$CONTENT_BASE_DIR" -name \*.xml.tmp log PANIC "Found incomplete Atom feed files with the suffix .xml.tmp" fi - find $CONTENT_BASE_DIR -name atom.xml | while read -r atom_xml; do + find "$CONTENT_BASE_DIR" -name atom.xml | while read -r atom_xml; do atomfeed::xmllint "$atom_xml" done diff --git a/lib/generate.source.sh b/lib/generate.source.sh index aabb600..03c33bf 100644 --- a/lib/generate.source.sh +++ b/lib/generate.source.sh @@ -34,7 +34,10 @@ generate::make_link () { # Markdown internal href format, we use it also for HTML generate::internal_link_id () { local -r text="$1"; shift - tr '[:upper:]' '[:lower:]' <<< "$text" | tr ' ' '-' | tr -cd 'A-Za-z0-9-' + # Replace uppercase with lowercase + # Replace ' and space with dashes + # Remove all other characters but alnum + tr '[:upper:]' '[:lower:]' <<< "$text" | tr "' " '-' | tr -cd 'A-Za-z0-9-' } # Add other docs (e.g. images, videos) from Gemtext to output format. @@ -211,3 +214,8 @@ generate::draft () { log INFO 'For HTML preview, open in your browser:' find "$CONTENT_BASE_DIR/html" -name DRAFT-\*.html } + +generate::test () { + local text="I can't believe it!" + assert::equals "$(generate::internal_link_id "$text")" 'i-can-t-believe-it' +} |
