Google Code Prettify for ES2
npm install es2-code-prettify| Google Code Prettify | ES2 Code Prettify
| |
|---|---|---|
| Lower limit of supported browsers | IE6, Gecko 1.8, Opera 8 | 🌸IE5, 🌸Gecko 0.6, 🌸Opera 7.0
|
| Languages | Add dynamically except built-in | Select the language to be used on the site or page at build time
|
| Dynamic addition of theme | ✔ | ✖
|
| File size | 🌸14.551 bytes | 50,042 bytes(+24KB: RegExp ponyfill), Build with "web,c,cs,java,bash,python,perl,ruby,coffee".
|
| Dependency | 🌸none | web-doc-base, what-browser-am-i, ES2 RegExpCompat
|
| Line Numbering | ✔ | ✔ (You can disable the function at build time.)
|
| Set by comment node | ✔ | ✔ (You can disable the feature at build time. Some browsers do not support comment nodes.)
|
| Execution by time division | Manual. Measure and schedule the elapsed time at the time to finish highlighting the code block. | Always. Elapsed time is measured and scheduled at each timing of regular expression instance creation, token creation, and decoration.
|
...
or
... and it will automatically be
HTML
class Voila {
public:
// Voila
static const string VOILA = "Voila";
// will not interfere with embedded tags.
}
`
How to build
Please see gulpfile.js or web-doc-base / gulpfile.js.
~~~
gulp all
gulp web
~~~
FAQ
$3
C and friends, Java, Python, Bash, SQL, HTML,
XML, CSS, JavaScript, Makefile, and Rust.
It works passably on Ruby, PHP, VB, and Awk and a decent subset of Perl and
Ruby.
Apollo;
Basic;
Clojure;
CSS;
Dart;
Erlang;
Go;
Haskell;
Lasso;
Lisp, Scheme;
LLVM;
Logtalk;
Lua;
MATLAB;
MLs: F#, Ocaml,SML;
Mumps;
Nemerle;
Pascal;
Protocol buffers;
R, S;
RD;
Rust;
Scala;
SQL;
Swift;
TCL;
LaTeX;
Visual Basic;
VHDL;
Wiki;
XQ;
YAML
$3
You can specify a language by specifying the language extension along with the
prettyprint class:
`HTML
The lang-* class specifies the language file extensions.
`
You may also use the [HTML 5][3] convention of embedding a element
inside the and using language-java style classes:
`HTML
...
`
$3
Yes. Prettifying obfuscated code is like putting lipstick on a pig —
i.e. outside the scope of this tool.
$3
It's been tested with IE 5, Gecko 0.6, Opera 7.0. Look at
[the tests][4] to see if it works in your browser.
$3
You can use the linenums class to turn on line numbering. If your code
doesn't start at line number 1, you can add a colon and a line number to the
end of that class as in linenums:52. For example:
`HTML
>// This is line 4.
foo();
bar();
baz();
boo();
far();
faz();
`
$3
You can use the nocode class to identify a span of markup that is not code:
`HTML
int x = foo(); /* This is a comment This is not code
Continuation of comment */
int y = bar();
`
For a more complete example see the [issue #22 testcase][6].
$3
Prettify adds with classes describing the kind of code. You can
create CSS styles to matches these classes.
See the [theme gallery][1] for examples.
$3
Prettify puts lines into an HTML list element so that line numbers aren't
caught by copy/paste, and the line numbering is controlled by CSS in the
default stylesheet, prettify.css.
The following should turn line numbering back on for the other lines:
`HTML
``