On the main site, this

<!-- language: lang-shell -->

    # do these steps on each distro
    mv Documents Documents.old
    ln -s /shared/your-user/Documents Documents
    mv -i Documents.old/* Documents/
    rmdir Documents.old

produced rather silly syntax highlighting (screenshot, since I can't get any syntax highlighting to happen on meta):

Above example, screenshot from the preview

It seems to think Documents means something to shell. And possibly that rmdir introduces a comment (or at least it uses the same color as the comment up top). I tried lang-sh and lang-bash as well, both do the same.

The documentation says shell should be supported: What is syntax highlighting and how does it work?

2 Answers 2


You either need to specify a tag name, or a language prefixed with lang-. There is no registered language named shell, so lang-shell kicks it into a default mode the same as if you'd done lang-foobarbaz, and apparently in that mode it looks for C-style comments.

If you do <!-- language: lang-sh -->, or <!-- language: shell --> (which tells it to use the language associated with the tag, which is lang-sh), it should work, and the last section doesn't get highlighted as a comment. Documents is still wrong though, it gets colored as a typename, which seems to be happening because it's capitalized. I tried to look into code-prettify to see why they do that, but I don't even see support for lang-sh, so it's not clear to me how this all fits together. But whatever the problem is, it's probably in code-prettify, not anything in Stack Exchange.

  • Odd, as I mentioned, I tried lang-sh, and it did the same thing for me... I'll have to try again when I'm back at a computer.
    – derobert
    May 15, 2017 at 19:32
  • @derobert I figured you got distracted by "Documents" still being wrong and didn't check the comment at the end. This is what I get with lang-sh: i.stack.imgur.com/ivo7j.png May 15, 2017 at 19:33
  • could be, will have to check once I'm not on a phone
    – derobert
    May 15, 2017 at 19:35
  • Turns out you're right—I was indeed distracted by the broken highlight of Documents.
    – derobert
    May 15, 2017 at 20:33
  • Bug reported: github.com/google/code-prettify/issues/489
    – derobert
    May 15, 2017 at 20:48

You didn't notice (or at least didn't mention) that the last word of the fourth line, and the entire fifth line, are colored gray as comments.  That is almost surely because, right in the middle of the fourth line, you have /*, so everything up through a matching */ is a comment.

I find lang-sh formatting to be annoying and distracting, so I often suppress it with lang-none.  You can also get a code block displayed in the fixed-width font that we're accustomed to, but no silly colors, by putting it in a <pre>...</pre> block.  (Of course then you must use &lt; instead of <, and maybe also &gt; in place of >.)

This is documented somewhere, but I don't know how well known it is, so I'll repeat it here.

<!-- language: lang-xxx -->
sets the pretty-printing language for the immediately following code block.

<!-- language-all: lang-xxx -->

sets it for all remaining code blocks in the post (or until it is overridden by another

<!-- language: lang-xxx -->

You must log in to answer this question.

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