[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Checking I-Ds for nits.



On Wed, 23 Apr 2003 Mukesh.Gupta@nokia.com wrote:

> How do people make sure that the draft submitted to the WG are compliant to ID nits on this page ?
> http://www.ietf.org/ID-nits.html
>
> Is there any tool available to help in doing this ??

I have a simple awk script that checks the formatting aspects.  It
does not check any of the content nits.  I've attached it.

                                                        -- Steve
#!/usr/bin/awk -f
#
# check pagination of Internet-Drafts
#
# @(#) $Id$

BEGIN {
#    linelim = 68;
#    charlim = 80;
    linelim = 58;
    charlim = 72;
    lines = 0;
    longpages = 0;
    badformfeeds = 0;
    maxlines = 0;
    maxchars = 0;
    longlines = 0;
    mschars = 0;
    badchars = 0;
}

{
    prefeed = 0;
    postfeed = 0;
    line = gensub(/\r$/, "", "g");
}

/^/ {
    prefeed = 1;
    if (length(line) != 1) {
	++badformfeeds;
    }
}

/$/ {
    postfeed = 1;
    if (length(line) != 1) {
	++badformfeeds;
    }
}

/[^-~]/ {
    ++badchars;
    print "Bad chars at", NR;
}

{
    mschars += gsub(/‘/, "'");
    mschars += gsub(/’/, "'");
    mschars += gsub(/“/, "\"");
    mschars += gsub(/”/, "\"");
    mschars += gsub(/–/, "-");
    if (length(line) > charlim) {
	++longlines;
	if (length(gensub(/ *$/, "", "g", line)) > charlim) {
	    print "Long line at", NR, "with", length(line), "chars";
	} else {
	    print "Long line at", NR, "with", length(line), "chars, only spaces extra";
	}
	if (length(line) > maxchars) {
	    maxchars = length(line);
	}
    }
    if ((lines < linelim) || ((postfeed == 1) && (prefeed == 0))) {
	++lines;
	if (prefeed == 1) lines = 1;
	if (postfeed == 1) lines = 0;
    } else { # (lines >= linelim) && ((postfeed == 0) || (prefeed == 1))
	if (prefeed == 0) {  # => (postfeed == 0))
	    if (lines == linelim) {
		++longpages;
		print "Long page at", NR;
	    }
	    ++lines;
	    if (lines > maxlines) maxlines = lines;
	} else {
	    lines = 0;
	    if (postfeed == 0) lines = 1;
	}
	blanks = 0;
    }
}

END {
    if (mschars) {
	print FILENAME ":", mschars, "stupid quotes/dashes characters";
    }
    if (badchars) {
	print FILENAME ":", badchars, "lines containing non-US-ASCII characters";
    }
    if (longlines) {
	print FILENAME ":", longlines, "lines longer than", charlim, "characters, max", maxchars;
    }
    if (longpages) {
	print FILENAME ":", longpages, "pages longer than", linelim, "lines, max", maxlines, "lines";
    }
    if (badformfeeds) {
	print FILENAME ":", badformfeeds, "formfeeds not on a line by themselves";
    }
    if (longlines || longpages) {
	exit(1);
    }
}