|
16 | 16 | /** |
17 | 17 | * @fileoverview |
18 | 18 | * some functions for browser-side pretty printing of code contained in html. |
| 19 | + * <p> |
19 | 20 | * |
20 | | - * The lexer should work on a number of languages including C and friends, |
21 | | - * Java, Python, Bash, SQL, HTML, XML, CSS, Javascript, and Makefiles. |
22 | | - * It works passably on Ruby, PHP and Awk and a decent subset of Perl, but, |
23 | | - * because of commenting conventions, doesn't work on Smalltalk, Lisp-like, or |
24 | | - * CAML-like languages. |
25 | | - * |
26 | | - * If there's a language not mentioned here, then I don't know it, and don't |
27 | | - * know whether it works. If it has a C-like, Bash-like, or XML-like syntax |
28 | | - * then it should work passably. |
29 | | - * |
30 | | - * Usage: |
31 | | - * 1) include this source file in an html page via |
32 | | - * <script type="text/javascript" src="/path/to/prettify.js"></script> |
33 | | - * 2) define style rules. See the example page for examples. |
34 | | - * 3) mark the <pre> and <code> tags in your source with class=prettyprint. |
35 | | - * You can also use the (html deprecated) <xmp> tag, but the pretty printer |
36 | | - * needs to do more substantial DOM manipulations to support that, so some |
37 | | - * css styles may not be preserved. |
| 21 | + * For a fairly comprehensive set of languages see the |
| 22 | + * <a href="http://google-code-prettify.googlecode.com/svn/trunk/README.html#langs">README</a> |
| 23 | + * file that came with this source. At a minimum, the lexer should work on a |
| 24 | + * number of languages including C and friends, Java, Python, Bash, SQL, HTML, |
| 25 | + * XML, CSS, Javascript, and Makefiles. It works passably on Ruby, PHP and Awk |
| 26 | + * and a subset of Perl, but, because of commenting conventions, doesn't work on |
| 27 | + * Smalltalk, Lisp-like, or CAML-like languages without an explicit lang class. |
| 28 | + * <p> |
| 29 | + * Usage: <ol> |
| 30 | + * <li> include this source file in an html page via |
| 31 | + * {@code <script type="text/javascript" src="/path/to/prettify.js"></script>} |
| 32 | + * <li> define style rules. See the example page for examples. |
| 33 | + * <li> mark the {@code <pre>} and {@code <code>} tags in your source with |
| 34 | + * {@code class=prettyprint.} |
| 35 | + * You can also use the (html deprecated) {@code <xmp>} tag, but the pretty |
| 36 | + * printer needs to do more substantial DOM manipulations to support that, so |
| 37 | + * some css styles may not be preserved. |
| 38 | + * </ol> |
38 | 39 | * That's it. I wanted to keep the API as simple as possible, so there's no |
39 | | - * need to specify which language the code is in. |
40 | | - * |
41 | | - * Change log: |
| 40 | + * need to specify which language the code is in, but if you wish, you can add |
| 41 | + * another class to the {@code <pre>} or {@code <code>} element to specify the |
| 42 | + * language, as in {@code <pre class="prettyprint lang-java">}. Any class that |
| 43 | + * starts with "lang-" followed by a file extension, specifies the file type. |
| 44 | + * See the "lang-*.js" files in this directory for code that implements |
| 45 | + * per-language file handlers. |
| 46 | + * <p> |
| 47 | + * Change log:<br> |
42 | 48 | * cbeust, 2006/08/22 |
| 49 | + * <blockquote> |
43 | 50 | * Java annotations (start with "@") are now captured as literals ("lit") |
| 51 | + * </blockquote> |
| 52 | + * @requires console |
| 53 | + * @overrides window |
44 | 54 | */ |
45 | 55 |
|
46 | 56 | // JSLint declarations |
@@ -97,12 +107,12 @@ window['_pr_isIE6'] = function () { |
97 | 107 | "double enum extern float goto int long register short signed sizeof " + |
98 | 108 | "static struct switch typedef union unsigned void volatile "; |
99 | 109 | var COMMON_KEYWORDS = C_KEYWORDS + "catch class delete false import " + |
100 | | - "new operator private protected public this throw true try "; |
| 110 | + "new operator private protected public this throw true try typeof "; |
101 | 111 | var CPP_KEYWORDS = COMMON_KEYWORDS + "alignof align_union asm axiom bool " + |
102 | 112 | "concept concept_map const_cast constexpr decltype " + |
103 | 113 | "dynamic_cast explicit export friend inline late_check " + |
104 | 114 | "mutable namespace nullptr reinterpret_cast static_assert static_cast " + |
105 | | - "template typeid typename typeof using virtual wchar_t where "; |
| 115 | + "template typeid typename using virtual wchar_t where "; |
106 | 116 | var JAVA_KEYWORDS = COMMON_KEYWORDS + |
107 | 117 | "abstract boolean byte extends final finally implements import " + |
108 | 118 | "instanceof null native package strictfp super synchronized throws " + |
@@ -283,7 +293,7 @@ window['_pr_isIE6'] = function () { |
283 | 293 | // unnecessary computed style objects. |
284 | 294 | if ('PRE' === node.tagName) { return true; } |
285 | 295 | if (!newlineRe.test(content)) { return true; } // Don't care |
286 | | - var whitespace; |
| 296 | + var whitespace = ''; |
287 | 297 | // For disconnected nodes, IE has no currentStyle. |
288 | 298 | if (node.currentStyle) { |
289 | 299 | whitespace = node.currentStyle.whiteSpace; |
@@ -477,7 +487,6 @@ window['_pr_isIE6'] = function () { |
477 | 487 |
|
478 | 488 | // Walk over and identify back references to build the capturedGroups |
479 | 489 | // mapping. |
480 | | - var groupIndex; |
481 | 490 | for (var i = 0, groupIndex = 0; i < n; ++i) { |
482 | 491 | var p = parts[i]; |
483 | 492 | if (p === '(') { |
@@ -842,7 +851,7 @@ window['_pr_isIE6'] = function () { |
842 | 851 | for (var ti = 0, nTokens = tokens.length; ti < nTokens; ++ti) { |
843 | 852 | var token = tokens[ti]; |
844 | 853 | var style = styleCache[token]; |
845 | | - var match; |
| 854 | + var match = void 0; |
846 | 855 |
|
847 | 856 | var isEmbedded; |
848 | 857 | if (typeof style === 'string') { |
|
0 commit comments