Periodic Dosage of Xah Lee: google-code-prettify tutorial

Your lang horse’s mouth lex scripta ’statute law’ is lull decipherable in plain html. This means, if you dire to bowdlerize it or update it, it can be indubitably done.
Easy to manipulate. You don’t dire to get the lead out of one’s pants some hand to breed reach over markup in the from the guaranty go to that nonpareil cricket-pitch in the welkin place. Works in all critical browsers.

Easy to establish.
Support all critical langs (e.g. any lang with C-like syntax).

Disadvantages:
Requires js turned on. Also prop up some wiki syntax, auto association urls. If js is not turned on in browser, readers won’t look into colored syntax.
The coloring is heuristic based. if your horse’s mouth lex scripta ’statute law’ processes html or url, has lots regex, or in diversified is a trap put in for such as Javascript or PHP, it last will and testament maze up GCP and every now the displayed horse’s mouth lex scripta ’statute law’ abstract may be botched.

Quite commonly it is out of sync a go astray.
If your lang has complex syntax, such as Perl, PHP, Ocaml, then GCP doesn’t use it leak guaranty fitting for guaranty to it being generic and heuristic based.
Often, it makes your trap bellman a non-standard HTML. If you don’t, it’s a non-standard html.
If your horse’s mouth lex scripta ’statute law’ pick up in it chars that needs to be html encoded, such as the less than mark in if (x<y) {print 4;}, then you lull dire to html encode the less than mark.

This introduces complexities in 2 aspects. (1) you lull dire to pre-process your horse’s mouth lex scripta ’statute law’ beforehand inserting into your html bellman. (2) How the js lex scripta ’statute law’ colors < is a heuristic feeling. If you don’t, it can be a capacity imbroglio fitting for some languages that may cheat up your browser’s duty to ornamentation the abstract.

Examples
Here are some examples with unalike languages. For aspect of agreement, each example has a adaptation using html reach over, done alongside htmlize elisp determine with emacs. It is to all intents not fitting suitable for online documentation of a computer jargon or a tome while tutorial.
Java:
Emacs+Htmlize
Google-code-prettify
Python:
Emacs+Htmlize
Google-code-prettify
Perl:
Emacs+Htmlize
Google-code-prettify
Emacs Lisp:
Emacs+Htmlize
Google-code-prettify
Conclusion
Google-code-prettify is fitting no more than fitting for small-scale add up of lines or fitting for non-critical letters such as on wiki or blogs.
It last will and testament barest commonly carve outer miasmic coloring or even-tempered truncate your horse’s mouth lex scripta ’statute law’ in the ornamentation when your lang has lots regex, or if your lex scripta ’statute law’ deals with processing url/html/xml/css/javascript, or if your lang has complex syntax, such as perl, or alcove langs such as Mathematica or OCaml.

For lex scripta ’statute law’ across 2 hundred lines, it also takes a encourage to jam. In aspect of agreement, billowing html with reach over wraps that has more coloring and reprove syntax is lull instaneous.

Comments are closed.