Mercurial > hg
comparison tests/test-minirst.py @ 39310:a2a5d4ad5276
minirst: make format() simply return a formatted text
It's a source of bugs to change the type of the return value conditionally.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sun, 05 Aug 2018 12:11:19 +0900 |
parents | 32bc3815efae |
children | 2372284d9457 |
comparison
equal
deleted
inserted
replaced
39309:0a766cb1092a | 39310:a2a5d4ad5276 |
---|---|
5 from mercurial.utils import ( | 5 from mercurial.utils import ( |
6 stringutil, | 6 stringutil, |
7 ) | 7 ) |
8 | 8 |
9 def debugformat(text, form, **kwargs): | 9 def debugformat(text, form, **kwargs): |
10 blocks, pruned = minirst.parse(text, **kwargs) | |
10 if form == b'html': | 11 if form == b'html': |
11 print("html format:") | 12 print("html format:") |
12 out = minirst.format(text, style=form, **kwargs) | 13 out = minirst.format(text, style=form, **kwargs) |
13 else: | 14 else: |
14 print("%d column format:" % form) | 15 print("%d column format:" % form) |
15 out = minirst.format(text, width=form, **kwargs) | 16 out = minirst.format(text, width=form, **kwargs) |
16 | 17 |
17 print("-" * 70) | 18 print("-" * 70) |
18 if type(out) == tuple: | 19 print(out[:-1].decode('utf8')) |
19 print(out[0][:-1].decode('utf8')) | 20 if kwargs.get('keep'): |
20 print("-" * 70) | 21 print("-" * 70) |
21 print(stringutil.pprint(out[1]).decode('utf8')) | 22 print(stringutil.pprint(pruned).decode('utf8')) |
22 else: | |
23 print(out[:-1].decode('utf8')) | |
24 print("-" * 70) | 23 print("-" * 70) |
25 print() | 24 print() |
26 | 25 |
27 def debugformats(title, text, **kwargs): | 26 def debugformats(title, text, **kwargs): |
28 print("== %s ==" % title) | 27 print("== %s ==" % title) |