##// END OF EJS Templates
minirst: create valid output when table data contains a newline...
Simon Heimberg -
r20654:af9d9b77 default
parent child Browse files
Show More
@@ -697,6 +697,10 b' def maketable(data, indent=0, header=Fal'
697 for row in data:
697 for row in data:
698 l = []
698 l = []
699 for w, v in zip(widths, row):
699 for w, v in zip(widths, row):
700 if '\n' in v:
701 # only remove line breaks and indentation, long lines are
702 # handled by the next tool
703 v = ' '.join(e.lstrip() for e in v.split('\n'))
700 pad = ' ' * (w - encoding.colwidth(v))
704 pad = ' ' * (w - encoding.colwidth(v))
701 l.append(v + pad)
705 l.append(v + pad)
702 out.append(indent + ' '.join(l) + "\n")
706 out.append(indent + ' '.join(l) + "\n")
@@ -657,7 +657,10 b' Test command without options'
657 > pass
657 > pass
658 >
658 >
659 > cmdtable = {
659 > cmdtable = {
660 > "nohelp": (nohelp, [], "hg nohelp"),
660 > "nohelp": (nohelp, [('', 'longdesc', 3, 'x'*90),
661 > ('n', '', None, 'normal desc'),
662 > ('', 'newline', '', 'line1\nline2'),
663 > ], "hg nohelp"),
661 > }
664 > }
662 >
665 >
663 > commands.norepo += ' nohelp'
666 > commands.norepo += ' nohelp'
@@ -672,6 +675,13 b' Test command with no help text'
672
675
673 (no help text available)
676 (no help text available)
674
677
678 options:
679
680 --longdesc VALUE xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
681 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx (default: 3)
682 -n -- normal desc
683 --newline VALUE line1 line2
684
675 use "hg -v help nohelp" to show the global options
685 use "hg -v help nohelp" to show the global options
676
686
677 $ hg help -k nohelp
687 $ hg help -k nohelp
@@ -244,3 +244,14 b" table = ''.join(rst)"
244 print table
244 print table
245
245
246 debugformats('table', table)
246 debugformats('table', table)
247
248 data = [['s', 'long', 'line\ngoes on here'],
249 ['', 'xy', 'tried to fix here\n by indenting']]
250
251 rst = minirst.maketable(data, 1, False)
252 table = ''.join(rst)
253
254 print table
255
256 debugformats('table+nl', table)
257
@@ -773,3 +773,34 b' html format:'
773 </table>
773 </table>
774 ----------------------------------------------------------------------
774 ----------------------------------------------------------------------
775
775
776 = ==== ======================================
777 s long line goes on here
778 xy tried to fix here by indenting
779 = ==== ======================================
780
781 == table+nl ==
782 60 column format:
783 ----------------------------------------------------------------------
784 s long line goes on here
785 xy tried to fix here by indenting
786 ----------------------------------------------------------------------
787
788 30 column format:
789 ----------------------------------------------------------------------
790 s long line goes on here
791 xy tried to fix here by
792 indenting
793 ----------------------------------------------------------------------
794
795 html format:
796 ----------------------------------------------------------------------
797 <table>
798 <tr><td>s</td>
799 <td>long</td>
800 <td>line goes on here</td></tr>
801 <tr><td></td>
802 <td>xy</td>
803 <td>tried to fix here by indenting</td></tr>
804 </table>
805 ----------------------------------------------------------------------
806
General Comments 0
You need to be logged in to leave comments. Login now