Vidalia 0.2.15
|
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.torproject.org/projects/vidalia.html. No part of Vidalia, 00007 ** including this file, may be copied, modified, propagated, or distributed 00008 ** except according to the terms described in the LICENSE file. 00009 */ 00010 00011 /* 00012 ** \file html.cpp 00013 ** \brief HTML formatting functions 00014 */ 00015 00016 #include "html.h" 00017 00018 00019 /** Wraps a string in "<p>" tags, converts "\n" to "<br/>" and converts "\n\n" 00020 * to a new paragraph. */ 00021 QString 00022 p(QString str) 00023 { 00024 str = "<p>" + str + "</p>"; 00025 str.replace("\n\n", "</p><p>"); 00026 str.replace("\n", "<br/>"); 00027 return str; 00028 } 00029 00030 /** Wraps a string in "<i>" tags. */ 00031 QString 00032 i(QString str) 00033 { 00034 return QString("<i>%1</i>").arg(str); 00035 } 00036 00037 /** Wraps a string in "<b>" tags. */ 00038 QString 00039 b(QString str) 00040 { 00041 return QString("<b>%1</b>").arg(str); 00042 } 00043 00044 /** Wraps a string in "<tr>" tags. */ 00045 QString 00046 trow(QString str) 00047 { 00048 return QString("<tr>%1</tr>").arg(str); 00049 } 00050 00051 /** Wraps a string in "<td>" tags. */ 00052 QString 00053 tcol(QString str) 00054 { 00055 return QString("<td>%1</td>").arg(str); 00056 } 00057 00058 /** Wraps a string in "<th>" tags. */ 00059 QString 00060 thead(QString str) 00061 { 00062 return QString("<th>%1</th>").arg(str); 00063 } 00064 00065 /** Escapes "<" and ">" characters in the given string. */ 00066 QString 00067 escape(QString str) 00068 { 00069 str.replace("<", "<"); 00070 str.replace(">", ">"); 00071 return str; 00072 } 00073