##// 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 initindent=indent,
433 initindent=indent,
434 hangindent=subindent)
434 hangindent=subindent)
435
435
436
436 def parse(text, indent=0, keep=None):
437 def format(text, width, indent=0, keep=None):
437 """Parse text into a list of blocks"""
438 """Parse and format the text according to width."""
438 pruned = []
439 blocks = findblocks(text)
439 blocks = findblocks(text)
440 for b in blocks:
440 for b in blocks:
441 b['indent'] += indent
441 b['indent'] += indent
@@ -450,6 +450,11 b' def format(text, width, indent=0, keep=N'
450 blocks = addmargins(blocks)
450 blocks = addmargins(blocks)
451 blocks = prunecomments(blocks)
451 blocks = prunecomments(blocks)
452 blocks = findadmonitions(blocks)
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 text = '\n'.join(formatblock(b, width) for b in blocks)
458 text = '\n'.join(formatblock(b, width) for b in blocks)
454 if keep is None:
459 if keep is None:
455 return text
460 return text
General Comments 0
You need to be logged in to leave comments. Login now