summaryrefslogtreecommitdiff
path: root/word2org.sh
blob: 2aff59f0a7461b2f8356bfe342a5d75721da5c0a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/bash
export LANG='en_US.UTF-8'
quote=''
quote_credit=''
block=''

out=$1

while read line; do
    case "$line" in
	'“'*) # quote
	    line="`echo "$line"|sed 's/[“”]//g'`"
	    quote="$quote $line"
	    :;;
	'-'*) # quote-credit
	    credit="`echo "$line"|sed 's/^-//'`"
	    block="$block
*** $credit
    $quote"
	    quote=''
	    :;;
	'Reporter: '*) # reporter-credit
	    reporter="`echo "$line"|sed 's/^Reporter: //'`"
	    echo "** $reporter$block"
	    block=''
	    :;;
	'') :;; # blank
	*) # error
	    echo "error: \`$line'" >>/dev/stderr
	    exit 1;;
    esac
done