blob: 6aa7df8884d257f61ca419d2b667f234f00a6905 (
plain) (
blame)
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
#!/bin/sh
format_table() {
first_row=""
table_lines=""
while read line
do first_row="$first_row$line"
if test "$line" = "</tr>"
then break
fi
done
while read line
do if test "$line" = "</table>"
then break
fi
table_lines="$table_lines $line"
done
printf '%s' "$first_row" | sed -E \
-e 's/<tr>/|/g' \
-e 's/<\/tr>/|\n/g' \
-e 's/<\/t[hd]> *<t[hd]>/|/g' \
-e 's/<\/?t[hd]>//g' \
-e 's/^ *//g;s/ *$//g'
printf '%s\n' "$first_row" | sed -E \
-e 's/<tr>/|/g' \
-e 's/<\/tr>/|\n/g' \
-e 's/<\/t[hd]> *<t[hd]>/|/g' \
-e 's/<\/?t[hd]>//g' \
-e 's/[^|]/-/g' \
-e 's/^ *//g;s/ *$//g'
printf '%s\n' "$table_lines" | sed -E \
-e 's/<tr>/|/g' \
-e 's/<\/tr>/|\n/g' \
-e 's/<\/t[hd]> *<t[hd]>/|/g' \
-e 's/<\/?t[hd]>//g' \
-e 's/^ *//g;s/ *$//g'
}
sed -e 's/<!-- MANOFF -->.*<!-- MANON -->//g' \
-e 's/<!-- MANON \(.*\) MANOFF -->/\1/g' \
-e '/<!-- MANOFF -->/,/<!-- MANON -->/d' \
-e '/^<!-- MANON$/d' \
-e '/^MANOFF -->$/d' "$@" \
| \
while read line
do if test "$line" = "<table>"
then format_table
else printf '%s\n' "$line"
fi
done
|