Details
-
Bug
-
Resolution: Incomplete
-
P5: Not important
-
None
-
4.8.1
-
None
Description
If you have a QTextDocument that includes a QTextBlockFormat which sets non-breakable lines:
QTextBlockFormat fooBlockFormat;
fooBlockFormat.setNonBreakableLines( true );
...then QTextHtmlExporter will generate HTML like this for the block:
<pre align="center" style="...
which is invalid HTML since the <pre> tag doesn't define an align attribute. While this actually works correctly in some browsers (Chrome) it doesn't work in others (Firefox), so text alignment is incorrect.
This is set in QTextHtmlExporter::emitAlignment() which simply adds the align attribute to the current element:
void QTextHtmlExporter::emitAlignment(Qt::Alignment align) { if (align & Qt::AlignLeft) return; else if (align & Qt::AlignRight) html += QLatin1String(" align=\"right\""); else if (align & Qt::AlignHCenter) html += QLatin1String(" align=\"center\""); else if (align & Qt::AlignJustify) html += QLatin1String(" align=\"justify\""); }
Possible fix: this could just be changed to use style="text-align:XXX", but I'm not sure if there are other elements which require the actual align attribute.