diff --git a/mercurial/minirst.py b/mercurial/minirst.py --- a/mercurial/minirst.py +++ b/mercurial/minirst.py @@ -697,6 +697,10 @@ def maketable(data, indent=0, header=Fal for row in data: l = [] for w, v in zip(widths, row): + if '\n' in v: + # only remove line breaks and indentation, long lines are + # handled by the next tool + v = ' '.join(e.lstrip() for e in v.split('\n')) pad = ' ' * (w - encoding.colwidth(v)) l.append(v + pad) out.append(indent + ' '.join(l) + "\n") diff --git a/tests/test-help.t b/tests/test-help.t --- a/tests/test-help.t +++ b/tests/test-help.t @@ -657,7 +657,10 @@ Test command without options > pass > > cmdtable = { - > "nohelp": (nohelp, [], "hg nohelp"), + > "nohelp": (nohelp, [('', 'longdesc', 3, 'x'*90), + > ('n', '', None, 'normal desc'), + > ('', 'newline', '', 'line1\nline2'), + > ], "hg nohelp"), > } > > commands.norepo += ' nohelp' @@ -672,6 +675,13 @@ Test command with no help text (no help text available) + options: + + --longdesc VALUE xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx (default: 3) + -n -- normal desc + --newline VALUE line1 line2 + use "hg -v help nohelp" to show the global options $ hg help -k nohelp diff --git a/tests/test-minirst.py b/tests/test-minirst.py --- a/tests/test-minirst.py +++ b/tests/test-minirst.py @@ -244,3 +244,14 @@ table = ''.join(rst) print table debugformats('table', table) + +data = [['s', 'long', 'line\ngoes on here'], + ['', 'xy', 'tried to fix here\n by indenting']] + +rst = minirst.maketable(data, 1, False) +table = ''.join(rst) + +print table + +debugformats('table+nl', table) + diff --git a/tests/test-minirst.py.out b/tests/test-minirst.py.out --- a/tests/test-minirst.py.out +++ b/tests/test-minirst.py.out @@ -773,3 +773,34 @@ html format: ---------------------------------------------------------------------- + = ==== ====================================== + s long line goes on here + xy tried to fix here by indenting + = ==== ====================================== + +== table+nl == +60 column format: +---------------------------------------------------------------------- + s long line goes on here + xy tried to fix here by indenting +---------------------------------------------------------------------- + +30 column format: +---------------------------------------------------------------------- + s long line goes on here + xy tried to fix here by + indenting +---------------------------------------------------------------------- + +html format: +---------------------------------------------------------------------- + + + + + + + +
slongline goes on here
xytried to fix here by indenting
+---------------------------------------------------------------------- +