Patchwork [3,of,7] minirst: extract function that formats parsed blocks as plain text

login
register
mail settings
Submitter Yuya Nishihara
Date Aug. 22, 2018, 12:19 p.m.
Message ID <8c4b4d138cd4139dc5e0.1534940391@mimosa>
Download mbox | patch
Permalink /patch/33969/
State Accepted
Headers show

Comments

Yuya Nishihara - Aug. 22, 2018, 12:19 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1533436985 -32400
#      Sun Aug 05 11:43:05 2018 +0900
# Node ID 8c4b4d138cd4139dc5e0579bd82bf89eea8ab395
# Parent  ba490a52393234d168b28ba731de68f81f68a796
minirst: extract function that formats parsed blocks as plain text

Patch

diff --git a/mercurial/minirst.py b/mercurial/minirst.py
--- a/mercurial/minirst.py
+++ b/mercurial/minirst.py
@@ -663,6 +663,10 @@  def formatblocks(blocks, width):
     text = ''.join(formatblock(b, width) for b in blocks)
     return text
 
+def formatplain(blocks, width):
+    """Format parsed blocks as plain text"""
+    return ''.join(formatblock(b, width) for b in blocks)
+
 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 [])
@@ -671,7 +675,7 @@  def format(text, width=80, indent=0, kee
     if style == 'html':
         text = formathtml(blocks)
     else:
-        text = ''.join(formatblock(b, width) for b in blocks)
+        text = formatplain(blocks, width=width)
     if keep is None:
         return text
     else: