Show More
@@ -666,8 +666,21 b' def formatblocks(blocks, width):' | |||
|
666 | 666 | def format(text, width=80, indent=0, keep=None, style='plain', section=None): |
|
667 | 667 | """Parse and format the text according to width.""" |
|
668 | 668 | blocks, pruned = parse(text, indent, keep or []) |
|
669 | if section: | |
|
670 | blocks = filtersections(blocks, section) | |
|
671 | if style == 'html': | |
|
672 | text = formathtml(blocks) | |
|
673 | else: | |
|
674 | text = ''.join(formatblock(b, width) for b in blocks) | |
|
675 | if keep is None: | |
|
676 | return text | |
|
677 | else: | |
|
678 | return text, pruned | |
|
679 | ||
|
680 | def filtersections(blocks, section): | |
|
681 | """Select parsed blocks under the specified section""" | |
|
669 | 682 | parents = [] |
|
670 |
if |
|
|
683 | if True: | |
|
671 | 684 | sections = getsections(blocks) |
|
672 | 685 | blocks = [] |
|
673 | 686 | i = 0 |
@@ -714,14 +727,7 b' def format(text, width=80, indent=0, kee' | |||
|
714 | 727 | '.'.join(path + [realline[0]]).replace('"', '')) |
|
715 | 728 | del blocks[s[0]:real] |
|
716 | 729 | |
|
717 | if style == 'html': | |
|
718 | text = formathtml(blocks) | |
|
719 | else: | |
|
720 | text = ''.join(formatblock(b, width) for b in blocks) | |
|
721 | if keep is None: | |
|
722 | return text | |
|
723 | else: | |
|
724 | return text, pruned | |
|
730 | return blocks | |
|
725 | 731 | |
|
726 | 732 | def getsections(blocks): |
|
727 | 733 | '''return a list of (section name, nesting level, blocks) tuples''' |
General Comments 0
You need to be logged in to leave comments.
Login now