Skip to content

Commit

Permalink
refactored display_file()
Browse files Browse the repository at this point in the history
  • Loading branch information
tj committed May 27, 2012
1 parent ad65e9f commit 7886824
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions bin/mad
Expand Up @@ -79,17 +79,16 @@ display_file() {
local strong=$(get strong)
local em=$(get em)

cat $1 \
| perl -pe "
s|^#+ *(.+)|\e[$heading\1\e[0m|g; \
s|\`(.+?)\`|\e[$code\1\e[0m|g; \
s|\*\*(.+?)\*\*|\e[$strong\1\e[0m|g; \
s|__(.+?)__|\e[$strong\1\e[0m|g; \
s|\*(.+?)\*|\e[$em\1\e[0m|g; \
s|_(.+?)_|\e[$em\1\e[0m|g; \
s| (.+)| \e[$code\1\e[0m|g; \
s|<(.+?)>||g; \
s|^| |;" \
< "$1" perl -pe "
s|^#+ *(.+)|\e[$heading\1\e[0m|g; \
s|\`(.+?)\`|\e[$code\1\e[0m|g; \
s|\*\*(.+?)\*\*|\e[$strong\1\e[0m|g; \
s|__(.+?)__|\e[$strong\1\e[0m|g; \
s|\*(.+?)\*|\e[$em\1\e[0m|g; \
s|_(.+?)_|\e[$em\1\e[0m|g; \
s| (.+)| \e[$code\1\e[0m|g; \
s|<(.+?)>||g; \
s|^| |;" \
| less -R
exit
}
Expand Down

0 comments on commit 7886824

Please sign in to comment.