Add formatted diagnostic output to NotebookCell
diff --git a/PPrint.cpp b/PPrint.cpp
index de43582..c5ad222 100644
--- a/PPrint.cpp
+++ b/PPrint.cpp
@@ -7,22 +7,35 @@
QTextStream(stdout) << string << '\n';
}
-QString pprint(ParseResult val, const Parser &parser)
+QString pprint(ParseResult val, const Parser &parser, PPrint::Style style)
{
if (val)
{
return "\033[32mOK\033[0m";
}
- QString highlighted = parser.line(val.pos().line - 1) + "\n";
+ QString newline = (style == PPrint::ANSI ? "\n" : "<br>");
+
+ QString highlighted = parser.line(val.pos().line - 1) + newline;
for (int i = 1; i < val.pos().lineOffset; i++)
{
- highlighted += " ";
+ if (style == PPrint::ANSI)
+ highlighted += " ";
+ else
+ highlighted += " ";
}
- highlighted += "\033[31m^~~\033[0m";
- return val.message() + " at " + val.pos() + "\n" + highlighted;
+ if (style == PPrint::ANSI)
+ {
+ highlighted += "\033[31m^~~\033[0m";
+ }
+ else if (style == PPrint::HTML)
+ {
+ highlighted += "<font color=\"red\">^~~</font>";
+ }
+
+ return val.message() + " at " + val.pos() + newline + highlighted;
}
void eout(QString string)