From: Chris Koeritz Date: Wed, 8 Nov 2017 07:10:51 +0000 (-0500) Subject: clean_json and json_text are working X-Git-Tag: 2.140.90~39 X-Git-Url: https://feistymeow.org/gitweb/?a=commitdiff_plain;h=b8cb2a405ef5ff881ed7c256c57f0b06fe7615b5;hp=6a22472524839190e6b156befd8886c81be6e550;p=feisty_meow.git clean_json and json_text are working --- diff --git a/scripts/core/functions.sh b/scripts/core/functions.sh index cbd9dbe0..5771586f 100644 --- a/scripts/core/functions.sh +++ b/scripts/core/functions.sh @@ -743,7 +743,7 @@ return 0 } # pretty prints the json files provided as parameters. - function json_view() + function clean_json() { if [ -z "$*" ]; then return; fi local show_list=() @@ -760,6 +760,16 @@ return 0 rm "${show_list[@]}" } + function json_text() + { + # only print our special headers or text fields. + local CR=$'\r' + local LF=$'\n' + clean_json $* | + grep -i "\"text\":\|^=.*" | + sed -e "s/\\\\r/$CR/g" -e "s/\\\\n/\\$LF/g" + } + ############## # NOTE: no more function definitions are allowed after this point. diff --git a/scripts/files/filedump.pl b/scripts/files/filedump.pl index 3fa5b0f3..de91299c 100644 --- a/scripts/files/filedump.pl +++ b/scripts/files/filedump.pl @@ -68,10 +68,14 @@ sub do_dump { $shorter_name =~ s/\.txt$//; $shorter_name =~ s/_/ /g; - $dashed_line = $shorter_name; - $dashed_line =~ s/./-/g; - - $header_copy =~ s/%1/$shorter_name/; + # we're using the extra equals in front as an almost uniquifier for the + # header lines. we then can treat any matching line as a header, although + # some input files could trick this heuristic. + $munged_name = "= $shorter_name"; + $dashed_line = $munged_name; + $dashed_line =~ s/./=/g; + + $header_copy =~ s/%1/$munged_name/; $header_copy =~ s/%2/$dashed_line/g; ##print $header_copy;