Mercurial > hg
changeset 12620:9a9312e84e4e
minirst: small code cleanup
author | Martin Geisler <mg@lazybytes.net> |
---|---|
date | Fri, 08 Oct 2010 22:42:32 +0200 |
parents | 7178f6fedb9d |
children | 9a2de8dae27b |
files | mercurial/minirst.py |
diffstat | 1 files changed, 7 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/minirst.py Fri Oct 08 14:02:23 2010 -0500 +++ b/mercurial/minirst.py Fri Oct 08 22:42:32 2010 +0200 @@ -296,28 +296,25 @@ i += 2 return blocks +_admonitionre = re.compile(r"\.\. (admonition|attention|caution|danger|" + r"error|hint|important|note|tip|warning)::", + flags=re.IGNORECASE) + def findadmonitions(blocks): """ Makes the type of the block an admonition block if the first line is an admonition directive """ - i = 0 - - pattern = (r"\.\. (admonition|attention|caution|danger|error|hint|" - r"important|note|tip|warning)::") - - prog = re.compile(pattern, flags=re.IGNORECASE) while i < len(blocks): - m = prog.match(blocks[i]['lines'][0]) + m = _admonitionre.match(blocks[i]['lines'][0]) if m: blocks[i]['type'] = 'admonition' admonitiontitle = blocks[i]['lines'][0][3:m.end() - 2].lower() firstline = blocks[i]['lines'][0][m.end() + 1:] - if firstline != '': - blocks[i]['lines'].insert(1, ' ' + firstline + '') - + if firstline: + blocks[i]['lines'].insert(1, ' ' + firstline) blocks[i]['admonitiontitle'] = admonitiontitle del blocks[i]['lines'][0]