##// 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 411 i += 1
412 412 return blocks
413 413
414 _admonitionre = re.compile(r"\.\. (admonition|attention|caution|danger|"
415 r"error|hint|important|note|tip|warning)::",
416 flags=re.IGNORECASE)
414
415 _admonitions = set([
416 'admonition',
417 'attention',
418 'caution',
419 'danger',
420 'error',
421 'hint',
422 'important',
423 'note',
424 'tip',
425 'warning',
426 ])
417 427
418 428 def findadmonitions(blocks):
419 429 """
420 430 Makes the type of the block an admonition block if
421 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 436 i = 0
424 437 while i < len(blocks):
425 m = _admonitionre.match(blocks[i]['lines'][0])
438 m = admonitionre.match(blocks[i]['lines'][0])
426 439 if m:
427 440 blocks[i]['type'] = 'admonition'
428 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