3

My recent answer starts with an overriding syntax selection:

<!-- language: lang-none -->

however the syntax colouring within the first block quote, which is done by using > followed by five spaces, reverts to Stack Overflow's best guess -- Perl in this case.

This shouldn't happen.

3
  • The overriding syntax is supposed to be done right before the code block.
    – Naftali
    Aug 1, 2016 at 14:36
  • 2
    You need <!-- language-all: lang-none --> if you want to do it globally on the answer.
    – Tunaki
    Aug 1, 2016 at 14:37
  • @Tunaki: That is my mistake. Thank you. Please post this as an answer.
    – Borodin
    Aug 1, 2016 at 14:38

2 Answers 2

4

There are two different ways to override the syntax coloring:

  • Globably on the answer with <!-- language-all: lang-java -->.
  • Per code block with <!-- language: lang-java -->. This has precedence over the global override syntax.

This answer is written with <!-- language-all: lang-none -->. The following is unformatted:

Blob blob
Caused by: NullPointerException

just like

Blob blob
Caused by: NullPointerException

But I can write Java if I want:

public static final String LIFE = "Java";

Or (although the syntax highlight for quotes on Meta doesn't render as well as on Main):

quote XML:

<foo> <bar /> </foo>
1
  • The reason for my confusion is that I have a short Perl utility that builds the awkward <!-- language-all: lang-none --> line and puts it on the clipboard for pasting into a SO post. I had misused it so that it generated <!-- language: lang-none --> but I overlooked the mistake. All is now as it should be. Thank you.
    – Borodin
    Aug 1, 2016 at 15:18
0

The overriding syntax is supposed to be done right before the code block.


Also you should not be putting code in a quote block -- there is no point to that, that is what the code block is for.

4
  • 2
    Disagree, code in quote block is the way to go when you're quoting code you didn't write.
    – Tunaki
    Aug 1, 2016 at 14:38
  • @Tunaki there is no code like that in the question, that code is all from the answer itself, an example, which belongs in just a code block...
    – Naftali
    Aug 1, 2016 at 14:39
  • What Tunaki said, plus warning and error messages are often sensitive to character positions and should be put into a literal
    – Borodin
    Aug 1, 2016 at 14:40
  • Sometimes there is more than just code to be quoted. Say for example a text from a documentation. In some situations like that it can make sense to have code in a quote.
    – null
    Aug 1, 2016 at 14:42

You must log in to answer this question.

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