concatenate sed commands
authorMatteo Nastasi <nastasi@alternativeoutput.it>
Wed, 7 Sep 2011 12:50:30 +0000 (14:50 +0200)
committerMatteo Nastasi <nastasi@alternativeoutput.it>
Wed, 7 Sep 2011 12:50:30 +0000 (14:50 +0200)
populate.sh

index de6b1b7..9a9b7e6 100755 (executable)
@@ -118,8 +118,12 @@ s/é/\\'"'"'e/g;s/í/\\'"'"'i/g;s/ó/\\'"'"'o/g;s/ú/\\'"'"'u/g;s/°/\$\^\\circ\
 s/<i>/\\textit{/g;s/<b>/\\textbf{/g;s/<\/[ib]>/}/g;s/<url>/URL: \\textit\{/g;s/<\/url>/\}/g;
 s/“/``/g;s/”/'"''"'/g;s/<lang:tex>//g;s/<\/lang:tex>//g;s/<lang:[^>]*>.*<\/lang:[^>]*>//g'
        elif [ "$1" = "htm" ]; then
-           sed "s/${NEWLI}${NEWLI}/<br>${NEWLI}/g;"'s/<url>\([^<]*\)<\/url>/<a href="\1">\1<\/a>/g;
-s/<lang:htm>//g;s/<\/lang:htm>//g;s/<lang:[^>]*>.*<\/lang:[^>]*>//g'
+            sed 's/<url>/\n<url>\n/g;s/<\/url>/\n<\/url>\n/g;
+                 /^<url>$/,/^<\/url>$/ { s/\\_/_/g; };
+                 /^<url>$/,/^<\/url>$/ { s/\(^[^<].*\)/<a href="\1">\1<\/a>/g; };
+                 s/^<url>$//g;s/^<\/url>$//g' | tr -d '\n' | \
+           sed "s/${NEWLI}${NEWLI}/<br>${NEWLI}/g;"'
+                 s/<lang:htm>//g;s/<\/lang:htm>//g;s/<lang:[^>]*>.*<\/lang:[^>]*>//g'
        fi
     )