diff options
author | Michael Kerrisk <mtk.manpages@gmail.com> | 2014-02-10 11:38:24 +0100 |
---|---|---|
committer | Michael Kerrisk <mtk.manpages@gmail.com> | 2014-02-10 11:38:24 +0100 |
commit | cf98af1408d364c80f63d5b952d18da7c96e226c (patch) | |
tree | a58c8f8e5b513a0d829f2603bcf26ccbb3403aa7 /scripts | |
parent | 92cfcaf7e5e76c4adc11ef6974f26d4edb124b54 (diff) | |
download | man-pages-cf98af1408d364c80f63d5b952d18da7c96e226c.tar.gz |
markup_check.sh: Script to check for common man-page markup errors
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/markup_check.sh | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/scripts/markup_check.sh b/scripts/markup_check.sh new file mode 100644 index 0000000000..fdf047af06 --- /dev/null +++ b/scripts/markup_check.sh @@ -0,0 +1,48 @@ +#!/bin/sh + +LOG=/tmp/markup_check.$$ +rm -f $LOG $LOG.full + +if test $# -eq 0; then + echo 1>&2 "Usage: $0 filename-or-dirname ... $#" + exit 1 +fi + +file_list=$(find $* -type f | grep '\.[1-9][a-zA-Z]*$') + +pagename_pattern='[a-z_A-Z][^ ]*' + +( + echo "" + echo "Checking for page xref without space before left parenthesis:" + pattern='^\.BR *'"$pagename_pattern"'([1-8][^1-9]' + echo " Pattern: '$pattern'" + grep "$pattern" $file_list | sed 's/^/ /' | tee -a $LOG + + echo "" + echo "Checking for .IR xrefs that should be .BR" + pattern='^\.IR *'"$pagename_pattern"' *([1-8][^1-9]' + echo " Pattern: '$pattern'" + grep "$pattern" $file_list | sed 's/^/ /' | tee -a $LOG + + echo "" + echo "Checking for misformmatted punctuation in .BR xrefs" + pattern='^\.BR *'"$pagename_pattern"' *([1-8a-zA-Z]*) [^ ]' + echo " Pattern: '$pattern'" + grep "$pattern" $file_list | sed 's/^/ /' | tee -a $LOG + + echo "" + echo "Checking for .B xrefs that should be .BR" + pattern='^\.B '"$pagename_pattern"' *([1-8a-zA-Z]*)' + echo " Pattern: '$pattern'" + grep "$pattern" $file_list | sed 's/^/ /' | tee -a $LOG +) > $LOG.full + +if test $(cat $LOG | wc -l) -gt 0; then + echo "" + echo "MARKUP ERRORS!!!!!" + cat $LOG.full + exit 1 +fi + +exit 0 |