Skip to content

Instantly share code, notes, and snippets.

@JourneymanGeek
Last active July 3, 2019 01:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JourneymanGeek/136caf29a26a56c82b113bd4dd1387a6 to your computer and use it in GitHub Desktop.
Save JourneymanGeek/136caf29a26a56c82b113bd4dd1387a6 to your computer and use it in GitHub Desktop.
Broken links 1 http://code.google.com/p/google-code-prettify/
2 http://google-code-prettify.googlecode.com/svn/trunk/README.html
3 https://code.google.com/archive/p/google-code-prettify/source#svn%2Ftrunk%2Fsrc
We're changing the way syntax highlighting is done on the Stack Exchange engine.
As you probably know, we use [Google Code Prettify][1] for automatic syntax highlighting.
Since the beginning, we've had kind of a boolean setting **per website**:
1. code blocks are *always* automatically highlighted (Stack Overflow, programmers.se, etc)
2. code blocks are *never* highlighted (Super User, photo.se, bicycles.se, etc)
We are now moving to a **more tag-based syntax highlighting** method. There are one of three possible syntax highlighting hints associated with each tag:
1. *specific* language hint -- tell prettify to use that language
2. *default* language hint -- let prettify infer a language
3. *null* -- no hint, no syntax highlighting
(all specific languages must be in the [set that prettify supports][2], obviously)
> bsh, c, cc, cpp, cs, csh, cyc, cv, htm, html,
java, js, m, mxml, perl, pl, pm, py, rb, sh,
xhtml, xml, xsl.
[extensions available][3] are
> apollo, css, go, hs, lisp, lua, ml, proto, scala, sql, vb, vhdl, wiki, yaml
Thus:
- If a question has no tags with a default or specific language hint, *no* syntax highlighting will be performed.
- If a question has at most one tag with a specific language hint, plus any number of default or null hints, then syntax highlighting will be performed only for that *specific* language.
- If a question has two tags that both define specific languages, it uses *default* and lets prettify infer as it always has.
- As long as a question has one or more tags with default language hints, but none with a specific language hint, it uses *default* and let prettify infer as it always has.
The default tag syntax highlighting hint is *null*. So the question is, **which tags should have the *default* and *specific language* hints?** I put my initial pass through the first 6 pages of tags here:
http://pastebin.com/AWMtu5rK
If you feel there should be changes, post your diffs as answers.
(and yes, there are plans to allow [an explicit override syntax][4] but for now we want to try to get the defaults mostly correct before worrying about the edge conditions)
[1]: https://github.com/google/code-prettify
[2]: https://github.com/google/code-prettify/blob/master/README.md
[3]: https://github.com/google/code-prettify/tree/master/src
[4]: https://meta.stackexchange.com/questions/63800/interface-options-for-specifying-language-prettify
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment