CVS: spip/ecrire articles.php3, 1.157, 1.158 articles_edit.php3, 1.79, 1.80 inc_filtres.php3, 1.99, 1.100 inc_texte.php3, 1.184, 1.185

Update of /home/spip-cvs/spip/ecrire
In directory miel:/tmp/cvs-serv10493/ecrire

Modified Files:
  articles.php3 articles_edit.php3 inc_filtres.php3
  inc_texte.php3
Log Message:
"prendre en compte les sauts de ligne simples"

Index: articles.php3

RCS file: /home/spip-cvs/spip/ecrire/articles.php3,v
retrieving revision 1.157
retrieving revision 1.158
diff -u -d -r1.157 -r1.158
--- articles.php3 2 Feb 2004 01:49:37 -0000 1.157
+++ articles.php3 22 Feb 2004 16:36:03 -0000 1.158
@@ -182,6 +182,14 @@
}
$texte = $texte_ajout . $texte;

+//
+// Traiter les fins de lignes
+//
+if ($post_autobr) {
+ $chapo = post_autobr($chapo);
+ $texte = post_autobr($texte);
+}
+
// preparer le virtuel

if ($changer_virtuel && $flag_editable) {

Index: articles_edit.php3

RCS file: /home/spip-cvs/spip/ecrire/articles_edit.php3,v
retrieving revision 1.79
retrieving revision 1.80
diff -u -d -r1.79 -r1.80
--- articles_edit.php3 26 Jan 2004 20:57:25 -0000 1.79
+++ articles_edit.php3 22 Feb 2004 16:36:03 -0000 1.80
@@ -508,10 +508,16 @@
   echo afficher_barre('formulaire', 'texte');
   echo "<TEXTAREA NAME='texte' ".afficher_claret()." CLASS='formo' ROWS='$rows' COLS='40' wrap=soft>";
   echo $texte;
- echo "</TEXTAREA><P>\n";
+ echo "</TEXTAREA>\n";
+
+ if ($options == "avancees") {
+ echo '<div class="verdana2">';
+ echo '<input type="checkbox" class="checkbox" name="post_autobr" id="autobr" value="1" />';
+ echo '<label for="autobr">'._L("prendre en compte les sauts de ligne simples").'</label></div>';
+ }

   if (($articles_ps != "non" AND $options == "avancees") OR $ps) {
- echo "<B>"._T('info_post_scriptum')."</B><BR>";
+ echo "<P><B>"._T('info_post_scriptum')."</B><BR>";
     echo "<TEXTAREA NAME='ps' CLASS='forml' ROWS='5' COLS='40' wrap=soft>";
     echo $ps;
     echo "</TEXTAREA><P>\n";

Index: inc_filtres.php3

RCS file: /home/spip-cvs/spip/ecrire/inc_filtres.php3,v
retrieving revision 1.99
retrieving revision 1.100
diff -u -d -r1.99 -r1.100
--- inc_filtres.php3 3 Feb 2004 11:10:25 -0000 1.99
+++ inc_filtres.php3 22 Feb 2004 16:36:03 -0000 1.100
@@ -550,4 +550,29 @@
   return $champs[$champ];
}

+// postautobr : transforme les sauts de ligne en _
+function post_autobr($texte) {
+ $texte = str_replace("\r\n", "\r", $texte);
+ $texte = str_replace("\r", "\n", $texte);
+ list($texte, $les_echap) = echappe_html($texte, "POSTAUTOBR", true);
+
+ $debut = '';
+ $suite = $texte;
+ while ($t = strpos('-'.$suite, "\n", 1)) {
+ $debut .= substr($suite, 0, $t);
+ $suite = substr($suite, $t);
+ $car = substr($suite, 0, 1);
+ if (($car<>'-') AND ($car<>'_') AND ($car<>"\n"))
+ $debut .='_ ';
+ if (ereg("^\n+", $suite, $regs)) {
+ $debut.=$regs[0];
+ $suite = substr($suite, strlen($regs[0]));
+ }
+ }
+ $texte = $debut.$suite;
+
+ $texte = echappe_retour($texte, $les_echap, "POSTAUTOBR");
+ return $texte;
+}
+
?>

Index: inc_texte.php3

RCS file: /home/spip-cvs/spip/ecrire/inc_texte.php3,v
retrieving revision 1.184
retrieving revision 1.185
diff -u -d -r1.184 -r1.185
--- inc_texte.php3 2 Feb 2004 10:37:30 -0000 1.184
+++ inc_texte.php3 22 Feb 2004 16:36:03 -0000 1.185
@@ -170,7 +170,7 @@

// Mise de cote des echappements
-function echappe_html($letexte,$source) {
+function echappe_html($letexte, $source, $no_transform=false) {
   global $flag_pcre;

   if ($flag_pcre) { // beaucoup plus rapide si on a pcre
@@ -189,6 +189,10 @@
     || (!$flag_pcre && eregi($regexp_echap, $letexte, $regs))) {
     $num_echap++;

+ if ($no_transform) { // echappements bruts
+ $les_echap[$num_echap] = $regs[0];
+ }
+ else
     if ($regs[1]) {
       // Echapper les <html>...</ html>
       $les_echap[$num_echap] = $regs[2];