Mercurial > hg
changeset 10447:e957cc7cbd14
minirst: support line blocks
author | Martin Geisler <mg@lazybytes.net> |
---|---|
date | Sat, 13 Feb 2010 21:21:40 +0100 |
parents | a565a2445eb5 |
children | 6e5a47398fc5 |
files | mercurial/minirst.py tests/test-minirst.py tests/test-minirst.py.out |
diffstat | 3 files changed, 26 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/minirst.py Sat Feb 13 18:44:19 2010 +0100 +++ b/mercurial/minirst.py Sat Feb 13 21:21:40 2010 +0100 @@ -111,7 +111,7 @@ i += 1 return blocks -_bulletre = re.compile(r'(-|[0-9A-Za-z]+\.|\(?[0-9A-Za-z]+\)) ') +_bulletre = re.compile(r'(-|[0-9A-Za-z]+\.|\(?[0-9A-Za-z]+\)|\|) ') _optionre = re.compile(r'^(--[a-z-]+)((?:[ =][a-zA-Z][\w-]*)? +)(.*)$') _fieldre = re.compile(r':(?![: ])([^:]*)(?<! ):[ ]+(.*)') _definitionre = re.compile(r'[^ ]') @@ -291,8 +291,13 @@ subsequent_indent=defindent)) initindent = subindent = indent if block['type'] == 'bullet': - m = _bulletre.match(block['lines'][0]) - subindent = indent + m.end() * ' ' + if block['lines'][0].startswith('| '): + # Remove bullet for line blocks and add no extra + # indention. + block['lines'][0] = block['lines'][0][2:] + else: + m = _bulletre.match(block['lines'][0]) + subindent = indent + m.end() * ' ' elif block['type'] == 'field': keywidth = block['keywidth'] key = block['key']
--- a/tests/test-minirst.py Sat Feb 13 18:44:19 2010 +0100 +++ b/tests/test-minirst.py Sat Feb 13 21:21:40 2010 +0100 @@ -106,6 +106,12 @@ 1) Another 2) List + +Line blocks are also a form of list: + +| This is the first line. + The line continues here. +| This is the second line. """ debugformat('lists', lists, 60)
--- a/tests/test-minirst.py.out Sat Feb 13 18:44:19 2010 +0100 +++ b/tests/test-minirst.py.out Sat Feb 13 21:21:40 2010 +0100 @@ -120,6 +120,11 @@ (2) bar 1) Another 2) List + +Line blocks are also a form of list: + +This is the first line. The line continues here. +This is the second line. ---------------------------------------------------------------------- lists formatted to fit within 30 characters: @@ -157,6 +162,13 @@ (2) bar 1) Another 2) List + +Line blocks are also a form of +list: + +This is the first line. The +line continues here. +This is the second line. ---------------------------------------------------------------------- options formatted to fit within 60 characters: