##// END OF EJS Templates
minirst: add parse method to get document structure
Matt Mackall -
r15012:ee766af4 default
parent child Browse files
Show More
@@ -433,9 +433,9 b' def formatblock(block, width):'
433 433 initindent=indent,
434 434 hangindent=subindent)
435 435
436
437 def format(text, width, indent=0, keep=None):
438 """Parse and format the text according to width."""
436 def parse(text, indent=0, keep=None):
437 """Parse text into a list of blocks"""
438 pruned = []
439 439 blocks = findblocks(text)
440 440 for b in blocks:
441 441 b['indent'] += indent
@@ -450,6 +450,11 b' def format(text, width, indent=0, keep=N'
450 450 blocks = addmargins(blocks)
451 451 blocks = prunecomments(blocks)
452 452 blocks = findadmonitions(blocks)
453 return blocks, pruned
454
455 def format(text, width, indent=0, keep=None):
456 """Parse and format the text according to width."""
457 blocks, pruned = parse(text, indent, keep or [])
453 458 text = '\n'.join(formatblock(b, width) for b in blocks)
454 459 if keep is None:
455 460 return text
General Comments 0
You need to be logged in to leave comments. Login now