]> glassweightruler.freedombox.rocks Git - xdg-ninja.git/commitdiff
Normalize number of trailing newlines in markdown to 2 (#70)
authorLayerex <layerex@dismail.de>
Sat, 28 May 2022 20:05:07 +0000 (23:05 +0300)
committerGitHub <noreply@github.com>
Sat, 28 May 2022 20:05:07 +0000 (20:05 +0000)
For output to look uniform with formatters like bat

xdg-ninja.sh

index e398f4a2c3113ae37e1a9b349707cadacd08653a..94a8969674fd020713e75807d5f389c37ff97f3e 100755 (executable)
@@ -98,8 +98,10 @@ check_if_file_exists() {
 }
 
 decode_string() {
 }
 
 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
 }
 
 # Function to handle the formatting of output