Patchwork [5,of,6] minirst: HTML formatter tweaks

login
register
mail settings
Submitter Dan Villiom Podlaski Christiansen
Date Feb. 9, 2013, 1 p.m.
Message ID <45b34ea40358b6f8fe14.1360414839@s0-0.paconsult7.bbnplanet.net>
Download mbox | patch
Permalink /patch/863/
State Accepted, archived
Commit 13aa81e2fded35389403d2ae3a750e5af6c65dab
Delegated to: Augie Fackler
Headers show

Comments

Dan Villiom Podlaski Christiansen - Feb. 9, 2013, 1 p.m.
# HG changeset patch
# User Dan Villiom Podlaski Christiansen  <danchr@gmail.com>
# Date 1360414106 0
# Node ID 45b34ea40358b6f8fe14ef874ebbc5de5556f23c
# Parent  675a399c2c9d5c94d4798bc8fd11f855eaff5672
minirst: HTML formatter tweaks

- output table rows on distinct lines
- don't make the first row a table header
Pierre-Yves David - Feb. 9, 2013, 2:02 p.m.
On Sat, Feb 09, 2013 at 01:00:39PM +0000, Dan Villiom Podlaski Christiansen wrote:
> # HG changeset patch
> # User Dan Villiom Podlaski Christiansen  <danchr@gmail.com>
> # Date 1360414106 0
> # Node ID 45b34ea40358b6f8fe14ef874ebbc5de5556f23c
> # Parent  675a399c2c9d5c94d4798bc8fd11f855eaff5672
> minirst: HTML formatter tweaks
> 
> - output table rows on distinct lines
> - don't make the first row a table header

You should make the reason for this change clear.

Are you sure it does not break any other valid usage ?

(note: two changes in a patches, but pretty related)

> 
> diff --git a/mercurial/minirst.py b/mercurial/minirst.py
> --- a/mercurial/minirst.py
> +++ b/mercurial/minirst.py
> @@ -546,11 +546,8 @@ def formathtml(blocks):
>              for row in table:
>                  l = []
>                  for v in zip(row):
> -                    if not t:
> -                        l.append('<th>%s</th>' % v)
> -                    else:
> -                        l.append('<td>%s</td>' % v)
> -                t.append(' <tr>%s</tr>\n' % ''.join(l))
> +                    l.append('<td>%s</td>' % v)
> +                t.append(' <tr>%s</tr>\n' % '\n'.join(l))
>              out.append('<table>\n%s</table>\n' % ''.join(t))
>          elif btype == 'definition':
>              openlist('dl', level)
> 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
> @@ -758,9 +758,15 @@ 30 column format:
>  html format:
>  ----------------------------------------------------------------------
>  <table>
> - <tr><th>a</th><th>b</th><th>c</th></tr>
> - <tr><td>1</td><td>2</td><td>3</td></tr>
> - <tr><td>foo</td><td>bar</td><td>baz this list is very very very long man</td></tr>
> + <tr><td>a</td>
> +<td>b</td>
> +<td>c</td></tr>
> + <tr><td>1</td>
> +<td>2</td>
> +<td>3</td></tr>
> + <tr><td>foo</td>
> +<td>bar</td>
> +<td>baz this list is very very very long man</td></tr>
>  </table>
>  ----------------------------------------------------------------------
>  
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel

Patch

diff --git a/mercurial/minirst.py b/mercurial/minirst.py
--- a/mercurial/minirst.py
+++ b/mercurial/minirst.py
@@ -546,11 +546,8 @@  def formathtml(blocks):
             for row in table:
                 l = []
                 for v in zip(row):
-                    if not t:
-                        l.append('<th>%s</th>' % v)
-                    else:
-                        l.append('<td>%s</td>' % v)
-                t.append(' <tr>%s</tr>\n' % ''.join(l))
+                    l.append('<td>%s</td>' % v)
+                t.append(' <tr>%s</tr>\n' % '\n'.join(l))
             out.append('<table>\n%s</table>\n' % ''.join(t))
         elif btype == 'definition':
             openlist('dl', level)
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
@@ -758,9 +758,15 @@  30 column format:
 html format:
 ----------------------------------------------------------------------
 <table>
- <tr><th>a</th><th>b</th><th>c</th></tr>
- <tr><td>1</td><td>2</td><td>3</td></tr>
- <tr><td>foo</td><td>bar</td><td>baz this list is very very very long man</td></tr>
+ <tr><td>a</td>
+<td>b</td>
+<td>c</td></tr>
+ <tr><td>1</td>
+<td>2</td>
+<td>3</td></tr>
+ <tr><td>foo</td>
+<td>bar</td>
+<td>baz this list is very very very long man</td></tr>
 </table>
 ----------------------------------------------------------------------