Revert "render system-user-interruption as styled yellow box in prose"
This reverts commit 4e455e2dd3.
This commit is contained in:
parent
4e455e2dd3
commit
64883cf9b8
|
|
@ -194,28 +194,26 @@ QString ChatBlockModel::highlightCode(const QString &code, const QString &langua
|
||||||
QString ChatBlockModel::renderMarkdown(const QString &markdown) const
|
QString ChatBlockModel::renderMarkdown(const QString &markdown) const
|
||||||
{
|
{
|
||||||
// Pre-process: render <system-user-interruption> blocks as styled boxes.
|
// Pre-process: render <system-user-interruption> blocks as styled boxes.
|
||||||
// These appear as prose between code fences (the server closes the tool
|
// Manual global-match loop instead of replace-with-lambda, which requires
|
||||||
// output fence before the interruption and reopens it after).
|
// Qt 6.5+ and isn't available on all target systems.
|
||||||
static const QRegularExpression interruptionRe(
|
static const QRegularExpression interruptionRe(
|
||||||
R"(<system-user-interruption>\n([\s\S]*?)\n</system-user-interruption>)");
|
R"(<system-user-interruption>\n([\s\S]*?)\n</system-user-interruption>)");
|
||||||
QString processed = markdown;
|
QString processed;
|
||||||
{
|
{
|
||||||
int cursor = 0;
|
int cursor = 0;
|
||||||
QString rebuilt;
|
|
||||||
auto it = interruptionRe.globalMatch(markdown);
|
auto it = interruptionRe.globalMatch(markdown);
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
const auto match = it.next();
|
const auto match = it.next();
|
||||||
rebuilt += markdown.mid(cursor, match.capturedStart() - cursor);
|
processed += markdown.mid(cursor, match.capturedStart() - cursor);
|
||||||
const QString content = match.captured(1).toHtmlEscaped();
|
const QString content = match.captured(1).toHtmlEscaped();
|
||||||
rebuilt += QStringLiteral(
|
processed += QStringLiteral(
|
||||||
"<div style=\"background:#fff8e1;border:1px solid #ffca28;"
|
"<div style=\"background:#fff8e1;border:1px solid #ffca28;"
|
||||||
"border-radius:4px;padding:8px;margin:8px 0;white-space:pre-wrap;\">"
|
"border-radius:4px;padding:8px;margin:8px 0;white-space:pre-wrap;\">"
|
||||||
"\u26A0\uFE0F <strong>User interruption</strong>\n")
|
"\u26A0\uFE0F <strong>User interruption</strong>\n")
|
||||||
+ content + QStringLiteral("</div>");
|
+ content + QStringLiteral("</div>");
|
||||||
cursor = match.capturedEnd();
|
cursor = match.capturedEnd();
|
||||||
}
|
}
|
||||||
rebuilt += markdown.mid(cursor);
|
processed += markdown.mid(cursor);
|
||||||
processed = rebuilt;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const QRegularExpression fenceRe(
|
static const QRegularExpression fenceRe(
|
||||||
|
|
|
||||||
Reference in New Issue