dlang.org icon indicating copy to clipboard operation
dlang.org copied to clipboard

Show colored error messages for the run.dlang.io backend

Open wilzbach opened this issue 6 years ago • 10 comments

Pretty horrible JS magic as most of the previous output from DPaste isn't supported, but it's not a huge deal as the user is either just interested in the normal output or the error message.

In a follow-up, I might also add support for colored error messages like run.dlang.io has

wilzbach avatar Dec 14 '17 06:12 wilzbach

Thanks for your pull request, @wilzbach!

Bugzilla references

Auto-close Bugzilla Description
18306 No compliation errors shown when running modified examples

dlang-bot avatar Dec 14 '17 06:12 dlang-bot

In a follow-up, I might also add support for colored error messages like run.dlang.io has

Turns out it's not that hard with AnsiUp (that's the lib we used for run.dlang.io):

image

Frontpage

image

More colors:

image

The colors are CSS classes and can be tweaked.

wilzbach avatar Dec 14 '17 07:12 wilzbach

That cyan looks pretty bad on white. Maybe a blue instead. Doesn't really matter to me, as long as it has more contrast.

JinShil avatar Dec 14 '17 07:12 JinShil

Do we really need to add another HTTP request for that CSS file?

CyberShadow avatar Dec 14 '17 11:12 CyberShadow

Do we really need to add another HTTP request for that CSS file?

No. Included into style.css. Should I also inline the regarding JS code?

wilzbach avatar Dec 15 '17 09:12 wilzbach

Thanks. Keeping things in separate files would be more amenable if they were concatenated during the build, but even so, I'm not sure it's worth it.

CyberShadow avatar Dec 15 '17 11:12 CyberShadow

Should I also inline the regarding JS code?

Honestly, I think doing the ANSI->HTML translation ought to be done by the server. There is no value in sending raw ANSI over the wire, as far as I can see.

CyberShadow avatar Dec 15 '17 11:12 CyberShadow

There is no value in sending raw ANSI over the wire, as far as I can see.

  • Security: sending HTML means that it easily holes for injecting arbitrary HTML
  • Simplicity: I didn't know of any D ANSI 2 HTML implementation. There are plenty in JS (main point)

But I do agree that adding the ansi JS increases the size of the sources needed for dlang.org :/

wilzbach avatar Dec 15 '17 13:12 wilzbach

On a second thought, I'm not planning on adding this HTML output to the backend for the reasons from above (security:holes for injecting arbitrary HTML + simplicity: I didn't know of any D ANSI 2 HTML implementation. There are plenty in JS). I rebased this to include a uglified version of AnsiUp. It's 10K without compression and and 2.3K with compression. Imho that's more than worth it for nice, colorized error messages without investing a lot of time to reinvent the wheel.

wilzbach avatar Feb 03 '18 21:02 wilzbach

I'm not going to block this PR, but I still don't like this.

DMD uses a very tiny subset of ANSI, parsing which should be absolutely trivial by hand. This both puts under the question of including an entire library someone else has written, and the argument that doing it on the server is too hard.

CyberShadow avatar Feb 03 '18 21:02 CyberShadow