Vidalia 0.2.10
|
00001 /* 00002 ** This file is part of Vidalia, and is subject to the license terms in the 00003 ** LICENSE file, found in the top level directory of this distribution. If you 00004 ** did not receive the LICENSE file with this file, you may obtain it from the 00005 ** Vidalia source package distributed by the Vidalia Project at 00006 ** http://www.vidalia-project.net/. No part of Vidalia, including this file, 00007 ** may be copied, modified, propagated, or distributed except according to the 00008 ** terms described in the LICENSE file. 00009 */ 00010 00011 /* 00012 ** \file html.cpp 00013 ** \version $Id: html.cpp 2362 2008-02-29 04:30:11Z edmanm $ 00014 ** \brief HTML formatting functions 00015 */ 00016 00017 #include "html.h" 00018 00019 00020 /** Wraps a string in "<p>" tags, converts "\n" to "<br/>" and converts "\n\n" 00021 * to a new paragraph. */ 00022 QString 00023 p(QString str) 00024 { 00025 str = "<p>" + str + "</p>"; 00026 str.replace("\n\n", "</p><p>"); 00027 str.replace("\n", "<br/>"); 00028 return str; 00029 } 00030 00031 /** Wraps a string in "<i>" tags. */ 00032 QString 00033 i(QString str) 00034 { 00035 return QString("<i>%1</i>").arg(str); 00036 } 00037 00038 /** Wraps a string in "<b>" tags. */ 00039 QString 00040 b(QString str) 00041 { 00042 return QString("<b>%1</b>").arg(str); 00043 } 00044 00045 /** Wraps a string in "<tr>" tags. */ 00046 QString 00047 trow(QString str) 00048 { 00049 return QString("<tr>%1</tr>").arg(str); 00050 } 00051 00052 /** Wraps a string in "<td>" tags. */ 00053 QString 00054 tcol(QString str) 00055 { 00056 return QString("<td>%1</td>").arg(str); 00057 } 00058 00059 /** Wraps a string in "<th>" tags. */ 00060 QString 00061 thead(QString str) 00062 { 00063 return QString("<th>%1</th>").arg(str); 00064 } 00065 00066 /** Escapes "<" and ">" characters in the given string. */ 00067 QString 00068 escape(QString str) 00069 { 00070 str.replace("<", "<"); 00071 str.replace(">", ">"); 00072 return str; 00073 } 00074