118

Let's add our own bells and whistles to the library. Especially, I'd like to see code highlighting (anything will do), which is clearly needed and would be a great way to emphasise the important parts.

Currently, the best posters can do is ASCII art arrows, which happens often enough and is probably not done more because it's a hassle, like:

printf("%5s", "foo")
         ^--- add a width value

It would be great to highlight the 5 in red or even circle it (too fancy?).

Other ideas welcome in discussion.

But seriously, why don't we have our own prettifier?

10
  • 7
    You post this at the same time as I was suggesting it too: meta.stackoverflow.com/questions/371740/…
    – Cœur
    Commented Jul 31, 2018 at 1:45
  • 15
    Currently, the best alternative I've seen is to use <pre><code> ... </code></pre> in the Markdown for code blocks in conjunction with other HTML tags like <b> and <i> to highlight certain parts of the code. Commented Jul 31, 2018 at 2:09
  • 1
    Prettify is light-weight already works with Stack Overflow and is easily extendable, seems like a no-brainer to me.
    – user692942
    Commented Jul 31, 2018 at 8:19
  • @4castle could this be included in the Code tab of the question/answer help section?
    – CPHPython
    Commented Jul 31, 2018 at 8:31
  • 24
    What's wrong with hand-drawn red circles? Commented Jul 31, 2018 at 15:45
  • 17
    @OwenJohnson maybe we could make the library hand-draw the circles automatically! :) Commented Jul 31, 2018 at 16:01
  • The good thing about ASCII arrows (if the person creating them has paid attention and made sure that they're interpreted by the appropriate language as comments or other ignorable noise) is that the code is still compilable. (Of course, in the sample you've given, assuming C, they didn't do that) Commented Aug 1, 2018 at 10:14
  • 1
    If this ends up happening please provide the link here
    – Hack-R
    Commented Aug 1, 2018 at 15:55
  • 3
    "But seriously, why don't we have our own prettifier?" This sounds a bit like the common pitfall that leads to just another mediocre library doing the same stuff everyone else is doing. I would say that the topic should be discussed more thoroughly before. Questions like: why do all the currently available prettifier not fullfill our needs, what needs to be done, how long will it take, come to my mind. Commented Aug 2, 2018 at 6:18
  • 1
    @Trilarion This post rejecting a feature request for Highlight.js summarizes some of those issues. At the moment it seems like forking Prettify may be one of the more realistic options.
    – Radiodef
    Commented Aug 2, 2018 at 20:45

2 Answers 2

1

Instead of forking it, is Stack Overflow in position to communication with Mike Samuel, the (current only ?) maintainer? Maybe Stack Overflow could try and share the development of the project with Google. Did Stack Overflow employees ever contribute to this project, considering that it's open source (just asking)?

I think we should either find another library, make a new one, or continue with prettify by contributing to the project. Because a fork wouldn't give much except divide the few resources this project already has.

-29

Let's make sure the language support stays up to date. I've seen several C# questions missing the correct formatting.

Is the automatic language detection part of the library? If so, perhaps we can improve its detection.

Or even better - bring in Monaco. https://microsoft.github.io/monaco-editor/

4
  • 7
    I'm definitely in favor of keeping the language support up-to-date. But how would a WYSIWYG editor fit into the SO markdown editor? Or do you suggest a rewrite of the complete editor?
    – BDL
    Commented Jul 31, 2018 at 6:48
  • 4
    The language detection on SO is based on the language tags in the question, hence why there are conflicts when more than 1 language tag is used.
    – Wolfie
    Commented Jul 31, 2018 at 8:00
  • 34
    Already mentioned in the other question comments - "Also consider this line for mobile SO view: "The Monaco editor is not supported in mobile browsers or mobile web frameworks."".
    – user692942
    Commented Jul 31, 2018 at 8:17
  • 3
    It helps to read the responses to your suggestion in the other post...
    – jhpratt
    Commented Aug 2, 2018 at 0:17

Not the answer you're looking for? Browse other questions tagged .