Vidalia 0.3.1
html.cpp
Go to the documentation of this file.
1/*
2** This file is part of Vidalia, and is subject to the license terms in the
3** LICENSE file, found in the top level directory of this distribution. If you
4** did not receive the LICENSE file with this file, you may obtain it from the
5** Vidalia source package distributed by the Vidalia Project at
6** http://www.torproject.org/projects/vidalia.html. No part of Vidalia,
7** including this file, may be copied, modified, propagated, or distributed
8** except according to the terms described in the LICENSE file.
9*/
10
11/*
12** \file html.cpp
13** \brief HTML formatting functions
14*/
15
16#include "html.h"
17
18
19/** Wraps a string in "<p>" tags, converts "\n" to "<br/>" and converts "\n\n"
20 * to a new paragraph. */
21QString
22p(QString str)
23{
24 str = "<p>" + str + "</p>";
25 str.replace("\n\n", "</p><p>");
26 str.replace("\n", "<br/>");
27 return str;
28}
29
30/** Wraps a string in "<i>" tags. */
31QString
32i(QString str)
33{
34 return QString("<i>%1</i>").arg(str);
35}
36
37/** Wraps a string in "<b>" tags. */
38QString
39b(QString str)
40{
41 return QString("<b>%1</b>").arg(str);
42}
43
44/** Wraps a string in "<tr>" tags. */
45QString
46trow(QString str)
47{
48 return QString("<tr>%1</tr>").arg(str);
49}
50
51/** Wraps a string in "<td>" tags. */
52QString
53tcol(QString str)
54{
55 return QString("<td>%1</td>").arg(str);
56}
57
58/** Wraps a string in "<th>" tags. */
59QString
60thead(QString str)
61{
62 return QString("<th>%1</th>").arg(str);
63}
64
65/** Escapes "<" and ">" characters in the given string. */
66QString
67escape(QString str)
68{
69 str.replace("<", "&lt;");
70 str.replace(">", "&gt;");
71 return str;
72}
73
QString i(QString str)
Definition: html.cpp:32
QString p(QString str)
Definition: html.cpp:22
QString thead(QString str)
Definition: html.cpp:60
QString trow(QString str)
Definition: html.cpp:46
QString tcol(QString str)
Definition: html.cpp:53
QString escape(QString str)
Definition: html.cpp:67
QString b(QString str)
Definition: html.cpp:39