Исправлен белый экран предпросмотра: CodeBlock отдельный компонент

- CodeBlock.qml: Qt.rgba вместо "rgba(...)", убран lineHeight, contentHeight для ScrollView, width via availableWidth
- MarkdownView.qml: ListModel с полными ролями (codeText/highlightedText), delegate без required model, Column anchors.top/left/right, parseBlocks сохраняет codeBlocks
- MdParser: parseBlocks с QRegularExpression и сохранением codeBlocks, forceDark highlight
- mdparser_test: проверка parseBlocks 3 блока
- ctest 21/21, offscreen/cocoa RUNNING OK, Flora.app 180М
This commit is contained in:
2026-09-01 21:47:40 +03:00
parent b3fa778d88
commit bfd955a3f9
4 changed files with 53 additions and 13 deletions
+31 -7
View File
@@ -768,8 +768,16 @@ QVariantList MdParser::parseBlocks(const QString &markdown, const QString &vault
if (m) { savedBlocks = m->codeBlocks; savedCounter = m->codeCounter; }
QString html = render(htmlPart, vaultRoot, fileDir);
if (m) { m->codeBlocks = savedBlocks; m->codeCounter = savedCounter; }
if (!html.trimmed().isEmpty())
blocks.append(QVariantMap{{"type", "html"}, {"html", html}});
if (!html.trimmed().isEmpty()) {
QVariantMap block;
block["type"] = "html";
block["html"] = html;
block["codeText"] = "";
block["language"] = "";
block["codeId"] = "";
block["highlightedText"] = "";
blocks.append(block);
}
}
}
QString langRaw = match.captured(1).trimmed();
@@ -789,10 +797,11 @@ QVariantList MdParser::parseBlocks(const QString &markdown, const QString &vault
}
QVariantMap block;
block["type"] = "code";
block["code"] = code;
block["codeText"] = code;
block["language"] = lang.isEmpty() ? "text" : lang;
block["codeId"] = codeId;
block["highlighted"] = highlighted;
block["highlightedText"] = highlighted;
block["html"] = "";
blocks.append(block);
lastPos = end;
}
@@ -805,8 +814,16 @@ QVariantList MdParser::parseBlocks(const QString &markdown, const QString &vault
if (m) { savedBlocks = m->codeBlocks; savedCounter = m->codeCounter; }
QString html = render(htmlPart, vaultRoot, fileDir);
if (m) { m->codeBlocks = savedBlocks; m->codeCounter = savedCounter; }
if (!html.trimmed().isEmpty())
blocks.append(QVariantMap{{"type", "html"}, {"html", html}});
if (!html.trimmed().isEmpty()) {
QVariantMap block;
block["type"] = "html";
block["html"] = html;
block["codeText"] = "";
block["language"] = "";
block["codeId"] = "";
block["highlightedText"] = "";
blocks.append(block);
}
}
}
// Если вообще не нашли блоки, но markdown не пустой — вернём как html
@@ -816,7 +833,14 @@ QVariantList MdParser::parseBlocks(const QString &markdown, const QString &vault
if (m) { savedBlocks = m->codeBlocks; savedCounter = m->codeCounter; }
QString html = render(markdown, vaultRoot, fileDir);
if (m) { m->codeBlocks = savedBlocks; m->codeCounter = savedCounter; }
blocks.append(QVariantMap{{"type", "html"}, {"html", html}});
QVariantMap block;
block["type"] = "html";
block["html"] = html;
block["codeText"] = "";
block["language"] = "";
block["codeId"] = "";
block["highlightedText"] = "";
blocks.append(block);
}
return blocks;
}