##// END OF EJS Templates
minirst: make format() simply return a formatted text...
Yuya Nishihara -
r39346:a2a5d4ad default
parent child Browse files
Show More
@@ -673,13 +673,9 b' def format(text, width=80, indent=0, kee'
673 673 if section:
674 674 blocks = filtersections(blocks, section)
675 675 if style == 'html':
676 text = formathtml(blocks)
676 return formathtml(blocks)
677 677 else:
678 text = formatplain(blocks, width=width)
679 if keep is None:
680 return text
681 else:
682 return text, pruned
678 return formatplain(blocks, width=width)
683 679
684 680 def filtersections(blocks, section):
685 681 """Select parsed blocks under the specified section"""
@@ -575,7 +575,7 b' def rstdoc(context, mapping, args):'
575 575 text = evalstring(context, mapping, args[0])
576 576 style = evalstring(context, mapping, args[1])
577 577
578 return minirst.format(text, style=style, keep=['verbose'])[0]
578 return minirst.format(text, style=style, keep=['verbose'])
579 579
580 580 @templatefunc('separate(sep, args...)', argspec='sep *args')
581 581 def separate(context, mapping, args):
@@ -7,6 +7,7 b' from mercurial.utils import ('
7 7 )
8 8
9 9 def debugformat(text, form, **kwargs):
10 blocks, pruned = minirst.parse(text, **kwargs)
10 11 if form == b'html':
11 12 print("html format:")
12 13 out = minirst.format(text, style=form, **kwargs)
@@ -15,12 +16,10 b' def debugformat(text, form, **kwargs):'
15 16 out = minirst.format(text, width=form, **kwargs)
16 17
17 18 print("-" * 70)
18 if type(out) == tuple:
19 print(out[0][:-1].decode('utf8'))
19 print(out[:-1].decode('utf8'))
20 if kwargs.get('keep'):
20 21 print("-" * 70)
21 print(stringutil.pprint(out[1]).decode('utf8'))
22 else:
23 print(out[:-1].decode('utf8'))
22 print(stringutil.pprint(pruned).decode('utf8'))
24 23 print("-" * 70)
25 24 print()
26 25
General Comments 0
You need to be logged in to leave comments. Login now