Code (be it snippets, complete code blocks, or identifiers as defined by each language but that are interspersed with regular text) should be formatted as code. So should file paths and file names.
For error/standard output and logs, it is a bit less defined. While some users strongly prefer quotes or code-blocks; I personally think it depends on the type of output/error log; which is very technology/tag dependent.
I've seen a lot of error logs in the web side of technology were formatting them as code is simply very bad by hindering readability without adding any additional detail (even when the user remembers to use lang=none
).
But for certain technologies or even for specific questions, simply formatting the error or output as a quote instead of monospaced code can hide the necessary details to diagnose the issue.
In my experience, these preferences are more or less consistent within each tag, so trying to set any hard site-wide rule would not be very useful.
If possible, I always try to avoid anything that would force the reader to use horizontal scrolling, which has a really nasty impact on readability. Which means that that for long error messages where I know preserving spacing is not essential, I would use block-quotes.
For example:
Deprecation Notice: Class Foo\Bar\Baz located in ./foo/bar/Baz.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v2.0. in phar:///usr/local/bin/composer/src/Composer/Autoload/ClassMapGenerator.php:201
On the other hand, if the output is multiline, and I believe including all the original spacing would make the result more readable (or even that not including the original output would make debugging the problem harder), I will just use an unformatted code-block:
Your branch is up to date with 'origin/main'.
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
new file: src/Domain/Entity/Lead
new file: src/Domain/Entity/PartnerUser
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: src/Domain/Entity/PartnerProfile
So in essence, it depends. Users should use their own judgement to style the output as faithfully as possible; while trying to preserve readability as much as they can. If they get it wrong, hopefully other users can help with edits to get the best possible result.
jQuery
".lang-none
for logs.like this
or like this once or twice (too much - and it will become less readable). There are hidden features, but not many knows about them. So why bother? Why create rules and think where to put them if there is no problem? Or do you have some concrete "wacky" post for us to have a look?