##// END OF EJS Templates
minirst: small code cleanup
Martin Geisler -
r12620:9a9312e8 default
parent child Browse files
Show More
@@ -296,28 +296,25 b' def addmargins(blocks):'
296 i += 2
296 i += 2
297 return blocks
297 return blocks
298
298
299 _admonitionre = re.compile(r"\.\. (admonition|attention|caution|danger|"
300 r"error|hint|important|note|tip|warning)::",
301 flags=re.IGNORECASE)
302
299 def findadmonitions(blocks):
303 def findadmonitions(blocks):
300 """
304 """
301 Makes the type of the block an admonition block if
305 Makes the type of the block an admonition block if
302 the first line is an admonition directive
306 the first line is an admonition directive
303 """
307 """
304
305 i = 0
308 i = 0
306
307 pattern = (r"\.\. (admonition|attention|caution|danger|error|hint|"
308 r"important|note|tip|warning)::")
309
310 prog = re.compile(pattern, flags=re.IGNORECASE)
311 while i < len(blocks):
309 while i < len(blocks):
312 m = prog.match(blocks[i]['lines'][0])
310 m = _admonitionre.match(blocks[i]['lines'][0])
313 if m:
311 if m:
314 blocks[i]['type'] = 'admonition'
312 blocks[i]['type'] = 'admonition'
315 admonitiontitle = blocks[i]['lines'][0][3:m.end() - 2].lower()
313 admonitiontitle = blocks[i]['lines'][0][3:m.end() - 2].lower()
316
314
317 firstline = blocks[i]['lines'][0][m.end() + 1:]
315 firstline = blocks[i]['lines'][0][m.end() + 1:]
318 if firstline != '':
316 if firstline:
319 blocks[i]['lines'].insert(1, ' ' + firstline + '')
317 blocks[i]['lines'].insert(1, ' ' + firstline)
320
321
318
322 blocks[i]['admonitiontitle'] = admonitiontitle
319 blocks[i]['admonitiontitle'] = admonitiontitle
323 del blocks[i]['lines'][0]
320 del blocks[i]['lines'][0]
General Comments 0
You need to be logged in to leave comments. Login now