00001 /**************************************************************** 00002 * Vidalia is distributed under the following license: 00003 * 00004 * Copyright (C) 2006, Matt Edman, Justin Hipple 00005 * 00006 * This program is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU General Public License 00008 * as published by the Free Software Foundation; either version 2 00009 * of the License, or (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software 00018 * Foundation, Inc., 51 Franklin Street, Fifth Floor, 00019 * Boston, MA 02110-1301, USA. 00020 ****************************************************************/ 00021 00022 /** 00023 * \file html.cpp 00024 * \version $Id: html.cpp 1563 2006-12-26 06:06:04Z edmanm $ 00025 * \brief HTML formatting functions 00026 */ 00027 00028 #include "html.h" 00029 00030 00031 /** Wraps a string in "<p>" tags, converts "\n" to "<br/>" and converts "\n\n" 00032 * to a new paragraph. */ 00033 QString 00034 p(QString str) 00035 { 00036 str = "<p>" + str + "</p>"; 00037 str.replace("\n\n", "</p><p>"); 00038 str.replace("\n", "<br/>"); 00039 return str; 00040 } 00041 00042 /** Wraps a string in "<i>" tags. */ 00043 QString 00044 i(QString str) 00045 { 00046 return QString("<i>%1</i>").arg(str); 00047 } 00048 00049 /** Wraps a string in "<b>" tags. */ 00050 QString 00051 b(QString str) 00052 { 00053 return QString("<b>%1</b>").arg(str); 00054 } 00055 00056 /** Wraps a string in "<tr>" tags. */ 00057 QString 00058 trow(QString str) 00059 { 00060 return QString("<tr>%1</tr>").arg(str); 00061 } 00062 00063 /** Wraps a string in "<td>" tags. */ 00064 QString 00065 tcol(QString str) 00066 { 00067 return QString("<td>%1</td>").arg(str); 00068 } 00069 00070 /** Wraps a string in "<th>" tags. */ 00071 QString 00072 thead(QString str) 00073 { 00074 return QString("<th>%1</th>").arg(str); 00075 } 00076 00077 /** Escapes "<" and ">" characters in the given string. */ 00078 QString 00079 escape(QString str) 00080 { 00081 str.replace("<", "<"); 00082 str.replace(">", ">"); 00083 return str; 00084 } 00085