");
- const QTextCharFormat blockFmt = formatDifference(defaultCharFormat, block.charFormat()).toCharFormat();
-
- if (!blockFmt.properties().isEmpty()) {
- emitCharFormatStyle(blockFmt);
- defaultCharFormat.merge(block.charFormat());
- }
- }
-
- const QTextBlockFormat blockFormat = block.blockFormat();
- if (blockFormat.hasProperty(QTextFormat::BlockTrailingHorizontalRulerWidth)) {
- html += QLatin1String("
");
- return;
- }
-
- const bool pre = blockFormat.nonBreakableLines();
- static bool inPre = false;
- if (pre && !inPre) {
- html += QLatin1String("");
- inPre = true;
- } else if (!list) {
- const QTextCharFormat charFmt = formatDifference(defaultCharFormat, block.charFormat()).toCharFormat();
- QString tagname = getTagName(charFmt);
- if ( !inPre || tagname != "p" ) {
- html += QString("<%1>").arg( tagname );
- }
- }
-
- // Text
- QTextBlock::Iterator it = block.begin();
- for (; !it.atEnd(); ++it)
- emitFragment(it.fragment());
- block.next();
-
- if ((pre && !block.next().isValid()) ||
- (pre && block.next().isValid() && !block.next().blockFormat().nonBreakableLines())) {
- html += QLatin1String("");
- inPre = false;
- if ( !block.next().isValid() ) {
- html+="
";
- }
- } else if (list)
- html += QLatin1String("");
- else {
- const QTextCharFormat charFmt = formatDifference(defaultCharFormat, block.charFormat()).toCharFormat();
- QString tagname = getTagName(charFmt);
- if ( !inPre ) {
- html += QString("%1>").arg( tagname );
- }
- }
- if (list) {
- if (list->itemNumber(block) == list->count() - 1) { // last item? close list
- html += QString("<%1>").arg(numbered_list ? "ol" : "ul");
- }
- }
- defaultCharFormat = oldDefaultCharFormat;
+ html += QLatin1Char('\n');
+ // save and later restore, in case we 'change' the default format by
+ // emitting block char format information
+ QTextCharFormat oldDefaultCharFormat = defaultCharFormat;
+ QTextList *list = block.textList();
+ bool numbered_list = false;
+ if (list) {
+ if (list->itemNumber(block) == 0) { // first item? emit