diff options
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | doc/config.md | 4 | ||||
-rwxr-xr-x | table_rewrite.sh | 45 |
3 files changed, 48 insertions, 3 deletions
diff --git a/Makefile b/Makefile index 942e2f09..d10ccf11 100644 --- a/Makefile +++ b/Makefile @@ -51,7 +51,7 @@ clean: .PHONY: manpage manpage: - sed '/<!-- TOCSTART -->/,/<!-- TOCEND -->/d' doc/config.md > .obj/cha-config.md + sed '/<!-- TOCSTART -->/,/<!-- TOCEND -->/d' doc/config.md | ./table_rewrite.sh > .obj/cha-config.md pandoc --standalone --to man .obj/cha-config.md -o .obj/cha-config.5 cp doc/cha.1 "$(OBJDIR)/cha.1" diff --git a/doc/config.md b/doc/config.md index 2e989bd1..8c8acff6 100644 --- a/doc/config.md +++ b/doc/config.md @@ -286,8 +286,8 @@ completely.</td> </tr> <tr> -<td>no-format-mode -<td>["bold", "italic", "underline", "reverse", "strike", "overline", "blink"] +<td>no-format-mode</td> +<td>["bold", "italic", "underline", "reverse", "strike", "overline", "blink"]</td> <td>Disable specified formatting modes.</td> </tr> diff --git a/table_rewrite.sh b/table_rewrite.sh new file mode 100755 index 00000000..dcf51edb --- /dev/null +++ b/table_rewrite.sh @@ -0,0 +1,45 @@ +#!/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 '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 '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 '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' +} + +while read line +do if test "$line" = "<table>" + then format_table + else + printf '%s\n' "$line" + fi +done |