")));
}
void HtmlDocExtractor::stripTagsStyles(QString *html)
{
const QRegExp &exp = createMinimalExp(QLatin1String("<(.*\\s+)class=\".*\">"));
html->replace(exp, QLatin1String("<\\1>"));
}
void HtmlDocExtractor::stripTeletypes(QString *html)
{
html->remove(createMinimalExp(QLatin1String("
|")));
}
void HtmlDocExtractor::replaceNonStyledHeadingsForBold(QString *html)
{
const QRegExp &hStart = createMinimalExp(QLatin1String("
"));
const QRegExp &hEnd = createMinimalExp(QLatin1String(""));
html->replace(hStart, QLatin1String("
"));
html->replace(hEnd, QLatin1String("
"));
}
void HtmlDocExtractor::replaceTablesForSimpleLines(QString *html)
{
html->remove(createMinimalExp(QLatin1String("
")));
html->remove(QLatin1String(""));
html->remove(createMinimalExp(QLatin1String(".*")));
html->replace(QLatin1String(" | remove(createMinimalExp(QLatin1String(" | ")));
html->remove(QLatin1String(""));
html->replace(QLatin1String(""), QLatin1String(" - "));
html->replace(QLatin1String("
"), QLatin1String("
"));
}
void HtmlDocExtractor::replaceListsForSimpleLines(QString *html)
{
html->remove(createMinimalExp(QLatin1String("<(?:ul|ol).*>")));
html->remove(createMinimalExp(QLatin1String("(?:ul|ol)>")));
html->replace(QLatin1String(""), QLatin1String(" - "));
html->replace(QLatin1String(""), QLatin1String("
"));
}
/*
@todo: We need to clean the anchor in the same way qtdoc does. Currently, this method is a
duplicate of HtmlGenerator::cleanRef. It would be good to reuse the same code either by exposing
parts of qtdocs or by refactoring the behavior to use some Qt component for example.
*/
QString HtmlDocExtractor::cleanReference(const QString &reference)
{
QString clean;
if (reference.isEmpty())
return clean;
clean.reserve(reference.size() + 20);
const QChar c = reference[0];
const uint u = c.unicode();
if ((u >= QLatin1Char('a') && u <= QLatin1Char('z')) ||
(u >= QLatin1Char('A') && u <= QLatin1Char('Z')) ||
(u >= QLatin1Char('0') && u <= QLatin1Char('9'))) {
clean += c;
} else if (u == QLatin1Char('~')) {
clean += QLatin1String("dtor.");
} else if (u == QLatin1Char('_')) {
clean += QLatin1String("underscore.");
} else {
clean += QLatin1String("A");
}
for (int i = 1; i < (int) reference.length(); i++) {
const QChar c = reference[i];
const uint u = c.unicode();
if ((u >= QLatin1Char('a') && u <= QLatin1Char('z')) ||
(u >= QLatin1Char('A') && u <= QLatin1Char('Z')) ||
(u >= QLatin1Char('0') && u <= QLatin1Char('9')) || u == QLatin1Char('-') ||
u == QLatin1Char('_') || u == QLatin1Char(':') || u == QLatin1Char('.')) {
clean += c;
} else if (c.isSpace()) {
clean += QLatin1String("-");
} else if (u == QLatin1Char('!')) {
clean += QLatin1String("-not");
} else if (u == QLatin1Char('&')) {
clean += QLatin1String("-and");
} else if (u == QLatin1Char('<')) {
clean += QLatin1String("-lt");
} else if (u == QLatin1Char('=')) {
clean += QLatin1String("-eq");
} else if (u == QLatin1Char('>')) {
clean += QLatin1String("-gt");
} else if (u == QLatin1Char('#')) {
clean += QLatin1String("#");
} else {
clean += QLatin1String("-");
clean += QString::number((int)u, 16);
}
}
return clean;
}