##// END OF EJS Templates
minirst: dynamically compile admonitions regexp...
Gregory Szorc -
r31131:50a49ead default
parent child Browse files
Show More
@@ -411,18 +411,31 b' def prunecomments(blocks):'
411 i += 1
411 i += 1
412 return blocks
412 return blocks
413
413
414 _admonitionre = re.compile(r"\.\. (admonition|attention|caution|danger|"
414
415 r"error|hint|important|note|tip|warning)::",
415 _admonitions = set([
416 flags=re.IGNORECASE)
416 'admonition',
417 'attention',
418 'caution',
419 'danger',
420 'error',
421 'hint',
422 'important',
423 'note',
424 'tip',
425 'warning',
426 ])
417
427
418 def findadmonitions(blocks):
428 def findadmonitions(blocks):
419 """
429 """
420 Makes the type of the block an admonition block if
430 Makes the type of the block an admonition block if
421 the first line is an admonition directive
431 the first line is an admonition directive
422 """
432 """
433 admonitionre = re.compile(r'\.\. (%s)::' % '|'.join(sorted(_admonitions)),
434 flags=re.IGNORECASE)
435
423 i = 0
436 i = 0
424 while i < len(blocks):
437 while i < len(blocks):
425 m = _admonitionre.match(blocks[i]['lines'][0])
438 m = admonitionre.match(blocks[i]['lines'][0])
426 if m:
439 if m:
427 blocks[i]['type'] = 'admonition'
440 blocks[i]['type'] = 'admonition'
428 admonitiontitle = blocks[i]['lines'][0][3:m.end() - 2].lower()
441 admonitiontitle = blocks[i]['lines'][0][3:m.end() - 2].lower()
General Comments 0
You need to be logged in to leave comments. Login now