From 232dd36b786d2cc9f12ba91089af9e993924f043 Mon Sep 17 00:00:00 2001 From: Cotes Chung <11371340+cotes2020@users.noreply.github.com> Date: Tue, 1 Sep 2020 01:05:23 +0800 Subject: [PATCH] Enhance the script to remove the space between `categories`/`tags` and colon in YAML. --- _scripts/sh/create_pages.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/_scripts/sh/create_pages.sh b/_scripts/sh/create_pages.sh index 248ae77..d46e912 100755 --- a/_scripts/sh/create_pages.sh +++ b/_scripts/sh/create_pages.sh @@ -27,20 +27,20 @@ _read_yaml() { read_categories() { local _yaml="$(_read_yaml "$1")" - local _categories="$(echo "$_yaml" | grep "^categories:")" - local _category="$(echo "$_yaml" | grep "^category:")" + local _categories="$(echo "$_yaml" | grep "^categories *:")" + local _category="$(echo "$_yaml" | grep "^category *:")" if [[ ! -z "$_categories" ]]; then - echo "$_categories" | sed "s/categories: *//;s/\[//;s/\].*//;s/, */,/g;s/\"//g;s/'//g" + echo "$_categories" | sed "s/categories *: *//;s/\[//;s/\].*//;s/, */,/g;s/\"//g;s/'//g" elif [[ ! -z "_category" ]]; then - echo "$_category" | sed "s/category: *//;s/\[//;s/\].*//;s/, */,/g;s/\"//g;s/'//g" + echo "$_category" | sed "s/category *: *//;s/\[//;s/\].*//;s/, */,/g;s/\"//g;s/'//g" fi } read_tags() { local _yaml="$(_read_yaml "$1")" - echo "$_yaml" | grep "^tags:" | sed "s/tags: *//;s/\[//;s/\].*//;s/, */,/g;s/\"//g;s/'//g" + echo "$_yaml" | grep "^tags *:" | sed "s/tags *: *//;s/\[//;s/\].*//;s/, */,/g;s/\"//g;s/'//g" }