@@ -167,7 +167,7 @@ def test(self, text, s, e):
167167class md002 (mddef ):
168168 flag = re .M
169169 desc = "First header should be a h1 header"
170- locator = r"^(?:#{1,6}(?!#))|(?:-+$|=+$)"
170+ locator = r"^(?:#{1,6}(?!#))|(?:\S[^\n]*\n)+?(?: -+$|=+$)"
171171
172172 def test (self , text , s , e ):
173173 ret = {}
@@ -176,9 +176,8 @@ def test(self, text, s, e):
176176 if re .match (r"#{1,6}(?!#)" , text [s :e ]):
177177 if e - s != 1 :
178178 ret [s ] = "level %d found" % (e - s )
179- elif re .match ("-+|=+" , text [s :e ]):
180- if not re .match ("=+" , text [s :e ]):
181- ret [s ] = "level 2 found"
179+ elif re .match (r"(?:[^\n]*\n)+?-+" , text [s :e ]):
180+ ret [s ] = "level 2 found"
182181 return ret
183182
184183
@@ -220,7 +219,7 @@ def test(self, text, s, e):
220219class md004 (mddef ):
221220 flag = re .M
222221 desc = "Unordered list style"
223- locator = r"^([ ]{0,3})[*+-](?=\s)"
222+ locator = r"^([ ]{0,3})(?!(?:\-(?:[ \t]*\-){2,}|\*(?:[ \t]*\*){2,}|_(?:[ \t]*_){2,})[ \t]*$) [*+-](?=\s)"
224223 eol = r"^(?=\S)"
225224 gid = 1
226225 lastSym = None
@@ -316,7 +315,7 @@ def testcyc(self, sym, lv):
316315class md005 (mddef ):
317316 flag = re .M
318317 desc = "Inconsistent indentation for list items at the same level"
319- locator = r"^([ ]{0,3})[*+-](?=\s)"
318+ locator = r"^([ ]{0,3})(?!(?:\-(?:[ \t]*\-){2,}|\*(?:[ \t]*\*){2,}|_(?:[ \t]*_){2,})[ \t]*$) [*+-](?=\s)"
320319 eol = r"^(?=\S)"
321320 gid = 1
322321 lastpos = - 1
@@ -384,7 +383,7 @@ def test(self, text, s, e):
384383class md006 (mddef ):
385384 flag = re .M
386385 desc = "Consider starting bulleted lists at the beginning of the line"
387- locator = r"^([ ]{0,3})[*+-](?=\s)"
386+ locator = r"^([ ]{0,3})(?!(?:\-(?:[ \t]*\-){2,}|\*(?:[ \t]*\*){2,}|_(?:[ \t]*_){2,})[ \t]*$) [*+-](?=\s)"
388387 eol = r"^(?=\S)"
389388 gid = 1
390389 lastpos = - 1
@@ -421,7 +420,7 @@ def test(self, text, s, e):
421420class md007 (mddef ):
422421 flag = re .M
423422 desc = "Unordered list indentation"
424- locator = r"^([ ]{0,3})[*+-](?=\s)"
423+ locator = r"^([ ]{0,3})(?!(?:\-(?:[ \t]*\-){2,}|\*(?:[ \t]*\*){2,}|_(?:[ \t]*_){2,})[ \t]*$) [*+-](?=\s)"
425424 eol = r"^(?=\S)"
426425 gid = 1
427426 lastpos = - 1
@@ -570,13 +569,9 @@ def test(self, text, s, e):
570569class md022 (mddef ):
571570 flag = re .M
572571 desc = "Headers should be surrounded by blank lines"
573- locator = r"^((?:-+|=+)| (?:#{1,6}(?!#).*))$"
572+ locator = r"^(?: (?:#{1,6}(?!#).*)|(?:\S[^\n]*\n)+?(?:-+|=+ ))$"
574573
575574 def test (self , text , s , e ):
576- if re .match (r"-+|=+" , text [s :e ]):
577- st = text .rfind ("\n " , 0 , s - 1 )
578- s = st + 1
579-
580575 if s > 1 and text [s - 2 ] != "\n " :
581576 return {s : "blank line required before this line" }
582577
0 commit comments