diff --git a/bin/lesson_check.py b/bin/lesson_check.py index c85661e..aaec64f 100755 --- a/bin/lesson_check.py +++ b/bin/lesson_check.py @@ -40,6 +40,9 @@ # Episode filename pattern. P_EPISODE_FILENAME = re.compile(r'/_episodes/(\d\d)-[-\w]+.md$') +# Pattern to match lines ending with whitespace. +P_TRAILING_WHITESPACE = re.compile(r'\s+$') + # What kinds of blockquotes are allowed? KNOWN_BLOCKQUOTES = { 'callout', @@ -106,6 +109,7 @@ def parse_args(): parser = OptionParser() parser.add_option('-l', '--linelen', default=False, + action="store_true", dest='line_lengths', help='Check line lengths') parser.add_option('-p', '--parser', @@ -118,6 +122,7 @@ def parse_args(): help='source directory') parser.add_option('-w', '--whitespace', default=False, + action="store_true", dest='trailing_whitespace', help='Check for trailing whitespace') @@ -263,11 +268,11 @@ def check_trailing_whitespace(self): """Check for whitespace at the ends of lines.""" if self.args.trailing_whitespace: - trailing = [i for (i, l, n) in self.lines if l.endswidth(' ')] + trailing = [i for (i, l, n) in self.lines if P_TRAILING_WHITESPACE.match(l)] self.reporter.check(not trailing, self.filename, 'Line(s) end with whitespace: {0}', - ', '.join([str[i] for i in over])) + ', '.join([str(i) for i in trailing])) def check_blockquote_classes(self):