mercurial/minirst.py
changeset 39305 200ad3e85a97
parent 38783 e7aa113b14f7
child 39306 9fe97e676250
--- a/mercurial/minirst.py	Sat Aug 25 20:19:27 2018 +0900
+++ b/mercurial/minirst.py	Sun Aug 05 11:38:56 2018 +0900
@@ -666,8 +666,21 @@
 def format(text, width=80, indent=0, keep=None, style='plain', section=None):
     """Parse and format the text according to width."""
     blocks, pruned = parse(text, indent, keep or [])
+    if section:
+        blocks = filtersections(blocks, section)
+    if style == 'html':
+        text = formathtml(blocks)
+    else:
+        text = ''.join(formatblock(b, width) for b in blocks)
+    if keep is None:
+        return text
+    else:
+        return text, pruned
+
+def filtersections(blocks, section):
+    """Select parsed blocks under the specified section"""
     parents = []
-    if section:
+    if True:
         sections = getsections(blocks)
         blocks = []
         i = 0
@@ -714,14 +727,7 @@
                                '.'.join(path + [realline[0]]).replace('"', ''))
                 del blocks[s[0]:real]
 
-    if style == 'html':
-        text = formathtml(blocks)
-    else:
-        text = ''.join(formatblock(b, width) for b in blocks)
-    if keep is None:
-        return text
-    else:
-        return text, pruned
+    return blocks
 
 def getsections(blocks):
     '''return a list of (section name, nesting level, blocks) tuples'''