Skip to content

Commit d41302d

Browse files
committed
Include Ansi for colored error messages
1 parent 84ef54b commit d41302d

File tree

4 files changed

+26
-4
lines changed

4 files changed

+26
-4
lines changed

css/ansi.css

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
.ansi-black-fg { color: black; }
2+
.ansi-red-fg { color: red; }
3+
.ansi-green-fg { color: green; }
4+
.ansi-yellow-fg { color: yellow; }
5+
.ansi-blue-fg { color: blue; }
6+
.ansi-magenta-fg { color: magenta; }
7+
.ansi-cyan-fg { color: cyan; }
8+
.ansi-white-fg { color: white; }
9+
.ansi-bright-black-fg { color: black; }
10+
.ansi-bright-red-fg { color: red; }
11+
.ansi-bright-green-fg { color: green; }
12+
.ansi-bright-yellow-fg { color: yellow; }
13+
.ansi-bright-blue-fg { color: blue; }
14+
.ansi-bright-magenta-fg { color: magenta; }
15+
.ansi-bright-cyan-fg { color: cyan; }
16+
.ansi-bright-white-fg { color: black; }

dlang.org.ddoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ _=
2727

2828
COMMON_HEADERS_DLANG=
2929
<link rel="stylesheet" href="$(STATIC css/codemirror.css)">
30+
<link rel="stylesheet" href="$(STATIC css/ansi.css)">
3031
_=
3132
COMMON_SCRIPTS =
3233
$(SCRIPTLOAD https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js)
@@ -36,6 +37,7 @@ COMMON_SCRIPTS =
3637
_=
3738
COMMON_SCRIPTS_DLANG =
3839
$(SCRIPTLOAD $(STATIC js/codemirror-compressed.js))
40+
$(SCRIPTLOAD $(STATIC js/ansi_up.min.js))
3941
$(SCRIPTLOAD $(STATIC js/run.js))
4042
_=
4143

js/run.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ var nl2br = function()
4747
return this.replace(/\n/g, "<br>");
4848
}
4949

50+
var ansi_up = new AnsiUp;
51+
ansi_up.use_classes = true;
52+
5053
function safeVar(data, path)
5154
{
5255
var p = path.split(".");
@@ -101,7 +104,8 @@ var backends = {
101104
requestTransform: function(data) {
102105
var req = {
103106
source: data.code,
104-
compiler: dmdCompilerBranch
107+
compiler: dmdCompilerBranch,
108+
color: true
105109
}
106110
// only send set attributes
107111
if (data.stdin) {
@@ -150,7 +154,7 @@ function parseOutput(res, o, oTitle)
150154
if ($.browser.msie)
151155
o.html(nl2br(res.cout));
152156
else
153-
o.text(res.cout);
157+
o.html(ansi_up.ansi_to_html(res.cout));
154158

155159
return;
156160
}

posix.mak

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,10 +297,10 @@ IMAGES=favicon.ico $(ORGS_USING_D) $(addprefix images/, \
297297

298298
JAVASCRIPT=$(addsuffix .js, $(addprefix js/, \
299299
codemirror-compressed dlang ddox listanchors platform-downloads run \
300-
run_examples show_contributors jquery-1.7.2.min))
300+
run_examples show_contributors jquery-1.7.2.min ansi_up.min))
301301

302302
STYLES=$(addsuffix .css, $(addprefix css/, \
303-
style print codemirror ddox))
303+
style print codemirror ddox ansi))
304304

305305
################################################################################
306306
# HTML Files

0 commit comments

Comments
 (0)