CVS commit by johnflux: Make the pasting of html a bit nicer. M +27 -16 ircinput.cpp 1.59 --- kdeextragear-2/konversation/konversation/ircinput.cpp #1.58:1.59 @@ -259,5 +259,9 @@ void IRCInput::insertHtml(const QString& { QString text(htmlTextToInsert); - // replace \r with \n to make xterm pastes happy + //We will treat \n as a \n in the paste, despite it usually being ignored + //This is so
 etc work fine.  It's works fairly well, as this is only for pasting
+  //a few lines, and those few lines will probably not have many arbituary \n's in it.
+  
+// replace \r with \n to make xterm pastes happy
   text.replace("\r","\n");
   text.replace("

","\n", false); @@ -276,29 +280,33 @@ void IRCInput::insertHtml(const QString& text.replace("","%U", false); - text.replace(QRegExp("]*color *= *[\"']black[^>]*>", false), "%C1"); - text.replace(QRegExp("]*color *= *[\"']#000000[^>]*>", false), "%C1"); + text.replace(QRegExp("< *font [^>]*color *= *[\"']black[^>]*>", false), "%C1"); + text.replace(QRegExp("< *font [^>]*color *= *[\"']#000000[^>]*>", false), "%C1"); - text.replace(QRegExp("]*color *= *[\"']orange[^>]*>", false), "%C7"); - text.replace(QRegExp("]*color *= *[\"']#ffa500[^>]*>", false), "%C7"); + text.replace(QRegExp("< *font [^>]*color *= *[\"']orange[^>]*>", false), "%C7"); + text.replace(QRegExp("< *font [^>]*color *= *[\"']#ffa500[^>]*>", false), "%C7"); - text.replace(QRegExp("]*color *= *[\"']pink[^>]*>", false), "%C13"); - text.replace(QRegExp("]*color *= *[\"']#ffc0cb[^>]*>", false), "%C13"); + text.replace(QRegExp("< *font [^>]*color *= *[\"']pink[^>]*>", false), "%C13"); + text.replace(QRegExp("< *font [^>]*color *= *[\"']#ffc0cb[^>]*>", false), "%C13"); - text.replace(QRegExp("]*color *= *[\"']aqua[^>]*>", false), "%C12"); - text.replace(QRegExp("]*color *= *[\"']#00ffff[^>]*>", false), "%C12"); + text.replace(QRegExp("< *font [^>]*color *= *[\"']aqua[^>]*>", false), "%C12"); + text.replace(QRegExp("< *font [^>]*color *= *[\"']#00ffff[^>]*>", false), "%C12"); - text.replace(QRegExp("]*color *= *[\"']red[^>]*>", false), "%C4"); - text.replace(QRegExp("]*color *= *[\"']#ff0000[^>]*>", false), "%C4"); + text.replace(QRegExp("< *font [^>]*color *= *[\"']red[^>]*>", false), "%C4"); + text.replace(QRegExp("< *font [^>]*color *= *[\"']#ff0000[^>]*>", false), "%C4"); - text.replace(QRegExp("]*color *= *[\"']green[^>]*>", false), "%C9"); - text.replace(QRegExp("]*color *= *[\"']#00ff00[^>]*>", false), "%C9"); + text.replace(QRegExp("< *font [^>]*color *= *[\"']green[^>]*>", false), "%C9"); + text.replace(QRegExp("< *font [^>]*color *= *[\"']#00ff00[^>]*>", false), "%C9"); - text.replace(QRegExp("]*color *= *[\"']blue[^>]*>", false), "%C2"); - text.replace(QRegExp("]*color *= *[\"']#0000ff[^>]*>", false), "%C2"); + text.replace(QRegExp("< *font [^>]*color *= *[\"']blue[^>]*>", false), "%C2"); + text.replace(QRegExp("< *font [^>]*color *= *[\"']#0000ff[^>]*>", false), "%C2"); text.replace(QRegExp("",false), "%C1"); + //get rid of anything else not recognised text.replace(QRegExp("<[^>]*>"), ""); + //strip multiple empty newlines + text.replace(QRegExp("\n[ "); + //strip newlines at the start and end. + text = text.stripWhiteSpace(); + // is there a newline in the pasted/inserted text? if(text.find('\n')!=-1)