##// END OF EJS Templates
minirst: add style flag to format
Matt Mackall -
r15262:e8076af1 default
parent child Browse files
Show More
@@ -608,10 +608,13 b' def formatblocks(blocks, width):'
608 text = ''.join(formatblock(b, width) for b in blocks)
608 text = ''.join(formatblock(b, width) for b in blocks)
609 return text
609 return text
610
610
611 def format(text, width, indent=0, keep=None):
611 def format(text, width=80, indent=0, keep=None, style='plain'):
612 """Parse and format the text according to width."""
612 """Parse and format the text according to width."""
613 blocks, pruned = parse(text, indent, keep or [])
613 blocks, pruned = parse(text, indent, keep or [])
614 text = ''.join(formatblock(b, width) for b in blocks)
614 if style == 'html':
615 text = formathtml(blocks)
616 else:
617 text = ''.join(formatblock(b, width) for b in blocks)
615 if keep is None:
618 if keep is None:
616 return text
619 return text
617 else:
620 else:
@@ -4,16 +4,18 b' from mercurial import minirst'
4 def debugformat(title, text, width, **kwargs):
4 def debugformat(title, text, width, **kwargs):
5 print "%s formatted to fit within %d characters:" % (title, width)
5 print "%s formatted to fit within %d characters:" % (title, width)
6 formatted = minirst.format(text, width, **kwargs)
6 formatted = minirst.format(text, width, **kwargs)
7 html = minirst.formathtml(minirst.parse(text, **kwargs)[0])
7 html = minirst.format(text, width, style='html', **kwargs)
8 print "-" * 70
8 print "-" * 70
9 if type(formatted) == tuple:
9 if type(formatted) == tuple:
10 print formatted[0]
10 print formatted[0]
11 print "-" * 70
11 print "-" * 70
12 print html
13 print "-" * 70
12 pprint(formatted[1])
14 pprint(formatted[1])
13 else:
15 else:
14 print formatted
16 print formatted
15 print "-" * 70
17 print "-" * 70
16 print html
18 print html
17 print "-" * 70
19 print "-" * 70
18 print
20 print
19
21
@@ -615,15 +615,9 b' Normal output.'
615 Verbose output.
615 Verbose output.
616
616
617 ----------------------------------------------------------------------
617 ----------------------------------------------------------------------
618 ['debug', 'debug']
618 ('<p>\nNormal output.\n</p>\n<p>\nVerbose output.\n</p>\n', ['debug', 'debug'])
619 ----------------------------------------------------------------------
619 ----------------------------------------------------------------------
620 <p>
620 ['debug', 'debug']
621 Normal output.
622 </p>
623 <p>
624 Verbose output.
625 </p>
626
627 ----------------------------------------------------------------------
621 ----------------------------------------------------------------------
628
622
629 containers (debug) formatted to fit within 60 characters:
623 containers (debug) formatted to fit within 60 characters:
@@ -633,15 +627,9 b' Normal output.'
633 Initial debug output.
627 Initial debug output.
634
628
635 ----------------------------------------------------------------------
629 ----------------------------------------------------------------------
636 ['verbose']
630 ('<p>\nNormal output.\n</p>\n<p>\nInitial debug output.\n</p>\n', ['verbose'])
637 ----------------------------------------------------------------------
631 ----------------------------------------------------------------------
638 <p>
632 ['verbose']
639 Normal output.
640 </p>
641 <p>
642 Initial debug output.
643 </p>
644
645 ----------------------------------------------------------------------
633 ----------------------------------------------------------------------
646
634
647 containers (verbose debug) formatted to fit within 60 characters:
635 containers (verbose debug) formatted to fit within 60 characters:
@@ -655,21 +643,9 b' Verbose output.'
655 Debug output.
643 Debug output.
656
644
657 ----------------------------------------------------------------------
645 ----------------------------------------------------------------------
658 []
646 ('<p>\nNormal output.\n</p>\n<p>\nInitial debug output.\n</p>\n<p>\nVerbose output.\n</p>\n<p>\nDebug output.\n</p>\n', [])
659 ----------------------------------------------------------------------
647 ----------------------------------------------------------------------
660 <p>
648 []
661 Normal output.
662 </p>
663 <p>
664 Initial debug output.
665 </p>
666 <p>
667 Verbose output.
668 </p>
669 <p>
670 Debug output.
671 </p>
672
673 ----------------------------------------------------------------------
649 ----------------------------------------------------------------------
674
650
675 roles formatted to fit within 60 characters:
651 roles formatted to fit within 60 characters:
General Comments 0
You need to be logged in to leave comments. Login now