From e434cbe312c6cb1cf17ee71db828019121cb6c6e Mon Sep 17 00:00:00 2001
From: "Committo,Ergo:sum" <esj@rezo.net>
Date: Fri, 15 Feb 2008 14:51:41 +0000
Subject: [PATCH] =?UTF-8?q?Petite=20douceur=20dans=20le=20raccourci=20des?=
 =?UTF-8?q?=20tableaux:=20si=20toutes=20les=20colonnes=20sont=20num=C3=A9r?=
 =?UTF-8?q?iques,=20compte=20non=20tenu=20de=20celles=20commen=C3=A7ant=20?=
 =?UTF-8?q?par=20une=20balise=20HTML=20ou=20une=20accoloade=20(raccourci?=
 =?UTF-8?q?=20SPIP)=20ni=20du=20Caption,=20les=20cellules=20seront=20align?=
 =?UTF-8?q?=C3=A9es=20=C3=A0=20droite.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Exemple (mais d'où sort-il ?):

{{{
||Conseil d'Administration Collège B|
|{}|{{Liste 1}}|{{Liste 2}}|{{Liste 3}}|{{Total}}|
|{Jussieu}|185|323|190|698|
|{Pitié}|68|16|8|92|
|{Saint-Antoine}|29|10|6|45|
|{Tenon}|16|12|2|30|
|{Roscoff+Banyuls}|10|9|6|25|
|{Villefranche}|13|2|1|16|
|{{Total}}|321|372|213|{/}|
|{{Sièges}}|1|5|1|{/}|
}}}
---
 ecrire/inc/texte.php | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/ecrire/inc/texte.php b/ecrire/inc/texte.php
index e803e4f097..a1fb159528 100644
--- a/ecrire/inc/texte.php
+++ b/ecrire/inc/texte.php
@@ -663,6 +663,7 @@ function traiter_tableau($bloc) {
 	$lignes = array();
 	$debut_table = $summary = '';
 	$l = 0;
+	$numeric = true;
 
 	// Traiter chaque ligne
 	foreach ($regs[1] as $ligne) {
@@ -729,6 +730,7 @@ function traiter_tableau($bloc) {
 	// et on parcourt le tableau a l'envers pour ramasser les
 	// colspan et rowspan en passant
 	$html = '';
+
 	for($l=count($lignes)-1; $l>=0; $l--) {
 		$cols= $lignes[$l];
 		$colspan=1;
@@ -751,15 +753,17 @@ function traiter_tableau($bloc) {
 				$attr.= " rowspan='$rowspans[$c]'";
 				$rowspans[$c]=1;
 			  }
-			  $ligne= '<td'.$attr.'>'.$cols[$c].'</td>'.$ligne;
+			  $ligne= "\n<td".$attr.'>'.$cols[$c].'</td>'.$ligne;
 			}
+			$numeric &= (preg_match('/[{<]/',$cols[$c][0]) || is_numeric($cols[$c]));
 		}
 
 		// ligne complete
 		$class = 'row_'.alterner($l+1, 'even', 'odd');
 		$html = "<tr class=\"$class\">" . $ligne . "</tr>\n".$html;
 	}
-
+	if ($numeric) 
+		$html = str_replace("\n<td", "\n<td style='text-align: right'", $html);
 	return "\n\n<table".$GLOBALS['class_spip_plus'].$summary.">\n"
 		. $debut_table
 		. "<tbody>\n"
-- 
GitLab