21

Currently, if a poster wants to format an error (e.g. from a console), she has to format it either as a blockquote, or a code block.

Both options are inadequate for formatting console output, as such output is neither a quote, nor a code block.

One issue with using code block formatting, is the poster will have to de-highlight that block (language: lang-none) as to not unintentionally color any phrases.
Further more, code blocks don't wrap their text (due the underlying <pre> tags), so in order for the output to be readable the poster would have to break the output lines, in most cases.

Let's have a predefined formatting option for console output, with the said features, i.e. pre-formatted with word-wrapping, no highlight (or perhaps proper highlight for different outputs like Apache logs etc.), and with its own style to differ it from other formatted blocks.

8
  • 4
    "word-wrapping"?.. No thanks SO's used screen real estate is narrow enough as it is.
    – Cerbrus
    Commented Jul 9, 2015 at 11:16
  • @Cerbrus - good point. we can address this issue by making wrapping optional (with a comment on top, like the code highlight?), or by using a smaller font-size on output blocks. Commented Jul 9, 2015 at 11:22
  • 2
    My feature-request on MSE: meta.stackexchange.com/questions/235084/… Commented Jul 9, 2015 at 11:23
  • 2
    "with a comment on top, like the code highlight?" Then you might as well just use a code block with <!-- language: lang-none -->.
    – Cerbrus
    Commented Jul 9, 2015 at 11:24
  • @Cerbrus - you could also focus on the other suggestion - make the font smaller. what do you think? Commented Jul 9, 2015 at 11:37
  • 2
    @EliranMalka: I'm not "Attacking". I'm stating my opinion, which happens to be in disagreement with yours. That wasn't a suggestion in the OP. If a user wants a smaller font, he could just as well zoom out a bit. I doubt you'll want to go smaller than the current font size (13px). In regards of the comment: If you do want to make wrapping optional with a comment, what difference does it make if you have to set the language in a comment too?
    – Cerbrus
    Commented Jul 9, 2015 at 11:42
  • You can also wrap code in ` tags as well as <code> tags.
    – TylerH
    Commented Jul 9, 2015 at 13:54
  • 1
    well, perhaps wrapping shouldn't be optional after all. as stated, my aim is to have a convenient and predefined way of formatting console output. Commented Jul 9, 2015 at 14:30

2 Answers 2

8

"Let's have a predefined formatting option for console output, with the said features, i.e. pre-formatted with word-wrapping, no highlight (or perhaps proper highlight for different outputs like apache logs etc.), and with its own style to differ it from other formatted block."

There are a couple of thing about those features that I disagree with, or object to:

  • Pre-formatted.
    We already have normal code blocks for that.
  • Word-wrapping.
    SO already uses too little of the available screen width. I disagree with your readability argument. Wrapped text isn't easier to read. Don't force 200-character strings to wrap. Use a scroll bar instead:

    abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz
    
  • No highlight
    Fair enough, but you could easily add <!-- language: lang-none --> to code blocks.
  • It's own style to differ it from other formatted block.
    I don't think we need more differently styled elements in answers. This will only lead to confusion and misuse.

Besides, this feature would mean adding another sort of syntax to answers, specifically for console output, while all requested features can already be accomplished using SO's existing capabilities.

Altogether, I don't see the point of, or benefit to gain from this feature request.

13
  • 3
    to me, horizontal scrollbars are much more tedious than shorter lines. about the gain - to me it's obvious; ease-of-use. true - we have other tools to do that (i find myself repeatedly using code-blocks with no highlight), but i would love just to click a button, or use a hot-key on a block of code to accomplish the same thing. so, the main incentive, in my eyes, is better usability. Commented Jul 9, 2015 at 11:26
  • 1
    Even if the console output is a 1000 character JSON string? Breaking that up won't make it more readable, it'll only take more and more space in an answer.
    – Cerbrus
    Commented Jul 9, 2015 at 11:30
  • 1
    So, adding a <!-- language: lang-none --> button, or better yet, a dropdown with a couple of choices, would be enough.
    – Cerbrus
    Commented Jul 9, 2015 at 11:31
  • 2
    You know, even with word-wrapping enabled, long words won't be split. Also, all individual features can be achieved currently, but not in combination. Commented Jul 9, 2015 at 11:35
  • breaking that up would make it more readable. shorter lines are easier to read (to some extent), and the narrow width of the content has already been determined with exactly that in mind. if you're concerned about the container height - we can limit the height and use a vertical scrollbar, like the case is with code blocks, currently. Commented Jul 9, 2015 at 11:36
  • 1
    also, there are many ways to wrap, we could decide to break words, so long non-wrapable words will wrap. and, i know all individual features can be achieved - exactly my point - i want them all in one feature :) Commented Jul 9, 2015 at 11:38
  • 1
    A vertically limited code block is still quite high. Especially if it just contains a dump of sample data with no indentation. "i want them all in one feature" --> Let's start making buttons for every combination you can think of.
    – Cerbrus
    Commented Jul 9, 2015 at 11:40
  • "Let's start making buttons for every combination you can think of" - that's not very constructive; my intention was not to make a button out of everything, just a very common case (i find myself in need of such feature very often). Commented Jul 9, 2015 at 14:29
  • 3
    Whenever I see console output in the JavaScript tag, a simple code block is plenty. Add in the lang-none comment if you must, but I really don't see how adding this feature could benefit the site, considering how much trouble (new) users already have properly formatting their code.
    – Cerbrus
    Commented Jul 9, 2015 at 14:39
  • 4
    I find a horizontally scrolling console output easier to read than a wrapping one, particularly in stack traces.
    – Kevin B
    Commented Jul 9, 2015 at 15:04
  • 1
    @Kevin: Depends on how much the output is adjusted for screen width by the program. If it just word-wraps/ignores line-length, and the poster removes those inserted word-wraps, it's better to have such a word-wrapped pre-block. Commented Jul 9, 2015 at 19:49
  • Your answer was almost "so good" except for the argument that it's easier to grab a scroll bar to navigate a long string. If I have to scroll right and left to read the whole thing, that's a lot of effort that must be done just to maintain usability. Additional effort should be reserved for increasing usability, not maintaining it.
    – Edwin Buck
    Commented Jan 26, 2022 at 21:42
  • 1
    The content of the code block shouldn't be made unclear in the name of "usability." The lack of line numbers means if they wrapped it, we'd have no way of knowing (other than by clicking edit) whether or not there was a line break involved. if the user wants a line break, they can insert one.
    – Kevin B
    Commented Jan 26, 2022 at 21:48
-3

Currently, if a poster wants to format an error (e.g. from a console), she has to format it either as a blockquote, or a code block.

Both options are inadequate for formatting console output, as such output is neither a quote, nor a code block.

Why not both?

I usually combine blockquote and code block to edit snippets like this one

print(my_variable)
"hello, world!"

into this:

print(my_variable)
"hello, world!"

To format the console output like this, by starting typing from the beginning of the line, it's one space, greater than, 5 spaces, and then the console output.

Of course this applies only to short code snippets and I would actually be glad to have a dedicated button to format the console output with a new unique style.

1
  • this is interesting, if you think about console output like "quoting the code" i guess :) Commented Jan 26, 2022 at 16:46

You must log in to answer this question.

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