2 * HTMLPrimitives.cpp - TaskJuggler
4 * Copyright (c) 2001, 2002, 2003, 2004 by Chris Schlaeger <cs@kde.org>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of version 2 of the GNU General Public License as
8 * published by the Free Software Foundation.
13 /* The following encoding table was copied from the Qt library sources since
14 * this information is not available over the public API. */
16 #include "HTMLPrimitives.h"
24 HTMLPrimitives::htmlFilter(const QString& s) const
28 for (uint i = 0; i < s.length(); i++)
33 /* Preserve HTML tags */
35 if (j < s.length() && s[j] == '/')
38 for ( ; j < s.length() && isalpha(s[j]); ++j)
40 if (j < s.length() && s[j] == '/')
42 if (s[j] == '>' && tagNameLen > 0)
44 repl = s.mid(i, j - i + 1);
56 else if (s.mid(i, 2) == "\n\n")
58 // Expand double line breaks to HTML paragraphs.
63 else if(s[i].row() != 0 || s[i].cell() >= 128)
65 // Quote all non-ASCII characters as hex values
66 repl.sprintf("&#x%02x%02x;", s[i].row(), s[i].cell());
75 return parTags ? QString("<p>") + out + "</p>" : out;