Created
August 6, 2012 01:06
-
-
Save fmoralesc/3268765 to your computer and use it in GitHub Desktop.
cleaning up pacmatic output
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 5fa8c1c3e8bfa0ae7cf928e56df2bd408ce14e89 Mon Sep 17 00:00:00 2001 | |
From: Felipe Morales <[email protected]> | |
Date: Sat, 4 Aug 2012 19:27:06 -0300 | |
Subject: [PATCH] Further cleanup of rss feeds | |
If available, pass the feed data through pandoc or html2text before displaying. | |
--- | |
pacmatic | 8 +++++++- | |
1 file changed, 7 insertions(+), 1 deletion(-) | |
diff --git a/pacmatic b/pacmatic | |
index 847a4be..34e86bf 100755 | |
--- a/pacmatic | |
+++ b/pacmatic | |
@@ -122,7 +122,13 @@ check_news() # none : news (logfile) | |
line2=`xml_decode "$line"` | |
this_date=`echo -n "$line2" | cut -d ' ' -f 1 | sed 's/ //g'` | |
if [ $(( $this_date )) -gt $(( $last_news_date )) ]; then | |
- echo "$line2" | cut -d ' ' -f 2- | sed -e 's|<br />|\n|g' -e 's|\\n||g' -e 's|<p>|\n|g' -e 's|</p>||g' | |
+ if [[ `command -v pandoc` != '' ]]; then | |
+ echo "$line2" | cut -d ' ' -f 2- | sed -e 's|<br />|\n|g' -e 's|\\n||g' -e 's|<p>|\n|g' -e 's|</p>||g' | pandoc -f html -t markdown | sed 's/wrote: /wrote:\n/'; | |
+ elif [[ `command -v html2text` != '' ]]; then | |
+ echo "$line2" | cut -d ' ' -f 2- | sed -e 's|<br />|\n|g' -e 's|\\n||g' -e 's|<p>|\n|g' -e 's|</p>||g' | html2text | sed 's/wrote: /wrote:\n/'; | |
+ else | |
+ echo "$line2" | cut -d ' ' -f 2- | sed -e 's|<br />|\n|g' -e 's|\\n||g' -e 's|<p>|\n|g' -e 's|</p>||g'; | |
+ fi | |
echo "" | |
echo "$line2" >> $log_file | |
fi | |
-- | |
1.7.11.4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment