From: Layerex Date: Sat, 28 May 2022 20:05:07 +0000 (+0300) Subject: Normalize number of trailing newlines in markdown to 2 (#70) X-Git-Tag: v0.2.0.0~6 X-Git-Url: https://glassweightruler.freedombox.rocks/gitweb/xdg-ninja.git/commitdiff_plain/4e9316b332eaa0ed5832a1246878dd6b015cb038?ds=sidebyside Normalize number of trailing newlines in markdown to 2 (#70) For output to look uniform with formatters like bat --- diff --git a/xdg-ninja.sh b/xdg-ninja.sh index e398f4a..94a8969 100755 --- a/xdg-ninja.sh +++ b/xdg-ninja.sh @@ -98,8 +98,10 @@ check_if_file_exists() { } decode_string() { - printf "%s\n" "$1" | sed -e 's/\\n/\ -/g' -e 's/\\\"/\"/g' # Replace \n with literal newline and \" with " + printf "%s" "$1" | sed -e 's/\\n/\ +/g' -e 's/\\\"/\"/g' -e '$ s/\n*$/\ +\ +/' # Replace \n with literal newline and \" with ", normalize number of trailing newlines to 2 } # Function to handle the formatting of output