Just noted that there is a little bug regarding diacritics in code blocks. See the screenshot:

Why are Ionic and Biz blue and the other part of code is black?


Because the Google Code Prettifier doesn't count non-ASCII characters in identifiers and type names.

In 'unknown' code, anything starting with an uppercase ASCII character, followed by a mix of upper and lowercase ASCII letters is considered a type name and marked up as such. The ă in your name is not an ASCII character, so the type name stops before that point as far as the prettifier is concerned. See the regular expression in the prettifier source code.

In this case, it is just highlighting non-code with a best-guess effort. It might be a bug if you encountered this in a programming language that allows for a broad range of Unicode characters in identifiers and type names (such as Python 3), but that'd be something to report to the Google Code Prettify project, not to Stack Exchange. See the SE syntax highlighting FAQ.

Note that they already have this on their TODO list, however. Two lines before the regular expression that picks up only part of your name is the comment:

// TODO(mikesamuel): recognize non-latin letters and numerals in idents

There is an existing bug report, apparently the problem lies with JavaScript's lack of decent Unicode support in regular expressions.

  • As far as I am aware, the current state-of-the-art way to address Javascript’s pessimal Unicode non-handling is via the XRegExp addon. It’s now broken out into smaller pieces so you can get only as much as you need, of which the \p{Letter} General Category is the most common one, included in the base addon; that would probably suffice here. You can also pull in the rest of the General Categories, the Script properties, &c at your leisure and pleasure. See also these SO Q&As about XRegExp. – tchrist Aug 28 '14 at 11:46
  • @tchrist: the bug report I linked to also recommends using XRegExp to solve the issue. Further discussion about this is probably best directed to the project, not here. – Martijn Pieters Aug 28 '14 at 11:47

Martijn Pieters's answer explains what's going on in this specific case. But you might have weird colors for other reasons than non-ASCII characters. If the content of your code block isn't code in a programming language, tell the syntax highlighting engine not to use any colors by putting a magic comment immediately before the code block.

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

    $ npm init
    author: (Ionică Bizău)
  • Indeed, but this code is expected to have lang-shell highlight. – Ionică Bizău Aug 28 '14 at 12:22
  • @IonicăBizău; but if it is just one line of shell command and the rest is arbitrary output, then perhaps switching of highlighting is appropriate. – Martijn Pieters Aug 28 '14 at 14:16

You must log in to answer this question.

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