Changes in output processing from HtmlDocExtractor.

This commit is contained in:
Leandro Melo
2010-07-22 15:09:52 +02:00
parent bd5512dc3b
commit 4995c38861
2 changed files with 24 additions and 21 deletions

View File

@@ -72,6 +72,7 @@ QString HtmlDocExtractor::getClassOrNamespaceBrief(const QString &html, const QS
contents.prepend(QLatin1String("<nobr>")); contents.prepend(QLatin1String("<nobr>"));
contents.append(QLatin1String("</nobr>")); contents.append(QLatin1String("</nobr>"));
} }
processOutput(&contents);
return contents; return contents;
} }
@@ -83,10 +84,9 @@ QString HtmlDocExtractor::getClassOrNamespaceDescription(const QString &html,
return getClassOrNamespaceBrief(html, mark); return getClassOrNamespaceBrief(html, mark);
QString contents = getContentsByMarks(html, mark + QLatin1String("-description"), mark); QString contents = getContentsByMarks(html, mark + QLatin1String("-description"), mark);
if (!contents.isEmpty() && m_formatContents) { if (!contents.isEmpty() && m_formatContents)
contents.remove(QLatin1String("Detailed Description")); contents.remove(QLatin1String("Detailed Description"));
formatContents(&contents); processOutput(&contents);
}
return contents; return contents;
} }
@@ -154,9 +154,7 @@ QString HtmlDocExtractor::getClassOrNamespaceMemberDescription(const QString &ht
const QString &endMark) const const QString &endMark) const
{ {
QString contents = getContentsByMarks(html, startMark, endMark); QString contents = getContentsByMarks(html, startMark, endMark);
processOutput(&contents);
if (!contents.isEmpty())
formatContents(&contents);
return contents; return contents;
} }
@@ -183,8 +181,11 @@ QString HtmlDocExtractor::getContentsByMarks(const QString &html,
return contents; return contents;
} }
void HtmlDocExtractor::formatContents(QString *html) const void HtmlDocExtractor::processOutput(QString *html) const
{ {
if (html->isEmpty())
return;
if (!m_extendedExtraction) { if (!m_extendedExtraction) {
int paragraph = html->indexOf(QLatin1String("</p>")); int paragraph = html->indexOf(QLatin1String("</p>"));
if (paragraph != -1) { if (paragraph != -1) {
@@ -211,6 +212,7 @@ void HtmlDocExtractor::formatContents(QString *html) const
stripImagens(html); stripImagens(html);
stripEmptyParagraphs(html); stripEmptyParagraphs(html);
if (!html->startsWith(QLatin1String("<nobr>"))) {
if (!m_extendedExtraction) { if (!m_extendedExtraction) {
if (!html->endsWith(QLatin1String(".</p>"))) { if (!html->endsWith(QLatin1String(".</p>"))) {
// <p>For paragraphs similar to this. Example:</p> // <p>For paragraphs similar to this. Example:</p>
@@ -229,6 +231,7 @@ void HtmlDocExtractor::formatContents(QString *html) const
html->prepend(QLatin1String("<nobr>")); html->prepend(QLatin1String("<nobr>"));
} }
} }
}
if (m_extendedExtraction && m_lengthReference > -1 && html->length() > m_lengthReference) { if (m_extendedExtraction && m_lengthReference > -1 && html->length() > m_lengthReference) {
if (m_truncateAtParagraph) { if (m_truncateAtParagraph) {

View File

@@ -63,7 +63,7 @@ private:
QString startMark, QString startMark,
QString endMark) const; QString endMark) const;
void formatContents(QString *html) const; void processOutput(QString *html) const;
static void stripAllHtml(QString *html); static void stripAllHtml(QString *html);
static void stripHeadings(QString *html); static void stripHeadings(QString *html);