File tree Expand file tree Collapse file tree 1 file changed +14
-4
lines changed Expand file tree Collapse file tree 1 file changed +14
-4
lines changed Original file line number Diff line number Diff line change 5656# Pattern to match {% include ... %} statements
5757P_INTERNAL_INCLUDE_LINK = re .compile (r'^{% include ([^ ]*) %}$' )
5858
59+ # Pattern to match image-only and link-only lines
60+ P_LINK_IMAGE_LINE = re .compile ("^[> ]*(!?)\[([^]]+)\][([]([^)]+)[])][ ]*$" )
61+
5962# What kinds of blockquotes are allowed?
6063KNOWN_BLOCKQUOTES = {
6164 'callout' ,
@@ -376,12 +379,19 @@ def check_line_lengths(self):
376379 """Check the raw text of the lesson body."""
377380
378381 if self .args .line_lengths :
379- over = [i for (i , l , n ) in self .lines if (
380- n > MAX_LINE_LEN ) and (not l .startswith ('!' ))]
381- self .reporter .check (not over ,
382+ over_limit = []
383+
384+ for (i , l , n ) in self .lines :
385+ # Report lines that are longer than the suggested
386+ # line length limit only if they're not
387+ # link-only or image-only lines.
388+ if n > MAX_LINE_LEN and not P_LINK_IMAGE_LINE .match (l ):
389+ over_limit .append (i )
390+
391+ self .reporter .check (not over_limit ,
382392 self .filename ,
383393 'Line(s) too long: {0}' ,
384- ', ' .join ([str (i ) for i in over ]))
394+ ', ' .join ([str (i ) for i in over_limit ]))
385395
386396 def check_trailing_whitespace (self ):
387397 """Check for whitespace at the ends of lines."""
You can’t perform that action at this time.
0 commit comments