googlearchive / code-prettify

An embeddable script that makes source-code snippets in HTML prettier.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Wrong highlighting on stackoverflow.com vba if default is used

Imh0t3b opened this issue · comments

If there are multiple languages specified, the default highlighting is used, what looks awful with vba, especially if single-quotes are contained.
See https://stackoverflow.com/q/59558043/9439330

I would suggest using first tag with code hint as default language for site or create a default language specifier, e.g <!-- language-site: lang-vb -->

First off, this is not a Prettify bug; it's a Stack Exchange-specific issue. These should be posted on https://meta.stackoverflow.com.

Second, there's not a whole lot we can really do when there are multiple tags, each implying their own syntax-highlighting scheme. The [vba] tag is already set to assume "lang-vb" for syntax highlighting, but the [sql] tag also appears on that question, and it is set to assume "lang-sql". When a conflict occurs, as you said, Stack Overflow reverts to the "default" syntax highlighting, which is...not great. But how could it be?

Stack Overflow does allow you to work around this problem using an explicit syntax-highlighting hint. The format is:

<!-- language: lang-vb -->

right above the code block, or:

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

to affect the entire post.

See also Syntax highlighting for code in the Help Center.