diff --git a/.gitignore b/.gitignore index 82c2cb8f..433f78b2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,18 @@ -*.tstamp +# temporary files *~ -distrib/google-code-prettify -distrib/prettify-small.tar +*.swp +.DS_Store + +# package managers +/node_modules/ +/bower_components/ +npm-debug.log +.bower.json + +# generated files +#/src/prettify.js +#/src/run_prettify.js +#/loader/*.js +#/loader/*.css +#/loader/skins/*.css +#/distrib/*.zip diff --git a/CHANGES.md b/CHANGES.md index a4a5bdc5..7371e7c8 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -13,15 +13,15 @@ ## 29 March 2007 - * Added [tests](https://rawgit.com/google/code-prettify/master/tests/prettify_test.html#PHP) + * Added [tests](https://raw.githack.com/google/code-prettify/master/tests/prettify_test.html#php) for PHP support to address issue [#3](https://github.com/google/code-prettify/issues/3). * Fixed bug [#6](https://github.com/google/code-prettify/issues/6): `prettyPrintOne` was not halting. This was not reachable through the normal entry point. * Fixed bug [#4](https://github.com/google/code-prettify/issues/4): recursing into a script block or PHP tag that was not properly closed would not silently drop the content. - ([test](https://rawgit.com/google/code-prettify/master/tests/prettify_test.html#issue4)) + ([test](https://raw.githack.com/google/code-prettify/master/tests/prettify_test.html#js_script)) * Fixed bug [#8](https://github.com/google/code-prettify/issues/8): was eating tabs - ([test](https://rawgit.com/google/code-prettify/master/tests/prettify_test.html#issue8)) + ([test](https://raw.githack.com/google/code-prettify/master/tests/prettify_test.html#issue8)) * Fixed entity handling so that the caveat > Caveats: please properly escape less-thans. `x<y` instead of `x', + dest: '<%= uglify.prettify.dest %>' + }, + runprettify: { + options: { + externs: 'tools/closure-compiler/amd-externs.js', + define: 'IN_GLOBAL_SCOPE=false', + output_wrapper: '!function(){%output%}()' + }, + src: '<%= uglify.runprettify.src %>', + dest: '<%= uglify.runprettify.dest %>' + }, + langs: { + options: { + externs: 'js-modules/externs.js' + }, + files: '<%= uglify.langs.files %>' + } + }, + + // ./tasks/gcc.js + gcc: { + // same as 'closure-compiler:langs' + langs: { + options: { + externs: 'js-modules/externs.js' + }, + files: '<%= uglify.langs.files %>' + } + }, + + // grunt-contrib-cssmin + cssmin: { + // https://github.com/jakubpawlowicz/clean-css#how-to-use-clean-css-api + options: { + report: 'gzip' + }, + prettify: { + src: 'src/prettify.css', + dest: 'loader/prettify.css' + }, + skins: { + files: [{ + expand: true, + cwd: 'styles/', + src: ['*.css'], + dest: 'loader/skins/', + ext: '.css' + }] + } + }, + + // grunt-contrib-compress + compress: { + zip: { + options: { + archive: 'distrib/prettify-small.zip', + mode: 'zip', + level: 9 + }, + files: [{ + expand: true, + cwd: 'loader/', + src: ['*.js', '*.css', 'skins/*.css'], + dest: 'google-code-prettify/' + }] + } + }, + + // grunt-contrib-clean + clean: { + js: ['src/prettify.js', 'src/run_prettify.js', 'loader/*.js'], + css: ['loader/*.css', 'loader/skins/*.css'], + zip: ['distrib/*.zip'] + } + }); + + // load plugins that provide tasks + require('google-closure-compiler').grunt(grunt); + grunt.loadTasks('./tasks'); + grunt.loadNpmTasks('grunt-preprocess'); + grunt.loadNpmTasks('grunt-contrib-copy'); + grunt.loadNpmTasks('grunt-contrib-uglify'); + grunt.loadNpmTasks('grunt-contrib-cssmin'); + grunt.loadNpmTasks('grunt-contrib-compress'); + grunt.loadNpmTasks('grunt-contrib-clean'); + + // register task aliases + grunt.registerTask('default', [ + //'clean', + 'preprocess', + 'copy:prettify', + 'gcc', + 'copy:langs', + 'aliases', + 'cssmin', + 'compress' + ]); +}; diff --git a/Makefile b/Makefile deleted file mode 100644 index 70bbacfc..00000000 --- a/Makefile +++ /dev/null @@ -1,120 +0,0 @@ -SHELL := /bin/bash - -CLOSURE_COMPILER=java -jar tools/closure-compiler/compiler.jar \ - --warning_level VERBOSE \ - --language_in ECMASCRIPT5 \ - --compilation_level ADVANCED_OPTIMIZATIONS \ - --charset US-ASCII -# Don't specify --charset=UTF-8. If we do, then non-ascii codepoints -# that do not correspond to line terminators are converted -# to UTF-8 sequences instead of being emitted as ASCII. -# This makes the resulting JavaScript less portable. - -YUI_COMPRESSOR=java -jar tools/yui-compressor/yuicompressor-2.4.8.jar \ - --charset UTF-8 - -TAR_ROOT=distrib/google-code-prettify - -all: distrib loader - -clean: - rm -rf distrib.tstamp distrib loader.tstamp src/prettify.js src/run_prettify.js - -src/prettify.js: js-modules/*.js js-modules/*.pl - @if [ -e "$@" ]; then chmod +w "$@"; fi - @perl js-modules/js_include.pl "$$(basename $@)" > "$@" - @if [ -e "$@" ]; then chmod -w "$@"; fi - -src/run_prettify.js: js-modules/*.js js-modules/*.pl - @if [ -e "$@" ]; then chmod +w "$@"; fi - @perl js-modules/js_include.pl "$$(basename $@)" > "$@" - @if [ -e "$@" ]; then chmod -w "$@"; fi - -distrib: distrib.tstamp distrib/prettify-small.tgz distrib/prettify-small.zip distrib/prettify-small.tar.bz2 - @wc -c distrib/prettify-small.{tar.bz2,tgz,zip} \ - | grep -v total - -distrib.tstamp: src/prettify.js src/run_prettify.js src/*.js src/*.css - @echo Compiling - @mkdir -p $(TAR_ROOT) - @for f in src/*.css; do \ - $(YUI_COMPRESSOR) --type css $$f \ - > $(TAR_ROOT)/$$(basename $$f); \ - wc -c $$f $(TAR_ROOT)/$$(basename $$f) \ - | grep -v total; \ - done - @$(CLOSURE_COMPILER) --js src/prettify.js \ - --externs tools/closure-compiler/amd-externs.js \ - --define IN_GLOBAL_SCOPE=true \ - --output_wrapper='!function(){%output%}()' \ - > $(TAR_ROOT)/prettify.js - @wc -c src/prettify.js $(TAR_ROOT)/prettify.js \ - | grep -v total - @$(CLOSURE_COMPILER) --js src/run_prettify.js \ - --externs tools/closure-compiler/amd-externs.js \ - --define IN_GLOBAL_SCOPE=false \ - --output_wrapper='!function(){%output%}()' \ - > $(TAR_ROOT)/run_prettify.js - @wc -c src/run_prettify.js $(TAR_ROOT)/run_prettify.js \ - | grep -v total - @for f in src/lang*.js; do \ - if [ $$f -nt $(TAR_ROOT)/$$(basename $$f) ]; then \ - $(CLOSURE_COMPILER) --js $$f --externs js-modules/externs.js \ - | perl -pe 's/\bPR\.PR_ATTRIB_NAME\b/"atn"/g; \ - s/\bPR\.PR_ATTRIB_VALUE\b/"atv"/g; \ - s/\bPR\.PR_COMMENT\b/"com"/g; \ - s/\bPR\.PR_DECLARATION\b/"dec"/g; \ - s/\bPR\.PR_KEYWORD\b/"kwd"/g; \ - s/\bPR\.PR_LITERAL\b/"lit"/g; \ - s/\bPR\.PR_PLAIN\b/"pln"/g; \ - s/\bPR\.PR_PUNCTUATION\b/"pun"/g; \ - s/\bPR\.PR_STRING\b/"str"/g; \ - s/\bPR\.PR_TAG\b/"tag"/g; \ - s/\bPR\.PR_TYPE\b/"typ"/g;' \ - > $(TAR_ROOT)/$$(basename $$f); \ - wc -c $$f $(TAR_ROOT)/$$(basename $$f) \ - | grep -v total; \ - fi \ - done - @touch distrib.tstamp - -lang-aliases : lang-aliases.tstamp -lang-aliases.tstamp : distrib.tstamp - tools/lang-handler-aliases.sh \ - distrib/google-code-prettify \ - | perl -ne 'system("cp $$1 $$2") if m/^(\S+) (\S+)$$/ && ! -e $$2' \ - && touch lang-aliases.tstamp - -loader : loader.tstamp lang-aliases.tstamp styles/*.css - -loader.tstamp : distrib.tstamp - @cp distrib/google-code-prettify/*.{css,js} loader/ \ - && for f in styles/*.css; do \ - $(YUI_COMPRESSOR) --type css $$f \ - > loader/skins/$$(basename $$f); \ - wc -c $$f loader/skins/$$(basename $$f) \ - | grep -v total; \ - done \ - && touch loader.tstamp - -%.tgz: %.tar - @gzip -c -9 $^ > $@ - -%.tar.bz2: %.tar - @bzip2 -k -9f $^ - -distrib/prettify-small.tar: distrib.tstamp - tar cf $@ -C distrib google-code-prettify - -distrib/prettify-small.zip: distrib.tstamp - @pushd distrib >& /dev/null; \ - rm -f ../$@; \ - zip -q -9 -r ../$@ google-code-prettify; \ - popd >& /dev/null - -distrib/prettify.tar: distrib.tstamp - mkdir -p distrib/sources/google-code-prettify - cp -fr CHANGES.html COPYING README.html Makefile \ - examples js-modules src styles tests tools \ - distrib/sources/google-code-prettify - tar cf distrib/prettify.tar -C distrib/sources google-code-prettify diff --git a/README.md b/README.md index af3e91cd..41cd727e 100644 --- a/README.md +++ b/README.md @@ -1,25 +1,47 @@ -# Javascript code prettifier +# Status: Archived + +![status: inactive](https://img.shields.io/badge/status-inactive-red.svg) + +This repository has been archived and is no longer maintained. + +--- + +# JavaScript code prettifier + +Announcement: [**Action required** *rawgit.com* is going away](https://groups.google.com/forum/#!topic/js-code-prettifier/IFHev_kLm30). An embeddable script that makes source-code snippets in HTML prettier. -[See an example](https://rawgit.com/google/code-prettify/master/examples/quine.html) +* Works on HTML pages. +* Works even if code contains embedded links, line numbers, etc. +* Simple API: include some JS & CSS and add an onload handler. +* Lightweights: small download and does not block page from loading while + running. +* Customizable styles via CSS. See the [themes gallery][1]. +* Supports all C-like, Bash-like, and XML-like languages. No need to specify + the language. +* Extensible language handlers for other languages. You can specify the + language. +* Widely used with good cross-browser support. Powers https://code.google.com/ + and http://stackoverflow.com/ + +[See an example][2]. ## Setup - * Include the script tag below in your document + * Include the script tag below in your document: ```HTML - + ``` * See [Getting Started](docs/getting_started.md) to configure that URL with options you need. - * Look at the [skin gallery](https://rawgit.com/google/code-prettify/master/styles/index.html) - and pick styles that suit you. + * Look at the [skin gallery][1] and pick styles that suit you. ## Usage Put code snippets in `
...
` or `...` and it will automatically be -pretty printed. +pretty-printed. ```HTML
class Voila {
@@ -31,24 +53,17 @@ public:
 }
``` -## Discussion - -Please use the official support group for discussions, suggestions, and -general feedback at: - -http://groups.google.com/group/js-code-prettifier - ## FAQ ### For which languages does it work? -The comments in `prettify.js` are authoritative but the lexer should -work on a number of languages including C and friends, Java, Python, -Bash, SQL, HTML, XML, CSS, Javascript, Makefiles, and Rust. +The comments in `prettify.js` are authoritative but the lexer should work on a +number of languages including 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, but, because of commenting conventions, doesn't work on -Smalltalk, OCaml, etc. without a language extension. +It works passably on Ruby, PHP, VB, and Awk and a decent subset of Perl and +Ruby, but because of commenting conventions, doesn't work on Smalltalk, OCaml, +etc. without a language extension. Other languages are supported via extensions: @@ -62,10 +77,10 @@ Other languages are supported via extensions: [Haskell](src/lang-hs.js); [Lasso](src/lang-lasso.js); [Lisp, Scheme](src/lang-lisp.js); -[Llvm](src/lang-llvm.js); +[LLVM](src/lang-llvm.js); [Logtalk](src/lang-logtalk.js); [Lua](src/lang-lua.js); -[Matlab](src/lang-matlab.js); +[MATLAB](src/lang-matlab.js); [MLs: F#, Ocaml,SML](src/lang-ml.js); [Mumps](src/lang-mumps.js); [Nemerle](src/lang-n.js); @@ -78,40 +93,40 @@ Other languages are supported via extensions: [SQL](src/lang-sql.js); [Swift](src/lang-swift.js); [TCL](src/lang-tcl.js); -[Latek](src/lang-tex.js); +[LaTeX](src/lang-tex.js); [Visual Basic](src/lang-vb.js); [VHDL](src/lang-vhdl.js); [Wiki](src/lang-wiki.js); [XQ](src/lang-xq.js); [YAML](src/lang-yaml.js) -If you'd like to add an extension for your favorite language, please -look at `src/lang-lisp.js` and submit a pull request. +If you'd like to add an extension for your favorite language, please look at +`src/lang-lisp.js` and submit a pull request. ### How do I specify the language of my code? -You don't need to specify the language since `PR.prettyprint()` -will guess. You can specify a language by specifying the language extension -along with the `prettyprint` class: +You don't need to specify the language since `PR.prettyPrint()` will guess. +You can specify a language by specifying the language extension along with the +`prettyprint` class: ```HTML
   The lang-* class specifies the language file extensions.
-  File extensions supported by default include
-    "bsh", "c", "cc", "cpp", "cs", "csh", "cyc", "cv", "htm", "html",
-    "java", "js", "m", "mxml", "perl", "pl", "pm", "py", "rb", "sh",
-    "xhtml", "xml", "xsl".
+  File extensions supported by default include:
+    "bsh", "c", "cc", "cpp", "cs", "csh", "cyc", "cv", "htm", "html", "java",
+    "js", "m", "mxml", "perl", "pl", "pm", "py", "rb", "sh", "xhtml", "xml",
+    "xsl".
 
``` -You may also use the -[HTML 5](http://dev.w3.org/html5/spec-author-view/the-code-element.html#the-code-element) -convention of embedding a `code` element inside the `PRE` and using -`language-java` style classes. +You may also use the [HTML 5][3] convention of embedding a `` element +inside the `
` and using `language-java` style classes:
 
-E.g. `
...
` +```HTML +
...
+``` -### It doesn't work on ``? +### It doesn't work on "obfuscated code sample"? Yes. Prettifying obfuscated code is like putting lipstick on a pig — i.e. outside the scope of this tool. @@ -119,30 +134,26 @@ i.e. outside the scope of this tool. ### Which browsers does it work with? It's been tested with IE 6, Firefox 1.5 & 2, and Safari 2.0.4. Look at -[the tests](https://rawgit.com/google/code-prettify/master/tests/prettify_test.html) -to see if it works in your browser. +[the tests][4] to see if it works in your browser. ### What's changed? -See the [change log](CHANGES.md) +See the [changelog](CHANGES.md). ### Why doesn't Prettyprinting of strings work on WordPress? -Apparently wordpress does "smart quoting" which changes close quotes. -This causes end quotes to not match up with open quotes. +Apparently wordpress does "smart quoting" which changes close quotes. This +causes end quotes to not match up with open quotes. -This breaks prettifying as well as copying and pasting of code samples. -See [WordPress's help center](http://wordpress.org/support/topic/125038) -for info on how to stop smart quoting of code snippets. +This breaks prettifying as well as copying and pasting of code samples. See +[WordPress's help center][5] for info on how to stop smart quoting of code +snippets. ### How do I put line numbers in my code? -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 +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
+
 int x = foo();  /* This is a comment  This is not code
   Continuation of comment */
 int y = bar();
 
``` -For a more complete example see the issue22 -[testcase](https://rawgit.com/google/code-prettify/master/tests/prettify_test.html#issue22). +For a more complete example see the [issue #22 testcase][6]. ### I get an error message "a is not a function" or "opt_whenDone is not a function" If you are calling `prettyPrint` via an event handler, wrap it in a function. -Instead of doing +Instead of doing: ```JavaScript addEventListener('load', PR.prettyPrint, false); ``` -wrap it in a closure like +wrap it in a closure like: ```JavaScript -addEventListener('load', function (event) { PR.prettyPrint() }, false); +addEventListener('load', function(event) { PR.prettyPrint(); }, false); ``` so that the browser does not pass an event object to `PR.prettyPrint` @@ -192,35 +201,48 @@ which will confuse it. ### How can I customize the colors and styles of my code? -Prettify adds `` with `class`es describing the kind of code. -You can create CSS styles to matches these classes. +Prettify adds `` with `class`es describing the kind of code. You can +create CSS styles to matches these classes. -See the [theme gallery](https://rawgit.com/google/code-prettify/master/styles/index.html) -for examples. +See the [theme gallery][1] for examples. ### I can't add classes to my code (because it comes from Markdown, etc.) -Instead of `
` you can use a comment
-or processing instructions that survives processing instructions :
-`` works as explained in
-[Getting Started](docs/getting_started.md).
+Instead of `
` you can use a comment or processing
+instructions that survives processing instructions: `` works
+as explained in [Getting Started](docs/getting_started.md).
 
 ### How can I put line numbers on every line instead of just every fifth line?
 
-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`.
+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
 
 ```
 
-should turn line numbering back on for the other lines.
+## Discussion
+
+Please use the official [support group][7] for discussions, suggestions, and
+general feedback.
 
 ## License
 
-[Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0)
+[Apache License 2.0](COPYING)
+
+
+[1]: https://raw.githack.com/google/code-prettify/master/styles/index.html
+[2]: https://raw.githack.com/google/code-prettify/master/examples/quine.html
+[3]: http://dev.w3.org/html5/spec-author-view/the-code-element.html#the-code-element
+[4]: https://raw.githack.com/google/code-prettify/master/tests/prettify_test.html
+[5]: http://wordpress.org/support/topic/125038
+[6]: https://raw.githack.com/google/code-prettify/master/tests/prettify_test.html#issue22
+[7]: http://groups.google.com/group/js-code-prettifier
diff --git a/bower.json b/bower.json
new file mode 100644
index 00000000..27b13817
--- /dev/null
+++ b/bower.json
@@ -0,0 +1,40 @@
+{
+  "name": "code-prettify",
+  "description": "Google Code Prettify",
+  "authors": [
+    "Google"
+  ],
+  "license": "Apache-2.0",
+  "homepage": "https://github.com/google/code-prettify",
+  "repository": {
+    "type": "git",
+    "url": "git+https://github.com/google/code-prettify.git"
+  },
+  "keywords": [
+    "syntax",
+    "highlight",
+    "highlighting",
+    "source",
+    "code",
+    "prettify",
+    "google"
+  ],
+  "main": [
+    "src/prettify.js",
+    "src/prettify.css"
+  ],
+  "moduleType": [
+    "globals",
+    "amd"
+  ],
+  "ignore": [
+    "**/.*",
+    "node_modules",
+    "bower_components",
+    "distrib",
+    "js-modules",
+    "tasks",
+    "tests",
+    "tools"
+  ]
+}
diff --git a/distrib/prettify-small.tar.bz2 b/distrib/prettify-small.tar.bz2
deleted file mode 100644
index 8900c194..00000000
Binary files a/distrib/prettify-small.tar.bz2 and /dev/null differ
diff --git a/distrib/prettify-small.tgz b/distrib/prettify-small.tgz
deleted file mode 100644
index 9b320c42..00000000
Binary files a/distrib/prettify-small.tgz and /dev/null differ
diff --git a/distrib/prettify-small.zip b/distrib/prettify-small.zip
index 0f1e2473..c63da471 100644
Binary files a/distrib/prettify-small.zip and b/distrib/prettify-small.zip differ
diff --git a/docs/getting_started.md b/docs/getting_started.md
index 194f644e..81221bfe 100644
--- a/docs/getting_started.md
+++ b/docs/getting_started.md
@@ -1,19 +1,16 @@
 # Getting Started
 
-## How to style code in your web-pages
-
-## Getting Started
-
 You can load the Prettify script to highlight code in your web pages.
 
-It adds styles to code snippets so that token boundaries stand out and
-your readers can get the gist of your code without having to mentally
-perform a left-to-right parse.
+It adds styles to code snippets so that token boundaries stand out and your
+readers can get the gist of your code without having to mentally perform a
+left-to-right parse.
 
 ## Marking code sections
 
-The prettyprinter looks for `
`, ``, or `` elements
-with the *prettyprint* class:
+The prettyprinter looks for `<pre>`, `<code>`, or `<xmp>` elements with the
+*prettyprint* class, and adds `<span>`s to colorize keywords, strings,
+comments, and other token types.
 
 ```HTML
 <pre class="prettyprint">
@@ -21,12 +18,9 @@ source code here
 </pre>
 ```
 
-and adds `<span>`s to colorize keywords, strings, comments, and other
-token types.
-
-If you're using Markdown or some other HTML generator that does not
-add classes, you can alternatively ask the prettifier to target your
-code by preceding it with a processing instruction thus:
+If you're using Markdown or some other HTML generator that does not add
+classes, you can alternatively ask the prettifier to target your code by
+preceding it with a processing instruction thus:
 
 ```HTML
 <?prettify?>
@@ -35,95 +29,91 @@ code here
 </pre>
 ```
 
-[Larger example](https://rawgit.com/google/code-prettify/master/examples/quine.html)
-
+[Larger example](https://raw.githack.com/google/code-prettify/master/examples/quine.html)
 
 ## Auto-Loader
 
-You can load the JavaScript and CSS for prettify via one URL
+You can load the JavaScript and CSS for prettify via one URL:
 
 ```HTML
-<script src="https://cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js"></script>
+<script src="https://cdn.jsdelivr.net/gh/google/code-prettify@master/loader/run_prettify.js"></script>
 ```
 
-will load the entire system and schedule the prettifier to run on page
-load.  There are a variety of additional options you can specify (as
-CGI arguments) to configure the runner.
+This will load the entire system and schedule the prettifier to run on page
+load.  There are a variety of additional options you can specify (as CGI
+arguments) to configure the runner.
 
-| CGI parameter | default | meaning |
-| ------------- | ------- | ------- |
-| autoload=(true, false) | true | run automatically on page load |
-| lang=... | none | Loads the language handler for the given language which is usually the file extension for source files for that language.  See the [index of language handlers](https://github.com/google/code-prettify/tree/master/src).  If specified multiple times (`?lang=css&lang=ml`) then all are loaded. |
-| skin=... | none | See the [skin gallery](https://cdn.rawgit.com/google/code-prettify/master/styles/index.html).  If specified multiple times, the first one to successfully load is used. |
-| callback=js_ident | | `window.exports["js_ident"]` will be called when prettyprinting finishes.  If specified multiple times, all are called. |
+| CGI parameter         | default | meaning                        |
+| --------------------- | ------- | ------------------------------ |
+| autorun=(true, false) | true    | run automatically on page load |
+| lang=...              | none    | Loads the language handler for the given language which is usually the file extension for source files for that language.  See the [index of language handlers](../src).  If specified multiple times (`?lang=css&lang=ml`) then all are loaded. |
+| skin=...              | none    | See the [skin gallery](https://raw.githack.com/google/code-prettify/master/styles/index.html).  If specified multiple times, the first one to successfully load is used. |
+| callback=js_ident     |         | `window.exports["js_ident"]` will be called when prettyprinting finishes.  If specified multiple times, all are called. |
 
-For example
+For example:
 
 ```HTML
-<script src="https://cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js?lang=css&amp;skin=sunburst"></script>
+<script src="https://cdn.jsdelivr.net/gh/google/code-prettify@master/loader/run_prettify.js?lang=css&amp;skin=sunburst"></script>
 ```
 
-specifies the `lang` parameter to also load the CSS language extension
-and the `skin` parameter to load the
-[*sunburst*](https://cdn.rawgit.com/google/code-prettify/master/styles/index.html#sunburst) skin.
+The above specifies the `lang` parameter to also load the CSS language
+extension and the `skin` parameter to load the
+[*sunburst*](https://raw.githack.com/google/code-prettify/master/styles/index.html#sunburst)
+skin.
 
 ## Serving your own JS & CSS
 
 You can
-[download](https://raw.githubusercontent.com/google/code-prettify/master/distrib/prettify-small.tgz)
-the scripts and styles and serve them yourself.  Make sure to include
-both the script and a stylesheet:
+[download](https://github.com/google/code-prettify/raw/master/distrib/prettify-small.zip)
+the scripts and styles and serve them yourself.  Make sure to include both the
+script and a stylesheet:
 
 ```HTML
-<link href="prettify.css" type="text/css" rel="stylesheet" />
+<link rel="stylesheet" type="text/css" href="prettify.css">
 <script type="text/javascript" src="prettify.js"></script>
 ```
 
-and then run the `prettyPrint` function once your page has finished
-loading.  One way to do this is via the `onload` handler thus:
+Then run the `PR.prettyPrint()` function once your page has finished loading.
+One way to do this is via the `onload` handler thus:
 
 ```HTML
-<body onload="prettyPrint()">
+<body onload="PR.prettyPrint()">
 ```
 
 ## Styling
 
-The prettifier only adds `class`es; it does not specify exact colors
-or fonts, so you can swap in a different stylesheet to change the way
-code is prettified.
+The prettifier only adds `class`es; it does not specify exact colors or fonts,
+so you can swap in a different stylesheet to change the way code is
+prettified.
 
-The easiest way to create your own stylesheet is by starting with one
-from the
-[style gallery](https://cdn.rawgit.com/google/code-prettify/master/styles/index.html)
+The easiest way to create your own stylesheet is by starting with one from the
+[style gallery](https://raw.githack.com/google/code-prettify/master/styles/index.html)
 and tweaking it.
 
-You can use CSS `@media` rules to specify styles that work well with
-printers (for example, dark text on a white background) when someone
-tries to print it.
+You can use CSS `@media` rules to specify styles that work well with printers
+(for example, dark text on a white background) when someone tries to print it.
 
 ## Language Hints
 
-Prettify makes a best effort to guess the language but works best with
-C-like and HTML-like languages.  For others, there are special
-language handlers that are chosen based on language hints.
+Prettify makes a best effort to guess the language but works best with C-like
+and HTML-like languages.  For others, there are special language handlers that
+are chosen based on language hints.
+
+For example, set the `lang-scm` hint to specify that the code is Scheme code:
 
 ```HTML
 <pre class="prettyprint lang-scm">(friends 'of '(parentheses))</pre>
 ```
 
-uses the `lang-scm` hint to specify that the code is Scheme code.
+It can also be specified as:
 
 ```HTML
 <?prettify lang=scm?>
 <pre>(friends 'of '(parentheses))</pre>
 ```
 
-also works.
-
 ## Line Numbering
 
-The `linenums` class in
-
 ```HTML
 <pre class="prettyprint linenums">
 Many
@@ -133,17 +123,16 @@ code
 </pre>
 ```
 
-tells the prettyprinter to insert an `<ol>` element and `<li>`
-elements around each line so that you get line numbers.
+The `linenums` class in the above code tells the prettyprinter to insert an
+`<ol>` element and `<li>` elements around each line so that you get line
+numbers.
 
 Most stylesheets then hide the line numbers except for every fifth line.
 
-The class `linenums:40` makes line numbering start at line 40 if
-you're excerpting a larger chunk of code, and
+The class `linenums:40` makes line numbering start at line 40 if you're
+excerpting a larger chunk of code.  The following also works:
 
 ```HTML
 <?prettify linenums=40?>
 <pre>lots of code</pre>
 ```
-
-also works.
diff --git a/examples/quine.html b/examples/quine.html
index 595be912..d43eb11e 100644
--- a/examples/quine.html
+++ b/examples/quine.html
@@ -3,10 +3,13 @@
 <head>
 <meta charset="utf-8" />
 <title>Making Quines Prettier</title>
-<!-- The defer is not necessary for autoloading, but is necessary for the
-     script at the bottom to work as a Quine. -->
-<script src="https://cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js?autoload=true&amp;skin=sunburst&amp;lang=css" defer="defer"></script>
-<style>.operative { font-weight: bold; border:1px solid yellow }</style>
+<!-- The defer attribute is not necessary for autoloading, but is necessary
+     for the script at the bottom to work as a Quine. -->
+<script src="https://cdn.jsdelivr.net/gh/google/code-prettify@master/loader/run_prettify.js?autoload=true&amp;skin=sunburst&amp;lang=css" defer></script>
+<style type="text/css">
+.operative { font-weight: bold; border: 1px solid yellow; }
+#quine { border: 4px solid #88c; }
+</style>
 </head>
 
 <body>
@@ -23,33 +26,40 @@ <h1>Making Quines Prettier</h1>
 The line numbers to the left appear because the preceding comment
 <code>&lt;?prettify lang=html linenums=true?&gt;</code> turns on
 line-numbering and the
-<a href="https://cdn.rawgit.com/google/code-prettify/master/styles/index.html">stylesheet</a>
+<a href="https://raw.githack.com/google/code-prettify/master/styles/index.html">stylesheet</a>
 (see <code>skin=sunburst</code> in the <code>&lt;script src&gt;</code>)
 specifies that every fifth line should be numbered.
 </p>
 
 <!-- Language hints can be put in XML application directive style comments. -->
 <?prettify lang=html linenums=true?>
-<pre class="prettyprint" id="quine" style="border:4px solid #88c"></pre>
+<pre class="prettyprint" id="quine"></pre>
 
-<script>//<![CDATA[
+<script type="text/javascript">//<![CDATA[
 (function () {
-  function html(s) {
-    return s.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
+  function htmlEscape(s) {
+    return s
+      .replace(/&/g, '&amp;')
+      .replace(/</g, '&lt;')
+      .replace(/>/g, '&gt;');
   }
 
-  var quineHtml = html(
-        '<!DOCTYPE html>\n<html>\n'
-      + document.documentElement.innerHTML 
-      + '\n<\/html>\n');
+  // this page's own source code
+  var quineHtml = htmlEscape(
+    '<!DOCTYPE html>\n<html>\n' +
+    document.documentElement.innerHTML +
+    '\n<\/html>\n');
 
   // Highlight the operative parts:
   quineHtml = quineHtml.replace(
     /&lt;script src[\s\S]*?&gt;&lt;\/script&gt;|&lt;!--\?[\s\S]*?--&gt;|&lt;pre\b[\s\S]*?&lt;\/pre&gt;/g,
-    '<span class="operative">$&</span>');
+    '<span class="operative">$&<\/span>');
 
+  // insert into PRE
   document.getElementById("quine").innerHTML = quineHtml;
 })();
 //]]>
-</script></body>
+</script>
+
+</body>
 </html>
diff --git a/js-modules/defs.js b/js-modules/defs.js
index 487c5ee5..18f3e4aa 100644
--- a/js-modules/defs.js
+++ b/js-modules/defs.js
@@ -47,4 +47,9 @@ var JobT;
 var SourceSpansT;
 
 /** @define {boolean} */
+/* @ifndef RUN_PRETTIFY */
 var IN_GLOBAL_SCOPE = true;
+/* @endif */
+/* @ifdef RUN_PRETTIFY */
+var IN_GLOBAL_SCOPE = false;
+/* @endif */
diff --git a/js-modules/extractSourceSpans_test.html b/js-modules/extractSourceSpans_test.html
deleted file mode 100644
index 090f6e2b..00000000
--- a/js-modules/extractSourceSpans_test.html
+++ /dev/null
@@ -1,129 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
-<html> <head>
-<title>Extract Source Spans Test</title>
-<script src="extractSourceSpans.js"></script>
-<script src="http://github.com/douglascrockford/JSON-js/raw/master/json2.js"></script>
-<style>
-.ok { background: #dfd }
-.error, .failure { background: #fdd }
-td { font-family: monospace }
-.actual { white-space: pre }
-tr { vertical-align: top }
-.break { padding-left: 2px; border-right-style: dotted !important }
-.odd, .even { border-style: solid; border-width: 1px }
-.even { background: #fff; border-color: #888 }
-.odd { background: #ddd; border-color: #000 }
-</style>
-</head>
-
-<body>
-<h1>Extract Source Spans Test</h1>
-
-<table border=1 cellpadding=2 cellspacing=0>
-  <tr><th colspan=3>Test space preserved in PRE</th></tr>
-  <tr>
-    <td><pre class="testinput"><b>print </b>'Hello '<br>  + '&lt;World&gt;';</pre></td>
-    <td class="golden"><pre>^print ^'Hello '^\n^  + '&lt;World&gt;';^</pre></td>
-  </tr>
-  <tr><th colspan=3>Test class="nocode"</th></tr>
-  <tr>
-    <td><pre class="testinput"><span class=nocode>1. </span><b>print </b>'Hello '<br><span class=nocode>2. </span>  + '&lt;World&gt;';</pre></td>
-    <td class="golden"><pre>^print ^'Hello '^\n^  + '&lt;World&gt;';^</pre></td>
-  </tr>
-  <tr><th colspan=3>Test whitespace normalized in code</th></tr>
-  <tr>
-    <td><code class="testinput"><b>print </b>'Hello '
-  + '&lt;World&gt;';</pre></td>
-    <td class="golden"><pre>^print ^'Hello ' + '&lt;World&gt;';^</pre></td>
-  </tr>
-  <tr><th colspan=3>Test XMP</th></tr>
-  <tr>
-    <td><xmp class="testinput">print 'Hello '
-  + '<World>';
-    
^print 'Hello '\n  + '<World>';^
- - Test tabs - -
print 'Hello '
-	+ '<World>';
-
^print 'Hello '\n\t+ '<World>';^
- - Test number lines output - -
  • print 'Hello '
  • + '<World>';
-
^print ^'Hello '^\n^  + '<World>';^^
- - - - - -
-
- Last modified: Tue Mar 29 16:38:23 PDT 2011 - diff --git a/js-modules/js_include.pl b/js-modules/js_include.pl deleted file mode 100644 index 61ee4736..00000000 --- a/js-modules/js_include.pl +++ /dev/null @@ -1,77 +0,0 @@ -#!/usr/bin/perl - -# Given a JS file looks for lines like -# include("path/to/file/to/include"); -# and replaces them with the quoted file relative to the js-modules directory. -# If the included file ends with ".pl" then it is treated as a perl file to -# execute and the stdout is used as the JS to include. - -use strict; - -# Closure Compiler @define annotations that need to be pulled out of included -# files because @defines need to be top-level vars. -my $global_defs = ""; - -# Find @defines at the top of a JS file by pulling off comments and looking for -# comments containing @define followed by a var declaration. -sub extractGlobalDefs($) { - my @headerComments; - my $s = shift; - while ($s) { - last unless $s =~ m#^\s*(?://[^\r\n]*|/\*.*?\*/[ \t]*)[\r\n]*#s; - my $comment = $&; - $s = $'; - if ($comment =~ /[\@](define|typedef)/ - && $s =~ /^\s*var\s+[^;]+;[ \t]*[\r\n]*/) { - my $global = "$&"; - $s = $'; - $global =~ s/(var\s*IN_GLOBAL_SCOPE\s*=\s*)true\b/$1false/; - $global_defs .= "$comment$global"; - } else { - push(@headerComments, $comment); - } - } - return (join "", @headerComments) . $s; -} - -# readInclude(whiteSpacePrefix, path) returns the JS content at path -# (with the ".pl" adjustment above) and prepends each line with the -# whitespace in whiteSpacePrefix to produce a chunk of JS that matches the -# indentation of the including file. -# @defines are extracted so that they can all appear globally at the top of -# the file. -sub readInclude($$) { - my $prefix = shift; - my $name = "js-modules/" . (shift); - my $in; - if ($name =~ /\.pl$/) { - open($in, "perl $name|") or die "$name: $!"; - } else { - open($in, "<$name") or die "$name: $!"; - } - my $buf = ""; - while (<$in>) { - if (m/(\s*)include\("([^"]+)"\);\s*$/) { - my $inc = extractGlobalDefs(readInclude("$prefix$1", $2)); - $buf .= $inc; - } else { - $buf .= "$prefix$_"; - } - } - close($in); - return $buf; -} - -my $target = shift; -my $inc = readInclude("", $target); -my $header = ""; -# Put descriptive top level comments above the grouped @defines. -if ($inc =~ s#^(?://[^\r\n]*|/\*.*?\*/|\s)+##s) { - $header = $&; -} -my $globals = $global_defs; -# Un-indent @defines. -$globals =~ s#^[ \t]*##gm; -$globals .= "\n" unless $globals eq ""; - -print "$header$globals$inc"; diff --git a/js-modules/node_prettify.js b/js-modules/node_prettify.js new file mode 100644 index 00000000..7262a48e --- /dev/null +++ b/js-modules/node_prettify.js @@ -0,0 +1,16 @@ + +var IN_GLOBAL_SCOPE = false; + +/* @include prettify.js */ + +var path = require('path'); + +module.exports = { + prettyPrint: prettyPrint, + prettyPrintOne: prettyPrintOne, + // include paths for css preprocessor support + includePaths: [ + __dirname, + path.resolve(__dirname, '../styles') + ] +}; diff --git a/js-modules/numberLines.js b/js-modules/numberLines.js index 2701ec25..e7ee3a42 100644 --- a/js-modules/numberLines.js +++ b/js-modules/numberLines.js @@ -30,7 +30,7 @@ function numberLines(node, startLineNum, isPreformatted) { function walk(node) { var type = node.nodeType; if (type == 1 && !nocode.test(node.className)) { // Element - if ('br' === node.nodeName) { + if ('br' === node.nodeName.toLowerCase()) { breakAfter(node); // Discard the
since it is now flush against a . if (node.parentNode) { diff --git a/js-modules/numberLines_test.html b/js-modules/numberLines_test.html deleted file mode 100644 index a074e014..00000000 --- a/js-modules/numberLines_test.html +++ /dev/null @@ -1,119 +0,0 @@ - - -Number Lines Test - - - - - - -

Number Lines Test

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Test Nothing to Split
Hello, World!
  1. Hello, World!
Test Normalized Spaces
Hello, World!
  1. Hello, World!
Test BR
Hello,
World!
  1. Hello,
  2. World!
Test line breaks
Hello,
there
World!
  1. Hello,
  2. there
  3. World!
Test line breaks with followers
Hello,
there
World!
  1. Hello,
  2. there
  3. World!
Test nocode
Hello,
there
World!
  1. Hello,
  2. there World!
Test link
Hello,
there
World!
  1. Hello,
  2. there
  3. World!
Test blank lines
One

Three
  1. One
  2.  
  3. Three
- - - -
-
- Last modified: Tue Mar 29 16:44:05 PDT 2011 - diff --git a/js-modules/prettify.js b/js-modules/prettify.js index 389e03c4..872c44b7 100644 --- a/js-modules/prettify.js +++ b/js-modules/prettify.js @@ -57,7 +57,9 @@ // JSLint declarations /*global console, document, navigator, setTimeout, window, define */ -include("defs.js"); +/* @ifndef RUN_PRETTIFY */ +/* @include defs.js */ +/* @endif */ /** * {@type !{ @@ -89,7 +91,10 @@ var PR; * UI events. * If set to {@code false}, {@code prettyPrint()} is synchronous. */ -window['PR_SHOULD_USE_CONTINUATION'] = true; +var PR_SHOULD_USE_CONTINUATION = true +if (typeof window !== 'undefined') { + window['PR_SHOULD_USE_CONTINUATION'] = PR_SHOULD_USE_CONTINUATION; +} /** * Pretty print a chunk of code. @@ -114,37 +119,38 @@ var prettyPrint; (function () { - var win = window; + var win = (typeof window !== 'undefined') ? window : {}; // Keyword lists for various languages. // We use things that coerce to strings to make them compact when minified // and to defeat aggressive optimizers that fold large string constants. var FLOW_CONTROL_KEYWORDS = ["break,continue,do,else,for,if,return,while"]; var C_KEYWORDS = [FLOW_CONTROL_KEYWORDS,"auto,case,char,const,default," + - "double,enum,extern,float,goto,inline,int,long,register,short,signed," + + "double,enum,extern,float,goto,inline,int,long,register,restrict,short,signed," + "sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"]; var COMMON_KEYWORDS = [C_KEYWORDS,"catch,class,delete,false,import," + "new,operator,private,protected,public,this,throw,true,try,typeof"]; - var CPP_KEYWORDS = [COMMON_KEYWORDS,"alignof,align_union,asm,axiom,bool," + + var CPP_KEYWORDS = [COMMON_KEYWORDS,"alignas,alignof,align_union,asm,axiom,bool," + "concept,concept_map,const_cast,constexpr,decltype,delegate," + "dynamic_cast,explicit,export,friend,generic,late_check," + - "mutable,namespace,nullptr,property,reinterpret_cast,static_assert," + + "mutable,namespace,noexcept,noreturn,nullptr,property,reinterpret_cast,static_assert," + "static_cast,template,typeid,typename,using,virtual,where"]; var JAVA_KEYWORDS = [COMMON_KEYWORDS, "abstract,assert,boolean,byte,extends,finally,final,implements,import," + "instanceof,interface,null,native,package,strictfp,super,synchronized," + "throws,transient"]; var CSHARP_KEYWORDS = [COMMON_KEYWORDS, - "abstract,as,base,bool,by,byte,checked,decimal,delegate,descending," + - "dynamic,event,finally,fixed,foreach,from,group,implicit,in,interface," + - "internal,into,is,let,lock,null,object,out,override,orderby,params," + - "partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong," + - "unchecked,unsafe,ushort,var,virtual,where"]; + "abstract,add,alias,as,ascending,async,await,base,bool,by,byte,checked,decimal,delegate,descending," + + "dynamic,event,finally,fixed,foreach,from,get,global,group,implicit,in,interface," + + "internal,into,is,join,let,lock,null,object,out,override,orderby,params," + + "partial,readonly,ref,remove,sbyte,sealed,select,set,stackalloc,string,select,uint,ulong," + + "unchecked,unsafe,ushort,value,var,virtual,where,yield"]; var COFFEE_KEYWORDS = "all,and,by,catch,class,else,extends,false,finally," + "for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then," + "throw,true,try,unless,until,when,while,yes"; var JSCRIPT_KEYWORDS = [COMMON_KEYWORDS, - "debugger,eval,export,function,get,instanceof,null,set,undefined," + - "var,with,Infinity,NaN"]; + "abstract,async,await,constructor,debugger,enum,eval,export,from,function," + + "get,import,implements,instanceof,interface,let,null,of,set,undefined," + + "var,with,yield,Infinity,NaN"]; var PERL_KEYWORDS = "caller,delete,die,do,dump,elsif,eval,exit,foreach,for," + "goto,if,import,last,local,my,next,no,our,print,package,redo,require," + "sub,undef,unless,until,use,wantarray,while,BEGIN,END"; @@ -161,7 +167,7 @@ var prettyPrint; var ALL_KEYWORDS = [ CPP_KEYWORDS, CSHARP_KEYWORDS, JAVA_KEYWORDS, JSCRIPT_KEYWORDS, PERL_KEYWORDS, PYTHON_KEYWORDS, RUBY_KEYWORDS, SH_KEYWORDS]; - var C_TYPES = /^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)\b/; + var C_TYPES = /^(DIR|FILE|array|vector|(de|priority_)?queue|(forward_)?list|stack|(const_)?(reverse_)?iterator|(unordered_)?(multi)?(set|map)|bitset|u?(int|float)\d*)\b/; // token style names. correspond to css classes /** @@ -233,11 +239,11 @@ var prettyPrint; */ var PR_NOCODE = 'nocode'; - include("regexpPrecederPatterns.pl"); + /* @include regexpPrecederPatterns.js */ - include("combinePrefixPatterns.js"); + /* @include combinePrefixPatterns.js */ - include("extractSourceSpans.js"); + /* @include extractSourceSpans.js */ /** * Apply the given language handler to sourceCode and add the resulting @@ -658,9 +664,9 @@ var prettyPrint; 'regexLiterals': true }); - include("numberLines.js"); + /* @include numberLines.js */ - include("recombineTagsAndDecorations.js"); + /* @include recombineTagsAndDecorations.js */ /** Maps language-specific file extensions to handlers. */ var langHandlerRegistry = {}; @@ -778,7 +784,7 @@ var prettyPrint; 'keywords': JSCRIPT_KEYWORDS, 'cStyleComments': true, 'regexLiterals': true - }), ['javascript', 'js']); + }), ['javascript', 'js', 'ts', 'typescript']); registerLangHandler(sourceDecorator({ 'keywords': COFFEE_KEYWORDS, 'hashComments': 3, // ### style block comments @@ -1056,7 +1062,7 @@ var prettyPrint; IN_GLOBAL_SCOPE ? (win['prettyPrintOne'] = $prettyPrintOne) : (prettyPrintOne = $prettyPrintOne), - 'prettyPrint': prettyPrint = + 'prettyPrint': IN_GLOBAL_SCOPE ? (win['prettyPrint'] = $prettyPrint) : (prettyPrint = $prettyPrint) diff --git a/js-modules/recombineTagsAndDecorations_test.html b/js-modules/recombineTagsAndDecorations_test.html deleted file mode 100644 index 555ee3c6..00000000 --- a/js-modules/recombineTagsAndDecorations_test.html +++ /dev/null @@ -1,98 +0,0 @@ - - -Recombine Tags And Decorations - - - - - - - - - -

Recombine Tags And Decorations

- - - - - - - - - - - - - - - - - - - - -
Test Single Decoration
"Hello, World!"[0, 'str']"Hello, World!"
Test Single Span
print "Hello, <World>!";[0, 'kwd', 5, 'pln', 6, 'str', 14, 'tag', 21, 'str', 23, 'pun']print "Hello, <World>!";
Test Interleaved
print "Hello, <World>!";[0, 'kwd', 5, 'pln', 6, 'str', 14, 'tag', 21, 'str', 23, 'pun']print "Hello, <World>!";
- - - -
-
- Last modified: Tue Mar 29 10:41:34 PDT 2011 - diff --git a/js-modules/regexpPrecederPatterns.js b/js-modules/regexpPrecederPatterns.js new file mode 100644 index 00000000..65d3de53 --- /dev/null +++ b/js-modules/regexpPrecederPatterns.js @@ -0,0 +1,30 @@ + +// Regex pattern below is automatically generated by regexpPrecederPatterns.pl +// Do not modify, your changes will be erased. + +// CAVEAT: this does not properly handle the case where a regular +// expression immediately follows another since a regular expression may +// have flags for case-sensitivity and the like. Having regexp tokens +// adjacent is not valid in any language I'm aware of, so I'm punting. +// TODO: maybe style special characters inside a regexp as punctuation. + +/** + * A set of tokens that can precede a regular expression literal in + * javascript + * http://web.archive.org/web/20070717142515/http://www.mozilla.org/js/language/js20/rationale/syntax.html + * has the full list, but I've removed ones that might be problematic when + * seen in languages that don't support regular expression literals. + * + * Specifically, I've removed any keywords that can't precede a regexp + * literal in a syntactically legal javascript program, and I've removed the + * "in" keyword since it's not a keyword in many languages, and might be used + * as a count of inches. + * + * The link above does not accurately describe EcmaScript rules since + * it fails to distinguish between (a=++/b/i) and (a++/b/i) but it works + * very well in practice. + * + * @private + * @const + */ +var REGEXP_PRECEDER_PATTERN = '(?:^^\\.?|[+-]|[!=]=?=?|\\#|%=?|&&?=?|\\(|\\*=?|[+\\-]=|->|\\/=?|::?|<>?>?=?|,|;|\\?|@|\\[|~|{|\\^\\^?=?|\\|\\|?=?|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*'; diff --git a/js-modules/regexpPrecederPatterns.pl b/js-modules/regexpPrecederPatterns.pl index 488dbd68..0f1e1d59 100644 --- a/js-modules/regexpPrecederPatterns.pl +++ b/js-modules/regexpPrecederPatterns.pl @@ -1,6 +1,14 @@ use strict; print " +// Regex pattern below is automatically generated by regexpPrecederPatterns.pl +// Do not modify, your changes will be erased. + +// CAVEAT: this does not properly handle the case where a regular +// expression immediately follows another since a regular expression may +// have flags for case-sensitivity and the like. Having regexp tokens +// adjacent is not valid in any language I'm aware of, so I'm punting. +// TODO: maybe style special characters inside a regexp as punctuation. /** * A set of tokens that can precede a regular expression literal in @@ -9,12 +17,12 @@ * has the full list, but I've removed ones that might be problematic when * seen in languages that don't support regular expression literals. * - *

Specifically, I've removed any keywords that can't precede a regexp + * Specifically, I've removed any keywords that can't precede a regexp * literal in a syntactically legal javascript program, and I've removed the * \"in\" keyword since it's not a keyword in many languages, and might be used * as a count of inches. * - *

The link above does not accurately describe EcmaScript rules since + * The link above does not accurately describe EcmaScript rules since * it fails to distinguish between (a=++/b/i) and (a++/b/i) but it works * very well in practice. * @@ -34,7 +42,7 @@ "->", "\\/=?", # "/", "/=", "::?", # ":", "::", - "<>?>?=?", # ">", ">=", ">>", ">>=", ">>>", ">>>=", ",", ";", # ";" @@ -58,11 +66,3 @@ $pattern .= ")\\\\s*'"; # matches at end, and matches empty string print "$pattern;\n"; - -print " -// CAVEAT: this does not properly handle the case where a regular -// expression immediately follows another since a regular expression may -// have flags for case-sensitivity and the like. Having regexp tokens -// adjacent is not valid in any language I'm aware of, so I'm punting. -// TODO: maybe style special characters inside a regexp as punctuation. -"; diff --git a/js-modules/run_prettify.js b/js-modules/run_prettify.js index 84a34ff9..faae9897 100644 --- a/js-modules/run_prettify.js +++ b/js-modules/run_prettify.js @@ -35,7 +35,7 @@ * +------------------+---------------+------------------------------+--------+ * | skin= | skin name | Loads the skin stylesheet | none. | * | | | named ".css". | | - * | | | https://cdn.rawgit.com/ | | + * | | | https://raw.githack.com/ | | * | | | google/code-prettify/master/ | | * | | | styles/index.html | | * +------------------+---------------+------------------------------+--------+ @@ -48,19 +48,23 @@ * | | | injection. | | * +------------------+---------------+------------------------------+--------+ * - * Exmaples - * .../prettify.js?lang=css&skin=sunburst + * Examples + * .../run_prettify.js?lang=css&skin=sunburst * 1. Loads the CSS language handler which can be used to prettify CSS * stylesheets, HTML - - + - -

+ + +
+<!doctype html>
+<html>
+<head>
+<title>HTML Test</title>
 <script type="text/javascript">
 // Say hello world until the user starts questioning
 // the meaningfulness of their existence.
@@ -51,11 +94,18 @@
   }
 }
 </script>
-<style>
+<style type="text/css">
 p { color: pink }
 b { color: blue }
 u { color: "umber" }
 </style>
+</head>
+<body>
+<h1>Hello world!</h1>
+</body>
+</html>
 
- + + + diff --git a/styles/doxy.css b/styles/doxy.css index b0e89161..f328738a 100644 --- a/styles/doxy.css +++ b/styles/doxy.css @@ -51,7 +51,7 @@ li.L1,li.L3,li.L5,li.L7,li.L9 { } pre.prettyprint, code.prettyprint { background-color: #fff; } pre .str, code .str { color: #088; } pre .kwd, code .kwd { color: #006; font-weight: bold; } - pre .com, code .com { color: #oc3; font-style: italic; } + pre .com, code .com { color: #0c3; font-style: italic; } pre .typ, code .typ { color: #404; font-weight: bold; } pre .lit, code .lit { color: #044; } pre .pun, code .pun { color: #440; } diff --git a/styles/index.html b/styles/index.html index d538dc12..ba171df7 100644 --- a/styles/index.html +++ b/styles/index.html @@ -1,39 +1,73 @@ - + + Prettify Themes Gallery - @@ -47,43 +81,23 @@

Gallery of themes for Click on a theme name for a link to the file in revision control. Print preview this page to see how the themes work on the printed page.

- +})(); + - + + diff --git a/styles/sunburst.css b/styles/sunburst.css index 011d33e2..ae06306a 100644 --- a/styles/sunburst.css +++ b/styles/sunburst.css @@ -15,11 +15,6 @@ pre .dec, code .dec { color: #3387CC; } /* decimal - blue */ pre.prettyprint, code.prettyprint { background-color: #000; - -moz-border-radius: 8px; - -webkit-border-radius: 8px; - -o-border-radius: 8px; - -ms-border-radius: 8px; - -khtml-border-radius: 8px; border-radius: 8px; } diff --git a/tasks/aliases.js b/tasks/aliases.js new file mode 100644 index 00000000..e67aadf9 --- /dev/null +++ b/tasks/aliases.js @@ -0,0 +1,72 @@ +/** + * google-code-prettify + * https://github.com/google/code-prettify + * + * @author Amro + * @license Apache-2.0 + */ + +module.exports = function (grunt) { + 'use strict'; + + var fs = require('fs'); + var runLanguageHandler = require('./lib/lang-aliases'); + + /** + * Copy timestamp from source to destination file. + * @param {string} src + * @param {string} dest + * @param {boolean} timestamp + */ + function syncTimestamp(src, dest, timestamp) { + if (timestamp) { + var stat = fs.lstatSync(src); + var fd = fs.openSync(dest, process.platform === 'win32' ? 'r+' : 'r'); + fs.futimesSync(fd, stat.atime, stat.mtime); + fs.closeSync(fd); + } + } + + /** + * Copy file mode from source to destination. + * @param {string} src + * @param {string} dest + * @param {boolean|number} mode + */ + function syncMod(src, dest, mode) { + if (mode !== false) { + fs.chmodSync(dest, (mode === true) ? fs.lstatSync(src).mode : mode); + } + } + + // Create copies of language handler files under all registered aliases + grunt.registerMultiTask('aliases', 'Create language aliases', function () { + var opts = this.options({ + timestamp: false, + mode: false + }); + + var count = 0; + this.filesSrc.forEach(function (src) { + // run language handler in sandbox + grunt.verbose.subhead('Running ' + src.cyan + ' in sandbox...'); + var exts = runLanguageHandler(src); + grunt.verbose.ok(); + + // go over collected extensions + exts.forEach(function (ext) { + // copy file + var dest = src.replace(/\blang-\w+\b/, 'lang-' + ext); + grunt.verbose.writeln('Copying ' + src.cyan + ' -> ' + dest.cyan); + grunt.file.copy(src, dest); + + // sync timestamp and file mode + syncTimestamp(src, dest, opts.timestamp); + syncMod(src, dest, opts.mode); + count++; + }); + }); + grunt.log.ok('Copied ' + count.toString().cyan + + grunt.util.pluralize(count, ' file/ files')); + }); +}; diff --git a/tasks/gcc.js b/tasks/gcc.js new file mode 100644 index 00000000..cd64d29f --- /dev/null +++ b/tasks/gcc.js @@ -0,0 +1,49 @@ +/** + * google-code-prettify + * https://github.com/google/code-prettify + * + * @author Amro + * @license Apache-2.0 + */ + +module.exports = function (grunt) { + 'use strict'; + + /* + * HACK: Custom task to override "closure-compiler:langs" since all lang-* + * files are compiled in parallel, launching too many Java processes at once + * which easily runs out of memory! This task programmatically creates + * separate targets (one file per target) so that lang files are compiled + * sequentially (sync) instead of in parallel (async). + */ + grunt.registerMultiTask('gcc', 'Override closure-compiler', function () { + // closure-compiler:langs + var task = 'closure-compiler'; + var target = this.target; + if (!grunt.task.exists(task)) { + grunt.fail.warn(grunt.util.error('Require task "' + task + '".')); + } + + // create new targets for each file (one file per target) + var count = 0; + var opts = this.options(); + this.files.forEach(function (file, idx) { + // simple target config with only: src, dest, and options + delete file.orig; + file.options = opts; + + // configure new target + grunt.config.set([task, target + idx], file); + grunt.verbose.writeln('New target ' + (task + ':' + target + idx).cyan); + count++; + }); + grunt.log.ok('Configured ' + count.toString().cyan + ' lang targets'); + + // remove original multi-file target + grunt.config.set([task, target], {}); + + // enqueue modified task to run + //console.log(grunt.config.get(task)); + grunt.task.run(task); + }); +}; diff --git a/tasks/lib/lang-aliases.js b/tasks/lib/lang-aliases.js new file mode 100644 index 00000000..7272e829 --- /dev/null +++ b/tasks/lib/lang-aliases.js @@ -0,0 +1,92 @@ +/** + * google-code-prettify + * https://github.com/google/code-prettify + * + * @author Amro + * @license Apache-2.0 + */ + +var fs = require('fs'); +var path = require('path'); +var vm = require('vm'); + +/** + * Returns a mock object PR of the prettify API. This is used to collect + * registered language file extensions. + * + * @return {Object} PR object with an additional `extensions` property. + */ +function createSandbox() { + // collect registered language extensions + var sandbox = {}; + sandbox.extensions = []; + // mock prettify.js API + sandbox.window = {}; + sandbox.window.PR = sandbox.PR = { + registerLangHandler: function (handler, exts) { + sandbox.extensions = sandbox.extensions.concat(exts); + }, + createSimpleLexer: function (sPatterns, fPatterns) { + return function (job) {}; + }, + sourceDecorator: function (options) { + return function (job) {}; + }, + prettyPrintOne: function (src, lang, ln) { + return src; + }, + prettyPrint: function (done, root) {}, + PR_ATTRIB_NAME: 'atn', + PR_ATTRIB_VALUE: 'atv', + PR_COMMENT: 'com', + PR_DECLARATION: 'dec', + PR_KEYWORD: 'kwd', + PR_LITERAL: 'lit', + PR_NOCODE: 'nocode', + PR_PLAIN: 'pln', + PR_PUNCTUATION: 'pun', + PR_SOURCE: 'src', + PR_STRING: 'str', + PR_TAG: 'tag', + PR_TYPE: 'typ' + }; + return sandbox; +} + +/** + * Runs a language handler file under VM to collect extensions. + * + * Given a lang-*.js file, runs the language handler in a fake context where + * PR.registerLangHandler collects handler names without doing anything else. + * This is later used to makes copies of the JS extension under all its + * registered language names lang-.js + * + * @param {string} src path to lang-xxx.js language handler + * @return {Array} registered file extensions + */ +function runLanguageHandler(src) { + // execute source code in an isolated sandbox with a mock PR object + var sandbox = createSandbox(); + vm.runInNewContext(fs.readFileSync(src), sandbox, { + filename: src + }); + + // language name + var lang = path.basename(src, path.extname(src)).replace(/^lang-/, ''); + + // collect and filter extensions + var exts = sandbox.extensions.map(function (ext) { + // case-insensitive names + return ext.toLowerCase(); + }).filter(function (ext) { + // skip self, and internal names like foo-bar-baz or lang.foo + return ext !== lang && !/\W/.test(ext); + }); + exts = exts.filter(function (ext, pos) { + // remove duplicates + return exts.indexOf(ext) === pos; + }); + return exts; +} + +module.exports = runLanguageHandler; diff --git a/tests/debug-ie-compat-matrix.html b/tests/debug-ie-compat-matrix.html index 78125192..caa58ae4 100644 --- a/tests/debug-ie-compat-matrix.html +++ b/tests/debug-ie-compat-matrix.html @@ -1,8 +1,20 @@ - + + + + +

IE Standard/Quirks Modes Test

one short line, @@ -22,89 +34,100 @@
-

+

Results

+
+

+

+
- + if ('boolean' !== typeof quirksMode) { + throw new Error(quirksMode); + } else if ('number' !== typeof ieVersion || + !table.quirks.hasOwnProperty(+ieVersion)) { + throw new Error(ieVersion); + } + return table[quirksMode ? 'quirks' : 'standards'][ieVersion]; +} - - + + + diff --git a/tests/extractSourceSpans_test.html b/tests/extractSourceSpans_test.html new file mode 100644 index 00000000..60fa520b --- /dev/null +++ b/tests/extractSourceSpans_test.html @@ -0,0 +1,146 @@ + + + + +extractSourceSpans + + + + + + + +

Extract Source Spans Test

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Test space preserved in PRE
print 'Hello '
+ '<World>';
^print ^'Hello '^\n^  + '<World>';^
Test class="nocode"
1. print 'Hello '
2. + '<World>';
^print ^'Hello '^\n^  + '<World>';^
Test whitespace normalized in code
print 'Hello ' + + '<World>';
^print ^'Hello ' + '<World>';^
Test XMP
print 'Hello ' + + '<World>';
^print 'Hello '\n  + '<World>';^
Test tabs
print 'Hello '
+	+ '<World>';
^print 'Hello '\n\t+ '<World>';^
Test number lines output
  • print 'Hello '
  • + '<World>';
^print ^'Hello '^\n^  + '<World>';^^
+ +
+

Log

+
+ + + + + diff --git a/tests/ie-newline-copy-paste.html b/tests/ie-newline-copy-paste.html index faf6c698..bfd601de 100644 --- a/tests/ie-newline-copy-paste.html +++ b/tests/ie-newline-copy-paste.html @@ -1,119 +1,124 @@ + + + + IE Newline Copy/Paste Info Gathering + + + +

IE newline copy/paste

+

-I'm trying to squash, once and for all, the problems with newlines in -<PRE>s in IE. I can't run 3 versions of IE, so I'd +I'm trying to squash, once and for all, the problems with newlines in +<PRE>s in IE. I can't run all versions of IE, so I'd really appreciate any help from people who have IE open and running. +See bugs #20, +#104, and +#128 for +reference.

-Please copy from START through END below and paste it into the -textarea below. -Then hit Ctrl-A, Ctrl-C to copy the textarea contents, and paste that -into an email. -Please also copy and paste the RESULTS section below and include it in -the email response as well and send it -to me or respond to the -discussion list. +Please copy from START through END below +and paste it into the TEXTAREA below. Then hit +Ctrl-A, Ctrl-C to copy the textarea contents, and paste +that into an email. Please also copy and paste the RESULTS +section below and include it in the email response as well and send it to +me or respond to the discussion +list.

-In case you're interested, there are two problems: choosing a way to -split lines that doesn't introduce too few or extra newlines, and a -way to make sure that the resulting code can be copy-pasted into a -plain text editors such as the textarea below. This is my attempt to -gather information on both issues by IE version. +In case you're interested, there are two problems: choosing a way to split +lines that doesn't introduce too few or extra newlines, and a way to make sure +that the resulting code can be copy-pasted into a plain text editors such as +the textarea below. This is my attempt to gather information on both issues +by IE version.

-cheers. - - - - -

START

- - - - - - - - - - - - - - - - - - - - - - - - +

Cheers.

- +
- +

== START ==

- +
- - - - - - - - - - - +
before
+[manual CR]
+after
- +
before
[manual BR]
after
- +
before
+[manual CR+BR]
+after
- +
before
+
[manual BR+CR] +
after
- +

== END ==

-
before
-[Not generated via innerHTML CR]
+
before
+[text]
 after
-
before
[Not generated via innerHTML BR]
after
+
-
before
-[Not generated via innerHTML CR + BR]
-after
+

RESULTS

-
before
-
[Not generated via innerHTML BR + CR] -
after
+
-

END

+
-
one
-two
-three
+

TEXTAREA

+ -

RESULTS

- + logger('User Agent = ' + navigator.userAgent); + logger('Ok = ' + ok); + logger('Bad = ' + bad); +})(); + -

TEXTAREA

- + + diff --git a/tests/large_input_test.html b/tests/large_input_test.html index 7e40b898..5c4ff30c 100644 --- a/tests/large_input_test.html +++ b/tests/large_input_test.html @@ -1,120 +1,201 @@ - + + Tests of Prettifier w/ large data files - - - + + + - -
-
+ +

Benchmarks

+
+
+

Results

+
- diff --git a/tests/numberLines_test.html b/tests/numberLines_test.html new file mode 100644 index 00000000..317333f9 --- /dev/null +++ b/tests/numberLines_test.html @@ -0,0 +1,135 @@ + + + + +numberLines + + + + + + +

Number Lines Test

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Test Nothing to Split
Hello, World!
  1. Hello, World!
Test Normalized Spaces
Hello, World!
  1. Hello, World!
Test BR
Hello,
World!
  1. Hello,
  2. World!
Test line breaks
Hello,
there
World!
  1. Hello,
  2. there
  3. World!
Test line breaks with followers
Hello,
there
World!
  1. Hello,
  2. there
  3. World!
Test nocode
Hello,
there
World!
  1. Hello,
  2. there World!
Test link
Hello,
there
World!
  1. Hello,
  2. there
  3. World!
Test blank lines
One

Three
  1. One
  2.  
  3. Three
+ +
+

Log

+
+ + + + + diff --git a/tests/prettify_test.html b/tests/prettify_test.html index 563a7a99..04f55f22 100644 --- a/tests/prettify_test.html +++ b/tests/prettify_test.html @@ -1,67 +1,76 @@ - + + Code Prettifier - + + + - - - -
-
+ +

Test Results

+
+ +

Bash

#!/bin/bash
@@ -103,14 +112,14 @@ 

Bash w/ language specified

fib | /usr/bin/*head -10 | tail -1
-

Issue 165

+

Bash special characters

+

Issue #165

# Comment
 local $x = ${#x[@]}  # Previous is not a comment
 # A comment

C

- -
+
 #include <stdio.h>
 
 /* the n-th fibonacci number.
@@ -118,7 +127,7 @@ 

C

unsigned int fib(unsigned int n) { unsigned int a = 1, b = 1; unsigned int tmp; - while (--n >= 0) { + while (--n >= 0) { tmp = a; a += b; b = tmp; @@ -132,15 +141,14 @@

C

C w/ language specified

- -
+
 #include <stdio.h>
 
 /* the nth fibonacci number. */
 uint32 fib(unsigned int n) {
   uint32 a = 1, b = 1;
   uint32 tmp;
-  while (--n >= 0) {
+  while (--n >= 0) {
     tmp = a;
     a += b;
     b = tmp;
@@ -157,8 +165,9 @@ 

C w/ language specified

#define ZERO 0 /* a multiline comment */
+

C++

-
+
 #include <iostream>
 
 using namespace std;
@@ -167,7 +176,7 @@ 

C++

//! \param n an index into the fibonacci series //! \param fib0 element 0 of the series //! \return the nth element of the fibonacci series -template <class T> +template <class T> T fib(unsigned int n, const T& fib0) { T a(fib0), b(fib0); for (; n; --n) { @@ -184,7 +193,7 @@

C++

C++ w/ language specified

-
+
 #include <iostream>
 
 using namespace std;
@@ -193,10 +202,10 @@ 

C++ w/ language specified

//! \param n an index into the fibonacci series //! \param fib0 element 0 of the series //! \return the nth element of the fibonacci series -template <class T> +template <class T> T fib(int n, const T& fib0) { T a(fib0), b(fib0); - while (--n >= 0) { + while (--n >= 0) { T tmp(a); a += b; b = tmp; @@ -218,13 +227,13 @@

Java

/** * the fibonacci series implemented as an Iterable. */ -public final class Fibonacci implements Iterable<Integer> { +public final class Fibonacci implements Iterable<Integer> { /** the next and previous members of the series. */ private int a = 1, b = 1; @Override - public Iterator<Integer> iterator() { - return new Iterator<Integer>() { + public Iterator<Integer> iterator() { + return new Iterator<Integer>() { /** the series is infinite. */ public boolean hasNext() { return true; } public Integer next() { @@ -238,14 +247,14 @@

Java

} /** - * the n<sup>th</sup> element of the given series. + * the n<sup>th</sup> element of the given series. * @throws NoSuchElementException if there are less than n elements in the * given Iterable's {@link Iterable#iterator iterator}. */ - public static <T> - T nth(int n, Iterable<T> iterable) { - Iterator<? extends T> it = iterable.iterator(); - while (--n > 0) { + public static <T> + T nth(int n, Iterable<T> iterable) { + Iterator<? extends T> it = iterable.iterator(); + while (--n > 0) { it.next(); } return it.next(); @@ -257,7 +266,8 @@

Java

}
-

Java w/ language specified(first line shown is line 12)

+

Java w/ language specified

+

(first line shown is line 12)

 package foo;
 
@@ -266,13 +276,13 @@ 

Java w/ language specified(first line shown is line 12)

/** * the fibonacci series implemented as an Iterable. */ -public final class Fibonacci implements Iterable<Integer> { +public final class Fibonacci implements Iterable<Integer> { /** the next and previous members of the series. */ private int a = 1, b = 1; @Override - public Iterator<Integer> iterator() { - return new Iterator<Integer>() { + public Iterator<Integer> iterator() { + return new Iterator<Integer>() { /** the series is infinite. */ public boolean hasNext() { return true; } public Integer next() { @@ -286,14 +296,14 @@

Java w/ language specified(first line shown is line 12)

} /** - * the n<sup>th</sup> element of the given series. + * the n<sup>th</sup> element of the given series. * @throws NoSuchElementException if there are less than n elements in the * given Iterable's {@link Iterable#iterator iterator}. */ - public static <T> - T nth(int n, Iterable<T> iterable) { - Iterator<? extends T> in = iterable.iterator(); - while (--n > 0) { + public static <T> + T nth(int n, Iterable<T> iterable) { + Iterator<? extends T> in = iterable.iterator(); + while (--n > 0) { in.next(); } return in.next(); @@ -308,17 +318,17 @@

Java w/ language specified(first line shown is line 12)

# not keywords: static_cast and namespace
-

Javascript

+

JavaScript

 /**
  * nth element in the fibonacci series.
- * @param n >= 0
- * @return the nth element, >= 0.
+ * @param n >= 0
+ * @return the nth element, >= 0.
  */
 function fib(n) {
   var a = 1, b = 1;
   var tmp;
-  while (--n >= 0) {
+  while (--n >= 0) {
     tmp = a;
     a += b;
     b = tmp;
@@ -329,8 +339,9 @@ 

Javascript

document.write(fib(10));
-

Issue 12 - Javascript Regular Expressions

-
+

JavaScript Regular Expressions

+

Issue #12

+
 /foo/;  // a slash starting a line treated as a regexp beginning
 "foo".match(/fo+$/);
 // this line comment not treated as a regular expressions
@@ -367,14 +378,15 @@ 

Issue 12 - Javascript Regular Expressions

return /a regexp/; division = notreturn / not_a_regexp / 2; // keyword suffix does not match -// & not used as prefix operator in javascript but this should still work -&/foo/; +// & not used as prefix operator in javascript but this should still work +&/foo/; extends = /extends/;
-

Issue 12 - Javascript Regular Expressions w/ language specified

-
+

JavaScript Regular Expressions w/ language specified

+

Issue #12

+
 /foo/;  // a slash starting a line treated as a regexp beginning
 "foo".match(/fo+$/);
 // this line comment not treated as a regular expressions
@@ -411,19 +423,19 @@ 

Issue 12 - Javascript Regular Expressions w/ language specified

return /a regexp/; division = notreturn / not_a_regexp / 2; // keyword suffix does not match -// & not used as prefix operator in javascript but this should still work -&/foo/; +// & not used as prefix operator in javascript but this should still work +&/foo/; extends = /extends/;
-

Coffee

+

CoffeeScript

 class Animal
-  constructor: (@name) ->
-  move: (meters, loc) ->
+  constructor: (@name) ->
+  move: (meters, loc) ->
     alert @name + " moved " + meters + "m."
-  travel: (path...) ->
+  travel: (path...) ->
     for place in path
       @move place.distance, place.location
 
@@ -432,17 +444,17 @@ 

Coffee

@param name Horse name @param jumper Jumping ability ### - constructor: (name, jumper) -> + constructor: (name, jumper) -> super name @capable = jumper - step: -> + step: -> alert ''' Step, step... ''' - jump: -> + jump: -> @capable - move: (meters, where) -> + move: (meters, where) -> switch where when "ground" @step() @@ -476,11 +488,11 @@

Perl

use integer; # the nth element of the fibonacci series -# param n - an int >= 0 -# return an int >= 0 +# param n - an int >= 0 +# return an int >= 0 sub fib($) { my $n = shift, $a = 1, $b = 1; - ($a, $b) = ($a + $b, $a) until (--$n < 0); + ($a, $b) = ($a + $b, $a) until (--$n < 0); return $a; } @@ -510,7 +522,7 @@

Python

for x in series: n = n - 1 - if n <= 0: return x + if n <= 0: return x print nth(fib(), 10)
@@ -538,14 +550,14 @@

Python w/ language specified

for x in series: n -= 1 - if n <= 0: return x + if n <= 0: return x print nth(fib(), 10) /* not a comment and not keywords: null char true */
-

SQL w/ language specified

+

SQL

 /* A multi-line
  * comment */
@@ -562,7 +574,7 @@ 

XML

 <!DOCTYPE series PUBLIC "fibonacci numbers">
 
-<series.root base="1" step="s(n-2) + s(n-1)">
+<series.root base="1" step="s(n-2) + s(n-1)">
   <element i="0">1</element>
   <element i="1">1</element>
   <element i="2">2</element>
@@ -576,13 +588,13 @@ 

XML

HTML

 <html>
-  <head>
+  <head>
     <title>Fibonacci number</title>
     <style><!-- BODY { text-decoration: blink } --></style>
     <script src="foo.js"></script>
     <script src="bar.js"></script>
   </head>
-  <body>
+  <body>
     <noscript>
       <dl>
         <dt>Fibonacci numbers</dt>
@@ -596,11 +608,11 @@ 

HTML

</dl> </noscript> - <script type="text/javascript"><!-- + <script type="text/javascript"><!-- function fib(n) { var a = 1, b = 1; var tmp; - while (--n >= 0) { + while (--n >= 0) { tmp = a; a += b; b = tmp; @@ -610,7 +622,7 @@

HTML

document.writeln(fib(10)); // --> - </script> + </script> </body> </html>
@@ -632,11 +644,11 @@

HTML w/ language specified

</dl> </noscript> -<script type="text/javascript"><!-- +<script type="text/javascript"><!-- function fib(n) { var a = 1, b = 1; var tmp; - while (--n >= 0) { + while (--n >= 0) { tmp = a; a += b; b = tmp; @@ -646,12 +658,11 @@

HTML w/ language specified

document.writeln(fib(10)); // --> -</script> +</script>
- -

HTML using XMP

-HTML using &lt;XMP&gt;</h1> +<xmp class="prettyprint" id="html_xmp" ><html> <head> <title>Fibonacci number</title> @@ -695,7 +706,7 @@ <h1>XHTML</h1> &lt;head&gt; &lt;title&gt;Fibonacci number&lt;/title&gt; &lt;/head&gt; - &lt;body onload="alert(fib(10))"> + &lt;body onload="alert(fib(10))"&gt; &lt;script type="text/javascript"&gt;&lt;![CDATA[ function fib(n) { var a = 1, b = 1; @@ -714,10 +725,10 @@ <h1>XHTML</h1> </pre> <h1>PHP</h1> -<pre class="prettyprint" id="PHP"> -&lt;html> - &lt;head> - &lt;title>&lt;?= 'Fibonacci numbers' ?>&lt;/title> +<pre class="prettyprint" id="php"> +&lt;html&gt; + &lt;head&gt; + &lt;title&gt;&lt;?= 'Fibonacci numbers' ?&gt;&lt;/title&gt; &lt;?php // PHP has a plethora of comment types @@ -727,22 +738,23 @@ <h1>PHP</h1> # I don't know. $a = 1; $b = 1; - while (--$n >= 0) { + while (--$n &gt;= 0) { echo "$a\n"; $tmp = $a; $a += $b; $b = $tmp; } } - ?> - &lt;/head> - &lt;body> - &lt;?= fib(10) ?> - &lt;/body> -&lt;/html> + ?&gt; + &lt;/head&gt; + &lt;body&gt; + &lt;?= fib(10) ?&gt; + &lt;/body&gt; +&lt;/html&gt; </pre> -<h1>XSL (Issue 19)</h1> +<h1>XSL</h1> +<p><a href="https://github.com/google/code-prettify/issues/19">Issue #19</a></p> <pre class="prettyprint" id="xsl"> &lt;!-- Test elements and attributes with namespaces --&gt; @@ -754,17 +766,20 @@ <h1>XSL (Issue 19)</h1> </pre> <h1>Whitespace</h1> -<pre class=prettyprint id="whitespace"></pre> +<pre class="prettyprint" id="whitespace"></pre> <h1>Misc</h1> -<pre class=prettyprint id="misc1">// ends with line comment token +<pre class="prettyprint" id="misc1">// ends with line comment token //</pre> -<h1>User submitted testcase for Bug 4</h1> +<h1>JavaScript inside HTML &lt;SCRIPT&gt;</h1> <p> -Javascript Snippets wrapped in HTML SCRIPT tags hides/destroys inner content +<a href="https://github.com/google/code-prettify/issues/4">Issue #4</a>: +JavaScript Snippets wrapped in HTML SCRIPT tags hides/destroys inner content </p> -<pre class=prettyprint id="issue4"> +<p>The fact that the script tag was not closed properly was causing +<em>PR_splitSourceNodes</em> to end without emitting the script contents.</p> +<pre class="prettyprint" id="js_script"> &lt;script type="text/javascript"&gt; var savedTarget=null; // The target layer (effectively vidPane) var orgCursor=null; // The original mouse style so we can restore it @@ -776,70 +791,72 @@ <h1>User submitted testcase for Bug 4</h1> vidPaneID.style.left='75px'; // Starting location verticle &lt;script&gt; </pre> -<p>The fact that the script tag was not closed properly was causing -PR_splitSourceNodes to end without emitting the script contents.</p> - -<h1>Bug 8 - tabs mangled</h1> -<p>If tabs are used to indent code inside &lt;pre> IE6 and 7 won't honor them -after the script runs. -Code indented with tabs will be shown aligned to the left margin instead of -the proper indenting shown in Firefox. - -I'm using Revision 20 of prettify.js, IE 6.0.29.00 in English and IE -7.0.5730.11 in Spanish. -</p> -<pre class=prettyprint id="issue8"> +<h1>Tabs mangled</h1> +<p><a href="https://github.com/google/code-prettify/issues/8">Issue #8</a>: +If tabs are used to indent code inside &lt;pre&gt;, IE6 and 7 won't honor them +after the script runs.</p> +<p>Code indented with tabs will be shown aligned to the left margin instead of +the proper indenting shown in Firefox.</p> +<p>I'm using Revision 20 of prettify.js, IE 6.0.29.00 in English and IE +7.0.5730.11 in Spanish.</p> +<pre class="prettyprint" id="issue8"> <b>one</b>&#9;<b>Two</b>&#9;<b>three</b>&#9;Four&#9;<b>five</b>&#9;| Six&#9;<b>seven</b>&#9;Eight&#9;nine&#9;Ten&#9;| <b>eleven</b>&#9;Twelve&#9;<b>thirteen</b>&#9;Fourteen&#9;fifteen&#9;| </pre> -<h1>Bug 14a - does not recognize <code>&lt;br&gt;</code> as newline</h1> +<h1>Does not recognize <code>&lt;br&gt;</code> as newline</h1> +<p><a href="https://github.com/google/code-prettify/issues/14">Issue #14</a></p> <pre class="prettyprint" id="issue14a" >//comment<br />int main(int argc, char **argv) {}</pre> -<h1>Bug 14b - comments not ignored</h1> +<h1>Comments not ignored</h1> +<p><a href="https://github.com/google/code-prettify/issues/14">Issue #14</a></p> <pre class="prettyprint" id="issue14b" >&lt;!-- There's an <!-- BOO!! --><acronym title="tag soup">HTML</acronym> comment in my comment --&gt; &lt;p&gt;And another one inside the end tag&lt;/p<!-- GOTCHA!! -->&gt; </pre> -<h1>Bug 20 - missing blank lines</h1> +<h1>Missing blank lines</h1> +<p><a href="https://github.com/google/code-prettify/issues/20">Issue #20</a></p> <pre class="prettyprint" id="issue20" >&lt;html&gt; &lt;head&gt;</pre> -<h1>Bug 21 - code doesn't copy and paste well in IE</h1> +<h1>Code doesn't copy and paste well in IE</h1> +<p><a href="https://github.com/google/code-prettify/issues/21">Issue #21</a>: +To test this bug, disable overriding of <em>_pr_isIE6</em> in test_base.js +by putting <em>#testcopypaste</em> on the end of the URL and reloading the +page, then copy and paste the above into Notepad.</p> <pre class="prettyprint" id="issue21" >&lt;html&gt; &lt;head&gt; &lt;title&gt;Test&lt;/title&gt; &lt;/head&gt; &lt;/html&gt;</pre> -<p>To test this bug, disable overriding of _pr_isIE6 in test_base.js -by putting #testcopypaste on the end of the URL and reloading the -page, then copy and paste the above into Notepad.</p> -<h1>Bug 22 - Line numbers and other non-code spans in code</h1> +<h1>Line numbers and other non-code spans in code</h1> +<p><a href="https://github.com/google/code-prettify/issues/22">Issue #22</a></p> <pre class="prettyprint lang-java" id="issue22" -><span class=nocode>01: </span>// This is a line of code -<span class=nocode>02: </span>/* Multiline comments can -<span class=nocode>03: </span> * span over and around -<span class=nocode>04: </span> * line markers +><span class="nocode">01: </span>// This is a line of code +<span class="nocode">02: </span>/* Multiline comments can +<span class="nocode">03: </span> * span over and around +<span class="nocode">04: </span> * line markers <span class="nocode annot">And can even be interrupted</span> <span class="nocode annot">by inline code annotations</span> -<span class=nocode>05: </span> */ -<span class=nocode>06: </span>class MyClass extends Foo { -<span class=nocode>07: </span> public static void main(String... argv) { -<span class=nocode>08: </span> System.out.print("Hello World"); -<span class=nocode>09: </span> } -<span class=nocode>10: </span>}</pre> - -<h1>Bug 24 - Lua Syntax Highlighting</h1> -<pre class="prettyprint lang-lua" id="issue24"> +<span class="nocode">05: </span> */ +<span class="nocode">06: </span>class MyClass extends Foo { +<span class="nocode">07: </span> public static void main(String... argv) { +<span class="nocode">08: </span> System.out.print("Hello World"); +<span class="nocode">09: </span> } +<span class="nocode">10: </span>}</pre> + +<h1>Lua</h1> +<p><a href="https://github.com/google/code-prettify/issues/24">Issue #24</a></p> +<pre class="prettyprint lang-lua" id="lua"> os=require("os") math=require("math") @@ -884,16 +901,17 @@ <h1>Bug 24 - Lua Syntax Highlighting</h1> function shellsort(t, before, n) n = n or #t - if not before or before == "<" then return ssup(t, n) - elseif before == ">" then return ssdown(t, n) + if not before or before == "&lt;" then return ssup(t, n) + elseif before == "&gt;" then return ssdown(t, n) else return ssgeneral(t, n, before) end end return shellsort end</pre> -<h1>Bug 27 - VBScript w/ language specified</h1> -<pre class="prettyprint lang-vb" id="issue27"> +<h1>VBScript</h1> +<p><a href="https://github.com/google/code-prettify/issues/27">Issue #27</a></p> +<pre class="prettyprint lang-vb" id="vbs"> Imports System Class [class] @@ -945,8 +963,9 @@ <h1>Bug 27 - VBScript w/ language specified</h1> i = (0, 123, 45L, &amp;HA0I, &amp;O177S) </pre> -<h1>Bug 30 - Haskell w/ language specified</h1> -<pre class="prettyprint lang-hs" id="issue30"> +<h1>Haskell</h1> +<p><a href="https://github.com/google/code-prettify/issues/30">Issue #30</a></p> +<pre class="prettyprint lang-hs" id="haskell"> -- A comment Not(--"a comment&quot;) Also.not(--(A.comment)) @@ -962,9 +981,9 @@ <h1>Bug 30 - Haskell w/ language specified</h1> instance Thingy Foo where a = b -data Foo :: (* -> * -> *) -&gt; * > * -> * where +data Foo :: (* -&gt; * -&gt; *) -&gt; * &gt; * -&gt; * where Nil :: Foo a b c - Cons :: a b c -> Foo abc -> Foo a b c + Cons :: a b c -&gt; Foo abc -&gt; Foo a b c str = &quot;Foo\\Bar" char = 'x' @@ -975,8 +994,10 @@ <h1>Bug 30 - Haskell w/ language specified</h1> (0, 12, 0x45, 0xA7, 0o177, 0O377, 0.1, 1.0, 1e3, 0.5E-3, 1.0E+45) </pre> -<h1>Bug 33 - OCaml and F#</h1> -<pre class="prettyprint lang-ml" id="issue33"> +<h1>OCaml and F#</h1> +<p><a href="https://github.com/google/code-prettify/issues/33">Issue #33</a></p> +<p>TODO: handle nested <code>(* (* comments *) *)</code> properly.</p> +<pre class="prettyprint lang-ml" id="ml"> (* * Print the 10th fibonacci number *) @@ -987,8 +1008,8 @@ <h1>Bug 33 - OCaml and F#</h1> #if fibby let - rec fib = function (0, a, _) -> a - | (n, a, b) -> fib(n - 1, a + b, a) + rec fib = function (0, a, _) -&gt; a + | (n, a, b) -&gt; fib(n - 1, a + b, a) in print_int(fib(10, 1, 1));; #endif @@ -997,10 +1018,10 @@ <h1>Bug 33 - OCaml and F#</h1> let f' x' = x' + 1 </pre> -<p>Still TODO: handle nested <code>(* (* comments *) *)</code> properly.</p> -<h1>Bug 42 - Lisp Syntax Highlighting</h1> -<pre class="prettyprint lang-el" id="issue42" +<h1>Lisp</h1> +<p><a href="https://github.com/google/code-prettify/issues/42">Issue #42</a></p> +<pre class="prettyprint lang-el" id="lisp" >; -*- mode: lisp -*- (defun back-six-lines () (interactive) (forward-line -6)) @@ -1042,7 +1063,8 @@ <h1>Bug 42 - Lisp Syntax Highlighting</h1> (define (sqt x) (sqrt-iter 1.0 2.0 x)) </pre> -<h1>Bug 45 - Square brackets in strings</h1> +<h1>Square brackets in strings</h1> +<p><a href="https://github.com/google/code-prettify/issues/45">Issue #45</a></p> <pre class="prettyprint" id="issue45"> throw new RuntimeException("Element [" + element.getName() + "] missing attribute."); @@ -1067,7 +1089,7 @@ <h1>Protocol Buffers</h1> optional Corpus corpus = 4 [default = UNIVERSAL]; }</pre> -<h1>Wiki syntax w/ language specified</h1> +<h1>Wiki Syntax</h1> <pre class="prettyprint lang-wiki" id="wiki"> #summary hello world #labels HelloWorld WikiWord Hiya @@ -1120,9 +1142,10 @@ <h1>CSS w/ language specified</h1> --&gt; </pre> -<h1>Issue 79 CSS highlighting</h1> -<pre class="prettyprint" id="issue79"> -&lt;style type='text/css'> +<h1>CSS inside HTML &lt;STYLE&gt;</h1> +<p><a href="https://github.com/google/code-prettify/issues/79">Issue #79</a></p> +<pre class="prettyprint" id="css_style"> +&lt;style type='text/css'&gt; /* desert scheme ported from vim to google prettify */ code.prettyprint { display: block; padding: 2px; border: 1px solid #888; background-color: #333; } @@ -1137,27 +1160,36 @@ <h1>Issue 79 CSS highlighting</h1> .atn { color: #bdb76b; font-weight: bold; } /* attribute name - khaki*/ .atv { color: #ffa0a0; } /* attribute value - pink */ .dec { color: #98fb98; } /* decimal - lightgreen */ -&lt;/style> +&lt;/style&gt; </pre> -<h1>Issue 84 NBSPs</h1> +<h1>NBSPs</h1> +<p><a href="https://github.com/google/code-prettify/issues/84">Issue #84</a></p> <pre class="prettyprint lang-java" id="issue84">super("&amp;nbsp;");</pre> -<h1>Issue 86</h1> +<h1>Line breaks and preformatted style</h1> +<p><a href="https://github.com/google/code-prettify/issues/86">Issue #86</a></p> +<p>CODE tag</p> <p><code class="prettyprint" id="issue86_0">#One Two words</code></p> +<p>CODE tag with preformatted style</p> <p><code class="prettyprint known_ie6_failure" id="issue86_1" style="white-space: pre">#One Two lines</code></p> +<p>PRE tag</p> <pre class="prettyprint" id="issue86_2">#One Two lines</pre> +<p>PRE+CODE tag</p> <pre><code class="prettyprint known_ie6_failure" id="issue86_3">#One Two lines</code></pre> +<p>XMP tag</p> <xmp class="prettyprint" id="issue86_4">#One Two lines +

CODE tag with BR line break

#One
Two lines

-

Issue 92 -- capital letters in tag names

+

Capital letters in tag names

+

Issue #92

 <?xml version="1.0" encoding="UTF-8"?>
 <kml xmlns="http://www.opengis.net/kml/2.2">
@@ -1172,15 +1204,16 @@ 

Issue 92 -- capital letters in tag names

</kml>
-

Issue 93 -- C# verbatim strings

-
+

C# verbatim strings

+

Issue #93

+
 // The normal string syntax
 string a = "C:\\";
 // is equivalent to a verbatim string
 string b = @"C:\";
 
-

VHDL mode

+

VHDL

 library ieee;
 use ieee.std_logic_1164.all;
@@ -1211,7 +1244,7 @@ 

VHDL mode

dummy_p : process (clk_i) begin if b_i = 1 then - c_o <= (others => '0'); + c_o <= (others => '0'); elsif rising_edge(clk_i) then c_o <= "1011" & bar_s(1 downto 0); end if; @@ -1220,7 +1253,7 @@

VHDL mode

end architecture foo_architecture;
-

YAML mode

+

YAML

 application: mirah-lang
 version: 1
@@ -1246,6 +1279,8 @@ 

YAML mode

init_params: logType: special
+ +

YAML

 %YAML 1.1
 ---
@@ -1264,7 +1299,7 @@ 

YAML mode

: !!str "value" }
-

Scala mode

+

Scala

 /* comment 1 */
 /*
@@ -1310,12 +1345,12 @@ 

Scala mode

var pongCount = 0 loop { react { - case Ping => + case Ping => if (pongCount % 1000 == 0) Console.println("Pong: ping "+pongCount) sender ! Pong pongCount = pongCount + 1 - case Stop => + case Stop => Console.println("Pong: stop") exit() } @@ -1323,7 +1358,7 @@

Scala mode

}
-

Go mode

+

Go

 package main  /* Package of which this program is part. */
 
@@ -1338,7 +1373,7 @@ 

Go mode

/* ` */ `foo /* ` /*/ */
-

Erlang mode

+

Erlang

 % Sample comment
 
@@ -1352,22 +1387,22 @@ 

Erlang mode

-define(my_macro, Variable). %% @doc My function -test(Variables, MoreVariables) -> +test(Variables, MoreVariables) -> % Inline comment {ok,Scanned,_} = my_lib:do_stuff(), - Variable = fun(V) -> {ok, V} end, + Variable = fun(V) -> {ok, V} end, try ?my_macro({value, test}) of - {value, Result, _} -> + {value, Result, _} -> {ok, Result} catch - Type:Error -> + Type:Error -> {'error', Type, Error} end.
-

Rust mode

+

Rust

 // Single line comment
 /* Multi-line (nesting not highlighted properly, sorry)
@@ -1399,1731 +1434,5 @@ 

Rust mode

}
-Test IE by copy/pasting content here. - - - - diff --git a/tests/prettify_test.js b/tests/prettify_test.js new file mode 100644 index 00000000..9d40aa7b --- /dev/null +++ b/tests/prettify_test.js @@ -0,0 +1,1782 @@ +/** + * maps ids of rewritten code to the expected output. + * For brevity, has been changed to `FOO + * and < /span> has been changed to `END. + */ +var goldens = { + bash: ( + '`COM#!/bin/bash`END`PLN\n' + + '\n' + + '`END`COM# Fibonacci numbers`END`PLN\n' + + '`END`COM# Writes an infinite series to stdout, one entry per line`END' + + '`PLN\n' + + '`END`KWDfunction`END`PLN fib`END`PUN()`END`PLN `END`PUN{`END`PLN\n' + + ' `END`KWDlocal`END`PLN a`END`PUN=`END`LIT1`END`PLN\n' + + ' `END`KWDlocal`END`PLN b`END`PUN=`END`LIT1`END`PLN\n' + + ' `END`KWDwhile`END`PLN `END`KWDtrue`END`PLN `END`PUN;`END' + + '`PLN `END`KWDdo`END`PLN\n' + + ' echo $a\n' + + ' `END`KWDlocal`END`PLN tmp`END`PUN=`END`PLN$a\n' + + ' a`END`PUN=`END`PLN$`END`PUN((`END`PLN $a `END`PUN+`END' + + '`PLN $b `END`PUN))`END`PLN\n' + + ' b`END`PUN=`END`PLN$tmp\n' + + ' `END`KWDdone`END`PLN\n' + + '`END`PUN}`END`PLN\n' + + '\n' + + '`END`COM# output the 10th element of the series and halt`END`PLN\n' + + 'fib `END`PUN|`END`PLN head `END`PUN-`END`LIT10`END`PLN `END`PUN|`END' + + '`PLN tail `END`PUN-`END`LIT1`END' + ), + bash_lang: ( + '
    `#`COM#!/bin/bash`END' + + '`#1`PLN `END' + + '`#2`COM# Fibonacci numbers`END' + + '`#3`COM# Writes an infinite series to stdout, one entry per line`END' + + '`#4`KWDfunction`END`PLN fib`END`PUN()`END`PLN `END`PUN{`END' + + '`#5`PLN `END`KWDlocal`END`PLN a`END`PUN=`END`LIT1`END' + + '`#6`PLN `END`KWDlocal`END`PLN b`END`PUN=`END`LIT1`END' + + '`#7`PLN `END`KWDwhile`END`PLN true `END`PUN;`END' + + '`PLN `END`KWDdo`END' + + '`#8`PLN echo $a`END' + + '`#9`PLN `END`KWDlocal`END`PLN tmp`END`PUN=`END`PLN$a`END' + + '`#0`PLN a`END`PUN=`END`PLN$`END`PUN((`END`PLN $a `END`PUN+`END' + + '`PLN $b `END`PUN))`END' + + '`#1`PLN b`END`PUN=`END`PLN$tmp`END' + + '`#2`PLN `END`KWDdone`END' + + '`#3`PUN}`END' + + '`#4`PLN `END' + + '`#5`COM# output the 10th element of the series and halt`END' + + '`#6`PLNfib `END`PUN|`END`PLN `END`PUN/`END`PLNusr`END`PUN/`END`PLNbin`END' + + '`PUN/*`END`PLNhead `END`PUN-`END`LIT10`END`PLN `END`PUN|`END' + + '`PLN tail `END`PUN-`END`LIT1`END
' + ), + issue_165: ( + '`COM# Comment`END`PLN\n' + + '`END`KWDlocal`END`PLN $x `END`PUN=`END`PLN $`END`PUN{#`END`PLNx`END`PUN[@]}`END`PLN `END' + + '`COM# Previous is not a comment`END`PLN\n' + + '`END`COM# A comment`END' + ), + c: ( + '`COM#include`END`PLN `END`STR<stdio.h>`END`PLN\n' + + '\n' + + '`END`COM/* the n-th fibonacci number.\n' + + ' *\/`END`PLN\n' + + '`END`KWDunsigned`END`PLN `END`KWDint`END`PLN fib`END`PUN(`END' + + '`KWDunsigned`END`PLN `END`KWDint`END`PLN n`END`PUN)`END`PLN `END' + + '`PUN{`END`PLN\n' + + ' `END`KWDunsigned`END`PLN `END`KWDint`END`PLN a `END`PUN=`END' + + '`PLN `END`LIT1`END`PUN,`END`PLN b `END`PUN=`END`PLN `END`LIT1`END' + + '`PUN;`END`PLN\n' + + ' `END`KWDunsigned`END`PLN `END`KWDint`END`PLN tmp`END`PUN;`END' + + '`PLN\n' + + ' `END`KWDwhile`END`PLN `END`PUN(--`END`PLNn `END`PUN>=`END' + + '`PLN `END`LIT0`END`PUN)`END`PLN `END`PUN{`END`PLN\n' + + ' tmp `END`PUN=`END`PLN a`END`PUN;`END`PLN\n' + + ' a `END`PUN+=`END`PLN b`END`PUN;`END`PLN\n' + + ' b `END`PUN=`END`PLN tmp`END`PUN;`END`PLN\n' + + ' `END`PUN}`END`PLN\n' + + ' `END`KWDreturn`END`PLN a`END`PUN;`END`PLN\n' + + '`END`PUN}`END`PLN\n' + + '\n' + + 'main`END`PUN()`END`PLN `END`PUN{`END`PLN\n' + + ' printf`END`PUN(`END`STR"%u"`END`PUN,`END`PLN fib`END`PUN(`END' + + '`LIT10`END`PUN));`END`PLN\n' + + '`END`PUN}`END' + ), + c_lang: ( + '`COM#include`END`PLN `END`STR<stdio.h>`END`PLN\n' + + '\n' + + '`END`COM/* the n`END`COMth`END<\/sup>`COM fibonacci number. *\/`END`PLN\n' + + '`END`TYPuint32`END`PLN fib`END`PUN(`END' + + '`KWDunsigned`END`PLN `END`TYPint`END`PLN n`END`PUN)`END`PLN `END' + + '`PUN{`END`PLN\n' + + ' `END`TYPuint32`END`PLN a `END`PUN=`END`PLN `END`LIT1`END`PUN,`END' + + '`PLN b `END`PUN=`END`PLN `END`LIT1`END`PUN;`END`PLN\n' + + ' `END`TYPuint32`END`PLN tmp`END`PUN;`END`PLN\n' + + ' `END`KWDwhile`END`PLN `END`PUN(--`END`PLNn `END`PUN>=`END' + + '`PLN `END`LIT0`END`PUN)`END`PLN `END`PUN{`END`PLN\n' + + ' tmp `END`PUN=`END`PLN a`END`PUN;`END`PLN\n' + + ' a `END`PUN+=`END`PLN b`END`PUN;`END`PLN\n' + + ' b `END`PUN=`END`PLN tmp`END`PUN;`END`PLN\n' + + ' `END`PUN}`END`PLN\n' + + ' `END`KWDreturn`END`PLN a`END`PUN;`END`PLN\n' + + '`END`PUN}`END`PLN\n' + + '\n' + + '`END`KWDvoid`END`PLN main`END`PUN()`END`PLN `END`PUN{`END`PLN\n' + + ' `END`TYPsize_t`END`PLN size `END`PUN=`END`PLN `END`KWDsizeof`END' + + '`PUN(`END`TYPwchar_t`END`PUN);`END`PLN\n' + + ' ASSERT_EQ`END`PUN(`END`PLNsize`END`PUN,`END`PLN `END`LIT1`END' + + '`PUN);`END`PLN\n' + + ' printf`END`PUN(`END`STR"%u"`END`PUN,`END`PLN fib`END`PUN(`END' + + '`LIT10`END`PUN));`END`PLN\n' + + '`END`PUN}`END`PLN\n' + + '\n' + + '`END`COM#define`END`PLN ZERO `END`LIT0`END`PLN `END`COM/* a\n' + + ' multiline comment *\/`END' + ), + cpp: ( + '`COM#include`END`PLN `END`STR<iostream>`END`PLN\n' + + '\n' + + '`END`KWDusing`END`PLN `END`KWDnamespace`END`PLN std`END`PUN;`END' + + '`PLN\n' + + '\n' + + '`END`COM//! fibonacci numbers with gratuitous use of templates.`END' + + '`PLN\n' + + '`END`COM//! \\param n an index into the fibonacci series`END`PLN\n' + + '`END`COM//! \\param fib0 element 0 of the series`END`PLN\n' + + '`END`COM//! \\return the nth element of the fibonacci series`END' + + '`PLN\n' + + '`END`KWDtemplate`END`PLN `END`PUN<`END`KWDclass`END`PLN T`END' + + '`PUN>`END`PLN\n' + + 'T fib`END`PUN(`END`KWDunsigned`END`PLN `END`KWDint`END`PLN n`END' + + '`PUN,`END`PLN `END`KWDconst`END`PLN T`END`PUN&`END`PLN fib0' + + '`END`PUN)`END`PLN `END`PUN{`END`PLN\n' + + ' T a`END`PUN(`END`PLNfib0`END`PUN),`END`PLN b`END`PUN(`END' + + '`PLNfib0`END`PUN);`END`PLN\n' + + ' `END`KWDfor`END`PLN `END`PUN(;`END`PLN n`END`PUN;`END' + + '`PLN `END`PUN--`END`PLNn`END`PUN)`END`PLN `END`PUN{`END`PLN\n' + + ' T tmp`END`PUN(`END`PLNa`END`PUN);`END`PLN\n' + + ' a `END`PUN+=`END`PLN b`END`PUN;`END`PLN\n' + + ' b `END`PUN=`END`PLN tmp`END`PUN;`END`PLN\n' + + ' `END`PUN}`END`PLN\n' + + ' `END`KWDreturn`END`PLN a`END`PUN;`END`PLN\n' + + '`END`PUN}`END`PLN\n' + + '\n' + + '`END`KWDint`END`PLN main`END`PUN(`END`KWDint`END`PLN argc`END' + + '`PUN,`END`PLN `END`KWDchar`END`PLN `END`PUN**`END`PLNargv`END' + + '`PUN)`END`PLN `END`PUN{`END`PLN\n' + + ' cout `END`PUN<<`END`PLN fib`END`PUN(`END`LIT10`END' + + '`PUN,`END`PLN `END`LIT1U`END`PUN);`END`PLN\n' + + '`END`PUN}`END' + ), + cpp_lang: ( + '`COM#include`END`PLN `END`STR<iostream>`END`PLN\n' + + '\n' + + '`END`KWDusing`END`PLN `END`KWDnamespace`END`PLN std`END`PUN;`END' + + '`PLN\n' + + '\n' + + '`END`COM//! fibonacci numbers with gratuitous use of templates.`END' + + '`PLN\n' + + '`END`COM//! \\param n an index into the fibonacci series`END`PLN\n' + + '`END`COM//! \\param fib0 element 0 of the series`END`PLN\n' + + '`END`COM//! \\return the nth element of the fibonacci series`END' + + '`PLN\n' + + '`END`KWDtemplate`END`PLN `END`PUN<`END`KWDclass`END`PLN T`END' + + '`PUN>`END`PLN\n' + + 'T fib`END`PUN(`END`TYPint`END`PLN n`END' + + '`PUN,`END`PLN `END`KWDconst`END`PLN T`END`PUN&`END`PLN fib0' + + '`END`PUN)`END`PLN `END`PUN{`END`PLN\n' + + ' T a`END`PUN(`END`PLNfib0`END`PUN),`END`PLN b`END`PUN(`END' + + '`PLNfib0`END`PUN);`END`PLN\n' + + ' `END`KWDwhile`END`PLN `END`PUN(--`END`PLNn `END`PUN>=`END' + + '`PLN `END`LIT0`END`PUN)`END`PLN `END`PUN{`END`PLN\n' + + ' T tmp`END`PUN(`END`PLNa`END`PUN);`END`PLN\n' + + ' a `END`PUN+=`END`PLN b`END`PUN;`END`PLN\n' + + ' b `END`PUN=`END`PLN tmp`END`PUN;`END`PLN\n' + + ' `END`PUN}`END`PLN\n' + + ' `END`KWDreturn`END`PLN a`END`PUN;`END`PLN\n' + + '`END`PUN}`END`PLN\n' + + '\n' + + '`END`TYPint`END`PLN main`END`PUN(`END`TYPint`END`PLN argc`END' + + '`PUN,`END`PLN `END`KWDchar`END`PLN `END`PUN**`END`PLNargv`END' + + '`PUN)`END`PLN `END`PUN{`END`PLN\n' + + ' cout `END`PUN<<`END`PLN fib`END`PUN(`END`LIT10`END' + + '`PUN,`END`PLN `END`LIT1U`END`PUN);`END`PLN\n' + + '`END`PUN}`END' + ), + java: ( + '`KWDpackage`END`PLN foo`END`PUN;`END`PLN\n' + + '\n' + + '`END`KWDimport`END`PLN java`END`PUN.`END`PLNutil`END`PUN.`END' + + '`TYPIterator`END`PUN;`END`PLN\n' + + '\n' + + '`END`COM/**\n' + + ' * the fibonacci series implemented as an Iterable.\n' + + ' *\/`END`PLN\n' + + '`END`KWDpublic`END`PLN `END`KWDfinal`END`PLN `END`KWDclass`END' + + '`PLN `END`TYPFibonacci`END`PLN `END`KWDimplements`END`PLN `END' + + '`TYPIterable`END`PUN<`END`TYPInteger`END`PUN>`END`PLN `END`' + + 'PUN{`END`PLN\n' + + ' `END' + + '`COM/** the next and previous members of the series. *\/`END' + + '`PLN\n' + + ' `END`KWDprivate`END`PLN `END`KWDint`END`PLN a `END`PUN=`END' + + '`PLN `END`LIT1`END`PUN,`END`PLN b `END`PUN=`END`PLN `END`LIT1`END' + + '`PUN;`END`PLN\n' + + '\n' + + ' `END`LIT@Override`END`PLN\n' + + ' `END`KWDpublic`END`PLN `END`TYPIterator`END`PUN<`END' + + '`TYPInteger`END`PUN>`END`PLN iterator`END`PUN()`END`PLN `END' + + '`PUN{`END`PLN\n' + + ' `END`KWDreturn`END`PLN `END`KWDnew`END`PLN `END' + + '`TYPIterator`END`PUN<`END`TYPInteger`END`PUN>()`END`PLN `END' + + '`PUN{`END`PLN\n' + + ' `END`COM/** the series is infinite. *\/`END' + + '`PLN\n' + + ' `END`KWDpublic`END`PLN `END`KWDboolean`END' + + '`PLN hasNext`END`PUN()`END`PLN `END`PUN{`END`PLN `END' + + '`KWDreturn`END`PLN `END`KWDtrue`END`PUN;`END`PLN `END`PUN}`END' + + '`PLN\n' + + ' `END`KWDpublic`END`PLN `END`TYPInteger`END' + + '`PLN `END`KWDnext`END`PUN()`END`PLN `END`PUN{`END`PLN\n' + + ' `END`KWDint`END`PLN tmp `END`PUN=`END' + + '`PLN a`END`PUN;`END`PLN\n' + + ' a `END`PUN+=`END`PLN b`END`PUN;`END' + + '`PLN\n' + + ' b `END`PUN=`END`PLN tmp`END`PUN;`END' + + '`PLN\n' + + ' `END`KWDreturn`END`PLN a`END`PUN;`END' + + '`PLN\n' + + ' `END`PUN}`END`PLN\n' + + ' `END`KWDpublic`END`PLN `END`KWDvoid`END' + + '`PLN `END`KWDremove`END`PUN()`END`PLN `END`PUN{`END`PLN `END`KWDthrow`END' + + '`PLN `END`KWDnew`END`PLN `END' + + '`TYPUnsupportedOperationException`END`PUN();`END`PLN `END' + + '`PUN}`END`PLN\n' + + ' `END`PUN};`END`PLN\n' + + ' `END`PUN}`END`PLN\n' + + '\n' + + ' `END`COM/**\n' + + ' * the n<sup>th</sup> element of the given ' + + 'series.\n' + + ' * @throws NoSuchElementException if there are less than ' + + 'n elements in the\n' + + ' * given Iterable\'s {@link Iterable#iterator ' + + 'iterator}.\n' + + ' *\/`END`PLN\n' + + ' `END`KWDpublic`END`PLN `END`KWDstatic`END`PLN `END' + + '`PUN<`END`PLNT`END`PUN>`END`PLN\n' + + ' T nth`END`PUN(`END`KWDint`END`PLN n`END`PUN,`END`PLN `END' + + '`TYPIterable`END`PUN<`END`PLNT`END`PUN>`END' + + '`PLN iterable`END`PUN)`END`PLN `END`PUN{`END`PLN\n' + + ' `END`TYPIterator`END`PUN<?`END`PLN ' + + '`END`KWDextends`END`PLN T`END`PUN>`END`PLN it `END`PUN=`END' + + '`PLN iterable`END`PUN.`END`PLNiterator`END`PUN();`END`PLN\n' + + ' `END`KWDwhile`END`PLN `END`PUN(--`END`PLNn `END' + + '`PUN>`END`PLN `END`LIT0`END`PUN)`END`PLN `END`PUN{`END`PLN\n' + + ' it`END`PUN.`END`KWDnext`END`PUN();`END`PLN\n' + + ' `END`PUN}`END`PLN\n' + + ' `END`KWDreturn`END`PLN it`END`PUN.`END`KWDnext`END' + + '`PUN();`END`PLN\n' + + ' `END`PUN}`END`PLN\n' + + '\n' + + ' `END`KWDpublic`END`PLN `END`KWDstatic`END`PLN `END`KWDvoid`END' + + '`PLN main`END`PUN(`END`TYPString`END`PUN[]`END`PLN args`END' + + '`PUN)`END`PLN `END`PUN{`END`PLN\n' + + ' `END`TYPSystem`END`PUN.`END`KWDout`END`PUN.`END' + + '`KWDprint`END`PUN(`END`PLNnth`END`PUN(`END`LIT10`END`PUN,`END' + + '`PLN `END`KWDnew`END`PLN `END`TYPFibonacci`END`PUN()));`END' + + '`PLN\n' + + ' `END`PUN}`END`PLN\n' + + '`END`PUN}`END' + ), + java_lang: ( + '
  1. ' + + '`KWDpackage`END`PLN foo`END`PUN;`END' + + '`#2`PLN `END' + + '`#3`KWDimport`END`PLN java`END`PUN.`END`PLNutil`END`PUN.`END' + + '`TYPIterator`END`PUN;`END' + + '`#4`PLN `END' + + '`#5`COM/**`END' + + '`#6`COM * the fibonacci series implemented as an Iterable.`END' + + '`#7`COM *\/`END' + + '`#8`KWDpublic`END`PLN `END`KWDfinal`END`PLN `END`KWDclass`END' + + '`PLN `END`TYPFibonacci`END`PLN `END`KWDimplements`END`PLN `END' + + '`TYPIterable`END`PUN<`END`TYPInteger`END`PUN>`END`PLN `END`' + + 'PUN{`END' + + '`#9`PLN `END' + + '`COM/** the next and previous members of the series. *\/`END' + + '' + + '`#0`PLN `END`KWDprivate`END`PLN `END`KWDint`END`PLN a `END`PUN=`END' + + '`PLN `END`LIT1`END`PUN,`END`PLN b `END`PUN=`END`PLN `END`LIT1`END' + + '`PUN;`END' + + '`#1`PLN `END' + + '`#2`PLN `END`LIT@Override`END' + + '`#3`PLN `END`KWDpublic`END`PLN `END`TYPIterator`END`PUN<`END' + + '`TYPInteger`END`PUN>`END`PLN iterator`END`PUN()`END`PLN `END' + + '`PUN{`END' + + '`#4`PLN `END`KWDreturn`END`PLN `END`KWDnew`END`PLN `END' + + '`TYPIterator`END`PUN<`END`TYPInteger`END`PUN>()`END`PLN `END' + + '`PUN{`END' + + '`#5`PLN `END`COM/** the series is infinite. *\/`END' + + '' + + '`#6`PLN `END`KWDpublic`END`PLN `END`KWDboolean`END' + + '`PLN hasNext`END`PUN()`END`PLN `END`PUN{`END`PLN `END' + + '`KWDreturn`END`PLN `END`KWDtrue`END`PUN;`END`PLN `END`PUN}`END' + + '' + + '`#7`PLN `END`KWDpublic`END`PLN `END`TYPInteger`END' + + '`PLN next`END`PUN()`END`PLN `END`PUN{`END' + + '`#8`PLN `END`KWDint`END`PLN tmp `END`PUN=`END' + + '`PLN a`END`PUN;`END' + + '`#9`PLN a `END`PUN+=`END`PLN b`END`PUN;`END' + + '' + + '`#0`PLN b `END`PUN=`END`PLN tmp`END`PUN;`END' + + '' + + '`#1`PLN `END`KWDreturn`END`PLN a`END`PUN;`END' + + '' + + '`#2`PLN `END`PUN}`END' + + '`#3`PLN `END`KWDpublic`END`PLN `END`KWDvoid`END' + + '`PLN remove`END`PUN()`END`PLN `END`PUN{`END`PLN `END`KWDthrow`END' + + '`PLN `END`KWDnew`END`PLN `END' + + '`TYPUnsupportedOperationException`END`PUN();`END`PLN `END' + + '`PUN}`END' + + '`#4`PLN `END`PUN};`END' + + '`#5`PLN `END`PUN}`END' + + '`#6`PLN `END' + + '`#7`PLN `END`COM/**`END' + + '`#8`COM * the n<sup>th</sup> element of the given ' + + 'series.`END' + + '`#9`COM * @throws NoSuchElementException if there are less than ' + + 'n elements in the`END' + + '`#0`COM * given Iterable\'s {@link Iterable#iterator ' + + 'iterator}.`END' + + '`#1`COM *\/`END' + + '`#2`PLN `END`KWDpublic`END`PLN `END`KWDstatic`END`PLN `END' + + '`PUN<`END`PLNT`END`PUN>`END' + + '`#3`PLN T nth`END`PUN(`END`KWDint`END`PLN n`END`PUN,`END`PLN `END' + + '`TYPIterable`END`PUN<`END`PLNT`END`PUN>`END' + + '`PLN iterable`END`PUN)`END`PLN `END`PUN{`END' + + '`#4`PLN `END`TYPIterator`END`PUN<?`END`PLN `END' + + '`KWDextends`END`PLN T`END`PUN>`END`PLN in `END`PUN=`END' + + '`PLN iterable`END`PUN.`END`PLNiterator`END`PUN();`END' + + '`#5`PLN `END`KWDwhile`END`PLN `END`PUN(--`END`PLNn `END' + + '`PUN>`END`PLN `END`LIT0`END`PUN)`END`PLN `END`PUN{`END' + + '`#6`PLN in`END`PUN.`END`PLNnext`END`PUN();`END' + + '`#7`PLN `END`PUN}`END' + + '`#8`PLN `END`KWDreturn`END`PLN in`END`PUN.`END`PLNnext`END' + + '`PUN();`END' + + '`#9`PLN `END`PUN}`END' + + '`#0`PLN `END' + + '`#1`PLN `END`KWDpublic`END`PLN `END`KWDstatic`END`PLN `END`KWDvoid`END' + + '`PLN main`END`PUN(`END`TYPString`END`PUN[]`END`PLN args`END' + + '`PUN)`END`PLN `END`PUN{`END' + + '`#2`PLN `END`TYPSystem`END`PUN.`END`PLNout`END`PUN.`END' + + '`PLNprint`END`PUN(`END`PLNnth`END`PUN(`END`LIT10`END`PUN,`END' + + '`PLN `END`KWDnew`END`PLN `END`TYPFibonacci`END`PUN()));`END' + + '' + + '`#3`PLN `END`PUN}`END' + + '`#4`PUN}`END' + + '`#5`PLN `END' + + '`#6`PUN#`END`PLN not a java comment`END' + + '`#7`PUN#`END`PLN not keywords`END`PUN:`END' + + '`PLN static_cast and namespace`END
' + ), + javascript: ( + '`COM/**\n' + + ' * nth element in the fibonacci series.\n' + + ' * @param n >= 0\n' + + ' * @return the nth element, >= 0.\n' + + ' *\/`END`PLN\n' + + '`END`KWDfunction`END`PLN fib`END`PUN(`END`PLNn`END`PUN)`END`PLN `END' + + '`PUN{`END`PLN\n' + + ' `END`KWDvar`END`PLN a `END`PUN=`END`PLN `END`LIT1`END`PUN,`END' + + '`PLN b `END`PUN=`END`PLN `END`LIT1`END`PUN;`END`PLN\n' + + ' `END`KWDvar`END`PLN tmp`END`PUN;`END`PLN\n' + + ' `END`KWDwhile`END`PLN `END`PUN(--`END`PLNn `END`PUN>=`END' + + '`PLN `END`LIT0`END`PUN)`END`PLN `END`PUN{`END`PLN\n' + + ' tmp `END`PUN=`END`PLN a`END`PUN;`END`PLN\n' + + ' a `END`PUN+=`END`PLN b`END`PUN;`END`PLN\n' + + ' b `END`PUN=`END`PLN tmp`END`PUN;`END`PLN\n' + + ' `END`PUN}`END`PLN\n' + + ' `END`KWDreturn`END`PLN a`END`PUN;`END`PLN\n' + + '`END`PUN}`END`PLN\n' + + '\n' + + 'document`END`PUN.`END`PLNwrite`END`PUN(`END`PLNfib`END`PUN(`END' + + '`LIT10`END`PUN));`END' + ), + perl: ( + '`COM#!/usr/bin/perl`END`PLN\n' + + '\n' + + '`END`KWDuse`END`PLN strict`END`PUN;`END`PLN\n' + + '`END`KWDuse`END`PLN integer`END`PUN;`END`PLN\n' + + '\n' + + '`END`COM# the nth element of the fibonacci series`END`PLN\n' + + '`END`COM# param n - an int >= 0`END`PLN\n' + + '`END`COM# return an int >= 0`END`PLN\n' + + '`END`KWDsub`END`PLN fib`END`PUN(`END`PLN$`END`PUN)`END`PLN `END' + + '`PUN{`END`PLN\n' + + ' `END`KWDmy`END`PLN $n `END`PUN=`END`PLN shift`END`PUN,`END`PLN ' + + '$a `END`PUN=`END`PLN `END`LIT1`END`PUN,`END`PLN $b `END' + + '`PUN=`END`PLN `END`LIT1`END`PUN;`END`PLN\n' + + ' `END`PUN(`END`PLN$a`END`PUN,`END`PLN $b`END`PUN)`END' + + '`PLN `END`PUN=`END`PLN `END`PUN(`END`PLN$a `END`PUN+`END' + + '`PLN $b`END`PUN,`END`PLN $a`END`PUN)`END`PLN `END`KWDuntil`END' + + '`PLN `END`PUN(--`END`PLN$n `END`PUN<`END`PLN `END`LIT0`END' + + '`PUN);`END`PLN\n' + + ' `END`KWDreturn`END`PLN $a`END`PUN;`END`PLN\n' + + '`END`PUN}`END`PLN\n' + + '\n' + + '`END`KWDprint`END`PLN fib`END`PUN(`END`LIT10`END`PUN);`END' + ), + python: ( + '`COM#!/usr/bin/python2.4`END`PLN\n' + + '\n' + + '`END`KWDdef`END`PLN fib`END`PUN():`END`PLN\n' + + ' `END`STR\'\'\'\n' + + ' a generator that produces the elements of the fibonacci series' + + '\n' + + ' \'\'\'`END`PLN\n' + + '\n' + + ' a `END`PUN=`END`PLN `END`LIT1`END`PLN\n' + + ' b `END`PUN=`END`PLN `END`LIT1`END`PLN\n' + + ' `END`KWDwhile`END`PLN `END`KWDTrue`END`PUN:`END`PLN\n' + + ' a`END`PUN,`END`PLN b `END`PUN=`END`PLN a `END`PUN+`END' + + '`PLN b`END`PUN,`END`PLN a\n' + + ' `END`KWDyield`END`PLN a\n' + + '\n' + + '`END`KWDdef`END`PLN nth`END`PUN(`END`PLNseries`END`PUN,`END`PLN n`END' + + '`PUN):`END`PLN\n' + + ' `END`STR\'\'\'\n' + + ' returns the nth element of a series,\n' + + ' consuming the earlier elements of the series\n' + + ' \'\'\'`END`PLN\n' + + '\n' + + ' `END`KWDfor`END`PLN x `END`KWDin`END`PLN series`END`PUN:`END' + + '`PLN\n' + + ' n `END`PUN=`END`PLN n `END`PUN-`END`PLN `END`LIT1`END' + + '`PLN\n' + + ' `END`KWDif`END`PLN n `END`PUN<=`END`PLN `END' + + '`LIT0`END`PUN:`END`PLN `END`KWDreturn`END`PLN x\n' + + '\n' + + '`END`KWDprint`END`PLN nth`END`PUN(`END`PLNfib`END`PUN(),`END`PLN `END' + + '`LIT10`END`PUN)`END' + ), + python_lang: ( + '`COM#!/usr/bin/python2.4`END`PLN\n' + + '\n' + + '`END`KWDdef`END`PLN fib`END`PUN():`END`PLN\n' + + ' `END`STR\'\'\'\n' + + ' a generator that produces the fibonacci series\'s elements' + + '\n' + + ' \'\'\'`END`PLN\n' + + '\n' + + ' a `END`PUN=`END`PLN `END`LIT1`END`PLN\n' + + ' b `END`PUN=`END`PLN `END`LIT1`END`PLN\n' + + ' `END`KWDwhile`END`PLN `END`KWDTrue`END`PUN:`END`PLN\n' + + ' a`END`PUN,`END`PLN b `END`PUN=`END`PLN a `END`PUN+`END' + + '`PLN b`END`PUN,`END`PLN a\n' + + ' `END`KWDyield`END`PLN a\n' + + '\n' + + '`END`KWDdef`END`PLN nth`END`PUN(`END`PLNseries`END`PUN,`END`PLN n`END' + + '`PUN):`END`PLN\n' + + ' `END`STR\'\'\'\n' + + ' returns the nth element of a series,\n' + + ' consuming the series\' earlier elements.\n' + + ' \'\'\'`END`PLN\n' + + '\n' + + ' `END`KWDfor`END`PLN x `END`KWDin`END`PLN series`END`PUN:`END' + + '`PLN\n' + + ' n `END`PUN-=`END`PLN `END`LIT1`END' + + '`PLN\n' + + ' `END`KWDif`END`PLN n `END`PUN<=`END`PLN `END' + + '`LIT0`END`PUN:`END`PLN `END`KWDreturn`END`PLN x\n' + + '\n' + + '`END`KWDprint`END`PLN nth`END`PUN(`END`PLNfib`END`PUN(),`END`PLN `END' + + '`LIT10`END`PUN)`END`PLN\n' + + '\n' + + '`END`PUN/*`END`PLN `END`KWDnot`END`PLN a comment `END`KWDand`END' + + '`PLN `END`KWDnot`END`PLN keywords`END`PUN:`END' + + '`PLN null char true `END`PUN*\/`END' + ), + sql_lang: ( + '`COM/* A multi-line\n' + + ' * comment *\/`END`PLN\n' + + '`END`STR\'Another string /* Isn\\\'t a comment\'`END`PUN,`END`PLN\n' + + '`END`STR"A string *\/"`END`PLN\n' + + '`END`COM-- A line comment`END`PLN\n' + + '`END`KWDSELECT`END`PLN `END`PUN*`END`PLN `END`KWDFROM`END' + + '`PLN users `END`KWDWHERE`END`PLN id `END`KWDIN`END`PLN `END' + + '`PUN(`END`LIT1`END`PUN,`END`PLN `END`LIT2.0`END`PUN,`END`PLN `END' + + '`LIT+30e-1`END`PUN);`END`PLN\n' + + '`END`COM-- keywords are case-insensitive.`END`PLN\n' + + '`END`COM-- Note: user-table is a single identifier, not a pair of' + + ' keywords`END`PLN\n' + + '`END`KWDselect`END`PLN `END`PUN*`END`PLN `END`KWDfrom`END' + + '`PLN user-table `END`KWDwhere`END`PLN id `END`KWDin`END`PLN `END' + + '`PUN(`END`PLNx`END`PUN,`END`PLN y`END`PUN,`END`PLN z`END`PUN);`END' + ), + xml: ( + '`DEC<!DOCTYPE series PUBLIC "fibonacci numbers">`END`PLN\n' + + '\n' + + '`END`TAG<series.root`END`PLN `END`ATNbase`END`PUN=`END' + + '`ATV"1"`END`PLN `END' + + '`ATNstep`END`PUN=`END`ATV"s(n-2) + s(n-1)"`END`TAG>`END' + + '`PLN\n' + + ' `END`TAG<element`END`PLN `END`ATNi`END`PUN=`END' + + '`ATV"0"`END' + + '`TAG>`END`PLN1`END`TAG</element>`END' + + '`PLN\n' + + ' `END`TAG<element`END`PLN `END`ATNi`END`PUN=`END' + + '`ATV"1"`END' + + '`TAG>`END`PLN1`END`TAG</element>`END' + + '`PLN\n' + + ' `END`TAG<element`END`PLN `END`ATNi`END`PUN=`END' + + '`ATV"2"`END' + + '`TAG>`END`PLN2`END`TAG</element>`END' + + '`PLN\n' + + ' `END`TAG<element`END`PLN `END`ATNi`END`PUN=`END' + + '`ATV"3"`END' + + '`TAG>`END`PLN3`END`TAG</element>`END' + + '`PLN\n' + + ' `END`TAG<element`END`PLN `END`ATNi`END`PUN=`END' + + '`ATV"4"`END' + + '`TAG>`END`PLN5`END`TAG</element>`END' + + '`PLN\n' + + ' `END`TAG<element`END`PLN `END`ATNi`END`PUN=`END' + + '`ATV"5"`END' + + '`TAG>`END`PLN8`END`TAG</element>`END' + + '`PLN\n' + + ' ...\n' + + '`END`TAG</series.root>`END' + ), + html: ( + '`TAG<html>`END`PLN\n' + + ' `END`TAG<head>`END`PLN\n' + + ' `END`TAG<title>`END`PLNFibonacci number`END' + + '`TAG</title>`END`PLN\n' + + ' `END`TAG<style>`END`COM<!--`END' + + '`PLN BODY `END`PUN{`END`PLN `END`KWDtext-decoration`END`PUN:`END' + + '`PLN blink `END`PUN}`END`PLN `END`COM-->`END`TAG</' + + 'style>`END`PLN\n' + + ' `END`TAG<script`END`PLN `END`ATNsrc`END`PUN=`END' + + '`ATV"foo.js"`END`TAG></script>`END`PLN\n' + + ' `END`TAG<script`END`PLN `END`ATNsrc`END`PUN=`END' + + '`ATV"bar.js"`END`TAG></script>`END`PLN\n' + + ' `END`TAG</head>`END`PLN\n' + + ' `END`TAG<body>`END`PLN\n' + + ' `END`TAG<noscript>`END`PLN\n' + + ' `END`TAG<dl>`END`PLN\n' + + ' `END`TAG<dt>`END' + + '`PLNFibonacci numbers`END`TAG</dt>`END' + + '`PLN\n' + + ' `END`TAG<dd>`END`PLN1`END' + + '`TAG</dd>`END`PLN\n' + + ' `END`TAG<dd>`END`PLN1`END' + + '`TAG</dd>`END`PLN\n' + + ' `END`TAG<dd>`END`PLN2`END' + + '`TAG</dd>`END`PLN\n' + + ' `END`TAG<dd>`END`PLN3`END' + + '`TAG</dd>`END`PLN\n' + + ' `END`TAG<dd>`END`PLN5`END' + + '`TAG</dd>`END`PLN\n' + + ' `END`TAG<dd>`END`PLN8`END' + + '`TAG</dd>`END`PLN\n' + + ' &hellip;\n' + + ' `END`TAG</dl>`END`PLN\n' + + ' `END`TAG</noscript>`END`PLN\n' + + '\n' + + ' `END`TAG<script`END`PLN `END`ATNtype`END`PUN=`END' + + '`ATV"text/javascript"`END`TAG>`END`PUN<!--`END`PLN\n' + + '`END`KWDfunction`END`PLN fib`END`PUN(`END`PLNn`END`PUN)`END`PLN `END' + + '`PUN{`END`PLN\n' + + ' `END`KWDvar`END`PLN a `END`PUN=`END`PLN `END`LIT1`END`PUN,`END' + + '`PLN b `END`PUN=`END`PLN `END`LIT1`END`PUN;`END`PLN\n' + + ' `END`KWDvar`END`PLN tmp`END`PUN;`END`PLN\n' + + ' `END`KWDwhile`END`PLN `END`PUN(--`END`PLNn `END`PUN>=`END' + + '`PLN `END`LIT0`END`PUN)`END`PLN `END`PUN{`END`PLN\n' + + ' tmp `END`PUN=`END`PLN a`END`PUN;`END`PLN\n' + + ' a `END`PUN+=`END`PLN b`END`PUN;`END`PLN\n' + + ' b `END`PUN=`END`PLN tmp`END`PUN;`END`PLN\n' + + ' `END`PUN}`END`PLN\n' + + ' `END`KWDreturn`END`PLN a`END`PUN;`END`PLN\n' + + '`END`PUN}`END`PLN\n' + + '\n' + + 'document`END`PUN.`END`PLNwriteln`END`PUN(`END`PLNfib`END`PUN(`END' + + '`LIT10`END`PUN));`END`PLN\n' + + '`END`COM// -->`END`PLN\n' + + ' `END`TAG</script>`END`PLN\n' + + ' `END`TAG</body>`END`PLN\n' + + '`END`TAG</html>`END' + ), + html_lang: ( + '`PLNFibonacci Numbers\n' + + '\n' + + '`END`TAG<noscript>`END`PLN\n' + + ' `END`TAG<dl`END`PLN `END`ATNstyle`END`PUN=`END' + + '`ATV"`END`KWDlist-style`END`PUN:`END`PLN disc`END`ATV"`END' + + '`TAG>`END`PLN\n' + + ' `END`TAG<dt>`END' + + '`PLNFibonacci numbers`END`TAG</dt>`END`PLN\n' + + ' `END`TAG<dd>`END`PLN1`END`TAG</dd>`END' + + '`PLN\n' + + ' `END`TAG<dd>`END`PLN1`END`TAG</dd>`END' + + '`PLN\n' + + ' `END`TAG<dd>`END`PLN2`END`TAG</dd>`END' + + '`PLN\n' + + ' `END`TAG<dd>`END`PLN3`END`TAG</dd>`END' + + '`PLN\n' + + ' `END`TAG<dd>`END`PLN5`END`TAG</dd>`END' + + '`PLN\n' + + ' `END`TAG<dd>`END`PLN8`END`TAG</dd>`END' + + '`PLN\n' + + ' &hellip;\n' + + ' `END`TAG</dl>`END`PLN\n' + + '`END`TAG</noscript>`END`PLN\n' + + '\n' + + '`END`TAG<script`END`PLN `END`ATNtype`END`PUN=`END' + + '`ATV"text/javascript"`END`TAG>`END`PUN<!--`END`PLN\n' + + '`END`KWDfunction`END`PLN fib`END`PUN(`END`PLNn`END`PUN)`END`PLN `END' + + '`PUN{`END`PLN\n' + + ' `END`KWDvar`END`PLN a `END`PUN=`END`PLN `END`LIT1`END`PUN,`END' + + '`PLN b `END`PUN=`END`PLN `END`LIT1`END`PUN;`END`PLN\n' + + ' `END`KWDvar`END`PLN tmp`END`PUN;`END`PLN\n' + + ' `END`KWDwhile`END`PLN `END`PUN(--`END`PLNn `END`PUN>=`END' + + '`PLN `END`LIT0`END`PUN)`END`PLN `END`PUN{`END`PLN\n' + + ' tmp `END`PUN=`END`PLN a`END`PUN;`END`PLN\n' + + ' a `END`PUN+=`END`PLN b`END`PUN;`END`PLN\n' + + ' b `END`PUN=`END`PLN tmp`END`PUN;`END`PLN\n' + + ' `END`PUN}`END`PLN\n' + + ' `END`KWDreturn`END`PLN a`END`PUN;`END`PLN\n' + + '`END`PUN}`END`PLN\n' + + '\n' + + 'document`END`PUN.`END`PLNwriteln`END`PUN(`END`PLNfib`END`PUN(`END' + + '`LIT10`END`PUN));`END`PLN\n' + + '`END`COM// -->`END`PLN\n' + + '`END`TAG</script>`END' + ), + html_xmp: ( + '`TAG<html>`END`PLN\n' + + ' `END`TAG<head>`END`PLN\n' + + ' `END`TAG<title>`END`PLNFibonacci number`END' + + '`TAG</title>`END`PLN\n' + + ' `END`TAG</head>`END`PLN\n' + + ' `END`TAG<body>`END`PLN\n' + + ' `END`TAG<noscript>`END`PLN\n' + + ' `END`TAG<dl>`END`PLN\n' + + ' `END`TAG<dt>`END' + + '`PLNFibonacci numbers`END`TAG</dt>`END`PLN\n' + + ' `END`TAG<dd>`END`PLN1`END' + + '`TAG</dd>`END`PLN\n' + + ' `END`TAG<dd>`END`PLN1`END' + + '`TAG</dd>`END`PLN\n' + + ' `END`TAG<dd>`END`PLN2`END' + + '`TAG</dd>`END`PLN\n' + + ' `END`TAG<dd>`END`PLN3`END' + + '`TAG</dd>`END`PLN\n' + + ' `END`TAG<dd>`END`PLN5`END' + + '`TAG</dd>`END`PLN\n' + + ' `END`TAG<dd>`END`PLN8`END' + + '`TAG</dd>`END`PLN\n' + + ' &hellip;\n' + + ' `END`TAG</dl>`END`PLN\n' + + ' `END`TAG</noscript>`END`PLN\n' + + '\n' + + ' `END`TAG<script`END`PLN `END`ATNtype`END`PUN=`END' + + '`ATV"text/javascript"`END`TAG>`END`PUN<!--`END`PLN\n' + + '`END`KWDfunction`END`PLN fib`END`PUN(`END`PLNn`END`PUN)`END`PLN `END' + + '`PUN{`END`PLN\n' + + ' `END`KWDvar`END`PLN a `END`PUN=`END`PLN `END`LIT1`END`PUN,`END' + + '`PLN b `END`PUN=`END`PLN `END`LIT1`END`PUN;`END`PLN\n' + + ' `END`KWDvar`END`PLN tmp`END`PUN;`END`PLN\n' + + ' `END`KWDwhile`END`PLN `END`PUN(--`END`PLNn `END`PUN>=`END' + + '`PLN `END`LIT0`END`PUN)`END`PLN `END`PUN{`END`PLN\n' + + ' tmp `END`PUN=`END`PLN a`END`PUN;`END`PLN\n' + + ' a `END`PUN+=`END`PLN b`END`PUN;`END`PLN\n' + + ' b `END`PUN=`END`PLN tmp`END`PUN;`END`PLN\n' + + ' `END`PUN}`END`PLN\n' + + ' `END`KWDreturn`END`PLN a`END`PUN;`END`PLN\n' + + '`END`PUN}`END`PLN\n' + + '\n' + + 'document`END`PUN.`END`PLNwriteln`END`PUN(`END`PLNfib`END`PUN(`END' + + '`LIT10`END`PUN));`END`PLN\n' + + '`END`COM// -->`END`PLN\n' + + ' `END`TAG</script>`END`PLN\n' + + ' `END`TAG</body>`END`PLN\n' + + '`END`TAG</html>`END' + ), + xhtml: ( + '`TAG<xhtml>`END`PLN\n' + + ' `END`TAG<head>`END`PLN\n' + + ' `END`TAG<title>`END' + + '`PLNFibonacci number`END`TAG</title>`END' + + '`PLN\n' + + ' `END`TAG</head>`END`PLN\n' + + ' `END`TAG<body`END`PLN `END`ATNonload`END`PUN=`END' + + '`ATV"`END`PLNalert`END`PUN(`END`PLNfib`END`PUN(`END`LIT10`END' + + '`PUN))`END`ATV"`END`TAG>`END`PLN\n' + + ' `END`TAG<script`END`PLN `END`ATNtype`END' + + '`PUN=`END`ATV"text/javascript"`END`TAG>`END' + + '`PUN<![`END`PLNCDATA`END`PUN[`END`PLN\n' + + '`END`KWDfunction`END`PLN fib`END`PUN(`END`PLNn`END`PUN)`END`PLN `END' + + '`PUN{`END`PLN\n' + + ' `END`KWDvar`END`PLN a `END`PUN=`END`PLN `END`LIT1`END`PUN,`END' + + '`PLN b `END`PUN=`END`PLN `END`LIT1`END`PUN;`END`PLN\n' + + ' `END`KWDvar`END`PLN tmp`END`PUN;`END`PLN\n' + + ' `END`KWDwhile`END`PLN `END`PUN(--`END`PLNn `END`PUN>=`END' + + '`PLN `END`LIT0`END`PUN)`END`PLN `END`PUN{`END`PLN\n' + + ' tmp `END`PUN=`END`PLN a`END`PUN;`END`PLN\n' + + ' a `END`PUN+=`END`PLN b`END`PUN;`END`PLN\n' + + ' b `END`PUN=`END`PLN tmp`END`PUN;`END`PLN\n' + + ' `END`PUN}`END`PLN\n' + + ' `END`KWDreturn`END`PLN a`END`PUN;`END`PLN\n' + + '`END`PUN}`END`PLN\n' + + '`END`PUN]]>`END`PLN\n' + + ' `END`TAG</script>`END`PLN\n' + + ' `END`TAG</body>`END`PLN\n' + + '`END`TAG</xhtml>`END' + ), + php: ( + '`TAG<html>`END`PLN\n' + + ' `END`TAG<head>`END`PLN\n' + + ' `END`TAG<title>`END`PUN<?=`END' + + '`PLN `END' + + '`STR\'Fibonacci numbers\'`END`PLN `END' + + '`PUN?>`END`TAG</title>`END`PLN\n' + + '\n' + + ' `END`PUN<?`END`PLNphp\n' + + ' `END`COM// PHP has a plethora of comment types' + + '`END`PLN\n' + + ' `END`COM\/* What is a\n' + + ' "plethora"? *\/`END`PLN\n' + + ' `END`KWDfunction`END`PLN fib`END`PUN(`END' + + '`PLN$n`END`PUN)`END`PLN `END`PUN{`END`PLN\n' + + ' `END`COM# I don\'t know.`END`PLN\n' + + ' $a `END`PUN=`END`PLN `END`LIT1`END' + + '`PUN;`END`PLN\n' + + ' $b `END`PUN=`END`PLN `END`LIT1`END' + + '`PUN;`END`PLN\n' + + ' `END`KWDwhile`END`PLN `END`PUN(--`END' + + '`PLN$n `END`PUN>=`END`PLN `END`LIT0`END`PUN)`END`PLN `END' + + '`PUN{`END`PLN\n' + + ' echo `END`STR"$a\\n"`END`PUN;`END' + + '`PLN\n' + + ' $tmp `END`PUN=`END`PLN $a`END' + + '`PUN;`END`PLN\n' + + ' $a `END`PUN+=`END`PLN $b`END' + + '`PUN;`END`PLN\n' + + ' $b `END`PUN=`END`PLN $tmp`END' + + '`PUN;`END`PLN\n' + + ' `END`PUN}`END`PLN\n' + + ' `END`PUN}`END`PLN\n' + + ' `END`PUN?>`END`PLN\n' + + ' `END`TAG</head>`END`PLN\n' + + ' `END`TAG<body>`END`PLN\n' + + ' `END`PUN<?=`END`PLN fib`END' + + '`PUN(`END`LIT10`END`PUN)`END`PLN `END`PUN?>`END`PLN\n' + + ' `END`TAG</body>`END`PLN\n' + + '`END`TAG</html>`END' + ), + xsl: ( + '`COM<!-- Test elements and attributes with namespaces -->' + + '`END`PLN\n' + + '\n' + + '`END`TAG<xsl:stylesheet`END`PLN `END`ATNxml:lang`END' + + '`PUN=`END`ATV"en"`END`TAG>`END`PLN\n' + + ' `END`TAG<xsl:template`END' + + '`PLN `END`ATNmatch`END`PUN=`END`ATV"."`END' + + '`TAG>`END`PLN\n' + + ' `END`TAG<xsl:text>`END' + + '`PLNHello World`END' + + '`TAG</xsl:text>`END`PLN\n' + + ' `END`TAG</xsl:template>`END`PLN\n' + + '`END`TAG</xsl:stylesheet>`END' + ), + whitespace: '', + misc1: ( + '`COM// ends with line comment token`END`PLN\n' + + '`END`COM//`END' + ), + js_script: ( + '`TAG<script`END`PLN `END' + + '`ATNtype`END`PUN=`END`ATV"text/javascript"`END' + + '`TAG>`END`PLN\n' + + ' var savedTarget=null' + + '; ' + + ' // The target ' + + 'layer (effectively vidPane)\n' + + ' var orgCursor=null' + + '; ' + + ' // The ' + + 'original mouse style so we can restore it\n' + + ' var dragOK=false' + + '; ' + + ' ' + + '// True if we\'re allowed to move the element under mouse' + + '\n' + + ' var dragXoffset=0' + + '; ' + + ' ' + + '// How much we\'ve moved the element on the horozontal' + + '\n' + + ' var dragYoffset=0' + + '; ' + + ' ' + + '// How much we\'ve moved the element on the verticle' + + '\n' + + ' vidPaneID = document.' + + 'getElementById(\'vidPane\');' + + ' // Our movable layer\n' + + ' vidPaneID.style.top' + + '=\'75px\'; ' + + ' // ' + + 'Starting location horozontal\n' + + ' vidPaneID.style.left' + + '=\'75px\'; ' + + ' // ' + + 'Starting location verticle\n' + + '`END`TAG<script>`END' + ), + issue8: ( + '`PLNone`END`PLN\t`END`TYPTwo`END`PLN' + + '\t`END`PLNthree`END`PLN\t`END`TYPFour' + + '`END`PLN\t`END`PLNfive`END`PLN\t' + + '`END`PUN|`END`PLN\n' + + '`END`TYPSix`END`PLN\t`END`PLNseven`END`PLN\t' + + '`END`TYPEight`END`PLN\tnine\t`END`TYPTen`END' + + '`PLN\t`END`PUN|`END`PLN\n' + + '`END`PLNeleven`END`PLN\t`END`TYPTwelve`END`PLN\t`END' + + '`PLNthirteen`END`PLN\t`END' + + '`TYPFourteen`END`PLN\tfifteen\t`END`' + + 'PUN|`END' + ), + js_regexp: ( + '`STR/foo/`END`PUN;`END`PLN `END`COM// a slash starting a line ' + + 'treated as a regexp beginning`END`PLN\n' + + '`END`STR"foo"`END`PUN.`END`PLNmatch`END`PUN(`END`STR/fo+$/`END' + + '`PUN);`END`PLN\n' + + '`END`COM// this line comment not treated as a regular expressions`END' + + '`PLN\n' + + '`END`STR"foo /bar/"`END`PUN.`END`PLNtest`END`PUN(`END`STR/"baz"/`END' + + '`PUN);`END`PLN `END`COM// test string and regexp boundaries' + + '`END`PLN\n' + + '`END`KWDvar`END`PLN division `END`PUN=`END`PLN `END' + + '`STR/\\b\\d+\\/\\d+/`END`PLNg`END`PUN;`END`PLN `END' + + '`COM// test char sets and escaping of specials`END`PLN\n' + + '`END`KWDvar`END`PLN allSpecials `END`PUN=`END`PLN `END' + + '`STR/([^\\(\\)\\[\\]\\{\\}\\-\\?\\+\\*\\.\\^\\$\\/]+)\\\\/`END' + + '`PUN;`END`PLN\n' + + '`END`KWDvar`END`PLN slashInCharset `END`PUN=`END`PLN `END' + + '`STR/[^/]/`END`PLNg`END`PUN,`END`PLN notCloseSq `END`PUN=`END' + + '`PLN `END`STR/[^\\]]/`END`PUN;`END`PLN\n' + + '\n' + + '`END`COM// test that slash used in numeric context treated as an ' + + 'operator`END`PLN\n' + + '`END`LIT1`END`PLN `END`PUN/`END`PLN `END`LIT2`END`PUN;`END`PLN\n' + + '`END`LIT1.`END`PLN `END`PUN/`END`PLN x`END`PUN;`END`PLN\n' + + 'x `END`PUN/`END`PLN y`END`PUN;`END`PLN\n' + + '`END`PUN(`END`PLNx`END`PUN)`END`PLN `END`PUN/`END`PLN y`END`PUN;`END' + + '`PLN\n' + + '`END`LIT1`END`PLN `END`COM/* foo *\/`END`PLN `END`PUN/`END`PLN `END' + + '`LIT2`END`PUN;`END`PLN\n' + + '`END`LIT1`END`PLN `END`COM/* foo *\/`END`PUN/`END`PLN `END`LIT2`END' + + '`PUN;`END`PLN\n' + + '`END`LIT1`END`PUN/`END`LIT2`END`PUN;`END`PLN\n' + + '`END`LIT1.`END`PUN/`END`PLNx`END`PUN;`END`PLN\n' + + 'x`END`PUN/`END`PLNy`END`PUN;`END`PLN\n' + + '`END`PUN(`END`PLNx`END`PUN)/`END`PLNy`END`PUN;`END`PLN\n' + + '\n' + + '`END`COM// test split over two lines. line comment should not ' + + 'fool it`END`PLN\n' + + '`END`LIT1`END`COM//`END`PLN\n' + + '`END`PUN/`END`LIT2`END`PUN;`END`PLN\n' + + '\n' + + 'x`END`PUN++/`END`PLNy`END`PUN;`END`PLN\n' + + 'x`END`PUN--/`END`PLNy`END`PUN;`END`PLN\n' + + 'x`END`PUN[`END`PLNy`END`PUN]`END`PLN `END`PUN/`END`PLN z`END`PUN;`END' + + '`PLN\n' + + 'f`END`PUN()`END`PLN `END`PUN/`END`PLN n`END`PUN;`END`PLN\n' + + '\n' + + '`END`COM// test that slash after non postfix operator is start of ' + + 'regexp`END`PLN\n' + + 'log`END`PUN(`END`STR\'matches = \'`END`PLN `END`PUN+`END`PLN `END' + + '`STR/foo/`END`PUN.`END`PLNtest`END`PUN(`END`PLNfoo`END`PUN));`END' + + '`PLN\n' + + '\n' + + '`END`COM// test keyword preceders`END`PLN\n' + + '`END`KWDreturn`END`PLN `END`STR/a regexp/`END`PUN;`END`PLN\n' + + 'division `END`PUN=`END`PLN notreturn `END`PUN/`END`PLN not_a_regexp ' + + '`END`PUN/`END`PLN `END`LIT2`END`PUN;`END`PLN `END`COM// ' + + 'keyword suffix does not match`END`PLN\n' + + '\n' + + '`END`COM// & not used as prefix operator in javascript but this ' + + 'should still work`END`PLN\n' + + '`END`PUN&`END`STR/foo/`END`PUN;`END`PLN\n' + + '\n' + + '`END`KWDextends`END`PLN `END`PUN=`END`PLN `END`STR/extends/`END' + + '`PUN;`END' + ), + js_regexp_lang: ( + '`STR/foo/`END`PUN;`END`PLN `END`COM// a slash starting a line ' + + 'treated as a regexp beginning`END`PLN\n' + + '`END`STR"foo"`END`PUN.`END`PLNmatch`END`PUN(`END`STR/fo+$/`END' + + '`PUN);`END`PLN\n' + + '`END`COM// this line comment not treated as a regular expressions`END' + + '`PLN\n' + + '`END`STR"foo /bar/"`END`PUN.`END`PLNtest`END`PUN(`END`STR/"baz"/`END' + + '`PUN);`END`PLN `END`COM// test string and regexp boundaries' + + '`END`PLN\n' + + '`END`KWDvar`END`PLN division `END`PUN=`END`PLN `END' + + '`STR/\\b\\d+\\/\\d+/`END`PLNg`END`PUN;`END`PLN `END' + + '`COM// test char sets and escaping of specials`END`PLN\n' + + '`END`KWDvar`END`PLN allSpecials `END`PUN=`END`PLN `END' + + '`STR/([^\\(\\)\\[\\]\\{\\}\\-\\?\\+\\*\\.\\^\\$\\/]+)\\\\/`END' + + '`PUN;`END`PLN\n' + + '`END`KWDvar`END`PLN slashInCharset `END`PUN=`END`PLN `END' + + '`STR/[^/]/`END`PLNg`END`PUN,`END`PLN notCloseSq `END`PUN=`END' + + '`PLN `END`STR/[^\\]]/`END`PUN;`END`PLN\n' + + '\n' + + '`END`COM// test that slash used in numeric context treated as an ' + + 'operator`END`PLN\n' + + '`END`LIT1`END`PLN `END`PUN/`END`PLN `END`LIT2`END`PUN;`END`PLN\n' + + '`END`LIT1.`END`PLN `END`PUN/`END`PLN x`END`PUN;`END`PLN\n' + + 'x `END`PUN/`END`PLN y`END`PUN;`END`PLN\n' + + '`END`PUN(`END`PLNx`END`PUN)`END`PLN `END`PUN/`END`PLN y`END`PUN;`END' + + '`PLN\n' + + '`END`LIT1`END`PLN `END`COM/* foo *\/`END`PLN `END`PUN/`END`PLN `END' + + '`LIT2`END`PUN;`END`PLN\n' + + '`END`LIT1`END`PLN `END`COM/* foo *\/`END`PUN/`END`PLN `END`LIT2`END' + + '`PUN;`END`PLN\n' + + '`END`LIT1`END`PUN/`END`LIT2`END`PUN;`END`PLN\n' + + '`END`LIT1.`END`PUN/`END`PLNx`END`PUN;`END`PLN\n' + + 'x`END`PUN/`END`PLNy`END`PUN;`END`PLN\n' + + '`END`PUN(`END`PLNx`END`PUN)/`END`PLNy`END`PUN;`END`PLN\n' + + '\n' + + '`END`COM// test split over two lines. line comment should not ' + + 'fool it`END`PLN\n' + + '`END`LIT1`END`COM//`END`PLN\n' + + '`END`PUN/`END`LIT2`END`PUN;`END`PLN\n' + + '\n' + + 'x`END`PUN++/`END`PLNy`END`PUN;`END`PLN\n' + + 'x`END`PUN--/`END`PLNy`END`PUN;`END`PLN\n' + + 'x`END`PUN[`END`PLNy`END`PUN]`END`PLN `END`PUN/`END`PLN z`END`PUN;`END' + + '`PLN\n' + + 'f`END`PUN()`END`PLN `END`PUN/`END`PLN n`END`PUN;`END`PLN\n' + + '\n' + + '`END`COM// test that slash after non postfix operator is start of ' + + 'regexp`END`PLN\n' + + 'log`END`PUN(`END`STR\'matches = \'`END`PLN `END`PUN+`END`PLN `END' + + '`STR/foo/`END`PUN.`END`PLNtest`END`PUN(`END`PLNfoo`END`PUN));`END' + + '`PLN\n' + + '\n' + + '`END`COM// test keyword preceders`END`PLN\n' + + '`END`KWDreturn`END`PLN `END`STR/a regexp/`END`PUN;`END`PLN\n' + + 'division `END`PUN=`END`PLN notreturn `END`PUN/`END`PLN not_a_regexp ' + + '`END`PUN/`END`PLN `END`LIT2`END`PUN;`END`PLN `END`COM// ' + + 'keyword suffix does not match`END`PLN\n' + + '\n' + + '`END`COM// & not used as prefix operator in javascript but this ' + + 'should still work`END`PLN\n' + + '`END`PUN&`END`STR/foo/`END`PUN;`END`PLN\n' + + '\n' + + 'extends `END`PUN=`END`PLN `END`STR/extends/`END`PUN;`END' + ), + coffee: ( + '`KWDclass`END`PLN `END`TYPAnimal`END`PLN\n' + + ' constructor`END`PUN:`END`PLN `END`PUN(`END`LIT@name`END`PUN)`END`PLN `END`PUN->`END`PLN\n' + + ' move`END`PUN:`END`PLN `END`PUN(`END`PLNmeters`END`PUN,`END`PLN loc`END`PUN)`END`PLN `END`PUN->`END`PLN\n' + + ' alert `END`LIT@name`END`PLN `END`PUN+`END`PLN `END`STR" moved "`END`PLN `END`PUN+`END`PLN meters `END`PUN+`END`PLN `END`STR"m."`END`PLN\n' + + ' travel`END`PUN:`END`PLN `END`PUN(`END`PLNpath`END`PUN...)`END`PLN `END`PUN->`END`PLN\n' + + ' `END`KWDfor`END`PLN place `END`KWDin`END`PLN path\n' + + ' `END`LIT@move`END`PLN place`END`PUN.`END`PLNdistance`END`PUN,`END`PLN place`END`PUN.`END`PLNlocation\n' + + '\n' + + '`END`KWDclass`END`PLN `END`TYPHorse`END`PLN `END`KWDextends`END`PLN `END`TYPAnimal`END`PLN\n' + + ' `END`COM###\n' + + ' @param name Horse name\n' + + ' @param jumper Jumping ability\n' + + ' ###`END`PLN\n' + + ' constructor`END`PUN:`END`PLN `END`PUN(`END`PLNname`END`PUN,`END`PLN jumper`END`PUN)`END`PLN `END`PUN->`END`PLN\n' + + ' `END`KWDsuper`END`PLN name\n' + + ' `END`LIT@capable`END`PLN `END`PUN=`END`PLN jumper\n' + + ' step`END`PUN:`END`PLN `END`PUN->`END`PLN\n' + + ' alert `END`STR\'\'\'\n' + + ' Step,\n' + + ' step...\n' + + ' \'\'\'`END`PLN\n' + + ' jump`END`PUN:`END`PLN `END`PUN->`END`PLN\n' + + ' `END`LIT@capable`END`PLN\n' + + ' move`END`PUN:`END`PLN `END`PUN(`END`PLNmeters`END`PUN,`END`PLN where`END`PUN)`END`PLN `END`PUN->`END`PLN\n' + + ' switch where\n' + + ' `END`KWDwhen`END`PLN `END`STR"ground"`END`PLN\n' + + ' `END`LIT@step`END`PUN()`END`PLN\n' + + ' `END`KWDsuper`END`PLN meters\n' + + ' `END`KWDwhen`END`PLN `END`STR"hurdle"`END`PLN\n' + + ' `END`KWDsuper`END`PLN meters `END`KWDif`END`PLN `END`LIT@jump`END`PUN()`END`PLN\n' + + '\n' + + '`END`COM# Create horse`END`PLN\n' + + 'tom `END`PUN=`END`PLN `END`KWDnew`END`PLN `END`TYPHorse`END`PLN `END`STR"Tommy"`END`PUN,`END`PLN `END`KWDyes`END`PLN\n' + + '\n' + + 'street `END`PUN=`END`PLN\n' + + ' location`END`PUN:`END`PLN `END`STR"ground"`END`PLN\n' + + ' distance`END`PUN:`END`PLN `END`LIT12`END`PLN\n' + + 'car `END`PUN=`END`PLN\n' + + ' location`END`PUN:`END`PLN `END`STR"hurdle"`END`PLN\n' + + ' distance`END`PUN:`END`PLN `END`LIT2`END`PLN\n' + + '\n' + + '`END`COM###\n' + + 'Tell him to travel:\n' + + '1. through the street\n' + + '2. over the car\n' + + '###`END`PLN\n' + + 'tom`END`PUN.`END`PLNtravel street`END`PUN,`END`PLN car`END' + ), + issue14a: ( + '`COM//comment`END
' + + '`KWDint`END`PLN main`END`PUN(`END`KWDint`END`PLN argc`END`PUN,`END' + + '`PLN `END`KWDchar`END`PLN `END`PUN**`END`PLNargv`END`PUN)`END' + + '`PLN\n' + + '`END`PUN{}`END' + ), + issue14b: ( + '`COM<!-- There\'s an `END`COMHTML`END' + + '`COM comment in my comment -->`END`PLN\n' + + '`END`TAG<p>`END' + + '`PLNAnd another one inside the end tag`END' + + '`TAG</p`END`TAG>`END' + ), + issue20: ( + '`TAG<html>`END`PLN\n' + + '\n' + + '`END`TAG<head>`END' + ), + issue21: ( + '`TAG<html>`END`PLN\n' + + ' `END`TAG<head>`END`PLN\n' + + ' `END`TAG<title>`END`PLNTest`END' + + '`TAG</title>`END`PLN\n' + + ' `END`TAG</head>`END`PLN\n' + + '`END`TAG</html>`END' + ), + issue22: ( + '01: `END`COM// This is a line of code`END`PLN\n' + + '`END02: `END`COM/* Multiline comments can\n' + + '`END03: `END`COM * span over and around\n' + + '`END04: `END`COM * line markers\n' + + '`ENDAnd can even be interrupted`END`COM\n' + + '`ENDby inline code annotations`END`COM\n' + + '`END05: `END`COM *\/`END`PLN\n' + + '`END06: `END`KWDclass`END`PLN `END`TYPMyClass`END' + + '`PLN `END`KWDextends`END`PLN `END`TYPFoo`END`PLN `END`PUN{`END' + + '`PLN\n' + + '`END07: `END`PLN `END`KWDpublic`END' + + '`PLN `END`KWDstatic`END`PLN `END`KWDvoid`END`PLN main`END`PUN(`END' + + '`TYPString`END`PUN...`END`PLN argv`END`PUN)`END`PLN `END`PUN{`END' + + '`PLN\n' + + '`END08: `END`PLN `END`TYPSystem`END' + + '`PUN.`END`PLNout`END`PUN.`END`PLNprint`END`PUN(`END' + + '`STR"Hello World"`END`PUN);`END`PLN\n' + + '`END09: `END`PLN `END`PUN}`END`PLN\n' + + '`END10: `END`PUN}`END' + ), + lua: ( + '`PLNos`END`PUN=`END`PLNrequire`END`PUN(`END`STR"os"`END`PUN)`END`PLN\n' + + 'math`END`PUN=`END`PLNrequire`END`PUN(`END`STR"math"`END`PUN)`END`PLN\n' + + '\n' + + '`END`COM-- Examples from the language reference`END`PLN\n' + + ' a `END`PUN=`END`PLN `END`STR\'alo\\n123"\'`END' + + '`PLN\n' + + ' a `END`PUN=`END`PLN `END`STR"alo\\n123\\""`END' + + '`PLN\n' + + ' a `END`PUN=`END`PLN `END' + + '`STR\'\\97lo\\10\\04923"\'`END`PLN\n' + + ' a `END`PUN=`END`PLN `END`STR[[alo\n' + + ' 123"]]`END`PLN\n' + + ' a `END`PUN=`END`PLN `END`STR[==[\n' + + ' alo\n' + + ' 123"]==]`END`PLN\n' + + '\n' + + '`END`LIT3`END`PLN `END`LIT3.0`END`PLN `END`LIT3.1416`END' + + '`PLN `END`LIT314.16e-2`END`PLN `END`LIT0.31416E1`END' + + '`PLN `END`LIT0xff`END`PLN `END`LIT0x56`END`PLN\n' + + '\n' + + '`END`COM-- Some comments that demonstrate long brackets`END`PLN\n' + + 'double_quoted `END`PUN=`END`PLN `END`STR"Not a long bracket [=["`END' + + '`PLN\n' + + '`END`COM--[=[ quoting out\n' + + ' [[ foo ]]\n' + + ' [==[does not end comment either]==]\n' + + ']=]`END`PLN\n' + + 'past_end_of_comment\n' + + '`END`COM--]=]`END`PLN\n' + + '\n' + + '`END`COM-- Example code courtesy Joseph Harmbruster`END`PLN\n' + + '`END`PUN#`END`PLN\n' + + '`END`KWDdo`END`PLN\n' + + ' `END`KWDlocal`END`PLN `END`KWDfunction`END`PLN ssgeneral`END' + + '`PUN(`END`PLNt`END`PUN,`END`PLN n`END`PUN,`END`PLN before`END' + + '`PUN)`END`PLN\n' + + ' `END`KWDfor`END`PLN _`END`PUN,`END`PLN h `END`KWDin`END' + + '`PLN ipairs`END`PUN(`END`PLNincs`END`PUN)`END`PLN `END`KWDdo`END' + + '`PLN\n' + + ' `END`KWDfor`END`PLN i `END`PUN=`END`PLN h `END' + + '`PUN+`END`PLN `END`LIT1`END`PUN,`END`PLN n `END`KWDdo`END`PLN\n' + + ' `END`KWDlocal`END`PLN v `END`PUN=`END' + + '`PLN t`END`PUN[`END`PLNi`END`PUN]`END`PLN\n' + + ' `END`KWDfor`END`PLN j `END`PUN=`END' + + '`PLN i `END`PUN-`END`PLN h`END`PUN,`END`PLN `END`LIT1`END`PUN,`END' + + '`PLN `END`PUN-`END`PLNh `END`KWDdo`END`PLN\n' + + ' `END`KWDlocal`END`PLN testval `END' + + '`PUN=`END`PLN t`END`PUN[`END`PLNj`END`PUN]`END`PLN\n' + + ' `END`KWDif`END`PLN `END`KWDnot`END' + + '`PLN before`END`PUN(`END`PLNv`END`PUN,`END`PLN testval`END' + + '`PUN)`END`PLN `END`KWDthen`END`PLN `END`KWDbreak`END`PLN `END' + + '`KWDend`END`PLN\n' + + ' t`END`PUN[`END`PLNi`END`PUN]`END' + + '`PLN `END`PUN=`END`PLN testval`END`PUN;`END`PLN i `END`PUN=`END' + + '`PLN j\n' + + ' `END`KWDend`END`PLN\n' + + ' t`END`PUN[`END`PLNi`END`PUN]`END`PLN `END' + + '`PUN=`END`PLN v\n' + + ' `END`KWDend`END`PLN \n' + + ' `END`KWDend`END`PLN\n' + + ' `END`KWDreturn`END`PLN t\n' + + ' `END`KWDend`END`PLN\n' + + '\n' + + ' `END`KWDfunction`END`PLN shellsort`END`PUN(`END`PLNt`END' + + '`PUN,`END`PLN before`END`PUN,`END`PLN n`END`PUN)`END`PLN\n' + + ' n `END`PUN=`END`PLN n `END`KWDor`END`PLN `END`PUN#`END' + + '`PLNt\n' + + ' `END`KWDif`END`PLN `END`KWDnot`END`PLN before `END' + + '`KWDor`END`PLN before `END`PUN==`END`PLN `END`STR"<"`END' + + '`PLN `END`KWDthen`END`PLN `END`KWDreturn`END`PLN ssup`END`PUN(`END' + + '`PLNt`END`PUN,`END`PLN n`END`PUN)`END`PLN\n' + + ' `END`KWDelseif`END`PLN before `END`PUN==`END`PLN `END' + + '`STR">"`END`PLN `END`KWDthen`END`PLN `END`KWDreturn`END' + + '`PLN ssdown`END`PUN(`END`PLNt`END`PUN,`END`PLN n`END`PUN)`END' + + '`PLN\n' + + ' `END`KWDelse`END`PLN `END`KWDreturn`END' + + '`PLN ssgeneral`END`PUN(`END`PLNt`END`PUN,`END`PLN n`END`PUN,`END' + + '`PLN before`END`PUN)`END`PLN\n' + + ' `END`KWDend`END`PLN\n' + + ' `END`KWDend`END`PLN\n' + + ' `END`KWDreturn`END`PLN shellsort\n' + + '`END`KWDend`END' + ), + vbs: ( + '`KWDImports`END`PLN System\n' + + '\n' + + '`END`KWDClass`END`PLN [class]\n' + + ' `END`KWDShared`END`PLN `END`KWDSub`END`PLN [shared]`END' + + '`PUN(`END`KWDByVal`END`PLN [boolean] `END`KWDAs`END`PLN `END' + + '`KWDBoolean`END`PUN)`END`PLN\n' + + ' `END`KWDIf`END`PLN [boolean] `END' + + '`KWDThen`END`PLN\n' + + ' Console`END`PUN.`END' + + '`PLNWriteLine`END`PUN(`END`STR"true"`END`PUN)`END`PLN\n' + + ' `END`KWDElse`END`PLN\n' + + ' Console`END`PUN.`END' + + '`PLNWriteLine`END`PUN(`END`STR"false"`END`PUN)`END`PLN\n' + + ' `END`KWDEnd`END`PLN `END`KWDIf`END' + + '`PLN\n' + + ' `END`KWDEnd`END`PLN `END`KWDSub`END`PLN\n' + + '`END`KWDEnd`END`PLN `END`KWDClass`END`PLN\n' + + '\n' + + '`END`COM\' Comment`END`PLN\n' + + '`END`COM\u2018 Second Line comment with a smart quote _\n' + + ' continued line using VB6 syntax.`END`PLN\n' + + '`END`KWDModule`END`PLN [module]\n' + + ' `END`KWDSub`END`PLN Main`END`PUN()`END`PLN\n' + + ' [class]`END`PUN.`END`PLN[shared]`END' + + '`PUN(`END`LITTrue`END`PUN)`END`PLN\n' + + '\n' + + ' `END`COM\' This prints out: \".`END' + + '`PLN\n' + + ' Console`END`PUN.`END`PLNWriteLine`END' + + '`PUN(`END`STR""""`END`PUN)`END`PLN\n' + + '\n' + + ' `END`COM\' This prints out: a"b.`END' + + '`PLN\n' + + ' Console`END`PUN.`END`PLNWriteLine`END' + + '`PUN(`END`STR"a""b"`END`PUN)`END`PLN\n' + + '\n' + + ' `END`COM\' This prints out: a.`END' + + '`PLN\n' + + ' Console`END`PUN.`END`PLNWriteLine`END' + + '`PUN(`END`STR"a"c`END`PUN)`END`PLN\n' + + '\n' + + ' `END`COM\' This prints out: ".`END' + + '`PLN\n' + + ' Console`END`PUN.`END`PLNWriteLine`END' + + '`PUN(`END`STR""""c`END`PUN)`END`PLN\n' + + '\n' + + ' `END`COMREM an old-style comment`END`PLN\n' + + ' REMOVE`END`PUN(`END`PLNnot_a_comment`END`PUN)`END`PLN\n' + + ' `END`KWDEnd`END`PLN `END`KWDSub`END`PLN\n' + + '`END`KWDEnd`END`PLN `END`KWDModule`END`PLN\n' + + '\n' + + '`END`KWDDim`END`PLN d `END`KWDAs`END`PLN `END`KWDDate`END`PLN\n' + + 'd `END`PUN=`END`PLN `END`LIT# 8/23/1970 3:45:39AM #`END`PLN\n' + + 'd `END`PUN=`END`PLN `END`LIT# 8/23/1970 #`END`PLN\n' + + 'd `END`PUN=`END`PLN `END`LIT# 3:45:39AM #`END`PLN\n' + + 'd `END`PUN=`END`PLN `END`LIT# 3:45:39 #`END`PLN\n' + + 'd `END`PUN=`END`PLN `END`LIT# 13:45:39 #`END`PLN\n' + + 'd `END`PUN=`END`PLN `END`LIT# 13:45:39PM #`END`PLN\n' + + '\n' + + '`END`KWDDim`END`PLN n `END`KWDAs`END`PLN Float\n' + + 'n `END`PUN=`END`PLN `END`PUN(`END`LIT0.0`END`PUN,`END`PLN `END' + + '`LIT.99F`END`PUN,`END`PLN `END`LIT1.0E-2D`END`PUN,`END`PLN `END' + + '`LIT1.0E+3D`END`PUN,`END`PLN `END`LIT.5E4`END`PUN,`END`PLN `END' + + '`LIT1E3R`END`PUN,`END`PLN `END`LIT4D`END`PUN)`END`PLN\n' + + '\n' + + '`END`KWDDim`END`PLN i `END`KWDAs`END`PLN `END`KWDInteger`END`PLN\n' + + 'i `END`PUN=`END`PLN `END`PUN(`END`LIT0`END`PUN,`END`PLN `END' + + '`LIT123`END`PUN,`END`PLN `END`LIT45L`END`PUN,`END`PLN `END' + + '`LIT&HA0I`END`PUN,`END`PLN `END`LIT&O177S`END`PUN)`END' + ), + haskell: ( + '`COM-- A comment`END`PLN\n' + + 'Not`END`PUN(--`END`STR"a comment"`END`PUN)`END`PLN\n' + + 'Also.not`END`PUN(--(`END`PLNA.comment`END`PUN))`END`PLN\n' + + '\n' + + '`END`KWDmodule`END`PLN Foo`END`PUN(`END`PLNbar`END`PUN)`END`PLN `END' + + '`KWDwhere`END`PLN\n' + + '`END`KWDimport`END`PLN Blah\n' + + '`END`KWDimport`END`PLN BlahBlah`END`PUN(`END`PLNblah`END`PUN)`END' + + '`PLN\n' + + '`END`KWDimport`END`PLN Monads`END`PUN(`END`PLNException`END' + + '`PUN(..),`END`PLN FIO`END`PUN(..),`END`PLNunFIO`END`PUN,`END' + + '`PLNhandle`END`PUN,`END`PLNrunFIO`END`PUN,`END`PLNfixFIO`END' + + '`PUN,`END`PLNfio`END`PUN,`END`PLN\n' + + ' write`END`PUN,`END' + + '`PLNwriteln`END`PUN,`END`PLNHasNext`END`PUN(..),`END' + + '`PLNHasOutput`END`PUN(..))`END`PLN\n' + + '\n' + + '`END`COM{- nested comments\n' + + ' - don\'t work {-yet-}`END`PLN `END`PUN-}`END`PLN\n' + + '`END`KWDinstance`END`PLN Thingy Foo `END`KWDwhere`END`PLN\n' + + ' a `END`PUN=`END`PLN b\n' + + '\n' + + '`END`KWDdata`END`PLN Foo `END`PUN::`END`PLN `END`PUN(*`END`PLN `END' + + '`PUN->`END`PLN `END`PUN*`END`PLN `END`PUN->`END`PLN `END' + + '`PUN*)`END`PLN `END`PUN->`END`PLN `END`PUN*`END`PLN `END' + + '`PUN>`END`PLN `END`PUN*`END`PLN `END`PUN->`END`PLN `END' + + '`PUN*`END`PLN `END`KWDwhere`END`PLN\n' + + ' Nil `END`PUN::`END`PLN Foo a b c\n' + + ' Cons `END`PUN::`END`PLN a b c `END`PUN->`END' + + '`PLN Foo abc `END`PUN->`END`PLN Foo a b c\n' + + '\n' + + 'str `END`PUN=`END`PLN `END`STR"Foo\\\\Bar"`END`PLN\n' + + 'char `END`PUN=`END`PLN `END`STR\'x\'`END`PLN\n' + + 'Not.A.Char `END`PUN=`END`PLN `END`STR\'t`END`PLNoo long\' `END' + + '`COM-- Don\'t barf. Show that \'t is a lexical error.`END' + + '`PLN\n' + + '\n' + + '`END`PUN(`END`PLNident`END`PUN,`END`PLN ident\'`END`PUN,`END' + + '`PLN Fo\'\'o.b\'ar`END`PUN)`END`PLN\n' + + '\n' + + '`END`PUN(`END`LIT0`END`PUN,`END`PLN `END`LIT12`END`PUN,`END`PLN `END' + + '`LIT0x45`END`PUN,`END`PLN `END`LIT0xA7`END`PUN,`END`PLN `END' + + '`LIT0o177`END`PUN,`END`PLN `END`LIT0O377`END`PUN,`END`PLN `END' + + '`LIT0.1`END`PUN,`END`PLN `END`LIT1.0`END`PUN,`END`PLN `END' + + '`LIT1e3`END`PUN,`END`PLN `END`LIT0.5E-3`END`PUN,`END`PLN `END' + + '`LIT1.0E+45`END`PUN)`END' + ), + ml: ( + '`COM(*\n' + + ' * Print the 10th fibonacci number\n' + + ' *)`END`PLN\n' + + '\n' + + '`END`COM//// A line comment`END`PLN\n' + + '`END`STR"A string"`END`PUN;;`END`PLN\n' + + '`END`PUN(`END`LIT0`END`PUN,`END`PLN `END`LIT125`END`PUN,`END' + + '`PLN `END`LIT0xa0`END`PUN,`END`PLN `END`LIT-1.0`END`PUN,`END' + + '`PLN `END`LIT1e6`END`PUN,`END`PLN `END`LIT1.2e-3`END`PUN);;`END' + + '`PLN `END`COM// number literals`END`PLN\n' + + '\n' + + '`END`COM#if fibby`END`PLN\n' + + ' `END`KWDlet`END`PLN\n' + + ' `END`KWDrec`END`PLN fib `END`PUN=`END`PLN `END' + + '`KWDfunction`END`PLN `END`PUN(`END`LIT0`END`PUN,`END`PLN a`END' + + '`PUN,`END`PLN _`END`PUN)`END`PLN `END`PUN->`END`PLN a\n' + + ' ' + + ' `END`PUN|`END`PLN `END`PUN(`END`PLNn`END`PUN,`END`PLN a`END' + + '`PUN,`END`PLN b`END`PUN)`END`PLN `END`PUN->`END`PLN fib`END' + + '`PUN(`END`PLNn `END`PUN-`END`PLN `END`LIT1`END`PUN,`END' + + '`PLN a `END`PUN+`END`PLN b`END`PUN,`END`PLN a`END`PUN)`END' + + '`PLN\n' + + ' `END`KWDin`END`PLN\n' + + ' print_int`END`PUN(`END`PLNfib`END`PUN(`END`LIT10`END' + + '`PUN,`END`PLN `END`LIT1`END`PUN,`END`PLN `END`LIT1`END' + + '`PUN));;`END`PLN\n' + + '`END`COM#endif`END`PLN\n' + + '\n' + + '`END`KWDlet`END`PLN zed `END`PUN=`END`PLN `END`STR\'z\'`END`PLN\n' + + '\n' + + '`END`KWDlet`END`PLN f\' x\' `END`PUN=`END`PLN x\' `END`PUN+`END`PLN `END`LIT1`END' + ), + lisp: ( + '`COM; -*- mode: lisp -*-`END`PLN\n' + + '\n' + + '`END`OPN(`END`KWDdefun`END`PLN back-six-lines `END`OPN(`END`CLO)`END' + + '`PLN `END`OPN(`END`PLNinteractive`END`CLO)`END`PLN `END`OPN(`END' + + '`PLNforward-line `END`LIT-6`END`CLO))`END`PLN\n' + + '`END`OPN(`END`KWDdefun`END`PLN forward-six-lines `END`OPN(`END' + + '`CLO)`END`PLN `END`OPN(`END`PLNinteractive`END`CLO)`END`PLN `END' + + '`OPN(`END`PLNforward-line `END`LIT6`END`CLO))`END`PLN\n' + + '\n' + + '`END`OPN(`END`PLNglobal-set-key `END`STR"\\M-l"`END`PLN `END' + + '`LIT\'goto-line`END`CLO)`END`PLN\n' + + '`END`OPN(`END`PLNglobal-set-key `END`STR"\\C-z"`END`PLN `END' + + '`LIT\'advertised-undo`END`CLO)`END`PLN\n' + + '`END`OPN(`END`PLNglobal-set-key `END`PUN[`END`PLNC-insert`END' + + '`PUN]`END`PLN `END`LIT\'clipboard-kill-ring-save`END`CLO)`END' + + '`PLN\n' + + '`END`OPN(`END`PLNglobal-set-key `END`PUN[`END`PLNS-insert`END`PUN]`END' + + '`PLN `END`LIT\'clipboard-yank`END`CLO)`END`PLN\n' + + '`END`OPN(`END`PLNglobal-set-key `END`PUN[`END`PLNC-up`END`PUN]`END' + + '`PLN `END`LIT\'back-six-lines`END`CLO)`END`PLN\n' + + '`END`OPN(`END`PLNglobal-set-key `END`PUN[`END`PLNC-down`END`PUN]`END' + + '`PLN `END`LIT\'forward-six-lines`END`CLO)`END`PLN\n' + + '\n' + + '`END`OPN(`END`KWDsetq`END`PLN visible-bell `END`KWDt`END`CLO)`END' + + '`PLN\n' + + '`END`OPN(`END`KWDsetq`END`PLN user-mail-address `END' + + '`STR"foo@bar.com"`END`CLO)`END`PLN\n' + + '`END`OPN(`END`KWDsetq`END`PLN default-major-mode `END' + + '`LIT\'text-mode`END`CLO)`END`PLN\n' + + '\n' + + '`END`OPN(`END`PLNsetenv `END`STR"TERM"`END`PLN `END' + + '`STR"emacs"`END`CLO)`END`PLN\n' + + '`END`OPN(`END`PLNc-set-offset `END`LIT\'case-label`END`PLN `END' + + '`LIT2`END`CLO)`END`PLN\n' + + '`END`OPN(`END`KWDsetq`END`PLN c-basic-offset `END`LIT2`END`CLO)`END' + + '`PLN\n' + + '`END`OPN(`END`KWDsetq`END`PLN perl-indent-level `END`LIT0x2`END`CLO)`END' + + '`PLN\n' + + '`END`OPN(`END`KWDsetq`END`PLN delete-key-deletes-forward `END`KWDt`END' + + '`CLO)`END`PLN\n' + + '`END`OPN(`END`KWDsetq`END`PLN indent-tabs-mode `END`KWDnil`END' + + '`CLO)`END`PLN\n' + + '\n' + + '`END`COM;; Text mode`END`PLN\n' + + '`END`OPN(`END`PLNadd-hook `END`LIT\'text-mode-hook`END`PLN \n' + + ' `END`LIT\'`END`OPN(`END`KWDlambda`END`PLN `END`OPN(`END' + + '`CLO)`END`PLN\n' + + ' `END`OPN(`END`PLNturn-on-auto-fill`END`CLO)`END' + + '`PLN\n' + + ' `END`CLO)`END`PLN\n' + + '`END`CLO)`END`PLN\n' + + '\n' + + '`END`COM;; Fundamental mode`END`PLN\n' + + '`END`OPN(`END`PLNadd-hook `END`LIT\'fundamental-mode-hook`END' + + '`PLN \n' + + ' `END`LIT\'`END`OPN(`END`KWDlambda`END`PLN `END`OPN(`END' + + '`CLO)`END`PLN\n' + + ' `END`OPN(`END`PLNturn-on-auto-fill`END' + + '`CLO)`END`PLN\n' + + ' `END`CLO)`END`PLN\n' + + '`END`CLO)`END`PLN\n' + + '\n' + + '`END`COM;; Define and cond are keywords in scheme`END`PLN\n' + + '`END`OPN(`END`KWDdefine`END`PLN `END`OPN(`END`PLNsqt x`END`CLO)`END' + + '`PLN `END`OPN(`END`PLNsqrt-iter `END`LIT1.0`END`PLN `END' + + '`LIT2.0`END`PLN x`END`CLO))`END' + ), + issue45: ( + '`KWDthrow`END`PLN `END`KWDnew`END`PLN `END`TYPRuntimeException`END' + + '`PUN(`END`STR"Element ["`END`PLN `END`PUN+`END`PLN element`END' + + '`PUN.`END`PLNgetName`END`PUN()`END`PLN `END`PUN+`END`PLN \n' + + ' `END`STR"] missing attribute."`END`PUN);`END`PLN\n' + + 'variable`END`PUN++;`END' + ), + proto: ( + '`KWDmessage`END`PLN `END`TYPSearchRequest`END`PLN `END`PUN{`END' + + '`PLN\n' + + ' `END`KWDrequired`END`PLN `END`TYPstring`END`PLN query `END' + + '`PUN=`END`PLN `END`LIT1`END`PUN;`END`PLN\n' + + ' `END`KWDoptional`END`PLN `END`TYPint32`END`PLN page_number `END' + + '`PUN=`END`PLN `END`LIT2`END`PUN;`END`PLN\n' + + ' `END`KWDoptional`END`PLN `END`TYPint32`END' + + '`PLN result_per_page `END`PUN=`END`PLN `END`LIT3`END`PLN `END' + + '`PUN[`END`KWDdefault`END`PLN `END`PUN=`END`PLN `END`LIT10`END' + + '`PUN];`END`PLN\n' + + ' `END`KWDenum`END`PLN `END`TYPCorpus`END`PLN `END`PUN{`END' + + '`PLN\n' + + ' UNIVERSAL `END`PUN=`END`PLN `END`LIT0`END`PUN;`END' + + '`PLN\n' + + ' WEB `END`PUN=`END`PLN `END`LIT1`END`PUN;`END`PLN\n' + + ' IMAGES `END`PUN=`END`PLN `END`LIT2`END`PUN;`END`PLN\n' + + ' LOCAL `END`PUN=`END`PLN `END`LIT3`END`PUN;`END`PLN\n' + + ' NEWS `END`PUN=`END`PLN `END`LIT4`END`PUN;`END`PLN\n' + + ' PRODUCTS `END`PUN=`END`PLN `END`LIT5`END`PUN;`END' + + '`PLN\n' + + ' VIDEO `END`PUN=`END`PLN `END`LIT6`END`PUN;`END`PLN\n' + + ' `END`PUN}`END`PLN\n' + + ' `END`KWDoptional`END`PLN `END`TYPCorpus`END`PLN corpus `END' + + '`PUN=`END`PLN `END`LIT4`END`PLN `END`PUN[`END`KWDdefault`END' + + '`PLN `END`PUN=`END`PLN UNIVERSAL`END`PUN];`END`PLN\n' + + '`END`PUN}`END' + ), + wiki: ( + '`KWD#summary`END`PLN hello world\n' + + '`END`KWD#labels`END`PLN `END`LITHelloWorld`END`PLN `END' + + '`LITWikiWord`END`PLN Hiya\n' + + '\n' + + '`END`PUN[`END' + + '`STRhttp://www.google.com/?q=WikiSyntax+site:code.google.com`END' + + '`PLN `END`LITWikiSyntax`END`PUN]`END`PLN\n' + + '\n' + + 'Lorem Ipsum ``END`KWDwhile`END`PLN `END`PUN(`END`LIT1`END' + + '`PUN)`END`PLN `END`KWDprint`END`PUN(`END`STR"blah blah"`END' + + '`PUN);`END`PLN`\n' + + '\n' + + ' `END`PUN*`END`PLN Bullet\n' + + ' `END`PUN*`END`PLN Points\n' + + ' `END`PUN*`END`PLN `END`LITNestedBullet`END' + + '`PLN\n' + + '\n' + + '`END`PUN==`END`LITDroningOnAndOn`END`PUN==`END`PLN\n' + + '{{{\n' + + ' `END`COM// Some EmbeddedSourceCode`END`PLN\n' + + ' `END`KWDvoid`END`PLN main`END`PUN()`END`PLN `END`PUN{`END' + + '`PLN\n' + + ' `END`TYPPrint`END`PUN(`END`STR\'hello world\'`END' + + '`PUN);`END`PLN\n' + + ' `END`PUN}`END`PLN\n' + + '}}}\n' + + '\n' + + '{{{\n' + + ' `END`COM<!-- Embedded XML -->`END`PLN\n' + + ' `END`TAG<foo`END`PLN `END`ATNbar`END`PUN=`END' + + '`ATV"baz"`END`TAG><boo`END`PLN `END' + + '`TAG/><foo>`END`PLN\n' + + '}}}`END' + ), + css: ( + '`COM<!--`END`PLN\n' + + '`END`KWD@charset`END`PUN(`END`STR\'UTF-8\'`END`PUN);`END`PLN\n' + + '\n' + + '`END`COM/** A url that is not quoted. *\/`END`PLN\n' + + '`END`KWD@import`END`PUN(`END`KWDurl`END`PUN(`END`STR/more-styles.css`END' + + '`PUN));`END`PLN\n' + + '\n' + + 'HTML `END`PUN{`END`PLN `END`KWDcontent-before`END`PUN:`END`PLN `END' + + '`STR\'hello\\20\'`END`PUN;`END`PLN `END`KWDcontent-after`END' + + '`PUN:`END`PLN `END`STR\'w\\6f rld\'`END`PUN;`END`PLN\n' + + ' `END`KWD-moz-spiff`END`PUN:`END`PLN `END' + + '`KWDinherit`END`PLN `END`KWD!important`END`PLN `END`PUN}`END' + + '`PLN\n' + + '\n' + + '`END`COM/* Test units on numbers. *\/`END`PLN\n' + + 'BODY `END`PUN{`END`PLN `END`KWDmargin-bottom`END`PUN:`END`PLN `END' + + '`LIT4px`END`PUN;`END`PLN `END`KWDmargin-left`END`PUN:`END' + + '`PLN `END`LIT3in`END`PUN;`END`PLN `END`KWDmargin-bottom`END' + + '`PUN:`END`PLN `END`LIT0`END`PUN;`END`PLN `END`KWDmargin-top`END' + + '`PUN:`END`PLN `END`LIT5%`END`PLN `END`PUN}`END`PLN\n' + + '\n' + + '`END`COM/** Test number literals and quoted values. *\/`END`PLN\n' + + 'TABLE`END`PUN.`END`PLNfoo TR`END`PUN.`END`PLNbar A`END`PUN#`END' + + '`PLNvisited `END`PUN{`END`PLN `END`KWDcolor`END`PUN:`END`PLN `END' + + '`LIT#001123`END`PUN;`END`PLN `END`KWDfont-family`END`PUN:`END' + + '`PLN `END`STR"monospace"`END`PLN `END`PUN}`END`PLN\n' + + '`END`COM/** bolder is not a name, so should be plain. ' + + ' !IMPORTANT is a keyword\n' + + ' * regardless of case.\n' + + ' *\/`END`PLN\n' + + 'blink `END`PUN{`END`PLN `END`KWDtext-decoration`END`PUN:`END' + + '`PLN BLINK `END`KWD!IMPORTANT`END`PUN;`END`PLN `END' + + '`KWDfont-weight`END`PUN:`END`PLN bolder `END`PUN}`END`PLN\n' + + '`END`COM/* Empty url() was causing infinite recursion */`END`PLN\n' + + 'a `END`PUN{`END`PLN `END`KWDbackground-image`END`PUN:`END`PLN ' + + '`END`KWDurl`END`PUN();`END`PLN `END`PUN}`END`PLN\n' + + 'p`END`PUN#`END`PLNfeatured`END`PUN{`END`KWDbackground`END`PUN:`END`LIT#fea`END`PUN}`END`PLN\n' + + '`END`COM-->`END' + ), + css_style: ( + '`TAG<style`END`PLN `END`ATNtype`END`PUN=`END`ATV\'text/css\'`END' + + '`TAG>`END`PLN\n' + + '`END`COM/* desert scheme ported from vim to google prettify */`END' + + '`PLN\n' + + 'code`END`PUN.`END`PLNprettyprint `END`PUN{`END`PLN `END' + + '`KWDdisplay`END`PUN:`END`PLN block`END`PUN;`END`PLN `END' + + '`KWDpadding`END`PUN:`END`PLN `END`LIT2px`END`PUN;`END`PLN `END' + + '`KWDborder`END`PUN:`END`PLN `END`LIT1px`END`PLN solid `END' + + '`LIT#888`END`PUN;`END`PLN\n' + + '`END`KWDbackground-color`END`PUN:`END`PLN `END`LIT#333`END`PUN;`END' + + '`PLN `END`PUN}`END`PLN\n' + + '`END`PUN.`END`PLNstr `END`PUN{`END`PLN `END`KWDcolor`END`PUN:`END' + + '`PLN `END`LIT#ffa0a0`END`PUN;`END`PLN `END`PUN}`END`PLN `END' + + '`COM/* string - pink */`END`PLN\n' + + '`END`PUN.`END`PLNkwd `END`PUN{`END`PLN `END`KWDcolor`END`PUN:`END' + + '`PLN `END`LIT#f0e68c`END`PUN;`END`PLN `END`KWDfont-weight`END' + + '`PUN:`END`PLN bold`END`PUN;`END`PLN `END`PUN}`END`PLN\n' + + '`END`PUN.`END`PLNcom `END`PUN{`END`PLN `END`KWDcolor`END`PUN:`END' + + '`PLN `END`LIT#87ceeb`END`PUN;`END`PLN `END`PUN}`END`PLN `END' + + '`COM/* comment - skyblue */`END`PLN\n' + + '`END`PUN.`END`PLNtyp `END`PUN{`END`PLN `END`KWDcolor`END`PUN:`END' + + '`PLN `END`LIT#98fb98`END`PUN;`END`PLN `END`PUN}`END`PLN `END' + + '`COM/* type - lightgreen */`END`PLN\n' + + '`END`PUN.`END`PLNlit `END`PUN{`END`PLN `END`KWDcolor`END`PUN:`END' + + '`PLN `END`LIT#cd5c5c`END`PUN;`END`PLN `END`PUN}`END`PLN `END' + + '`COM/* literal - darkred */`END`PLN\n' + + '`END`PUN.`END`PLNpun `END`PUN{`END`PLN `END`KWDcolor`END`PUN:`END' + + '`PLN `END`LIT#fff`END`PUN;`END`PLN `END`PUN}`END`PLN `END' + + '`COM/* punctuation */`END`PLN\n' + + '`END`PUN.`END`PLNpln `END`PUN{`END`PLN `END`KWDcolor`END`PUN:`END' + + '`PLN `END`LIT#fff`END`PUN;`END`PLN `END`PUN}`END`PLN `END' + + '`COM/* plaintext */`END`PLN\n' + + '`END`PUN.`END`PLNtag `END`PUN{`END`PLN `END`KWDcolor`END`PUN:`END' + + '`PLN `END`LIT#f0e68c`END`PUN;`END`PLN `END`KWDfont-weight`END' + + '`PUN:`END`PLN bold`END`PUN;`END`PLN `END`PUN}`END`PLN `END' + + '`COM/* html/xml tag - lightyellow*/`END`PLN\n' + + '`END`PUN.`END`PLNatn `END`PUN{`END`PLN `END`KWDcolor`END`PUN:`END' + + '`PLN `END`LIT#bdb76b`END`PUN;`END`PLN `END`KWDfont-weight`END' + + '`PUN:`END`PLN bold`END`PUN;`END`PLN `END`PUN}`END`PLN `END' + + '`COM/* attribute name - khaki*/`END`PLN\n' + + '`END`PUN.`END`PLNatv `END`PUN{`END`PLN `END`KWDcolor`END`PUN:`END' + + '`PLN `END`LIT#ffa0a0`END`PUN;`END`PLN `END`PUN}`END`PLN `END' + + '`COM/* attribute value - pink */`END`PLN\n' + + '`END`PUN.`END`PLNdec `END`PUN{`END`PLN `END`KWDcolor`END`PUN:`END' + + '`PLN `END`LIT#98fb98`END`PUN;`END`PLN `END`PUN}`END`PLN `END' + + '`COM/* decimal - lightgreen */`END`PLN\n' + + '`END`TAG</style>`END' + ), + issue84: '`KWDsuper`END`PUN(`END`STR"&nbsp;"`END`PUN);`END', + issue86_0: '`COM#One Two words`END', + issue86_1: ( + '`COM#One`END`PLN\n' + + '`END`TYPTwo`END`PLN lines`END' + ), + issue86_2: ( + '`COM#One`END`PLN\n' + + '`END`TYPTwo`END`PLN lines`END' + ), + issue86_3: ( + '`COM#One`END`PLN\n' + + '`END`TYPTwo`END`PLN lines`END' + ), + issue86_4: ( + '`COM#One`END`PLN\n' + + '`END`TYPTwo`END`PLN lines`END' + ), + issue86_5: ( + '`COM#One`END
`PLN ' + + '`END`TYPTwo`END`PLN lines`END' + ), + issue92: ( + '`PUN<?`END`PLNxml version`END`PUN=`END`STR"1.0"`END`PLN encoding`END`PUN=`END' + + '`STR"UTF-8"`END`PUN?>`END`PLN\n' + + '`END`TAG<kml`END`PLN `END`ATNxmlns`END`PUN=`END`ATV"http://www.opengis.net/kml/2.2"`END' + + '`TAG>`END`PLN\n' + + ' `END`TAG<Placemark>`END`PLN\n' + + ' `END`TAG<name>`END`PLNSimple placemark`END`TAG</name>`END`PLN\n' + + ' `END`TAG<description`END' + + '`PLN `END`ATNLang`END`PUN=`END`ATV"en"`END`TAG>`END' + + '`PLNAttached to the ground.' + + ' Intelligently places itself \n' + + ' at the height of the underlying terrain.`END' + + '`TAG</description>`END`PLN\n' + + ' `END`TAG<Point>`END`PLN\n' + + ' `END`TAG<coordinates>`END' + + '`PLN-122.0822035425683,37.42228990140251,0`END`TAG</coordinates>`END`PLN\n' + + ' `END`TAG</Point>`END`PLN\n' + + ' `END`TAG</Placemark>`END`PLN\n' + + '`END`TAG</kml>`END' + ), + cs_verbatim: ( + '`COM// The normal string syntax`END`PLN\n' + + '`END`KWDstring`END`PLN a `END`PUN=`END`PLN `END`STR"C:\\\\"`END`PUN;`END`PLN\n' + + '`END`COM// is equivalent to a verbatim string`END`PLN\n' + + '`END`KWDstring`END`PLN b `END`PUN=`END`PLN `END`STR@"C:\\"`END`PUN;`END' + ), + vhdl: ( + '`KWDlibrary`END`PLN ieee`END`PUN;`END`PLN\n' + + '`END`KWDuse`END`PLN ieee`END`PUN.`END`PLNstd_logic_1164`END`PUN.`END`KWDall`END`PUN;`END`PLN\n' + + '`END`KWDuse`END`PLN ieee`END`PUN.`END`PLNnumeric_std`END`PUN.`END`KWDall`END`PUN;`END`PLN\n' + + '\n' + + '`END`COM-- A line comment`END`PLN\n' + + '`END`KWDentity`END`PLN foo_entity `END`KWDis`END`PLN\n' + + '\n' + + ' `END`KWDgeneric`END`PLN `END`PUN(`END`COM-- comment after punc`END`PLN\n' + + ' a `END`PUN:`END`PLN `END`TYPnatural`END`PLN `END`PUN:=`END' + + '`PLN `END`LIT42`END`PUN;`END`PLN\n' + + ' x `END`PUN:`END`PLN `END`TYPreal`END`PLN `END' + + '`PUN:=`END`PLN `END`LIT16#ab.cd#-3`END`PLN\n' + + ' `END`PUN);`END`PLN\n' + + ' `END`KWDport`END`PLN `END`PUN(`END`PLN\n' + + ' clk_i `END`PUN:`END`PLN `END`KWDin`END`PLN `END`TYPstd_logic`END`PUN;`END`PLN\n' + + ' b_i `END`PUN:`END`PLN `END`KWDin`END`PLN `END`TYPnatural`END`PLN `END`KWDrange`END`PLN `END`LIT0`END`PLN `END`KWDto`END`PLN `END`LIT100`END`PUN;`END`PLN\n' + + ' c_o `END`PUN:`END`PLN `END`KWDout`END`PLN `END`TYPstd_logic_vector`END`PUN(`END`LIT5`END`PLN `END`KWDdownto`END`PLN `END`LIT0`END`PUN);`END`PLN\n' + + ' \\a "name"\\ `END`PUN:`END`PLN `END`KWDout`END`PLN `END`TYPinteger`END`PLN `END`COM-- extended identifier`END`PLN\n' + + ' `END`PUN);`END`PLN\n' + + '\n' + + '`END`KWDend`END`PLN `END`KWDentity`END`PLN foo_entity`END`PUN;`END`PLN\n' + + '\n' + + '`END`KWDarchitecture`END`PLN foo_architecture `END`KWDof`END`PLN foo_entity `END`KWDis`END`PLN\n' + + ' `END`KWDsignal`END`PLN bar_s `END`PUN:`END`PLN `END`TYPstd_logic_vector`END`PUN(`END`LIT2`END`PLN `END`KWDdownto`END`PLN `END`LIT0`END`PUN);`END`PLN\n' + + '`END`KWDbegin`END`PLN\n' + + ' \n' + + ' bar_s `END`PUN<=`END`PLN `END`STRb"101"`END`PUN;`END`PLN\n' + + '\n' + + ' dummy_p `END`PUN:`END`PLN `END`KWDprocess`END`PLN `END`PUN(`END`PLNclk_i`END`PUN)`END`PLN\n' + + ' `END`KWDbegin`END`PLN\n' + + ' `END`KWDif`END`PLN b_i `END`PUN=`END`PLN `END`LIT1`END`PLN `END`KWDthen`END`PLN\n' + + ' c_o `END`PUN<=`END`PLN `END`PUN(`END`KWDothers`END`PLN `END`PUN=>`END`PLN `END`STR\'0\'`END`PUN);`END`PLN\n' + + ' `END`KWDelsif`END`PLN rising_edge`END`PUN(`END`PLNclk_i`END`PUN)`END`PLN `END`KWDthen`END`PLN\n' + + ' c_o `END`PUN<=`END`PLN `END`STR"1011"`END`PLN `END`PUN&`END`PLN bar_s`END`PUN(`END`LIT1`END`PLN `END`KWDdownto`END`PLN `END`LIT0`END`PUN);`END`PLN\n' + + ' `END`KWDend`END`PLN `END`KWDif`END`PUN;`END`PLN\n' + + ' `END`KWDend`END`PLN `END`KWDprocess`END`PLN dummy_p`END`PUN;`END`PLN\n' + + '\n' + + '`END`KWDend`END`PLN `END`KWDarchitecture`END`PLN foo_architecture`END`PUN;`END' + ), + yaml1: ( + '`KWDapplication: `END`PLNmirah`END`PUN-`END`PLNlang\n' + + '`END`KWDversion: `END`PLN1\n' + + '\n' + + '`END`COM# Here\'s a comment`END`PLN\n' + + '`END`KWDhandlers:\n' + + '`END`PLN `END`PUN-`END`PLN `END`KWDurl: `END`PLN/red/*\n' + + ' `END`KWDservlet: `END`PLNmysite.server.TeamServlet\n' + + ' `END`KWDinit_params:\n' + + '`END`PLN `END`KWDteamColor: `END`PLNred\n' + + ' `END`KWDbgColor: `END`STR"#CC0000"`END`PLN\n' + + ' `END`KWDname: `END`PLNredteam\n' + + ' `END`PUN-`END`PLN `END`KWDurl: `END`PLN/blue/*\n' + + ' `END`KWDservlet: `END`PLNmysite.server.TeamServlet\n' + + ' `END`KWDinit_params:\n' + + '`END`PLN `END`KWDteamColor: `END`PLNblue\n' + + ' `END`KWDbgColor: `END`STR"#0000CC"`END`PLN\n' + + ' `END`KWDname: `END`PLNblueteam\n' + + ' `END`PUN-`END`PLN `END`KWDurl: `END`PLN/register/*\n' + + ' `END`KWDjsp: `END`PLN/register/start.jsp\n' + + ' `END`PUN-`END`PLN `END`KWDurl: `END`PLN*.special\n' + + ' `END`KWDfilter: `END`PLNmysite.server.LogFilterImpl\n' + + ' `END`KWDinit_params:\n' + + '`END`PLN `END`KWDlogType: `END`PLNspecial\n' + + ' `END' + ), + yaml2: ( + '`DEC%YAML 1.1`END`PLN\n' + + '`END`DEC---\n' + + '`END`TYP!!map`END`PLN {\n' + + ' `END`PUN?`END`PLN `END`TYP!!str`END`PLN `END`STR""`END`PLN\n' + + ' `END`PUN:`END`PLN `END`TYP!!str`END`PLN `END`STR"value"`END`PLN,\n' + + ' `END`PUN?`END`PLN `END`TYP!!str`END`PLN `END`STR"explicit key"`END`PLN\n' + + ' `END`PUN:`END`PLN `END`TYP!!str`END`PLN `END`STR"value"`END`PLN,\n' + + ' `END`PUN?`END`PLN `END`TYP!!str`END`PLN `END`STR"simple key"`END`PLN\n' + + ' `END`PUN:`END`PLN `END`TYP!!str`END`PLN `END`STR"value"`END`PLN,\n' + + ' `END`PUN?`END`PLN `END`TYP!!seq`END`PLN [\n' + + ' `END`TYP!!str`END`PLN `END`STR"collection"`END`PLN,\n' + + ' `END`TYP!!str`END`PLN `END`STR"simple"`END`PLN,\n' + + ' `END`TYP!!str`END`PLN `END`STR"key"`END`PLN\n' + + ' ]\n' + + ' `END`PUN:`END`PLN `END`TYP!!str`END`PLN `END`STR"value"`END`PLN\n' + + '}`END' + ), + scala: ( + '`COM/* comment 1 *\/`END`PLN\n' + + '`END`COM/*\n' + + 'comment 2\n' + + '*\/`END`PLN\n' + + '`END`COM/* comment / * comment 3 **\/`END`PLN\n' + + '`END`COM// strings`END`PLN\n' + + '`END`STR"Hello, World!"`END`PUN,`END`PLN `END`STR"\\n"`END`PUN,`END`PLN\n' + + '`END`LIT`an-identifier``END`PUN,`END`PLN `END`LIT`\\n``END`PUN,`END`PLN\n' + + '`END`STR\'A\'`END`PUN,`END`PLN `END`STR\'\\n\'`END`PUN,`END`PLN\n' + + '`END`LIT\'aSymbol`END`PUN,`END`PLN\n' + + '`END`STR"""Hello,\n' + + 'World"""`END`PUN,`END`PLN `END`STR"""Hello,\\nWorld"""`END`PUN,`END`PLN\n' + + '`END`STR"""Hello, "World"!"""`END`PUN,`END`PLN\n' + + '`END`STR"""Hello, \\"World\\""""`END`PLN\n' + + '\n' + + '`END`COM// Numbers`END`PLN\n' + + '`END`LIT0`END`PLN\n' + + '`END`LIT0123`END`PLN\n' + + '`END`LIT0xa0`END`PLN\n' + + '`END`LIT0XA0L`END`PLN\n' + + '`END`LIT123`END`PLN\n' + + '`END`LIT123.45`END`PLN\n' + + '`END`LIT1.50F`END`PLN\n' + + '`END`LIT0.50`END`PLN\n' + + '`END`PUN.`END`LIT50`END`PLN\n' + + '`END`LIT123e-1`END`PLN\n' + + '`END`LIT123.45e+1`END`PLN\n' + + '`END`LIT1.50e2`END`PLN\n' + + '`END`LIT0.50e-6`END`PLN\n' + + '`END`PUN.`END`LIT50e+42f`END`PLN\n' + + '\n' + + '`END`COM// Values`END`PLN\n' + + '`END`LITfalse`END`PUN,`END`PLN `END`LITtrue`END`PUN,`END`PLN `END`LITnull`END`PUN,`END`PLN `END`LITthis`END`PUN;`END`PLN\n' + + '\n' + + '`END`COM// Keywords`END`PLN\n' + + '`END`KWDclass`END`PLN `END`TYPMyClass`END`PUN;`END`PLN\n' + + '`END`KWDimport`END`PLN foo`END`PUN.`END`PLNbar`END`PUN;`END`PLN\n' + + '`END`KWDpackage`END`PLN baz`END`PUN;`END`PLN\n' + + '\n' + + '`END`COM// From scala-lang.org/node/242`END`PLN\n' + + '`END`KWDdef`END`PLN act`END`PUN()`END`PLN `END`PUN{`END`PLN\n' + + ' `END`KWDvar`END`PLN pongCount `END`PUN=`END`PLN `END`LIT0`END`PLN\n' + + ' loop `END`PUN{`END`PLN\n' + + ' react `END`PUN{`END`PLN\n' + + ' `END`KWDcase`END`PLN `END`TYPPing`END`PLN `END`PUN=>`END`PLN\n' + + ' `END`KWDif`END`PLN `END`PUN(`END`PLNpongCount `END`PUN%`END`PLN `END`LIT1000`END`PLN `END`PUN==`END`PLN `END`LIT0`END`PUN)`END`PLN\n' + + ' `END`TYPConsole`END`PUN.`END`PLNprintln`END`PUN(`END`STR"Pong: ping "`END`PUN+`END`PLNpongCount`END`PUN)`END`PLN\n' + + ' sender `END`PUN!`END`PLN `END`TYPPong`END`PLN\n' + + ' pongCount `END`PUN=`END`PLN pongCount `END`PUN+`END`PLN `END`LIT1`END`PLN\n' + + ' `END`KWDcase`END`PLN `END`TYPStop`END`PLN `END`PUN=>`END`PLN\n' + + ' `END`TYPConsole`END`PUN.`END`PLNprintln`END`PUN(`END`STR"Pong: stop"`END`PUN)`END`PLN\n' + + ' exit`END`PUN()`END`PLN\n' + + ' `END`PUN}`END`PLN\n' + + ' `END`PUN}`END`PLN\n' + + '`END`PUN}`END' + ), + go: ( + '`PLNpackage main `END`COM/* Package of which this program is part. *\/`END`PLN\n' + + '\n' + + 'import fmt "fmt" `END`COM// Package implementing formatted I/O.`END`PLN\n' + + '\n' + + '\n' + + 'func main() {\n' + + ' fmt.Printf("Hello, world; or \u039a\u03b1\u03bb\u03b7\u03bc\u03ad\u03c1\u03b1 \u03ba\u03cc\u03c3\u03bc\u03b5; or \u3053\u3093\u306b\u3061\u306f \u4e16\u754c\\n") `END`COM// Semicolon inserted here`END`PLN\n' + + '}\n' + + '\n' + + '`END`COM/* " *\/`END`PLN "foo /* " `END`COM/*\/ *\/`END`PLN\n' + + '`END`COM/* ` *\/`END`PLN `foo /* ` `END`COM/*\/ *\/`END' + ), + erlang: ( + '`COM% Sample comment`END`PLN\n' + + '\n' + + '`END`KWD-module`END`PLN(my_test)`END`PUN.`END`PLN\n' + + '`END`KWD-include_lib`END`PLN(`END`STR"my_sample_lib.hrl"`END`PLN)`END`PUN.`END`PLN\n' + + '`END`KWD-export`END`PLN([\n' + + ' test/`END`LIT2`END`PLN\n' + + '])`END`PUN.`END`PLN\n' + + '\n' + + '`END`COM%% @doc Define a macro`END`PLN\n' + + '`END`KWD-define`END`PLN(my_macro`END`PUN,`END`PLN `END`TYPVariable`END`PLN)`END`PUN.`END`PLN\n' + + '\n' + + '`END`COM%% @doc My function`END`PLN\n' + + 'test(`END`TYPVariables`END`PUN,`END`PLN `END`TYPMoreVariables`END`PLN) ->\n' + + ' `END`COM% Inline comment`END`PLN\n' + + ' {ok`END`PUN,`END`TYPScanned`END`PUN,`END`TYP_`END`PLN} = my_lib:do_stuff()`END`PUN,`END`PLN\n' + + '\n' + + ' `END`TYPVariable`END`PLN = `END`KWDfun`END`PLN(`END`TYPV`END`PLN) -> {ok`END`PUN,`END`PLN `END`TYPV`END`PLN} `END`KWDend`END`PUN,`END`PLN\n' + + '\n' + + ' `END`KWDtry`END`PLN `END`LIT?my_macro`END`PLN({value`END`PUN,`END`PLN test}) `END`KWDof`END`PLN\n' + + ' {value`END`PUN,`END`PLN `END`TYPResult`END`PUN,`END`PLN `END`TYP_`END`PLN} ->\n' + + ' {ok`END`PUN,`END`PLN `END`TYPResult`END`PLN}\n' + + ' `END`KWDcatch`END`PLN\n' + + ' `END`TYPType`END`PLN:`END`TYPError`END`PLN ->\n' + + ' {`END`LIT\'error\'`END`PUN,`END`PLN `END`TYPType`END`PUN,`END`PLN `END`TYPError`END`PLN}\n' + + ' `END`KWDend`END`PUN.`END' + ), + rust: ( + '`COM// Single line comment`END`PLN\n' + + '`END`COM/* Multi-line (nesting not highlighted properly, sorry)\n' + + 'comment */`END`PLN\n' + + '\n' + + '`END`ATV#![feature(code_prettification)]`END`PLN\n' + + '\n' + + '`END`KWDuse`END`PLN std`END`PUN::`END`PLNio`END`PUN::{`END`LITself`END`PUN,`END`PLN Write`END`PUN};`END`PLN\n' + + '\n' + + '`END`KWDimpl`END`PUN<`END`TAG\'a`END`PUN,`END`PLN T`END`PUN:`END`PLN `END`TAG\'a`END`PLN `END`PUN+`END`PLN `END`PUN?`END`TYPSized`END`PUN>`END`PLN Foo`END`PUN<`END`TAG\'a`END`PUN,`END`PLN `END`TAG\'static`END`PUN>`END`PLN `END`KWDfor`END`PLN Bar`END`PUN<`END`TAG\'b`END`PUN>`END`PLN\n' + + '`END`KWDwhere`END`PLN T`END`PUN:`END`PLN `END`TYPIterator`END`PUN<`END`PLNItem `END`PUN=`END`PLN `END`TYPBox`END`PUN<`END`TYPFn`END`PUN()`END`PLN `END`PUN->`END`PLN `END`TYPu32`END`PUN>>`END`PLN `END`PUN{`END`PLN\n' + + ' `END`KWDfn`END`PLN something`END`PUN(&`END`KWDmut`END`PLN `END`LITself`END`PUN)`END`PLN `END`PUN->`END`PLN `END`TYPu32`END`PLN `END`PUN{`END`PLN\n' + + ' `END`KWDif`END`PLN `END`KWDlet`END`PLN `END`TYPSome`END`PUN(`END`KWDref`END`PLN x`END`PUN)`END`PLN `END`PUN=`END`PLN `END`LITself`END`PUN.`END`PLNfoo`END`PUN(`END`STR"multi li\\ne\n' + + 's\\tring"`END`PUN)`END`PLN `END`PUN{`END`PLN\n' + + ' `END`ATNpanic!`END`PUN(`END`STRr"\\things is going wrong!"`END`PUN);`END`PLN\n' + + ' `END`ATNpanic!`END`PUN(`END`STRr#"Things is "really" goig\\n wront!"#`END`PUN);`END`PLN\n' + + ' `END`ATNpanic!`END`PUN(`END`STRr##"Raw strings are #"#fancy#"#"##`END`PUN);`END`PLN\n' + + ' `END`PUN}`END`PLN\n' + + ' `END`PUN}`END`PLN\n' + + '`END`PUN}`END`PLN\n' + + '\n' + + '`END`KWDpub`END`PLN `END`KWDtype`END`PLN CowString`END`PUN<`END`TAG\'a`END`PUN>`END`PLN `END`PUN=`END`PLN std`END`PUN::`END`PLNcow`END`PUN::`END`PLNCow`END`PUN<`END`TAG\'a`END`PUN,`END`PLN `END`TYPstr`END`PUN>;`END`PLN\n' + + '\n' + + '`END`KWDfn`END`PLN main`END`PUN()`END`PLN `END`PUN{`END`PLN\n' + + ' `END`KWDlet`END`PLN `END`PUN(`END`PLNi`END`PUN,`END`PLN r`END`PUN)`END`PLN `END`PUN=`END`PLN `END`PUN(`END`LIT1u8`END`PUN,`END`PLN `END`STR\'c\'`END`PUN);`END`PLN\n' + + ' `END`KWDlet`END`PLN s `END`PUN=`END`PLN `END`STRr#"Take a raw egg,\n' + + ' "break" it (or the line),\n' + + ' and beat it"#`END`PUN;`END`PLN\n' + + '`END`PUN}`END' + ) +}; diff --git a/tests/prettify_test_2.html b/tests/prettify_test_2.html index 4abef9e8..c62e032b 100644 --- a/tests/prettify_test_2.html +++ b/tests/prettify_test_2.html @@ -1,70 +1,80 @@ - + + Code Prettifier - + + + - - - -
-
+ +

Test Results

+
-

XQuery mode

-From http://www.patrick-wied.at/static/xquery/prettify/ +
+ +

XQuery

+

From http://www.patrick-wied.at/static/xquery/prettify/

 (: 
 	Took some of Mike Brevoort's xquery code samples because they are nice and show common xquery syntax 
@@ -399,8 +409,8 @@ 

XQuery mode

(: -------- :)
-

Nemerle code

-
+

Nemerle

+
 class Set ['a]
 {
   mutable storage : list ['a] = [];
@@ -425,8 +435,8 @@ 

Nemerle code

assert (s2.Contains ("foo"));
-

Tex support

-
% resume.tex
+

LaTeX

+
% resume.tex
 % vim:set ft=tex spell:
 \documentclass[10pt,letterpaper]{article}
 \usepackage[letterpaper,margin=0.8in]{geometry}
@@ -437,9 +447,9 @@ 

Tex support

\setlength{\tabcolsep}{0em}
-

Issue 144

-Escaped quotes in bash. -
+

Escaped quotes in Bash

+

Issue #144

+
 #! /bin/bash
 # toascii.sh
 for i in $(echo $* | fold -w 1);do
@@ -448,8 +458,9 @@ 

Issue 144

echo
-

Issue 145

-
+

Regular expression in <SCRIPT> body

+

Issue #145

+
 <script type="text/javascript">
 <!--
         var target = $$.css('backgroundImage').replace(/^url[\(\)'"]/g, '');
@@ -460,14 +471,14 @@ 

Issue 145

</script>
-

Clojure Syntax Highlighting

+

Clojure

 ; Clojure test comment
 (ns test
  (:gen-class))
 
 (def foo "bar")
-(defn bar [arg1 arg2 & args]
+(defn bar [arg1 arg2 & args]
   "sample function"
   (for [arg args]
     (prn arg)))
@@ -475,20 +486,19 @@ 

Clojure Syntax Highlighting

(bar "foo" "bar" "blah" :baz)
-

HTML 5 language on code

-

-The text is specified to be lisp by the class attribute. +

HTML5 language on CODE

+

The text is specified to be lisp by the class attribute. Semicolon is normally a valid punctuation character but in lisp it is a comment so should be colored as a comment if the className is being properly parsed.

; foo -

HTML 5 language on nested code element

+

HTML5 language on nested CODE element

The language is attached to a CODE element inside a PRE.

; foo
-

HTML 5 language on nested code element not foiled by space

+

HTML5 language on nested CODE element not foiled by space

The language is attached to a CODE element inside a PRE and there is space between the PRE element's tags and CODE element's tags.

@@ -497,7 +507,7 @@ 

HTML 5 language on nested code element not foiled by space

-

HTML 5 nested code element language ignored if not only content

+

HTML5 nested CODE element language ignored if not only content

The below is not treated as lisp despite there being a lisp language specifier on the contained CODE element, the CODE element does not wrap all non-space content.

@@ -506,38 +516,45 @@

HTML 5 nested code element language ignored if not only content

; foo
+

Language using XML processing instrution

The language is attached to an HTML5 comment that looks like an XML processing instruction.

; foo
+

Language and line numbers using HTML comment

The language is attached to a regular HTML5 comment that looks like an XML processing instruction.

; foo
+

Language and line numbers using HTML comment

The language is attached to a regular HTML5 comment that looks like an XML processing instruction.

; foo
+

Language and line numbers using HTML comment

The language is attached to a regular HTML5 comment that looks like an XML processing instruction.

; foo
-

Issues 185 and 261: Don't reprettify prettified content

+

Don't reprettify prettified content

+

Issue #185

"No tag backs." +

Issue #261

  1. "No tag backs."
-

Issue 201: C type not full word

+

C type not full word

+

Issue #201

static Persistent<String> listeners_symbol; -

Pascal w/ language specified

+

Pascal

 (* some comment here *)
 PROCEDURE TestCase.AssertEquals(msg:String; expect, act:Longint);
@@ -562,7 +579,7 @@ 

Pascal w/ language specified

END;
-

BASIC w/ language specified

+

BASIC

 200 REM ----- method teardown
 210 PRINT "green"
@@ -575,7 +592,7 @@ 

BASIC w/ language specified

1000 DATA "one", 1, 0
-

Dart language handler

+

Dart

 part of myLib;
 
@@ -620,12 +637,12 @@ 

Dart language handler

}
-

TCL_lang

+

TCL

#!/bin/tclsh
 proc fib {n} {
     set a 0
     set b 1
-    while {$n > 0} {
+    while {$n > 0} {
         set tmp $a
         set a [expr $a + $b]
         set b $tmp
@@ -635,21 +652,21 @@ 

TCL_lang

}
-

R, S language support

+

R, S

 ### Example R script for syntax highlighting
 
 # This is a comment
 
 ## Valid names
-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUV0123456789._a <- NULL
-.foo_ <- NULL
-._foo <- NULL
+abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUV0123456789._a <- NULL
+.foo_ <- NULL
+._foo <- NULL
 
 ## Invalid names
-0abc <- NULL
-.0abc <- NULL
-abc+cde <- NULL
+0abc <- NULL
+.0abc <- NULL
+abc+cde <- NULL
 
 ## Reserved Words
 NA
@@ -661,10 +678,10 @@ 

R, S language support

NaN Inf ## Not reserved -NULLa <- NULL -NULL1 <- NULL -NULL. <- NULL -NA_foo_ <- NULL +NULLa <- NULL +NULL1 <- NULL +NULL. <- NULL +NA_foo_ <- NULL ## Numbers 12345678901 @@ -697,7 +714,7 @@

R, S language support

1 %in% 1:10 diag(2) %o% diag(2) diag(2) %x% diag(2) -`%foo bar%` <- function(x, y) x + y +`%foo bar%` <- function(x, y) x + y 1 %foo bar% 2 ## Control Structures (3.2) and Function @@ -708,40 +725,40 @@

R, S language support

print(i) } ## While, break -i <- 1 +i <- 1 while (TRUE) { - i <- i + 1 - if (i > 3) break + i <- i + 1 + if (i > 3) break } ## Repeat repeat {1+1} ## Switch -x <- 3 +x <- 3 switch(x, 2+2, mean(1:10), rnorm(5)) ## Function, dot-dot-dot, return -foo <- function(...) { +foo <- function(...) { return(sum(...)) } # Not keywords -functiona <- 2 + 2 -function. <- 2 + 2 -function1 <- 2 + 2 +functiona <- 2 + 2 +function. <- 2 + 2 +function1 <- 2 + 2 ## Grouping Tokens 10.3.7 ## Parentheses 1 + (2 + 3) ## brackets -foo <- function(a) { +foo <- function(a) { a + 1 } ## Indexing 10.3.8 ## [] -bar <- 1:10 +bar <- 1:10 bar[3] ## [[]] -foo <- list(a=1, b=2, c=3) +foo <- list(a=1, b=2, c=3) foo[["a"]] ## $ foo$a @@ -757,38 +774,38 @@

R, S language support

2 * 2 2 / 2 2^2 -2 < 2 -2 > 2 +2 < 2 +2 > 2 2 == 2 -2 >= 2 -2 <= 2 +2 >= 2 +2 <= 2 2 != 2 -TRUE & FALSE -TRUE && FALSE +TRUE & FALSE +TRUE && FALSE TRUE | FALSE TRUE || FALSE -foo <- 2 + 2 +foo <- 2 + 2 foo = 2 + 2 -2 + 2 -> foo -foo <<- 2 + 2 -2 + 2 ->> foo +2 + 2 -> foo +foo <<- 2 + 2 +2 + 2 ->> foo base:::sum base::sum ## Strings -foo <- "hello, world!" -foo <- 'hello, world!' -foo <- "Hello, 'world!" -foo <- 'Hello, "world!' -foo <- 'Hello, \'world!\'' -foo <- "Hello, \"world!\"" -foo <- "Hello, +foo <- "hello, world!" +foo <- 'hello, world!' +foo <- "Hello, 'world!" +foo <- 'Hello, "world!' +foo <- 'Hello, \'world!\'' +foo <- "Hello, \"world!\"" +foo <- "Hello, world!" -foo <- 'Hello, +foo <- 'Hello, world!' ## Backtick strings -`foo123 +!"bar'baz` <- 2 + 2 +`foo123 +!"bar'baz` <- 2 + 2

MUMPS

@@ -806,12 +823,12 @@

MUMPS

I $E(IOST,1,2)="C-" W $C(13) D IOXY^VALM4(30,0) ; -- position cursor W $J("",((VALMWD-80)/2)),$$HTE^XLFDT($H,1),$J("",10+((VALMWD-80)/2)),"Page: ",$J(VALMPGE,4)," of ",$J($$PAGE^VALM4(VALMCNT,VALM("LINES")),4)_$S($D(VALMORE):"+",1:" ") ; -- prt rest of hdr W:VALMCC IOUOFF I $E(IOST,1,2)="C-" D IOXY^VALM4(0,0) ; -- turn off undln - F I=1:1:VALM("TM")-3 W !,$S('$D(VALMHDR(I)):"",$L(VALMHDR(I))>(VALMWD-1):$$EXTRACT^VALM4($G(VALMHDR(I))),1:VALMHDR(I)) ; -- prt hdr + F I=1:1:VALM("TM")-3 W !,$S('$D(VALMHDR(I)):"",$L(VALMHDR(I))>(VALMWD-1):$$EXTRACT^VALM4($G(VALMHDR(I))),1:VALMHDR(I)) ; -- prt hdr Q

LLVM

-Hello world module +

Hello world module

 ; Declare the string constant as a global constant.
 @.str = private unnamed_addr constant [13 x i8] c"hello world\0A\00"
@@ -834,15 +851,17 @@ 

LLVM

!foo = !{!1, null}
-

Issue 217 : Regex following '!'

-
+

Regex following '!'

+

Issue #217

+
 if(!/^https?:\/\//i.test(val) && foo == 'bar') {
     val = 'http://' + val;
 }
 
-

Issue 32 : Matlab

-
+

MATLAB

+

Issue #32

+
 %%%%%%%%%%%%%%%%%% DATA TYPES %%%%%%%%%%%%%%%%%%
 
 v = [1,2,3;4,5,6];
@@ -1066,948 +1085,121 @@ 

Issue 32 : Matlab

%}
- +

Elixir

+
+defmodule Foo.Bar do
+  @moduledoc """
+  Tests syntax highlighting for Elixir
+  """
+
+  use Bitwise
+  require Logger
+  alias __MODULE__, as: This
+
+  @default_token_length 10_000
+
+
+  @spec token(length :: integer) :: String.t
+
+  def token(length \\ @default_token_length), do: String.duplicate("x", length)
+
+
+  defp _not_exported(), do: 0xFF + 0xF_F - 0xff
+
+
+  def other(foo, bar) do
+    fun = fn{_a, b} -> b + 1_3.1_4 end
+    fun.(1.0e+20)
+    _str = "string without #{inspect(42)} interpolation" <> " some more
+    with newlines \
+    and newlines"
+    charlist = 'some\'chars
+    with newlines \
+    and newlines'
+    <<x::utf8, _y::size(8), data::binary>> = "fooo"
+    ls = [1 | [2, 3]]
+    map = %{"baz" => "ban"}
+    map = %{foo: :bar, "yes, this compiles": :"also an atom"}
+    :erlang.time()
+    case {foo, bar} do
+      {1, 2} -> 3
+      _something_else -> :error
+      _ -> :"this won't match"
+    end
+    r = 2
+    _bitwise_not = ~~~r
+
+    ~r/foo/iu # regex sigils are treated as normal ones
+    ~S|we have "quotes" and 'quotes' and| <> " more string"
+    ~c"custom sigil char \"is\" fine too"
+    ~r'hello'
+    ~w[hell\] #o] #sigil does not expand to the comment
+    ~w{hello}
+    ~C<hello>
+  end
 
-
 
+typealias SomeNumber = Int
+
+val number: Long = 1_000L
+var float: Float = 12.34f
+0xFF_FF
+3.14
+
+314e-2
+0.314e1
+
+protected override fun ifBoolean(condition: Boolean? = null) {}
+
+::ifBoolean
+
+constructor() : super()
+
+"\"true\""
+'a'
+
+"""
+aaaaaaaaaaa
+"""
+
+loop@ for()
+
+break @loop
+
+enum class `true`
+
+data class Person(val name: String)
+
+enum class Size {
+    BIG, MEDIUM, SMALL
+}
+
+class Ball(val color: String, val size: Size) {
+    companion object {}
+
+    fun isBig() = size == Size.BIG
+
+    val isMedium: Boolean
+        get() = size == Size.MEDIUM
+}
+
+fun Boolean?.isNull(): Boolean = this == null
+
+fun Boolean?.getOrThrow(): Boolean = this ?: throw Exception()
+
+ diff --git a/tests/prettify_test_2.js b/tests/prettify_test_2.js new file mode 100644 index 00000000..03e29f5a --- /dev/null +++ b/tests/prettify_test_2.js @@ -0,0 +1,1072 @@ +/** + * maps ids of rewritten code to the expected output. + * For brevity, has been changed to `FOO + * and < /span> has been changed to `END. + */ +var goldens = { + xquery: ( + '`COM(: \n' + + '\tTook some of Mike Brevoort\'s xquery code samples because they are nice and show common xquery syntax \n' + + ':)`END`PLN\n' + + ' \n' + + ' `END`COM(:~\n' + + ' : Given a sequence of version URIs, publish all of these versions of each document\n' + + ' : If there is a version of the same document already published, unpublish it 1st\n' + + ' :\n' + + ' : When "publish" is referred to, we mean that it is put into the PUBLISHED collection\n' + + ' : unpublish removes content from this collection\n' + + ' : @param $version_uris - sequence of uris of versions of managed documents to publish\n' + + ' :)`END`PLN\n' + + ' `END`KWDdeclare`END`PLN `END`KWDfunction`END`PLN comoms-dls:publish(`END$version_uris`END`PLN `END`KWDas`END`PLN `END`KWDitem`END`PLN()*) {\n' + + ' `END`KWDfor`END`PLN `END$uri`END`PLN `END`KWDin`END`PLN `END$version_uris`END`PLN\n' + + ' `END`KWDlet`END`PLN `END$doc`END`PLN := `ENDfn:doc`END`PLN(`END$uri`END`PLN)\n' + + ' `END`KWDlet`END`PLN `END$managed_base_uri`END`PLN := `END$doc`END`PLN/`END`KWDnode`END`PLN()/property::dls:version/dls:document-uri/`END`KWDtext`END`PLN()\n' + + ' `END`KWDlet`END`PLN `END$existing`END`PLN := comoms-dls:publishedDoc(`END$managed_base_uri`END`PLN)\n' + + ' `END`KWDlet`END`PLN `END$unpublishExisting`END`PLN := `END`KWDif`END`PLN(`END$existing`END`PLN) `END`KWDthen`END`PLN comoms-dls:unpublishVersion((`ENDxdmp:node-uri`END`PLN(`END$existing`END`PLN))) `END`KWDelse`END`PLN ()\n' + + ' `END`KWDlet`END`PLN `END$addPermissions`END`PLN := `ENDdls:document-add-permissions`END`PLN(`END$uri`END`PLN, (`ENDxdmp:permission`END`PLN(`END`STR\'mkp-anon\'`END`PLN, `END`STR\'read\'`END`PLN)))\n' + + ' `END`KWDreturn`END`PLN\n' + + ' `ENDdls:document-add-collections`END`PLN(`END$uri`END`PLN, (`END`STR"PUBLISHED"`END`PLN)) \n' + + ' };\n' + + ' \n' + + ' `END`KWDdeclare`END`PLN `END`KWDfunction`END`PLN comoms-dls:publishLatest(`END$uri`END`PLN) {\n' + + ' `END`COM(: TODO check if it\'s in the draft collection probably :)`END`PLN\n' + + ' \n' + + ' `END`KWDlet`END`PLN `END$latest_version_uri`END`PLN := comoms-dls:latestVersionUri(`END$uri`END`PLN)\n' + + ' `END`KWDlet`END`PLN `END$log`END`PLN:= `ENDxdmp:log`END`PLN(`ENDfn:concat`END`PLN(`END`STR"latest: "`END`PLN, `END$latest_version_uri`END`PLN)) \n' + + ' `END`KWDlet`END`PLN `END$log`END`PLN:= `ENDxdmp:log`END`PLN(`ENDfn:concat`END`PLN(`END`STR"uri: "`END`PLN, `END$uri`END`PLN)) \n' + + ' `END`KWDreturn`END`PLN comoms-dls:publish(`END$latest_version_uri`END`PLN) \n' + + ' \n' + + ' };\n' + + ' \n' + + ' `END`KWDdeclare`END`PLN `END`KWDfunction`END`PLN comoms-dls:latestVersionUri(`END$uri`END`PLN) {\n' + + ' `END`KWDlet`END`PLN `END$latest_version_num`END`PLN :=\n' + + ' (\n' + + ' `END`KWDfor`END`PLN `END$version`END`PLN `END`KWDin`END`PLN `ENDdls:document-history`END`PLN(`END$uri`END`PLN)/dls:version\n' + + ' `END`KWDorder`END`PLN `END`KWDby`END`PLN `ENDfn:number`END`PLN(`END$version`END`PLN//dls:version-id/`END`KWDtext`END`PLN()) `END`KWDdescending`END`PLN\n' + + ' `END`KWDreturn`END`PLN `END$version`END`PLN//dls:version-id/`END`KWDtext`END`PLN()\n' + + ' )[1]\n' + + ' \n' + + ' \n' + + ' `END`KWDreturn`END`PLN `ENDdls:document-version-uri`END`PLN(`END$uri`END`PLN, `END$latest_version_num`END`PLN)\n' + + ' };\n' + + ' \n' + + ' `END`KWDdeclare`END`PLN `END`KWDfunction`END`PLN comoms-dls:unpublish(`END$uris`END`PLN `END`KWDas`END`PLN `END`KWDitem`END`PLN()*) {\n' + + ' `END`KWDfor`END`PLN `END$uri`END`PLN `END`KWDin`END`PLN `END$uris`END`PLN\n' + + ' `END`KWDreturn`END`PLN\n' + + ' `END`KWDlet`END`PLN `END$published_doc`END`PLN := comoms-dls:publishedDoc(`END$uri`END`PLN)\n' + + ' `END`KWDreturn`END`PLN\n' + + ' `END`KWDif`END`PLN(`END$published_doc`END`PLN) `END`KWDthen`END`PLN\n' + + ' `END`KWDlet`END`PLN `END$published_version_uri`END`PLN := `ENDxdmp:node-uri`END`PLN(`END$published_doc`END`PLN)\n' + + ' `END`KWDreturn`END`PLN comoms-dls:unpublishVersion(`END$published_version_uri`END`PLN) \n' + + ' `END`KWDelse`END`PLN\n' + + ' ()\n' + + ' };\n' + + ' \n' + + ' `END`KWDdeclare`END`PLN `END`KWDfunction`END`PLN comoms-dls:latestPublishedDocAuthor(`END$uri`END`PLN) {\n' + + ' `END`KWDlet`END`PLN `END$author_id`END`PLN := `ENDdoc`END`PLN(`END$uri`END`PLN)/property::dls:version/dls:author/`END`KWDtext`END`PLN()\n' + + ' `END`KWDreturn`END`PLN\n' + + ' `END`KWDif`END`PLN(`END$author_id`END`PLN) `END`KWDthen`END`PLN\n' + + ' comoms-user:getUsername(`END$author_id`END`PLN)\n' + + ' `END`KWDelse`END`PLN\n' + + ' ()\n' + + ' \n' + + ' };\n' + + ' \n' + + ' `END`COM(:~\n' + + ' : Given a sequence of version URIs, unpublish all of these versions of each document\n' + + ' :)`END`PLN\n' + + ' `END`KWDdeclare`END`PLN `END`KWDfunction`END`PLN comoms-dls:unpublishVersion(`END$version_uris`END`PLN `END`KWDas`END`PLN `END`KWDitem`END`PLN()*) {\n' + + ' `END`KWDfor`END`PLN `END$uri`END`PLN `END`KWDin`END`PLN `END$version_uris`END`PLN\n' + + ' `END`KWDreturn`END`PLN\n' + + ' `END`KWDlet`END`PLN `END$removePermissions`END`PLN := `ENDdls:document-remove-permissions`END`PLN(`END$uri`END`PLN, (`ENDxdmp:permission`END`PLN(`END`STR\'mkp-anon\'`END`PLN, `END`STR\'read\'`END`PLN)))\n' + + ' `END`KWDreturn`END`PLN `ENDdls:document-remove-collections`END`PLN(`END$uri`END`PLN, (`END`STR"PUBLISHED"`END`PLN)) \n' + + ' };\n' + + ' \n' + + ' `END`COM(:~\n' + + ' : Given the base URI of a managed piece of content, return the document of the node\n' + + ' : of the version that is published\n' + + ' :)`END`PLN\n' + + ' `END`KWDdeclare`END`PLN `END`KWDfunction`END`PLN comoms-dls:publishedDoc(`END$uri`END`PLN) {\n' + + ' `ENDfn:collection`END`PLN(`END`STR"PUBLISHED"`END`PLN)[property::dls:version/dls:document-uri = `END$uri`END`PLN]\n' + + ' };\n' + + ' \n' + + ' \n' + + ' `END`COM(:~\n' + + ' : Test if any version of the managed document is published\n' + + ' :)`END`PLN\n' + + ' `END`KWDdeclare`END`PLN `END`KWDfunction`END`PLN comoms-dls:isPublished(`END$uri`END`PLN) {\n' + + ' `END`KWDif`END`PLN( comoms-dls:publishedDoc(`END$uri`END`PLN)) `END`KWDthen`END`PLN\n' + + ' `ENDfn:true`END`PLN()\n' + + ' `END`KWDelse`END`PLN\n' + + ' `ENDfn:false`END`PLN()\n' + + ' };\n' + + ' \n' + + ' \n' + + ' `END`KWDdeclare`END`PLN `END`KWDfunction`END`PLN comoms-dls:publishedState(`END$uri`END`PLN) {\n' + + ' `END`KWDlet`END`PLN `END$doc`END`PLN := comoms-dls:publishedDoc(`END$uri`END`PLN)\n' + + ' `END`KWDlet`END`PLN `END$published_uri`END`PLN := `END`KWDif`END`PLN(`END$doc`END`PLN) `END`KWDthen`END`PLN `ENDxdmp:node-uri`END`PLN(`END$doc`END`PLN) `END`KWDelse`END`PLN ()\n' + + ' `END`KWDlet`END`PLN `END$latest`END`PLN := comoms-dls:latestVersionUri(`END$uri`END`PLN)\n' + + ' `END`KWDreturn`END`PLN\n' + + ' `END`KWDif`END`PLN(`END$doc`END`PLN) `END`KWDthen`END`PLN\n' + + ' `END`KWDif`END`PLN(`END$latest`END`PLN ne `END$published_uri`END`PLN) `END`KWDthen`END`PLN\n' + + ' `END`STR"stale"`END`PLN\n' + + ' `END`KWDelse`END`PLN\n' + + ' `END`STR"published"`END`PLN\n' + + ' `END`KWDelse`END`PLN\n' + + ' `END`STR"unpublished"`END`PLN\n' + + ' };\n' + + ' \n' + + ' \n' + + ' `END`KWDdeclare`END`PLN `END`KWDfunction`END`PLN comoms-dls:getManagedDocUri(`END$uri`END`PLN) {\n' + + ' `END`KWDlet`END`PLN `END$doc`END`PLN := `ENDfn:doc`END`PLN(`END$uri`END`PLN)\n' + + ' `END`KWDlet`END`PLN `END$managed_uri`END`PLN := `END$doc`END`PLN/property::dls:version/dls:document-uri/`END`KWDtext`END`PLN()\n' + + ' `END`KWDlet`END`PLN `END$managed_uri`END`PLN := `END`KWDif`END`PLN(`END$managed_uri`END`PLN) `END`KWDthen`END`PLN `END$managed_uri`END`PLN `END`KWDelse`END`PLN `END$uri`END`PLN\n' + + ' `END`KWDreturn`END`PLN `END$managed_uri`END`PLN\n' + + ' };\n' + + ' \n' + + ' `END`COM(:~\n' + + ' : Given a manage content url (e.g. /content/123456.xml) return the appropriate\n' + + ' : version of the document based on what stage collection is being viewed and\n' + + ' : what\'s published\n' + + ' :\n' + + ' : @param $uri a manage content url (e.g. /content/123456.xml) - NOT A VERSIONED URI\n' + + ' :)`END`PLN\n' + + ' `END`KWDdeclare`END`PLN `END`KWDfunction`END`PLN comoms-dls:doc(`END$uri`END`PLN) {\n' + + ' `END`KWDlet`END`PLN `END$doc`END`PLN := `ENDfn:root`END`PLN(comoms-dls:collection()[property::dls:version/dls:document-uri = `END$uri`END`PLN][1])\n' + + ' `END`KWDreturn`END`PLN\n' + + ' `END`KWDif`END`PLN(`END$doc`END`PLN) `END`KWDthen`END`PLN\n' + + ' `END$doc`END`PLN\n' + + ' `END`KWDelse`END`PLN\n' + + ' `END`KWDlet`END`PLN `END$managedDocInCollection`END`PLN := comoms-dls:collection-name() = `ENDxdmp:document-get-collections`END`PLN(`END$uri`END`PLN)\n' + + ' `END`KWDreturn`END`PLN\n' + + ' `END`KWDif`END`PLN(`END$managedDocInCollection`END`PLN) `END`KWDthen`END`PLN\n' + + ' `ENDfn:doc`END`PLN(`END$uri`END`PLN)\n' + + ' `END`KWDelse`END`PLN\n' + + ' ()\n' + + ' };\n' + + ' \n' + + ' `END`COM(:~\n' + + ' : Get the collection to be used when querying for content\n' + + ' : THIS or comoms-dls:collection-name() SHOULD BE USED WHEN BUILDING ANY QUERY FOR MANAGED CONTENT\n' + + ' :)`END`PLN\n' + + ' `END`KWDdeclare`END`PLN `END`KWDfunction`END`PLN comoms-dls:collection() {\n' + + ' `ENDfn:collection`END`PLN( comoms-dls:collection-name() )\n' + + ' };\n' + + ' \n' + + ' `END`COM(:~\n' + + ' : Get the collection nameto be used when querying for content\n' + + ' : THIS or comoms-dls:collection() SHOULD BE USED WHEN BUILDING ANY QUERY FOR MANAGED CONTENT\n' + + ' :)`END`PLN\n' + + ' `END`KWDdeclare`END`PLN `END`KWDfunction`END`PLN comoms-dls:collection-name() `END`KWDas`END`PLN `END`TYPxs:string`END`PLN {\n' + + ' `END`KWDlet`END`PLN `END$default_collection`END`PLN := `END`STR"PUBLISHED"`END`PLN\n' + + ' `END`KWDreturn`END`PLN\n' + + ' `END`KWDif`END`PLN(comoms-user:isAdmin()) `END`KWDthen`END`PLN\n' + + ' `END`KWDlet`END`PLN `END$pub_stage_collection_cookie`END`PLN := comoms-util:getCookie(`END`STR"COMOMS_COLLECTION"`END`PLN)\n' + + ' `END`KWDreturn`END`PLN\n' + + ' `END`KWDif`END`PLN(`END$pub_stage_collection_cookie`END`PLN) `END`KWDthen`END`PLN\n' + + ' `END$pub_stage_collection_cookie`END`PLN\n' + + ' `END`KWDelse`END`PLN\n' + + ' `END$default_collection`END`PLN\n' + + ' `END`KWDelse`END`PLN\n' + + ' `END$default_collection`END`PLN\n' + + ' };\n' + + ' \n' + + ' `END`COM(:~\n' + + ' : Check if the published collection is being viewed\n' + + ' :)`END`PLN\n' + + ' `END`KWDdeclare`END`PLN `END`KWDfunction`END`PLN comoms-dls:isViewingPublished() {\n' + + ' `END`KWDif`END`PLN(comoms-dls:collection-name() = `END`STR"PUBLISHED"`END`PLN) `END`KWDthen`END`PLN\n' + + ' `ENDfn:true`END`PLN()\n' + + ' `END`KWDelse`END`PLN\n' + + ' `ENDfn:false`END`PLN()\n' + + ' };\n' + + ' \n' + + ' `END`COM(:~\n' + + ' : Get the best URL for the content URI.\n' + + ' : This is either the default URI based on detail type or should also take\n' + + ' : into account friendly urls and navigation structures to figure out the\n' + + ' : best choice\n' + + ' :)`END`PLN\n' + + ' `END`KWDdeclare`END`PLN `END`KWDfunction`END`PLN comoms-dls:contentUrl(`END$uri`END`PLN) {\n' + + ' \n' + + ' `END`COM(: TODO: add friendly URL and nav structure logic 1st :)`END`PLN\n' + + ' \n' + + ' `END`KWDlet`END`PLN `END$doc`END`PLN := `ENDfn:doc`END`PLN(`END$uri`END`PLN)\n' + + ' `END`KWDlet`END`PLN `END$managedDocUri`END`PLN := `END$doc`END`PLN/property::dls:version/dls:document-uri\n' + + ' `END`KWDlet`END`PLN `END$uri`END`PLN := `END`KWDif`END`PLN(`END$managedDocUri`END`PLN) `END`KWDthen`END`PLN `END$managedDocUri`END`PLN `END`KWDelse`END`PLN `END$uri`END`PLN\n' + + ' `END`KWDlet`END`PLN `END$type`END`PLN := `END$doc`END`PLN/`END`KWDnode`END`PLN()/`ENDfn:name`END`PLN()\n' + + ' `END`KWDlet`END`PLN `END$content_id`END`PLN := `ENDfn:tokenize`END`PLN( `ENDfn:tokenize`END`PLN(`END$uri`END`PLN, `END`STR"/"`END`PLN)[3], `END`STR"\\."`END`PLN)[1]\n' + + ' `END`KWDreturn`END`PLN\n' + + ' `ENDfn:concat`END`PLN(`END`STR"/"`END`PLN, `END$type`END`PLN, `END`STR"/"`END`PLN, `END$content_id`END`PLN)\n' + + ' };\n' + + ' \n' + + ' `END`COM(:\n' + + ' :\n' + + ' : gets list of doc versions and uri.\n' + + ' :\n' + + ' :)`END`PLN\n' + + ' `END`KWDdeclare`END`PLN `END`KWDfunction`END`PLN comoms-dls:versionHistory(`END$uri`END`PLN) {\n' + + ' `END`KWDlet`END`PLN `END$published_doc`END`PLN := comoms-dls:publishedDoc(`END$uri`END`PLN)\n' + + ' `END`KWDlet`END`PLN `END$published_uri`END`PLN := `END`KWDif`END`PLN(`END$published_doc`END`PLN) `END`KWDthen`END`PLN `ENDxdmp:node-uri`END`PLN(`END$published_doc`END`PLN) `END`KWDelse`END`PLN ()\n' + + ' `END`KWDreturn`END`PLN\n' + + ' `END`TAG<versions>`END`PLN\n' + + ' {\n' + + ' `END`KWDfor`END`PLN `END$version`END`PLN `END`KWDin`END`PLN `ENDdls:document-history`END`PLN(`END$uri`END`PLN)/dls:version\n' + + ' `END`KWDlet`END`PLN `END$version_num`END`PLN := `END$version`END`PLN/dls:version-id/`END`KWDtext`END`PLN()\n' + + ' `END`KWDlet`END`PLN `END$created`END`PLN := `END$version`END`PLN/dls:created/`END`KWDtext`END`PLN()\n' + + ' `END`KWDlet`END`PLN `END$author_id`END`PLN := `END$version`END`PLN/dls:author/`END`KWDtext`END`PLN()\n' + + ' `END`KWDlet`END`PLN `END$author`END`PLN := comoms-user:getUsername(`END$author_id`END`PLN)\n' + + ' \n' + + ' \n' + + ' `END`KWDlet`END`PLN `END$note`END`PLN := `END$version`END`PLN/dls:annotation/`END`KWDtext`END`PLN()\n' + + ' `END`KWDlet`END`PLN `END$version_uri`END`PLN := `ENDxdmp:node-uri`END`PLN(`ENDdls:document-version`END`PLN(`END$uri`END`PLN, `END$version_num`END`PLN))\n' + + ' `END`KWDlet`END`PLN `END$published`END`PLN := `END$published_uri`END`PLN `END`KWDeq`END`PLN `END$version_uri`END`PLN\n' + + ' `END`KWDreturn`END`PLN\n' + + ' `END`TAG<version>`END`PLN\n' + + ' `END`TAG<version-number>`END`PLN{`END$version_num`END`PLN}`END`TAG</version-number>`END`PLN\n' + + ' `END`TAG<created>`END`PLN{`END$created`END`PLN}`END`TAG</created>`END`PLN \n' + + ' `END`TAG<author>`END`PLN{`END$author`END`PLN}`END`TAG</author>`END`PLN\n' + + ' `END`TAG<published>`END`PLN{`END$published`END`PLN}`END`TAG</published>`END`PLN\n' + + ' `END`TAG<version-uri>`END`PLN{`END$version_uri`END`PLN}`END`TAG</version-uri>`END`PLN\n' + + ' `END`TAG</version>`END`PLN \n' + + ' } \n' + + ' `END`TAG</versions>`END`PLN\n' + + ' };\n' + + ' \n' + + ' \n' + + ' \n' + + ' \n' + + ' \n' + + ' \n' + + ' `END`COM(: ########################################################################### :)`END`PLN\n' + + ' `END`COM(: PRIVATE FUNCTIONS :)`END`PLN\n' + + ' `END`COM(: ########################################################################### :)`END`PLN\n' + + ' \n' + + ' `END`KWDdeclare`END`PLN `END`KWDfunction`END`PLN comoms-dls:_import() {\n' + + ' `END`STR"xquery version \'1.0-ml\';\n' + + ' import module namespace dls = \'http://marklogic.com/xdmp/dls\' at \'/MarkLogic/dls.xqy\'; "`END`PLN\n' + + ' }; \n' + + ' \n' + + '`END`COM(: ----\n' + + '---- :)`END`PLN\n' + + '`END`KWDxquery`END`PLN `END`KWDversion`END`PLN `END`STR\'1.0-ml\'`END`PLN;\n' + + '`END`KWDdeclare`END`PLN `END`KWDvariable`END`PLN `END$URI`END`PLN `END`KWDas`END`PLN `END`TYPxs:string`END`PLN `END`KWDexternal`END`PLN;\n' + + ' \n' + + '`END`KWDdeclare`END`PLN `END`KWDfunction`END`PLN local:document-move-forest(`END$uri`END`PLN `END`KWDas`END`PLN `END`TYPxs:string`END`PLN, `END$forest-ids`END`PLN `END`KWDas`END`PLN `END`TYPxs:unsignedLong`END`PLN*)\n' + + '{\n' + + ' `ENDxdmp:document-insert`END`PLN(\n' + + ' `END$uri`END`PLN,\n' + + ' `ENDfn:doc`END`PLN(`END$uri`END`PLN),\n' + + ' `ENDxdmp:document-get-permissions`END`PLN(`END$uri`END`PLN),\n' + + ' `ENDxdmp:document-get-collections`END`PLN(`END$uri`END`PLN),\n' + + ' `ENDxdmp:document-get-quality`END`PLN(`END$uri`END`PLN),\n' + + ' `END$forest-ids`END`PLN\n' + + ' )\n' + + '};\n' + + ' \n' + + '`END`KWDlet`END`PLN `END$xml`END`PLN :=\n' + + ' `END`TAG<xml`END`PLN att=`END`STR"blah"`END`PLN att2=`END`STR"blah"`END`TAG>`END`PLN\n' + + ' sdasd`END`TAG<b>`END`PLNasdasd`END`TAG</b>`END`PLN\n' + + ' `END`TAG</xml>`END`PLN\n' + + '`END`COM(: -------- :)`END`PLN\n' + + '`END`KWDfor`END`PLN `END$d`END`PLN `END`KWDin`END`PLN `ENDfn:doc`END`PLN(`END`STR"depts.xml"`END`PLN)/depts/deptno\n' + + '`END`KWDlet`END`PLN `END$e`END`PLN := `ENDfn:doc`END`PLN(`END`STR"emps.xml"`END`PLN)/emps/emp[deptno = `END$d`END`PLN]\n' + + '`END`KWDwhere`END`PLN `ENDfn:count`END`PLN(`END$e`END`PLN) >= 10\n' + + '`END`KWDorder`END`PLN `END`KWDby`END`PLN `ENDfn:avg`END`PLN(`END$e`END`PLN/salary) `END`KWDdescending`END`PLN\n' + + '`END`KWDreturn`END`PLN\n' + + ' `END`TAG<big-dept>`END`PLN\n' + + ' {\n' + + ' `END$d`END`PLN,\n' + + ' `END`TAG<headcount>`END`PLN{`ENDfn:count`END`PLN(`END$e`END`PLN)}`END`TAG</headcount>`END`PLN,\n' + + ' `END`TAG<avgsal>`END`PLN{`ENDfn:avg`END`PLN(`END$e`END`PLN/salary)}`END`TAG</avgsal>`END`PLN\n' + + ' }\n' + + ' `END`TAG</big-dept>`END`PLN\n' + + '`END`COM(: -------- :)`END`PLN\n' + + '`END`KWDdeclare`END`PLN `END`KWDfunction`END`PLN local:depth(`END$e`END`PLN `END`KWDas`END`PLN `END`KWDnode`END`PLN()) `END`KWDas`END`PLN `END`TYPxs:integer`END`PLN\n' + + '{\n' + + ' `END`COM(: A node with no children has depth 1 :)`END`PLN\n' + + ' `END`COM(: Otherwise, add 1 to max depth of children :)`END`PLN\n' + + ' `END`KWDif`END`PLN (`ENDfn:empty`END`PLN(`END$e`END`PLN/*)) `END`KWDthen`END`PLN 1\n' + + ' `END`KWDelse`END`PLN `ENDfn:max`END`PLN(`END`KWDfor`END`PLN `END$c`END`PLN `END`KWDin`END`PLN `END$e`END`PLN/* `END`KWDreturn`END`PLN local:depth(`END$c`END`PLN)) + 1\n' + + '};\n' + + ' \n' + + 'local:depth(`ENDfn:doc`END`PLN(`END`STR"partlist.xml"`END`PLN))\n' + + ' \n' + + '`END`COM(: -------- :)`END`PLN\n' + + '`END`TAG<html><head`END`PLN/`END`TAG><body>`END`PLN\n' + + '{\n' + + ' `END`KWDfor`END`PLN `END$act`END`PLN `END`KWDin`END`PLN `ENDdoc`END`PLN(`END`STR"hamlet.xml"`END`PLN)//ACT\n' + + ' `END`KWDlet`END`PLN `END$speakers`END`PLN := `ENDdistinct-values`END`PLN(`END$act`END`PLN//SPEAKER)\n' + + ' `END`KWDreturn`END`PLN\n' + + ' `END`TAG<div>`END`PLN{ `ENDstring`END`PLN(`END$act`END`PLN/TITLE) }`END`TAG</h1>`END`PLN\n' + + ' `END`TAG<ul>`END`PLN\n' + + ' {\n' + + ' `END`KWDfor`END`PLN `END$speaker`END`PLN `END`KWDin`END`PLN `END$speakers`END`PLN\n' + + ' `END`KWDreturn`END`PLN `END`TAG<li>`END`PLN{ `END$speaker`END`PLN }`END`TAG</li>`END`PLN\n' + + ' }\n' + + ' `END`TAG</ul>`END`PLN\n' + + ' `END`TAG</div>`END`PLN\n' + + '}\n' + + '`END`TAG</body></html>`END`PLN\n' + + '`END`COM(: -------- :)`END`PLN\n' + + '{\n' + + '\t`END`KWDfor`END`PLN `END$book`END`PLN `END`KWDin`END`PLN `ENDdoc`END`PLN(`END`STR"books.xml"`END`PLN)//book\n' + + ' `END`KWDreturn`END`PLN\n' + + '\t`END`KWDif`END`PLN (`ENDcontains`END`PLN(`END$book`END`PLN/author/`END`KWDtext`END`PLN(),`END`STR"Herbert"`END`PLN) `END`KWDor`END`PLN `ENDcontains`END`PLN(`END$book`END`PLN/author/`END`KWDtext`END`PLN(),`END`STR"Asimov"`END`PLN))\n' + + '\t\t`END`KWDthen`END`PLN `END$book`END`PLN\n' + + '\t`END`KWDelse`END`PLN `END$book`END`PLN/`END`KWDtext`END`PLN()\n' + + '\t\n' + + '\t`END`KWDlet`END`PLN `END$let`END`PLN := `END`TAG<x>`END`STR"test"`END`TAG</x>`END`PLN\n' + + '\t`END`KWDreturn`END`PLN `END`KWDelement`END`PLN `END`KWDelement`END`PLN {\n' + + '\t`END`KWDattribute`END`PLN `END`KWDattribute`END`PLN { 1 },\n' + + '\t`END`KWDelement`END`PLN test { `END`STR\'a\'`END`PLN },\n' + + '\t`END`KWDattribute`END`PLN foo { `END`STR"bar"`END`PLN },\n' + + '\t`ENDfn:doc`END`PLN()[ foo/`END`LIT@bar`END`PLN `END`KWDeq`END`PLN `END$let`END`PLN ],\n' + + '\t//x }\n' + + '}\n' + + '`END`COM(: -------- :)`END`PLN\n' + + '`END`TAG<bib>`END`PLN\n' + + ' {\n' + + ' `END`KWDfor`END`PLN `END$b`END`PLN `END`KWDin`END`PLN `ENDdoc`END`PLN(`END`STR"http://bstore1.example.com/bib.xml"`END`PLN)/bib/book\n' + + ' `END`KWDwhere`END`PLN `END$b`END`PLN/publisher = `END`STR"Addison-Wesley"`END`PLN `END`KWDand`END`PLN `END$b`END`PLN/`END`LIT@year`END`PLN > 1991\n' + + ' `END`KWDreturn`END`PLN\n' + + ' `END`TAG<book`END`PLN year=`END`STR"`END`PLN{ `END$b`END`PLN/`END`LIT@year`END`PLN }`END`STR"`END`TAG>`END`PLN\n' + + ' { `END$b`END`PLN/title }\n' + + ' `END`TAG</book>`END`PLN\n' + + ' }\n' + + '`END`TAG</bib>`END`PLN\n' + + '`END`COM(: -------- :)`END' + ), + nemerle: ( + '`KWDclass`END`PLN Set `END`PUN[`END`PLN\'a`END`PUN]`END`PLN\n' + + '`END`PUN{`END`PLN\n' + + ' `END`KWDmutable`END`PLN storage `END`PUN:`END`PLN `END`TYPlist`END`PLN `END`PUN[`END`PLN\'a`END`PUN]`END`PLN `END`PUN=`END`PLN `END`PUN[];`END`PLN\n' + + ' `END`KWDpublic`END`PLN Add `END`PUN(`END`PLNe `END`PUN:`END`PLN \'a`END`PUN)`END`PLN `END`PUN:`END`PLN `END`TYPvoid`END`PLN\n' + + ' `END`PUN{`END`PLN\n' + + ' `END`KWDwhen`END`PLN `END`PUN(!`END`PLN Contains `END`PUN(`END`PLNe`END`PUN))`END`PLN\n' + + ' storage `END`PUN::=`END`PLN e`END`PUN;`END`PLN\n' + + ' `END`PUN}`END`PLN\n' + + ' `END`KWDpublic`END`PLN Contains `END`PUN(`END`PLNe `END`PUN:`END`PLN \'a`END`PUN)`END`PLN `END`PUN:`END`PLN `END`TYPbool`END`PLN\n' + + ' `END`PUN{`END`PLN\n' + + ' storage`END`PUN.`END`PLNContains `END`PUN(`END`PLNe`END`PUN)`END`PLN\n' + + ' `END`PUN}`END`PLN\n' + + '`END`PUN}`END`PLN\n' + + ' \n' + + '`END`KWDdef`END`PLN s1 `END`PUN=`END`PLN Set `END`PUN();`END`PLN\n' + + 's1`END`PUN.`END`PLNAdd `END`PUN(`END`LIT3`END`PUN);`END`PLN\n' + + 's1`END`PUN.`END`PLNAdd `END`PUN(`END`LIT42`END`PUN);`END`PLN\n' + + '`END`KWDassert`END`PLN `END`PUN(`END`PLNs1`END`PUN.`END`PLNContains `END`PUN(`END`LIT3`END`PUN));`END`PLN\n' + + '`END`COM// s1.Add ("foo"); // error here!`END`PLN\n' + + '`END`KWDdef`END`PLN s2 `END`PUN=`END`PLN Set `END`PUN();`END`PLN\n' + + 's2`END`PUN.`END`PLNAdd `END`PUN(`END`STR"foo"`END`PUN);`END`PLN\n' + + '`END`KWDassert`END`PLN `END`PUN(`END`PLNs2`END`PUN.`END`PLNContains `END`PUN(`END`STR"foo"`END`PUN));`END' + ), + latex: ( + '`COM% resume.tex`END`PLN\n' + + '`END`COM% vim:set ft=tex spell:`END`PLN\n' + + '`END`KWD\\documentclass`END`PUN[`END`LIT10pt`END`PLN,letterpaper`END`PUN]{`END`PLNarticle`END`PUN}`END`PLN\n' + + '`END`KWD\\usepackage`END`PUN[`END`PLNletterpaper,margin`END`PUN=`END`LIT0.8in`END`PUN]{`END`PLNgeometry`END`PUN}`END`PLN\n' + + '`END`KWD\\usepackage`END`PUN{`END`PLNmdwlist`END`PUN}`END`PLN\n' + + '`END`KWD\\usepackage`END`PUN[`END`PLNT1`END`PUN]{`END`PLNfontenc`END`PUN}`END`PLN\n' + + '`END`KWD\\usepackage`END`PUN{`END`PLNtextcomp`END`PUN}`END`PLN\n' + + '`END`KWD\\pagestyle`END`PUN{`END`PLNempty`END`PUN}`END`PLN\n' + + '`END`KWD\\setlength`END`PUN{`END`KWD\\tabcolsep`END`PUN}{`END`LIT0em`END`PUN}`END' + ), + issue144: ( + '`COM#! /bin/bash`END`PLN\n' + + '`END`COM# toascii.sh`END`PLN\n' + + '`END`KWDfor`END`PLN i `END`KWDin`END`PLN $`END`PUN(`END`PLNecho $`END`PUN*' + + '`END`PLN `END`PUN|`END`PLN fold `END`PUN-`END`PLNw `END`LIT1`END`PUN);`END' + + '`KWDdo`END`PLN\n' + + ' printf `END`STR"%x "`END`PLN \\\'$i`END`PUN;`END`PLN\n' + + '`END`KWDdone`END`PUN;`END`PLN\n' + + 'echo`END' + ), + issue145: ( + '`TAG<script`END`PLN `END`ATNtype`END`PUN=`END`ATV"text/javascript"`END`TAG>`END`PLN\n' + + '`END`PUN<!--`END`PLN\n' + + ' `END`KWDvar`END`PLN target `END`PUN=`END`PLN $$`END`PUN.`END`PLNcss`END`PUN(`END`STR\'backgroundImage\'`END`PUN).`END`PLNreplace`END`PUN(`END`STR/^url[\\(\\)\'"]/`END`PLNg`END`PUN,`END`PLN `END`STR\'\'`END`PUN);`END`PLN\n' + + '\n' + + ' `END`COM// nice long chain: wrap img element in span`END`PLN\n' + + ' $$`END`PUN.`END`PLNwrap`END`PUN(`END`STR\'<span style="position: relative;"></span>\'`END`PUN)`END`PLN\n' + + '`END`PUN-->`END`PLN\n' + + '`END`TAG</script>`END' + ), + clojure: ( + '`COM; Clojure test comment`END`PLN\n' + + '`END`OPN(`END`KWDns`END`PLN test\n' + + ' `END`OPN(`END`TYP:gen-class`END`CLO))`END`PLN\n' + + '\n' + + '`END`OPN(`END`KWDdef`END`PLN foo `END`STR"bar"`END`CLO)`END`PLN\n' + + '`END`OPN(`END`KWDdefn`END`PLN bar `END`OPN[`END`PLNarg1 arg2 & args`END`CLO]`END`PLN\n' + + ' `END`STR"sample function"`END`PLN\n' + + ' `END`OPN(`END`KWDfor`END`PLN `END`OPN[`END`PLNarg args`END`CLO]`END`PLN\n' + + ' `END`OPN(`END`KWDprn`END`PLN arg`END`CLO)))`END`PLN\n' + + '\n' + + '`END`OPN(`END`PLNbar `END`STR"foo"`END`PLN `END`STR"bar"`END`PLN `END`STR"blah"`END`PLN `END`TYP:baz`END`CLO)`END' + ), + html5conv1: '`COM; foo`END', + html5conv2: '`COM; foo`END', + html5conv3: ( + '`PLN\n' + + '`END`COM; foo`END`PLN\n' + + '`END\n' + ), + html5conv4: ( + '`PLNbefore CODE\n' + + '`END`PUN;`END`PLN foo`END\n' + ), + procinstr1: '`COM; foo`END', + procinstr2: '
  1. `COM; foo`END
', + procinstr3: '
  1. `COM; foo`END
', + procinstr4: '`COM; foo`END', + issue185: '`STR"No tag backs."`END', + issue261: '
  1. `STR"No tag backs."`END
', + issue201: ( + '`KWDstatic`END`PLN `END`TYPPersistent`END' + + '`PUN<`END`TYPString`END`PUN>`END`PLN listeners_symbol`END`PUN;`END' + ), + dart: ( + '`KWDpart of`END`PLN myLib`END`PUN;`END`PLN\n' + + '\n' + + '`END`KWDpart`END`PLN `END`STR\'something.dart\'`END`PUN;`END`PLN\n' + + '\n' + + '`END`KWDimport`END`PLN `END`STR\'dart:math\'`END`PLN `END' + + '`KWDas`END`PLN test `END`KWDshow`END`PLN foo`END`PUN,`END`PLN bar`END`PUN;`END' + + '`PLN\n' + + '\n' + + '`END`KWDclass`END`PLN `END`TYPPoint`END`PLN `END`PUN{`END`PLN\n' + + ' `END`KWDfinal`END`PLN `END`TYPnum`END`PLN x`END`PUN,`END`PLN y`END`PUN;`END`PLN\n' + + '\n' + + ' `END`TYPPoint`END`PUN(`END`KWDthis`END`PUN.`END`PLNx`END' + + '`PUN,`END`PLN `END`KWDthis`END`PUN.`END`PLNy`END`PUN);`END`PLN\n' + + ' `END`TYPPoint`END`PUN.`END`PLNzero`END`PUN()`END`PLN `END' + + '`PUN:`END`PLN x `END`PUN=`END`PLN `END`LIT0`END`PUN,`END' + + '`PLN y `END`PUN=`END`PLN `END`LIT0`END`PUN;`END`PLN `END' + + '`COM// Named constructor`END`PLN\n' + + ' `END' + + '`COM// with an initializer list.`END`PLN\n' + + '\n' + + ' `END`TYPnum`END`PLN distanceTo`END`PUN(`END`TYPPoint`END`PLN other`END' + + '`PUN)`END`PLN `END`PUN{`END`PLN\n' + + ' `END`KWDvar`END`PLN dx `END`PUN=`END`PLN x `END`PUN-`END' + + '`PLN other`END`PUN.`END`PLNx`END`PUN;`END`PLN\n' + + ' `END`KWDvar`END`PLN dy `END`PUN=`END`PLN y `END`PUN-`END' + + '`PLN other`END`PUN.`END`PLNy`END`PUN;`END`PLN\n' + + ' `END`KWDreturn`END`PLN sqrt`END`PUN(`END`PLNdx `END`PUN*`END' + + '`PLN dx `END`PUN+`END`PLN dy `END`PUN*`END`PLN dy`END`PUN);`END' + + '`PLN\n' + + ' `END`PUN}`END`PLN\n' + + '`END`PUN}`END`PLN\n' + + '\n' + + '`END`COM// This is a single-line comment.`END`PLN\n' + + '\n' + + '`END`COM/*\n' + + 'This is a\n' + + 'multiline comment.\n' + + '*/`END`PLN\n' + + '\n' + + 'main`END`PUN()`END`PLN `END`PUN{`END`PLN\n' + + ' `END`TYPPoint`END`PLN p `END`PUN=`END`PLN `END`KWDnew`END' + + '`PLN `END`TYPPoint`END`PUN(`END`LIT7`END`PUN,`END`PLN `END' + + '`LIT12`END`PUN);`END`PLN\n' + + ' `END`TYPString`END`PLN thing `END`PUN=`END`PLN `END' + + '`STR\'It\\\'s awesome!\'`END`PUN;`END`PLN\n' + + ' `END`TYPString`END`PLN thing2 `END`PUN=`END`PLN `END' + + '`STR\'\'\'\n' + + 'This is a test! \\\'\'\'\n' + + 'This is the end of the test\'\'\'`END`PUN;`END`PLN\n' + + ' `END`TYPString`END`PLN thing3 `END`PUN=`END`PLN `END' + + '`STRr\"\"\"\n' + + 'This is a raw\n' + + 'multiline string!\"\"\"`END`PUN;`END`PLN\n' + + ' `END`TYPnum`END`PLN x `END`PUN=`END`PLN `END`LIT0x123ABC`END`PUN;`END`PLN\n' + + ' `END`TYPnum`END`PLN y `END`PUN=`END`PLN `END`LIT1.8e-12`END`PUN;`END`PLN\n' + + ' `END`TYPbool`END`PLN flag `END`PUN=`END`PLN `END`KWDfalse`END' + + '`PUN;`END`PLN\n' + + ' `END`TYPString`END`PLN raw `END`PUN=`END`PLN `END' + + '`STRr\"This is a raw string, where \\n doesn\'t matter\"`END' + + '`PUN;`END`PLN\n' + + '`END`PUN}`END' + ), + tcl_lang: ( + '`COM#!/bin/tclsh`END`PLN\n' + + '`END`KWDproc`END`PLN fib `END`OPN{`END`PLNn`END`CLO}`END`PLN `END`OPN{`END`PLN\n' + + ' `END`KWDset`END`PLN a `END`LIT0`END`PLN\n' + + ' `END`KWDset`END`PLN b `END`LIT1`END`PLN\n' + + ' `END`KWDwhile`END`PLN `END`OPN{`END`PUN$`END`PLNn `END`PUN>`END`PLN `END`LIT0`END`CLO}`END`PLN `END`OPN{`END`PLN\n' + + ' `END`KWDset`END`PLN tmp `END`PUN$`END`PLNa\n' + + ' `END`KWDset`END`PLN a `END`PUN[`END`KWDexpr`END`PLN `END`PUN$`END`PLNa `END`PUN+`END`PLN `END`PUN$`END`PLNb`END`PUN]`END`PLN\n' + + ' `END`KWDset`END`PLN b `END`PUN$`END`PLNtmp\n' + + ' `END`KWDincr`END`PLN n `END`LIT-1`END`PLN\n' + + ' `END`CLO}`END`PLN\n' + + ' `END`KWDreturn`END`PLN `END`PUN$`END`PLNa\n' + + '`END`CLO}`END' + ), + r_lang: ( + '`COM### Example R script for syntax highlighting`END`PLN\n' + + '\n' + + '`END`COM# This is a comment`END`PLN\n' + + '\n' + + '`END`COM## Valid names`END`PLN\n' + + 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUV0123456789._a `END`PUN<-`END`PLN `END`LITNULL`END`PLN\n' + + '.foo_ `END`PUN<-`END`PLN `END`LITNULL`END`PLN\n' + + '._foo `END`PUN<-`END`PLN `END`LITNULL`END`PLN\n' + + '\n' + + '`END`COM## Invalid names`END`PLN\n' + + '`END`LIT0`END`PLNabc `END`PUN<-`END`PLN `END`LITNULL`END`PLN\n' + + '`END`LIT.0`END`PLNabc `END`PUN<-`END`PLN `END`LITNULL`END`PLN\n' + + 'abc`END`PUN+`END`PLNcde `END`PUN<-`END`PLN `END`LITNULL`END`PLN\n' + + '\n' + + '`END`COM## Reserved Words`END`PLN\n' + + '`END`LITNA`END`PLN\n' + + '`END`LITNA_integer_`END`PLN\n' + + '`END`LITNA_real_`END`PLN\n' + + '`END`LITNA_character_`END`PLN\n' + + '`END`LITNA_complex_`END`PLN\n' + + '`END`LITNULL`END`PLN\n' + + '`END`LITNaN`END`PLN\n' + + '`END`LITInf`END`PLN\n' + + '`END`COM## Not reserved`END`PLN\n' + + 'NULLa `END`PUN<-`END`PLN `END`LITNULL`END`PLN\n' + + 'NULL1 `END`PUN<-`END`PLN `END`LITNULL`END`PLN\n' + + 'NULL. `END`PUN<-`END`PLN `END`LITNULL`END`PLN\n' + + 'NA_foo_ `END`PUN<-`END`PLN `END`LITNULL`END`PLN\n' + + '\n' + + '`END`COM## Numbers`END`PLN\n' + + '`END`LIT12345678901`END`PLN\n' + + '`END`LIT123456.78901`END`PLN\n' + + '`END`LIT123e3`END`PLN\n' + + '`END`LIT123E3`END`PLN\n' + + '`END`LIT1.23e-3`END`PLN\n' + + '`END`LIT1.23e3`END`PLN\n' + + '`END`LIT1.23e-3`END`PLN\n' + + '`END`COM## integer constants`END`PLN\n' + + '`END`LIT123L`END`PLN\n' + + '`END`LIT1.23L`END`PLN\n' + + '`END`COM## imaginary numbers`END`PLN\n' + + '`END`LIT123i`END`PLN\n' + + '`END`LIT-123i`END`PLN\n' + + '`END`LIT123e4i`END`PLN\n' + + '`END`LIT123e-4i`END`PLN\n' + + '`END`COM## Hex numbers`END`PLN\n' + + '`END`LIT0xabcdefABCDEF01234`END`PLN\n' + + '`END`LIT0xabcp123`END`PLN\n' + + '`END`LIT0xabcP123`END`PLN\n' + + '`END`COM## Not hex`END`PLN\n' + + '`END`LIT0`END`PLNxg\n' + + '\n' + + '`END`COM## Special operators %xyz%`END`PLN\n' + + '`END`COM## %xyz%`END`PLN\n' + + '`END`LIT1`END`PLN `END`PUN%%`END`PLN `END`LIT2`END`PLN\n' + + 'diag`END`PUN(`END`LIT2`END`PUN)`END`PLN `END`PUN%*%`END`PLN diag`END`PUN(`END`LIT2`END`PUN)`END`PLN\n' + + '`END`LIT1`END`PLN `END`PUN%/%`END`PLN `END`LIT2`END`PLN\n' + + '`END`LIT1`END`PLN `END`PUN%in%`END`PLN `END`LIT1`END`PUN:`END`LIT10`END`PLN\n' + + 'diag`END`PUN(`END`LIT2`END`PUN)`END`PLN `END`PUN%o%`END`PLN diag`END`PUN(`END`LIT2`END`PUN)`END`PLN\n' + + 'diag`END`PUN(`END`LIT2`END`PUN)`END`PLN `END`PUN%x%`END`PLN diag`END`PUN(`END`LIT2`END`PUN)`END`PLN\n' + + '`END`STR`%foo bar%``END`PLN `END`PUN<-`END`PLN `END`KWDfunction`END`PUN(`END`PLNx`END`PUN,`END`PLN y`END`PUN)`END`PLN x `END`PUN+`END`PLN y\n' + + '`END`LIT1`END`PLN `END`PUN%foo bar%`END`PLN `END`LIT2`END`PLN\n' + + '\n' + + '`END`COM## Control Structures (3.2) and Function`END`PLN\n' + + '`END`COM## if, else`END`PLN\n' + + '`END`KWDif`END`PLN `END`PUN(`END`LITTRUE`END`PUN)`END`PLN print`END`PUN(`END`STR"foo"`END`PUN)`END`PLN `END`KWDelse`END`PLN print`END`PUN(`END`STR"bar"`END`PUN)`END`PLN\n' + + '`END`COM## For, in`END`PLN\n' + + '`END`KWDfor`END`PUN(`END`PLNi `END`KWDin`END`PLN `END`LIT1`END`PUN:`END`LIT5`END`PUN)`END`PLN `END`PUN{`END`PLN\n' + + ' print`END`PUN(`END`PLNi`END`PUN)`END`PLN\n' + + '`END`PUN}`END`PLN\n' + + '`END`COM## While, break`END`PLN\n' + + 'i `END`PUN<-`END`PLN `END`LIT1`END`PLN\n' + + '`END`KWDwhile`END`PLN `END`PUN(`END`LITTRUE`END`PUN)`END`PLN `END`PUN{`END`PLN\n' + + ' i `END`PUN<-`END`PLN i `END`PUN+`END`PLN `END`LIT1`END`PLN\n' + + ' `END`KWDif`END`PLN `END`PUN(`END`PLNi `END`PUN>`END`PLN `END`LIT3`END`PUN)`END`PLN `END`KWDbreak`END`PLN\n' + + '`END`PUN}`END`PLN\n' + + '`END`COM## Repeat`END`PLN\n' + + '`END`KWDrepeat`END`PLN `END`PUN{`END`LIT1+1`END`PUN}`END`PLN\n' + + '`END`COM## Switch`END`PLN\n' + + 'x `END`PUN<-`END`PLN `END`LIT3`END`PLN\n' + + '`END`KWDswitch`END`PUN(`END`PLNx`END`PUN,`END`PLN `END`LIT2+2`END`PUN,`END`PLN mean`END`PUN(`END`LIT1`END`PUN:`END`LIT10`END`PUN),`END`PLN rnorm`END`PUN(`END`LIT5`END`PUN))`END`PLN\n' + + '`END`COM## Function, dot-dot-dot, return`END`PLN\n' + + 'foo `END`PUN<-`END`PLN `END`KWDfunction`END`PUN(`END`LIT...`END`PUN)`END`PLN `END`PUN{`END`PLN\n' + + ' `END`KWDreturn`END`PUN(`END`PLNsum`END`PUN(`END`LIT...`END`PUN))`END`PLN\n' + + '`END`PUN}`END`PLN\n' + + '`END`COM# Not keywords`END`PLN\n' + + 'functiona `END`PUN<-`END`PLN `END`LIT2`END`PLN `END`PUN+`END`PLN `END`LIT2`END`PLN\n' + + 'function. `END`PUN<-`END`PLN `END`LIT2`END`PLN `END`PUN+`END`PLN `END`LIT2`END`PLN\n' + + 'function1 `END`PUN<-`END`PLN `END`LIT2`END`PLN `END`PUN+`END`PLN `END`LIT2`END`PLN\n' + + '\n' + + '\n' + + '`END`COM## Grouping Tokens 10.3.7`END`PLN\n' + + '`END`COM## Parentheses`END`PLN\n' + + '`END`LIT1`END`PLN `END`PUN+`END`PLN `END`PUN(`END`LIT2`END`PLN `END`PUN+`END`PLN `END`LIT3`END`PUN)`END`PLN\n' + + '`END`COM## brackets`END`PLN\n' + + 'foo `END`PUN<-`END`PLN `END`KWDfunction`END`PUN(`END`PLNa`END`PUN)`END`PLN `END`PUN{`END`PLN\n' + + ' a `END`PUN+`END`PLN `END`LIT1`END`PLN\n' + + '`END`PUN}`END`PLN\n' + + '\n' + + '`END`COM## Indexing 10.3.8`END`PLN\n' + + '`END`COM## []`END`PLN\n' + + 'bar `END`PUN<-`END`PLN `END`LIT1`END`PUN:`END`LIT10`END`PLN\n' + + 'bar`END`PUN[`END`LIT3`END`PUN]`END`PLN\n' + + '`END`COM## [[]]`END`PLN\n' + + 'foo `END`PUN<-`END`PLN list`END`PUN(`END`PLNa`END`PUN=`END`LIT1`END`PUN,`END`PLN b`END`PUN=`END`LIT2`END`PUN,`END`PLN c`END`PUN=`END`LIT3`END`PUN)`END`PLN\n' + + 'foo`END`PUN[[`END`STR"a"`END`PUN]]`END`PLN\n' + + '`END`COM## $`END`PLN\n' + + 'foo`END`PUN$`END`PLNa\n' + + 'foo`END`PUN$`END`STR"a"`END`PLN\n' + + '\n' + + '`END`COM## Operators`END`PLN\n' + + '`END`LIT2`END`PLN `END`PUN-`END`PLN `END`LIT2`END`PLN\n' + + '`END`LIT2`END`PLN `END`PUN+`END`PLN `END`LIT2`END`PLN\n' + + '`END`LIT2`END`PLN `END`PUN~`END`PLN `END`LIT2`END`PLN\n' + + '`END`PUN!`END`PLN `END`LITTRUE`END`PLN\n' + + '`END`PUN?`END`STR"help"`END`PLN\n' + + '`END`LIT1`END`PUN:`END`LIT2`END`PLN\n' + + '`END`LIT2`END`PLN `END`PUN*`END`PLN `END`LIT2`END`PLN\n' + + '`END`LIT2`END`PLN `END`PUN/`END`PLN `END`LIT2`END`PLN\n' + + '`END`LIT2`END`PUN^`END`LIT2`END`PLN\n' + + '`END`LIT2`END`PLN `END`PUN<`END`PLN `END`LIT2`END`PLN\n' + + '`END`LIT2`END`PLN `END`PUN>`END`PLN `END`LIT2`END`PLN\n' + + '`END`LIT2`END`PLN `END`PUN==`END`PLN `END`LIT2`END`PLN\n' + + '`END`LIT2`END`PLN `END`PUN>=`END`PLN `END`LIT2`END`PLN\n' + + '`END`LIT2`END`PLN `END`PUN<=`END`PLN `END`LIT2`END`PLN\n' + + '`END`LIT2`END`PLN `END`PUN!=`END`PLN `END`LIT2`END`PLN\n' + + '`END`LITTRUE`END`PLN `END`PUN&`END`PLN `END`LITFALSE`END`PLN\n' + + '`END`LITTRUE`END`PLN `END`PUN&&`END`PLN `END`LITFALSE`END`PLN\n' + + '`END`LITTRUE`END`PLN `END`PUN|`END`PLN `END`LITFALSE`END`PLN\n' + + '`END`LITTRUE`END`PLN `END`PUN||`END`PLN `END`LITFALSE`END`PLN\n' + + 'foo `END`PUN<-`END`PLN `END`LIT2`END`PLN `END`PUN+`END`PLN `END`LIT2`END`PLN\n' + + 'foo `END`PUN=`END`PLN `END`LIT2`END`PLN `END`PUN+`END`PLN `END`LIT2`END`PLN\n' + + '`END`LIT2`END`PLN `END`PUN+`END`PLN `END`LIT2`END`PLN `END`PUN->`END`PLN foo\n' + + 'foo `END`PUN<<-`END`PLN `END`LIT2`END`PLN `END`PUN+`END`PLN `END`LIT2`END`PLN\n' + + '`END`LIT2`END`PLN `END`PUN+`END`PLN `END`LIT2`END`PLN `END`PUN->>`END`PLN foo\n' + + 'base`END`PUN:::`END`PLNsum\n' + + 'base`END`PUN::`END`PLNsum\n' + + '\n' + + '`END`COM## Strings`END`PLN\n' + + 'foo `END`PUN<-`END`PLN `END`STR"hello, world!"`END`PLN\n' + + 'foo `END`PUN<-`END`PLN `END`STR\'hello, world!\'`END`PLN\n' + + 'foo `END`PUN<-`END`PLN `END`STR"Hello, \'world!"`END`PLN\n' + + 'foo `END`PUN<-`END`PLN `END`STR\'Hello, "world!\'`END`PLN\n' + + 'foo `END`PUN<-`END`PLN `END`STR\'Hello, \\\'world!\\\'\'`END`PLN\n' + + 'foo `END`PUN<-`END`PLN `END`STR"Hello, \\"world!\\""`END`PLN\n' + + 'foo `END`PUN<-`END`PLN `END`STR"Hello,\n' + + 'world!"`END`PLN\n' + + 'foo `END`PUN<-`END`PLN `END`STR\'Hello,\n' + + 'world!\'`END`PLN\n' + + '\n' + + '`END`COM## Backtick strings`END`PLN\n' + + '`END`STR`foo123 +!"bar\'baz``END`PLN `END`PUN<-`END`PLN `END`LIT2`END`PLN `END`PUN+`END`PLN `END`LIT2`END' + ), + mumps: ( + '`PLNHDR `END`COM; -- prt/display header`END`PLN\n' + + ' `END`KWDN`END`PLN `END`KWDX`END`PUN,`END`KWDI`END`PLN\n' + + ' `END`KWDI`END`PLN `END`PUN\'`END`DEC$D`END`PUN(`END`PLNVALMHDR`END`PUN)`END`PLN `END`KWDX`END`PUN:`END`DEC$G`END`PUN(`END`PLNVALM`END`PUN(`END`STR"HDR"`END`PUN))]`END`STR""`END`PLN VALM`END`PUN(`END`STR"HDR"`END`PUN)`END`PLN\n' + + ' `END`COM; -- prt hdr line`END`PLN\n' + + ' `END`KWDW`END`PUN:\'`END`DEC$D`END`PUN(`END`PLNVALMPG1`END`PUN)`END`PLN `END`PUN@`END`PLNIOF `END`KWDK`END`PLN VALMPG1\n' + + ' `END`KWDW`END`PUN:`END`PLNVALMCC `END`DEC$C`END`PUN(`END`LIT13`END`PUN)_`END`PLNIOUON`END`PUN_`END`DEC$C`END`PUN(`END`LIT13`END`PUN)_`END`PLNIOINHI`END`PUN_`END`DEC$C`END`PUN(`END`LIT13`END`PUN)`END`PLN `END`COM; -- turn on undln/hi`END`PLN\n' + + ' `END`KWDI`END`PLN `END`DEC$E`END`PUN(`END`PLNIOST`END`PUN,`END`LIT1`END`PUN,`END`LIT2`END`PUN)=`END`STR"C-"`END`PLN `END`KWDD`END`PLN IOXY^VALM4`END`PUN(`END`LIT0`END`PUN,`END`LIT0`END`PUN)`END`PLN `END`COM; -- position cursor`END`PLN\n' + + ' `END`KWDW`END`PLN `END`DEC$E`END`PUN(`END`PLNVALM`END`PUN(`END`STR"TITLE"`END`PUN),`END`LIT1`END`PUN,`END`LIT30`END`PUN)`END`PLN `END`COM; -- prt title`END`PLN\n' + + ' `END`KWDW`END`PUN:`END`PLNVALMCC IOINORM`END`PUN,`END`PLNIOUON `END`COM; -- turn off hi`END`PLN\n' + + ' `END`KWDW`END`PLN `END`DEC$J`END`PUN(`END`STR""`END`PUN,`END`LIT30`END`PUN-`END`DEC$L`END`PUN(`END`PLNVALM`END`PUN(`END`STR"TITLE"`END`PUN)))`END`PLN `END`COM; -- fill in w/blanks`END`PLN\n' + + ' `END`KWDI`END`PLN `END`DEC$E`END`PUN(`END`PLNIOST`END`PUN,`END`LIT1`END`PUN,`END`LIT2`END`PUN)=`END`STR"C-"`END`PLN `END`KWDW`END`PLN `END`DEC$C`END`PUN(`END`LIT13`END`PUN)`END`PLN `END`KWDD`END`PLN IOXY^VALM4`END`PUN(`END`LIT30`END`PUN,`END`LIT0`END`PUN)`END`PLN `END`COM; -- position cursor`END`PLN\n' + + ' `END`KWDW`END`PLN `END`DEC$J`END`PUN(`END`STR""`END`PUN,((`END`PLNVALMWD`END`LIT-80`END`PUN)/`END`LIT2`END`PUN)),`END`PLN$$HTE^XLFDT`END`PUN(`END`DEC$H`END`PUN,`END`LIT1`END`PUN),`END`DEC$J`END`PUN(`END`STR""`END`PUN,`END`LIT10`END`PUN+((`END`PLNVALMWD`END`LIT-80`END`PUN)/`END`LIT2`END`PUN)),`END`STR"Page: "`END`PUN,`END`DEC$J`END`PUN(`END`PLNVALMPGE`END`PUN,`END`LIT4`END`PUN),`END`STR" of "`END`PUN,`END`DEC$J`END`PUN(`END`PLN$$PAGE^VALM4`END`PUN(`END`PLNVALMCNT`END`PUN,`END`PLNVALM`END`PUN(`END`STR"LINES"`END`PUN)),`END`LIT4`END`PUN)_`END`DEC$S`END`PUN(`END`DEC$D`END`PUN(`END`PLNVALMORE`END`PUN):`END`STR"+"`END`PUN,`END`LIT1`END`PUN:`END`STR" "`END`PUN)`END`PLN `END`COM; -- prt rest of hdr`END`PLN\n' + + ' `END`KWDW`END`PUN:`END`PLNVALMCC IOUOFF `END`KWDI`END`PLN `END`DEC$E`END`PUN(`END`PLNIOST`END`PUN,`END`LIT1`END`PUN,`END`LIT2`END`PUN)=`END`STR"C-"`END`PLN `END`KWDD`END`PLN IOXY^VALM4`END`PUN(`END`LIT0`END`PUN,`END`LIT0`END`PUN)`END`PLN `END`COM; -- turn off undln`END`PLN\n' + + ' `END`KWDF`END`PLN `END`KWDI`END`PUN=`END`LIT1`END`PUN:`END`LIT1`END`PUN:`END`PLNVALM`END`PUN(`END`STR"TM"`END`PUN)`END`LIT-3`END`PLN `END`KWDW`END`PLN `END`PUN!,`END`DEC$S`END`PUN(\'`END`DEC$D`END`PUN(`END`PLNVALMHDR`END`PUN(`END`KWDI`END`PUN)):`END`STR""`END`PUN,`END`DEC$L`END`PUN(`END`PLNVALMHDR`END`PUN(`END`KWDI`END`PUN))>(`END`PLNVALMWD`END`LIT-1`END`PUN):`END`PLN$`END`DEC$EXTRACT`END`PLN^VALM4`END`PUN(`END`DEC$G`END`PUN(`END`PLNVALMHDR`END`PUN(`END`KWDI`END`PUN))),`END`LIT1`END`PUN:`END`PLNVALMHDR`END`PUN(`END`KWDI`END`PUN))`END`PLN `END`COM; -- prt hdr`END`PLN\n' + + ' `END`KWDQ`END' + ), + basic_lang: ( + '`LIT200`END`PLN `END`COMREM ----- method teardown`END`PLN\n' + + '`END`LIT210`END`PLN `END`KWDPRINT`END`PLN `END`STR"green"`END`PLN\n' + + '`END`LIT220`END`PLN `END`KWDRETURN`END`PLN\n' + + '`END`LIT470`END`PLN `END`KWDIF`END`PLN af`END`PUN=`END`LIT0`END`PLN `END`KWDTHEN`END`PLN `END`KWDGOTO`END`PLN `END`LIT520`END`PLN\n' + + '`END`LIT480`END`PLN `END`KWDFOR`END`PLN j`END`PUN=`END`LIT1`END`PLN `END`KWDTO`END`PLN af\n' + + '`END`LIT500`END`PLN ac`END`PUN=`END`PLNpf`END`PUN(`END`PLNj`END`PUN)`END`PLN `END`PUN:`END`PLN me$`END`PUN=`END`PLNSTR$`END`PUN(`END`PLNj`END`PUN)+`END`STR". factor"`END`PLN `END`PUN:`END`PLN `END`KWDGOSUB`END`PLN `END`LIT100`END`PLN\n' + + '`END`LIT510`END`PLN `END`KWDNEXT`END`PLN\n' + + '`END`LIT530`END`PLN `END`KWDRETURN`END`PLN\n' + + '`END`LIT1000`END`PLN `END`KWDDATA`END`PLN `END`STR"one"`END`PUN,`END`PLN `END`LIT1`END`PUN,`END`PLN `END`LIT0`END' + ), + pascal_lang: ( + '`COM(* some comment here *)`END`PLN\n' + + '`END`KWDPROCEDURE`END`PLN TestCase`END`PUN.`END`PLNAssertEquals`END`PUN(`END`PLNmsg`END`PUN:`END`PLNString`END`PUN;`END`PLN expect`END`PUN,`END`PLN act`END`PUN:`END`PLNLongint`END`PUN);`END`PLN\n' + + '`END`KWDVAR`END`PLN ex`END`PUN,`END`PLN ac`END`PUN:`END`PLNString`END`PUN;`END`PLN\n' + + '`END`KWDBEGIN`END`PLN\n' + + ' `END`KWDIF`END`PLN expect `END`PUN<>`END`PLN act `END`KWDTHEN`END`PLN\n' + + ' `END`KWDBEGIN`END`PLN\n' + + ' Str`END`PUN(`END`PLNexpect`END`PUN,`END`PLN ex`END`PUN);`END`PLN\n' + + ' Fail`END`PUN(`END`PLNConcat`END`PUN(`END`PLNmsg`END`PUN,`END`STR\' expected \'`END`PUN,`END`PLNex`END`PUN,`END`STR\' but was \'`END`PUN,`END`PLNac`END`PUN));`END`PLN\n' + + ' `END`KWDEND`END`PUN;`END`PLN\n' + + '\n' + + ' factors `END`PUN:=`END`PLN new`END`PUN(`END`PLNArrayListPtr`END`PUN,`END`PLN Init`END`PUN);`END`PLN\n' + + '\n' + + ' `END`KWDFOR`END`PLN candidate `END`PUN:=`END`PLN `END`LIT2`END`PLN `END`KWDTO`END`PLN i `END`KWDDO`END`PLN\n' + + ' `END`KWDBEGIN`END`PLN\n' + + ' `END`KWDWHILE`END`PLN i `END`KWDMOD`END`PLN candidate `END`PUN=`END`PLN `END`LIT0`END`PLN `END`KWDDO`END`PLN\n' + + ' `END`KWDBEGIN`END`PLN\n' + + ' factors`END`PUN^.`END`PLNAdd`END`PUN(`END`PLNcandidate`END`PUN);`END`PLN\n' + + ' i `END`PUN:=`END`PLN i `END`KWDDIV`END`PLN candidate`END`PUN;`END`PLN\n' + + ' `END`KWDEND`END`PUN;`END`PLN\n' + + ' `END`KWDEND`END`PUN;`END`PLN\n' + + '`END`KWDEND`END`PUN;`END' + ), + kotlin: ( + '`KWDpackage`END`PLN test`END`PUN;`END`PLN\n' + + '\n' + + '`END`KWDimport`END`PLN kotlin`END`PUN.`END`TYPInt`END`PLN\n' + + '\n' + + '`END`COM// Single line comment`END`PLN\n' + + '`END`COM/*\n' + + ' * Multiline\n' + + ' * comment\n' + + ' */`END`PLN\n' + + '\n' + + '`END`KWDtypealias`END`PLN `END`TYPSomeNumber`END`PLN `END`PUN=`END`PLN `END`TYPInt`END`PLN\n' + + '\n' + + '`END`KWDval`END`PLN number`END`PUN:`END`PLN `END`TYPLong`END`PLN `END`PUN=`END`PLN `END`LIT1_000L`END`PLN\n' + + '`END`KWDvar`END`PLN float`END`PUN:`END`PLN `END`TYPFloat`END`PLN `END`PUN=`END`PLN `END`LIT12.34f`END`PLN\n' + + '`END`LIT0xFF_FF`END`PLN\n' + + '`END`LIT3.14`END`PLN\n' + + '\n' + + '`END`LIT314e-2`END`PLN\n' + + '`END`LIT0.314e1`END`PLN\n' + + '\n' + + '`END`KWDprotected`END`PLN `END`KWDoverride`END`PLN `END`KWDfun`END`PLN ifBoolean`END`PUN(`END`PLNcondition`END`PUN:`END`PLN `END`TYPBoolean`END`PUN?`END`PLN `END`PUN=`END`PLN `END`LITnull`END`PUN)`END' + + '`PLN `END`PUN{}`END`PLN\n' + + '\n' + + '`END`PUN::`END`PLNifBoolean\n' + + '\n' + + '`END`KWDconstructor`END`PUN()`END`PLN `END`PUN:`END`PLN `END`KWDsuper`END`PUN()`END`PLN\n' + + '\n' + + '`END`STR"\\\"true\\\""`END`PLN\n' + + '`END`STR\'a\'`END`PLN\n' + + '\n' + + '`END`STR"""\n' + + 'aaaaaaaaaaa\n' + + '"""`END`PLN\n' + + '\n' + + '`END`LITloop@`END`PLN `END`KWDfor`END`PUN()`END`PLN\n' + + '\n' + + '`END`KWDbreak`END`PLN `END`LIT@loop`END`PLN\n' + + '\n' + + '`END`KWDenum class`END`PLN `END`TYP\`true\``END`PLN\n' + + '\n' + + '`END`KWDdata class`END`PLN `END`TYPPerson`END`PUN(`END`KWDval`END`PLN name`END`PUN:`END`PLN `END`TYPString`END`PUN)`END`PLN\n' + + '\n' + + '`END`KWDenum class`END`PLN `END`TYPSize`END`PLN `END`PUN{`END`PLN\n' + + ' BIG`END`PUN,`END`PLN MEDIUM`END`PUN,`END`PLN SMALL\n' + + '`END`PUN}`END`PLN\n' + + '\n' + + '`END`KWDclass`END`PLN `END`TYPBall`END`PUN(`END`KWDval`END`PLN color`END`PUN:`END`PLN `END`TYPString`END`PUN,`END`PLN `END`KWDval`END`PLN size`END`PUN:`END`PLN `END`TYPSize`END`PUN)`END`PLN `END`PUN{`END`PLN\n' + + ' `END`KWDcompanion object`END`PLN `END`PUN{}`END`PLN\n' + + '\n' + + ' `END`KWDfun`END`PLN isBig`END`PUN()`END`PLN `END`PUN=`END`PLN size `END`PUN==`END`PLN `END`TYPSize`END`PUN.`END`PLNBIG\n' + + '\n' + + ' `END`KWDval`END`PLN isMedium`END`PUN:`END`PLN `END`TYPBoolean`END`PLN\n' + + ' `END`KWDget`END`PUN()`END`PLN `END`PUN=`END`PLN size `END`PUN==`END`PLN `END`TYPSize`END`PUN.`END`PLNMEDIUM\n' + + '`END`PUN}`END`PLN\n' + + '\n' + + '`END`KWDfun`END`PLN `END`TYPBoolean`END`PUN?.`END`PLNisNull`END`PUN():`END`PLN `END`TYPBoolean`END`PLN `END`PUN=`END`PLN `END`KWDthis`END`PLN `END`PUN==`END`PLN `END`LITnull`END`PLN\n' + + '\n' + + '`END`KWDfun`END`PLN `END`TYPBoolean`END`PUN?.`END`PLNgetOrThrow`END`PUN():`END`PLN `END`TYPBoolean`END`PLN `END`PUN=`END`PLN `END`KWDthis`END`PLN `END`PUN?:`END`PLN `END`KWDthrow`END`PLN `END`TYPException`END`PUN()`END' + ), + llvm: ( + '`COM; Declare the string constant as a global constant.`END`PLN\n' + + '@.str `END`PUN=`END`PLN `END`KWDprivate`END`PLN `END`KWDunnamed_addr`END`PLN `END`KWDconstant`END`PLN `END`PUN[`END`LIT13`END`PLN `END`KWDx`END`PLN `END`KWDi8`END`PUN]`END`PLN `END`KWDc`END`STR"hello world\\0A\\00"`END`PLN\n' + + '\n' + + '`END`COM; External declaration of the puts function`END`PLN\n' + + '`END`KWDdeclare`END`PLN `END`KWDi32`END`PLN @puts`END`PUN(`END`KWDi8`END`PUN*`END`PLN `END`KWDnocapture`END`PUN)`END`PLN `END`KWDnounwind`END`PLN\n' + + '\n' + + '`END`COM; Definition of main function`END`PLN\n' + + '`END`KWDdefine`END`PLN `END`KWDi32`END`PLN @main`END`PUN()`END`PLN `END`PUN{`END`PLN `END`COM; i32()*`END`PLN\n' + + ' `END`COM; Convert [13 x i8]* to i8 *...`END`PLN\n' + + ' %cast210 `END`PUN=`END`PLN `END`KWDgetelementptr`END`PLN `END`PUN[`END`LIT13`END`PLN `END`KWDx`END`PLN `END`KWDi8`END`PUN]*`END`PLN @.str`END`PUN,`END`PLN `END`KWDi64`END`PLN `END`LIT0`END`PUN,`END`PLN `END`KWDi64`END`PLN `END`LIT0`END`PLN\n' + + '\n' + + ' `END`COM; Call puts function to write out the string to stdout.`END`PLN\n' + + ' `END`KWDcall`END`PLN `END`KWDi32`END`PLN @puts`END`PUN(`END`KWDi8`END`PUN*`END`PLN %cast210`END`PUN)`END`PLN\n' + + ' `END`KWDret`END`PLN `END`KWDi32`END`PLN `END`LIT0`END`PLN\n' + + '`END`PUN}`END`PLN\n' + + '\n' + + '`END`COM; Named metadata`END`PLN\n' + + '!1 `END`PUN=`END`PLN `END`KWDmetadata`END`PLN !`END`PUN{`END`KWDi32`END`PLN `END`LIT42`END`PUN}`END`PLN\n' + + '!foo `END`PUN=`END`PLN !`END`PUN{`END`PLN!1`END`PUN,`END`PLN `END`KWDnull`END`PUN}`END' + ), + issue217: ( + '`KWDif`END`PUN(!`END`STR/^https?:\\/\\//`END`PLNi`END`PUN.`END`PLNtest`END`PUN(`END`PLNval`END`PUN)`END`PLN `END`PUN&&`END`PLN foo `END`PUN==`END`PLN `END`STR\'bar\'`END`PUN)`END`PLN `END`PUN{`END`PLN\n' + + ' val `END`PUN=`END`PLN `END`STR\'http://\'`END`PLN `END`PUN+`END`PLN val`END`PUN;`END`PLN\n' + + '`END`PUN}`END' + ), + matlab: ( + '`COM%%%%%%%%%%%%%%%%%% DATA TYPES %%%%%%%%%%%%%%%%%%`END`PLN\n' + + '\n' + + '`ENDv`END`PLN `END`PUN=`END`PLN `END`TAG[`END`LIT1`END`PUN,`END`LIT2`END`PUN,`END`LIT3`END`PUN;`END`LIT4`END`PUN,`END`LIT5`END`PUN,`END`LIT6`END`TAG]`END`PUN;`END`PLN\n' + + '`ENDv`END`TAG(`ENDv`END`PUN>`END`LIT4`END`TAG)`END`PLN `END`PUN=`END`PLN `END`LIT0`END`PUN;`END`PLN\n' + + '\n' + + '`ENDs`END`PLN `END`PUN=`END`PLN `END`TYPstruct`END`TAG(`END`STR\'key\'`END`PUN,`END`LIT1`END`PUN,`END`PLN `END`STR\'key2\'`END`PUN,`END`STR\'string\'`END`TAG)`END`PUN;`END`PLN\n' + + '`ENDs.key`END`PLN `END`PUN=`END`PLN `END`LIT2`END`PUN;`END`PLN\n' + + '\n' + + '`ENDC`END`PLN `END`PUN=`END`PLN `END`TYPcell`END`TAG(`END`LIT1`END`PUN,`END`LIT2`END`TAG)`END`PUN;`END`PLN\n' + + '`ENDC`END`TAG{`END`LIT1`END`PUN,`END`LIT1`END`TAG}`END`PLN `END`PUN=`END`PLN `END`LIT0`END`PUN:`END`LIT9`END`PUN;`END`PLN\n' + + '\n' + + '`END`TYPdouble`END`TAG(`END`LIT1`END`TAG)`END`PLN\n' + + '`END`TYPsingle`END`TAG(`END`LIT1`END`TAG)`END`PLN\n' + + '`END`TYPuint8`END`TAG(`END`LIT1`END`TAG)`END`PLN\n' + + '`END`TYPint8`END`TAG(`END`LIT1`END`TAG)`END`PLN\n' + + '\n' + + '`END`COM%%%%%%%%%%%%%%%%%% STRINGS & TRANSPOSE %%%%%%%%%%%%%%%%%%`END`PLN\n' + + '\n' + + '`END`FUNplot`END`TAG(`ENDdata`END\'`END`TAG)`END`PUN;`END`PLN\n' + + '`END`FUNlegend`END`TAG(`ENDlabels`END`TAG)`END`PLN\n' + + '\n' + + '`ENDstr`END`PLN `END`PUN=`END`PLN `END`STR\'asdasd\'`END`PUN;`END`PLN `END`COM% this is a string`END`PLN\n' + + '`ENDstr`END`PLN `END`PUN=`END`PLN `END`STR\'asdas\'`END`PUN;`END`PLN\n' + + '`ENDstr`END`PLN `END`PUN=`END`PLN `END`STR\'sdasd\'\'sdasd\'`END`PUN;`END`PLN\n' + + '\n' + + '`ENDstr`END`PLN `END`PUN=`END`PLN `END`TAG[`END`STR\'one\'`END`PLN `END`STR\'two\'`END`PLN `END`STR\'three\'`END`TAG]`END`PUN;`END`PLN\n' + + '`ENDstr`END`PLN `END`PUN=`END`PLN `END`FUNstrcat`END`TAG(`END`STR\'one\'`END`PUN,`END`PLN `END`STR\'two\'`END`PUN,`END`PLN `END`STR\'three\'`END`TAG)`END`PUN;`END`PLN\n' + + '\n' + + '`END`COM% matrix transpose`END`PLN\n' + + '`ENDM`END`PLN `END`PUN=`END`PLN `END`FUNrand`END`TAG(`END`LIT3`END`PUN,`END`LIT3`END`TAG)`END\'`END`PUN;`END`PLN\n' + + '`ENDx`END`PLN `END`PUN=`END`PLN `ENDM`END`PUN.`END\'`END`PUN;`END`PLN\n' + + '`ENDx`END`PLN `END`PUN=`END`PLN `END`TAG[`END`LIT10`END`PLN `END`LIT20`END`PUN;`END`PLN `END`LIT30`END`PUN,`END`PLN `END`LIT40`END`TAG]`END\'`END`PUN;`END`PLN\n' + + '`END`FUNdisp`END`TAG(`ENDx`END\'`END`TAG)`END`PLN\n' + + '`END`FUNfprintf`END`TAG(`END`STR\'%d\\n\'`END`PUN,`END`PLN `ENDx`END`TAG(`END`PUN:`END`TAG)`END\'`END`TAG)`END`PLN `END`COM% with comment`END`PLN\n' + + '`END`TAG{`END`LIT1`END`PUN,`END`LIT2`END`TAG}`END\'`END`PLN `END`COM% another comment`END`PLN\n' + + '\n' + + '`END`COM%%%%%%%%%%%%%%%%%% LINE CONTINUATION %%%%%%%%%%%%%%%%%%`END`PLN\n' + + '\n' + + '`END`TAG[`END`LIT1`END`PLN `END`LIT20`END`PUN;`END`PLN `END...\n' + + '`END`LIT30`END`PLN `END`LIT4`END`TAG]`END`PLN\n' + + '\n' + + '`END`TAG[`END`STR\'gdgsd\'`END...\n' + + '`END`STR\'sdfs\'`END`TAG]`END`PLN\n' + + '\n' + + '`END`TAG{`END...\n' + + '`END`STR\'sdasd\'`END`PLN `END`PUN;`END`PLN\n' + + '`END`STR\'asdsad\'`END`TAG}`END`PLN\n' + + '\n' + + '`END`COM%%%%%%%%%%%%%%%%%% SYSTEM COMMANDS %%%%%%%%%%%%%%%%%%`END`PLN\n' + + '\n' + + '`END!touch file.txt`END`PLN\n' + + '\n' + + '`END`COM%%%%%%%%%%%%%%%%%% COMMAND OUTPUT %%%%%%%%%%%%%%%%%%`END`PLN\n' + + '\n' + + '`END>> `END`LIT1+1`END`PLN\n' + + '`ENDans`END`PLN `END`PUN=`END`PLN\n' + + ' `END`LIT2`END`PLN\n' + + '\n' + + '`END>> `END`LIT1+1`END`PLN\n' + + '\n' + + '`ENDans`END`PLN `END`PUN=`END`PLN\n' + + '\n' + + ' `END`LIT2`END`PLN\n' + + '\n' + + '`END`COM%%%%%%%%%%%%%%%%%% KEYWORDS %%%%%%%%%%%%%%%%%%`END`PLN\n' + + '\n' + + '`END`KWDfunction`END`PLN `ENDret`END`PLN `END`PUN=`END`PLN `ENDfcn`END`TAG(`ENDin`END`TAG)`END`PLN\n' + + ' `ENDret`END`PLN `END`PUN=`END`PLN `END`FUNsum`END`TAG(`ENDin`END`PUN.^`END`LIT2`END`TAG)`END`PUN;`END`PLN\n' + + '`END`KWDend`END`PLN\n' + + '\n' + + '`END`KWDclassdef`END`PLN `ENDCC`END`PLN `END`PUN<`END`PLN `END`FUNhandle`END`PLN\n' + + ' `ENDproperties`END`PLN `END`TAG(`ENDSetAccess`END`PLN `END`PUN=`END`PLN `ENDpublic`END`TAG)`END`PLN\n' + + ' `ENDx`END`PLN `END`PUN=`END`PLN `END`LIT0`END`PUN;`END`PLN\n' + + ' `END`KWDend`END`PLN\n' + + ' `END`FUNmethods`END`PLN\n' + + ' `END`KWDfunction`END`PLN `ENDthis`END`PLN `END`PUN=`END`PLN `ENDCC`END`TAG(`ENDvarargin`END`TAG)`END`PLN\n' + + ' `ENDthis.x`END`PLN `END`PUN=`END`PLN `END`LIT9`END`PUN;`END`PLN\n' + + ' `END`KWDend`END`PLN\n' + + ' `END`KWDend`END`PLN\n' + + '`END`KWDend`END`PLN\n' + + '\n' + + '`ENDx`END`PLN `END`PUN=`END`PLN `END`TAG[]`END`PUN;`END`PLN\n' + + '`END`KWDparfor`END`PLN `ENDi`END`PUN=`END`LIT1`END`PUN:`END`LIT10`END`PLN\n' + + ' `ENDx`END`TAG[`ENDi`END`TAG]`END`PLN `END`PUN=`END`PLN `ENDi`END`PUN;`END`PLN\n' + + '`END`KWDend`END`PLN\n' + + '\n' + + '`ENDtrue`END`PLN `END`PUN~=`END`PLN `ENDfalse`END`PLN\n' + + '\n' + + '`END`KWDif`END`PLN `ENDx`END`PUN==`END`LIT1`END`PLN\n' + + ' `ENDtrue`END`PLN\n' + + '`END`KWDelseif`END`PLN\n' + + ' `ENDfalse`END`PLN\n' + + '`END`KWDelse`END`PLN\n' + + ' `END`KWDreturn`END`PLN\n' + + '`END`KWDend`END`PLN\n' + + '\n' + + '`END`KWDwhile`END`PLN `ENDtrue`END`PLN\n' + + ' `END`KWDcontinue`END`PLN\n' + + ' `END`KWDbreak`END`PLN\n' + + '`END`KWDend`END`PLN\n' + + '\n' + + '`END`KWDtry`END`PLN\n' + + ' `END`FUNerror`END`TAG(`END`STR\'aa:aa\'`END`PUN,`END`PLN `END`STR\'asdasd\'`END`TAG)`END`PLN\n' + + '`END`KWDcatch`END`PLN `ENDME`END`PLN\n' + + ' `END`FUNwarning`END`TAG(`ENDME`END`TAG)`END`PLN\n' + + '`END`KWDend`END`PLN\n' + + '\n' + + '`END`KWDswitch`END`PLN `ENDx`END`PLN\n' + + ' `END`KWDcase`END`PLN `END`LIT1`END`PLN\n' + + ' `END`FUNdisp`END`TAG(`END`LIT1`END`TAG)`END`PLN\n' + + ' `END`KWDotherwise`END`PLN\n' + + ' `END`LIT0`END`PLN\n' + + '`END`KWDend`END`PLN\n' + + '\n' + + '`END`COM%%%%%%%%%%%%%%%%%% NUM LITERALS %%%%%%%%%%%%%%%%%%`END`PLN\n' + + '\n' + + '`END`LIT1`END`PLN\n' + + '`END`LIT1.`END`PLN\n' + + '`END`LIT.1`END`PLN\n' + + '`END`LIT1.0`END`PLN\n' + + '`END`LIT-1`END`PLN\n' + + '`END`LIT-1.`END`PLN\n' + + '`END`LIT-.1`END`PLN\n' + + '`END`LIT-1.0`END`PLN\n' + + '`END`LIT+10`END`PLN\n' + + '`END`LIT+01.`END`PLN\n' + + '`END`LIT+.1`END`PLN\n' + + '`END`LIT+1.0`END`PLN\n' + + '`END`LIT1e1`END`PLN\n' + + '`END`LIT1e-1`END`PLN\n' + + '`END`LIT1.e1`END`PLN\n' + + '`END`LIT1.e-1`END`PLN\n' + + '`END`LIT1.0e1`END`PLN\n' + + '`END`LIT1.0e-1`END`PLN\n' + + '`END`LIT.1e1`END`PLN\n' + + '`END`LIT.1e-1`END`PLN\n' + + '`END`LIT-.1e+1`END`PLN\n' + + '`END`LIT+1.e-1`END`PLN\n' + + '\n' + + '`END`LIT1i`END`PLN\n' + + '`END`LIT.10j`END`PLN\n' + + '`END`LIT-1.001i`END`PLN\n' + + '`END`LIT+1e-100j`END`PLN\n' + + '`END`LIT-.10e-01i`END`PLN\n' + + '\n' + + '`END`COM% unary vs binary operators`END`PLN\n' + + '`END`LIT1+1`END`PLN\n' + + '`END`LIT1`END`PUN+`END`PLN `END`LIT1`END`PLN\n' + + '`END`LIT1`END`PLN `END`LIT+1`END`PLN\n' + + '`END`LIT1`END`PLN `END`PUN+`END`PLN `END`LIT1`END`PLN\n' + + '`END`LIT+1+1`END`PLN\n' + + '`END`LIT+1`END`PUN+`END`PLN `END`LIT1`END`PLN\n' + + '`END`LIT+1`END`PLN `END`LIT+1`END`PLN\n' + + '`END`LIT+1`END`PLN `END`PUN+`END`PLN `END`LIT1`END`PLN\n' + + '\n' + + '`END`COM%%%%%%%%%%%%%%%%%% COMMENTS %%%%%%%%%%%%%%%%%%`END`PLN\n' + + '\n' + + '`END`COM% % comment % %`END`PLN\n' + + ' `END`COM% comment`END`PLN\n' + + '`END`COM% comment`END`PLN\n' + + '`END`COM%# comment`END`PLN\n' + + '`END`COM%% comment`END`PLN\n' + + '`END`COM%#x = sum(x);`END`PLN\n' + + '\n' + + '`END`COM%{\n' + + 'block comment\n' + + '%}`END`PLN\n' + + '\n' + + '`END`COM%{\n' + + '%}`END`PLN\n' + + '\n' + + '`END`COM%{\n' + + '\n' + + '%}`END`PLN\n' + + '\n' + + '`END`COM%{\n' + + '1\n' + + '2\n' + + '%}`END`PLN\n' + + '\n' + + '`END`COM%{\n' + + '% sdf {}\n' + + 'sdf\n' + + '%asda{}\n' + + 'sfds\n' + + '%}`END`PLN\n' + + '\n' + + ' `END`COM%{\n' + + 'dsf\n' + + ' %}`END`PLN\n' + + '\n' + + '`END`COM%{%}`END`PLN\n' + + '\n' + + '`END`COM%{ zzz=10; %}`END`PLN\n' + + '\n' + + '`END`COM%{%x=10;%}`END`PLN\n' + + '\n' + + '`END`COM%{ x\n' + + 'a=10;\n' + + '%}`END`PLN\n' + + '\n' + + '`END`COM%{\n' + + '%a=10;\n' + + '%}`END`PLN `ENDx`END`PLN\n' + + '\n' + + '`END`COM% nested block comments fail`END`PLN\n' + + '`END`COM%{\n' + + 'dfsdf\n' + + '%{\n' + + 'xxx\n' + + '%}`END`PLN\n' + + '`ENDdfsdf`END`PLN\n' + + '`END`COM%}`END`PLN\n' + + '\n' + + '`END`COM% fails here!`END`PLN\n' + + '`END`COM%{\n' + + 'x=10;\n' + + '%%{\n' + + '%%}`END`PLN\n' + + '`ENDy`END`PUN=`END`LIT20`END`PUN;`END`PLN\n' + + '`END`COM%}`END' + ), + elixir: ('`KWDdefmodule`END`PLN `END`TYPFoo`END`PUN.`END`TYPBar`END`PLN `END`KWDdo`END`PLN\n' + +' `END`ATN@moduledoc`END`PLN `END`STR"""\n' + +' Tests syntax highlighting for Elixir\n' + +' """`END`PLN\n' + +'\n' + +' `END`KWDuse`END`PLN `END`TYPBitwise`END`PLN\n' + +' `END`KWDrequire`END`PLN `END`TYPLogger`END`PLN\n' + +' `END`KWDalias`END`PLN `END`ATN__MODULE__`END`PUN,`END`PLN `END`LITas:`END`PLN `END`TYPThis`END`PLN\n' + +'\n' + +' `END`ATN@default_token_length`END`PLN `END`LIT10_000`END`PLN\n' + +'\n' + +'\n' + +' `END`ATN@spec`END`PLN token`END`PUN(`END`PLNlength `END`PUN::`END`PLN integer`END`PUN)`END`PLN `END`PUN::`END`PLN `END`TYPString`END`PUN.`END`PLNt\n' + +'\n' + +' `END`KWDdef`END`PLN token`END`PUN(`END`PLNlength `END`PUN\\\\`END`PLN `END`ATN@default_token_length`END`PUN),`END`PLN `END`KWDdo`END`PUN:`END`PLN `END`TYPString`END`PUN.`END`PLNduplicate`END`PUN(`END`STR"x"`END`PUN,`END`PLN length`END`PUN)`END`PLN\n' + +'\n' + +'\n' + +' `END`KWDdefp`END`PLN `END`COM_not_exported`END`PUN(),`END`PLN `END`KWDdo`END`PUN:`END`PLN `END`LIT0xFF`END`PLN `END`PUN+`END`PLN `END`LIT0xF_F`END`PLN `END`PUN-`END`PLN `END`LIT0xff`END`PLN\n' + +'\n' + +'\n' + +' `END`KWDdef`END`PLN other`END`PUN(`END`PLNfoo`END`PUN,`END`PLN bar`END`PUN)`END`PLN `END`KWDdo`END`PLN\n' + +' fun `END`PUN=`END`PLN `END`KWDfn`END`PUN{`END`COM_a`END`PUN,`END`PLN b`END`PUN}`END`PLN `END`PUN->`END`PLN b `END`PUN+`END`PLN `END`LIT1_3.1_4`END`PLN `END`KWDend`END`PLN\n' + +' fun`END`PUN.(`END`LIT1.0e+20`END`PUN)`END`PLN\n' + +' `END`COM_str`END`PLN `END`PUN=`END`PLN `END`STR"string without #{inspect(42)} interpolation"`END`PLN `END`PUN<>`END`PLN `END`STR" some more\n' + +' with newlines \\\n' + +' and newlines"`END`PLN\n' + +' charlist `END`PUN=`END`PLN `END`LIT\'some\\\'chars\n' + +' with newlines \\\n' + +' and newlines\'`END`PLN\n' + +' `END`PUN<<`END`PLNx`END`PUN::`END`PLNutf8`END`PUN,`END`PLN `END`COM_y`END`PUN::`END`PLNsize`END`PUN(`END`LIT8`END`PUN),`END`PLN data`END`PUN::`END`PLNbinary`END`PUN>>`END`PLN `END`PUN=`END`PLN `END`STR"fooo"`END`PLN\n' + +' ls `END`PUN=`END`PLN `END`PUN[`END`LIT1`END`PLN `END`PUN|`END`PLN `END`PUN[`END`LIT2`END`PUN,`END`PLN `END`LIT3`END`PUN]]`END`PLN\n' + +' map `END`PUN=`END`PLN `END`PUN%{`END`STR"baz"`END`PLN `END`PUN=>`END`PLN `END`STR"ban"`END`PUN}`END`PLN\n' + +' map `END`PUN=`END`PLN `END`PUN%{`END`LITfoo:`END`PLN `END`LIT:bar`END`PUN,`END`PLN `END`LIT"yes, this compiles":`END`PLN `END`LIT:"also an atom"`END`PUN}`END`PLN\n' + +' `END`LIT:erlang`END`PUN.`END`PLNtime`END`PUN()`END`PLN\n' + +' `END`KWDcase`END`PLN `END`PUN{`END`PLNfoo`END`PUN,`END`PLN bar`END`PUN}`END`PLN `END`KWDdo`END`PLN\n' + +' `END`PUN{`END`LIT1`END`PUN,`END`PLN `END`LIT2`END`PUN}`END`PLN `END`PUN->`END`PLN `END`LIT3`END`PLN\n' + +' `END`COM_something_else`END`PLN `END`PUN->`END`PLN `END`LIT:error`END`PLN\n' + +' `END`COM_`END`PLN `END`PUN->`END`PLN `END`LIT:"this won\'t match"`END`PLN\n' + +' `END`KWDend`END`PLN\n' + +' r `END`PUN=`END`PLN `END`LIT2`END`PLN\n' + +' `END`COM_bitwise_not`END`PLN `END`PUN=`END`PLN `END`PUN~~~`END`PLNr\n' + +'\n' + +' `END`ATV~r/foo/iu`END`PLN `END`COM# regex sigils are treated as normal ones`END`PLN\n' + +' `END`ATV~S|we have "quotes" and \'quotes\' and|`END`PLN `END`PUN<>`END`PLN `END`STR" more string"`END`PLN\n' + +' `END`ATV~c"custom sigil char \\"is\\" fine too"`END`PLN\n' + +' `END`ATV~r\'hello\'`END`PLN\n' + +' `END`ATV~w[hell\\] #o]`END`PLN `END`COM#sigil does not expand to the comment`END`PLN\n' + +' `END`ATV~w{hello}`END`PLN\n' + +' `END`ATV~C<hello>`END`PLN\n' + +' `END`KWDend`END`PLN\n' + +'\n' + +'`END`KWDend`END') +}; diff --git a/tests/recombineTagsAndDecorations_test.html b/tests/recombineTagsAndDecorations_test.html new file mode 100644 index 00000000..f6997230 --- /dev/null +++ b/tests/recombineTagsAndDecorations_test.html @@ -0,0 +1,119 @@ + + + + +recombineTagsAndDecorations + + + + + + + + +

Recombine Tags And Decorations Test

+ + + + + + + + + + + + + + + + + + + + + + + +
Test Single Decoration
"Hello, World!"[0, 'str']"Hello, World!"
Test Single Span
print "Hello, <World>!";[0, 'kwd', 5, 'pln', 6, 'str', 14, 'tag', 21, 'str', 23, 'pun']print "Hello, <World>!";
Test Interleaved
print "Hello, <World>!";[0, 'kwd', 5, 'pln', 6, 'str', 14, 'tag', 21, 'str', 23, 'pun']print "Hello, <World>!";
+ +
+

Log

+
+ + + + + diff --git a/tests/run_prettify_test.html b/tests/run_prettify_test.html index 29bea05f..e71370e6 100644 --- a/tests/run_prettify_test.html +++ b/tests/run_prettify_test.html @@ -1,57 +1,78 @@ - + - - Run_Prettify Test - + + +Run_Prettify Test + + +// load run_prettify +(function () { + function injectJS(url) { + var script = document.createElement('script'); + script.type = 'text/javascript'; + script.src = url; + document.getElementsByTagName('head')[0].appendChild(script); + } + var srcDir = /[&?]loader\b/.test(location.search) ? '../loader/' : '../src/'; + injectJS(srcDir + 'run_prettify.js' + + '?lang=css' + + '&callback=print_done' + + '&skin=sunburst' + + '&callback=dump_globals'); +})(); + + - - - -
+
+
+

run_prettify test

+

Note: try appending ?loader to this page URL to test the +minified version instead.

+ +

Test

+
 <div style="color: #f00">
-  Hello, World!
+  Hello, World!
 </div>
 
- + +

Log

+
+ + diff --git a/tests/shims.js b/tests/shims.js new file mode 100644 index 00000000..77cb9dc9 --- /dev/null +++ b/tests/shims.js @@ -0,0 +1,105 @@ +/** + * Shim for ES5 Date.now + * for older browsers (IE < 9, FF < 3, etc.) + * + * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/now#Polyfill + */ +(function () { + if (!Date.now) { + Date.now = function now() { + return new Date().getTime(); + }; + } +})(); + +/** + * Shim for HTML5 getElementsByClassName + * for older browsers (IE < 9, FF < 3, etc.) + */ +(function () { + if (!document.getElementsByClassName) { + document.getElementsByClassName = function (className) { + className = className.replace(/\s+/g, ' ').replace(/^\s*|\s*$/g, ' '); + var results = []; + function walk(node) { + if (node.nodeType !== 1) { return; } + // This test should be order-insensitive. + if ((' ' + node.className + ' ').indexOf(className) >= 0) { + results[results.length] = node; + } + for (var child = node.firstChild; child; child = child.nextSibling) { + walk(child); + } + } + walk(document.body); + return results; + }; + } +})(); + +/** + * Shim for "fixing" IE's lack of support (IE < 9) for applying slice + * on host objects like NamedNodeMap, NodeList, and HTMLCollection + * (technically, since host objects have been implementation-dependent, + * at least before ES2015, IE hasn't needed to work this way). + * Also works on strings, fixes IE < 9 to allow an explicit undefined + * for the 2nd argument (as in Firefox), and prevents errors when + * called on other DOM objects. + * + * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice#Streamlining_cross-browser_behavior + */ +(function () { + 'use strict'; + var _slice = Array.prototype.slice; + + try { + // Can't be used with DOM elements in IE < 9 + _slice.call(document.documentElement); + } catch (e) { // Fails in IE < 9 + // This will work for genuine arrays, array-like objects, + // NamedNodeMap (attributes, entities, notations), + // NodeList (e.g., getElementsByTagName), HTMLCollection (e.g., childNodes), + // and will not fail on other DOM objects (as do DOM elements in IE < 9) + Array.prototype.slice = function(begin, end) { + // IE < 9 gets unhappy with an undefined end argument + end = (typeof end !== 'undefined') ? end : this.length; + + // For native Array objects, we use the native slice function + if (Object.prototype.toString.call(this) === '[object Array]') { + return _slice.call(this, begin, end); + } + + // For array like object we handle it ourselves. + var i, cloned = [], + size, len = this.length; + + // Handle negative value for "begin" + var start = begin || 0; + start = (start >= 0) ? start : Math.max(0, len + start); + + // Handle negative value for "end" + var upTo = (typeof end === 'number') ? Math.min(end, len) : len; + if (end < 0) { + upTo = len + end; + } + + // Actual expected size of the slice + size = upTo - start; + + if (size > 0) { + cloned = new Array(size); + if (this.charAt) { + for (i = 0; i < size; i++) { + cloned[i] = this.charAt(start + i); + } + } else { + for (i = 0; i < size; i++) { + cloned[i] = this[start + i]; + } + } + } + + return cloned; + }; + } +}()); diff --git a/tests/test_base.js b/tests/test_base.js index 873622be..6590c6a3 100644 --- a/tests/test_base.js +++ b/tests/test_base.js @@ -6,7 +6,7 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -15,23 +15,192 @@ * limitations under the License. */ -// get accurate timing. -// This file must be loaded after prettify.js for this to work. -PR_SHOULD_USE_CONTINUATION = false; +/** + * Dynamically load script + * + * @param {string} url JavaScript file + * @param {Function=} opt_func onload callback + */ +function injectJS(url, opt_func) { + var el = document.createElement('script'); + if (typeof opt_func === 'function') { + el.onload = el.onerror = el.onreadystatechange = function () { + if (el && (!el.readyState || /loaded|complete/.test(el.readyState))) { + el.onerror = el.onload = el.onreadystatechange = null; + el = null; + opt_func(); + } + }; + } + el.type = 'text/javascript'; + el.src = url; + document.getElementsByTagName('head')[0].appendChild(el); +} + +/** + * Dynamically load stylesheet + * + * @param {string} url CSS file + */ +function injectCSS(url) { + var el = document.createElement('link'); + el.rel = 'stylesheet'; + el.type = 'text/css'; + el.href = url; + document.getElementsByTagName('head')[0].appendChild(el); +} + +/** + * Perform syntax highlighting and execute tests to verify results. + * + * @param {Object} goldens a mapping from IDs of prettyprinted + * chunks to an abbreviated form of the expected output. See "var goldens" + * in prettify_test.html and prettify_test_2.html for examples. + */ +function runTests(goldens) { + // Regexp literals defined here so that the interpreter doesn't have to + // compile them each time the function containing them is called. + /** @const {RegExp} */ + var ampRe = /&/g; + /** @const {RegExp} */ + var ltRe = //g; + /** @const {RegExp} */ + var quotRe = /\"/g; + /** @const {RegExp} */ + var nbspRe = /\xa0/g; + /** @const {RegExp} */ + var newlineRe = /[\r\n]/g; + /** @const {RegExp} */ + var voidElemsRe = /^(?:br|hr|link|img)$/; -var attribToHtml, textToHtml; + /** @type {?boolean} */ + var innerHtmlWorks = null; -var getInnerHtml; + /** + * Get timestamp in milliseconds unit. + * + * @return {number} + */ + function now() { + return (Date.now ? Date.now() : (new Date()).getTime()); + } -(function () { - /** is the given node's innerHTML normally unescaped? */ - function isRawContent(node) { - return 'XMP' === node.tagName; + /** + * Escapes HTML special characters to HTML. + * + * @param {string} str the HTML to escape + * @return {string} output escaped HTML + */ + function textToHtml(str) { + return str + .replace(ampRe, '&') + .replace(ltRe, '<') + .replace(gtRe, '>'); + } + + /** + * Like {@link textToHtml} but escapes double quotes to be attribute safe. + * + * @param {string} str the HTML to escape + * @return {string} output escaped HTML + */ + function attribToHtml(str) { + return textToHtml(str).replace(quotRe, '"'); + } + + /** + * convert a plain text string to HTML by escaping HTML special chars. + * + * @param {string} plainText + * @return {string} + */ + function htmlEscape(plainText) { + return attribToHtml(plainText).replace(nbspRe, ' '); + } + + /** + * Traverse node and manually build `innerHTML`. + * + * @param {Node} node DOM node + * @param {string} out HTML content + * @param {boolean=} opt_sortAttrs if attributes should be sorted + */ + function normalizedHtml(node, out, opt_sortAttrs) { + switch (node.nodeType) { + case 1: // ELEMENT_NODE + // start-tag + var name = node.tagName.toLowerCase(); + out.push('<', name); + // attributes + var attrs = node.attributes; + var n = attrs.length; + if (n) { + if (opt_sortAttrs) { + // sort attributes by name + var sortedAttrs = []; + for (var i = n; --i >= 0;) { sortedAttrs[i] = attrs[i]; } + sortedAttrs.sort(function (a, b) { + return (a.name < b.name) ? -1 : (a.name === b.name ? 0 : 1); + }); + attrs = sortedAttrs; + } + for (var i = 0; i < n; ++i) { + var attr = attrs[i]; + // specified: vs. + if (!attr.specified) { continue; } + out.push(' ', attr.name.toLowerCase(), + '="', attribToHtml(attr.value), '"'); + } + } + out.push('>'); + // children + for (var child = node.firstChild; child; child = child.nextSibling) { + normalizedHtml(child, out, opt_sortAttrs); + } + // end-tag + if (node.firstChild || !voidElemsRe.test(name)) { + out.push('<\/', name, '>'); + } + break; + case 3: // TEXT_NODE + case 4: // CDATA_SECTION_NODE + out.push(textToHtml(node.nodeValue)); + break; + } + } + + /** + * get normalized markup. innerHTML varies enough across browsers that we + * can't use it. + * + * @param {Node} node + * @return {string} + */ + function normalizedInnerHtml(node) { + // manually build innerHTML with sorted attributes + var out = []; + for (var child = node.firstChild; child; child = child.nextSibling) { + normalizedHtml(child, out, true); + } + out = out.join(''); + + // more normalization to work around problems with non-ascii chars in + // regexps in Safari + for (var i = 0; (i = out.indexOf('\xa0')) >= 0;) { + out = out.substring(0, i) + ' ' + out.substring(i + 1); + } + return out.replace(/\r\n?/g, '\n'); } - var newlineRe = /[\r\n]/g; /** - * Are newlines and adjacent spaces significant in the given node's innerHTML? + * Are newlines and adjacent spaces significant in the given node's + * `innerHTML`? + * + * @param {Node} node DOM node + * @param {string} content its HTML content + * @return {boolean} is it preformatted */ function isPreformatted(node, content) { // PRE means preformatted, and is a very common case, so don't create @@ -50,113 +219,49 @@ var getInnerHtml; return !whitespace || whitespace === 'pre'; } - // Define regexps here so that the interpreter doesn't have to create an - // object each time the function containing them is called. - // The language spec requires a new object created even if you don't access - // the $1 members. - var pr_amp = /&/g; - var pr_lt = //g; - var pr_quot = /\"/g; - - /** escapest html special characters to html. */ - textToHtml = function (str) { - return str.replace(pr_amp, '&') - .replace(pr_lt, '<') - .replace(pr_gt, '>'); - }; - - /** like textToHtml but escapes double quotes to be attribute safe. */ - attribToHtml = function (str) { - return str.replace(pr_amp, '&') - .replace(pr_lt, '<') - .replace(pr_gt, '>') - .replace(pr_quot, '"'); - }; - - var PR_innerHtmlWorks = null; - getInnerHtml = function (node) { - // inner html is hopelessly broken in Safari 2.0.4 when the content is - // an html description of well formed XML and the containing tag is a PRE + /** + * Get `innerHTML` of a node + * + * @param {Node} node DOM node + * @return {string} HTML content + */ + function getInnerHtml(node) { + // innerHTML is hopelessly broken in Safari 2.0.4 when the content is + // an HTML description of well formed XML and the containing tag is a PRE // tag, so we detect that case and emulate innerHTML. - if (null === PR_innerHtmlWorks) { - var testNode = document.createElement('PRE'); + if (null === innerHtmlWorks) { + var testNode = document.createElement('pre'); testNode.appendChild( - document.createTextNode('\n')); - PR_innerHtmlWorks = !/\n')); + innerHtmlWorks = !/)[\r\n]+/g, '$1') - .replace(/(?:[\r\n]+[ \t]*)+/g, ' '); + .replace(/(?:[\r\n]+[ \t]*)+/g, ' '); } return content; - } - - var out = []; - for (var child = node.firstChild; child; child = child.nextSibling) { - normalizedHtml(child, out); - } - return out.join(''); - }; -})(); - -function normalizedHtml(node, out, opt_sortAttrs) { - switch (node.nodeType) { - case 1: // an element - var name = node.tagName.toLowerCase(); - - out.push('<', name); - var attrs = node.attributes; - var n = attrs.length; - if (n) { - if (opt_sortAttrs) { - var sortedAttrs = []; - for (var i = n; --i >= 0;) { sortedAttrs[i] = attrs[i]; } - sortedAttrs.sort(function (a, b) { - return (a.name < b.name) ? -1 : a.name === b.name ? 0 : 1; - }); - attrs = sortedAttrs; - } - for (var i = 0; i < n; ++i) { - var attr = attrs[i]; - if (!attr.specified) { continue; } - out.push(' ', attr.name.toLowerCase(), - '="', attribToHtml(attr.value), '"'); - } - } - out.push('>'); + } else { + var out = []; for (var child = node.firstChild; child; child = child.nextSibling) { - normalizedHtml(child, out, opt_sortAttrs); + normalizedHtml(child, out); } - if (node.firstChild || !/^(?:br|link|img)$/.test(name)) { - out.push('<\/', name, '>'); - } - break; - case 3: case 4: // text - out.push(textToHtml(node.nodeValue)); - break; + return out.join(''); + } } -} - - -/** - * @param golden a mapping from IDs of prettyprinted chunks to an abbreviated - * form of the expected output. See "var goldens" in prettify_test.html - * for an example. - */ -function go(goldens) { - startClock(); - prettyPrint(function () { stopClock(); runTests(goldens); }); -} -function runTests(goldens) { - /** number of characters in common at the end up to max. */ + /** + * number of characters in common from the beginning. + * + * @param {string} a + * @param {string} b + * @return {number} + */ function commonPrefix(a, b) { var n = Math.min(a.length, b.length); var i; @@ -166,7 +271,14 @@ function runTests(goldens) { return i; } - /** number of characters in common at the end up to max. */ + /** + * number of characters in common at the end up to max. + * + * @param {string} a + * @param {string} b + * @param {number} max + * @return {number} + */ function commonSuffix(a, b, max) { var n = Math.min(a.length - max, b.length - max); var i; @@ -176,93 +288,125 @@ function runTests(goldens) { return i; } - /** convert a plain text string to html by escaping html special chars. */ - function html(plainText) { - return attribToHtml(plainText).replace(/\xa0/g, ' '); + /** + * Replace whitespace characters with printable graphical representations. + * + * @param {string} txt + * @return {string} + */ + function showAllCharacters(txt) { + // space = \xb7, \u02f0, \u2219, \u2423, \u2420 + // htab = \xbb, \u21e5, \u25b8, \u2409 + // newline = \xac, \xb6, \u21b5, \u2424 + // vtab = \u240B + // ffeed = \u240C + return txt + .replace(/ /g, '\xb7') + .replace(/(\r?\n)/g, '\u21b5$1') + .replace(/\t/g, '\u25b8') + .replace(/\v/g, '\u240B') + .replace(/\f/g, '\u240C'); } /** - * get normalized markup. innerHTML varies enough across browsers that we - * can't use it. + * Find differences between two texts, and return an HTML report. + * + * @param {string} golden text + * @param {string} actual text + * @return {string} HTML representation */ - function normalizedInnerHtml(node) { - var out = []; - for (var child = node.firstChild; child; child = child.nextSibling) { - normalizedHtml(child, out, true); - } - out = out.join(''); - // more normalization to work around problems with non-ascii chars in - // regexps in Safari - for (var i = 0; (i = out.indexOf('\xa0')) >= 0;) { - out = out.substring(0, i) + ' ' + out.substring(i + 1); + function diffTexts(golden, actual) { + if (true) { + golden = showAllCharacters(golden); + actual = showAllCharacters(actual); } - return out.replace(/\r\n?/g, '\n'); + var npre = commonPrefix(golden, actual); + var npost = commonSuffix(golden, actual, npre); + return ( + '
Golden<\/th>' + + htmlEscape(golden.substring(0, npre)) + + '»' + + htmlEscape(golden.substring(npre, golden.length - npost)) + + '<\/span>«' + + htmlEscape(golden.substring(golden.length - npost)) + + '<\/code><\/td><\/tr>
Actual<\/th>' + + htmlEscape(actual.substring(0, npre)) + + '»' + + htmlEscape(actual.substring(npre, actual.length - npost)) + + '<\/span>«' + + htmlEscape(actual.substring(actual.length - npost)) + + '<\/code><\/td><\/tr><\/table>' + ); } - var htmlOut = []; - var failures = 0; - document.getElementById('errorReport').innerHTML = - '

Running tests…<\/h1>'; - htmlOut.push('

Test results<\/h1>'); - for (var lang in goldens) { - var container = document.getElementById(lang); - // Convert abbreviations that start with `. - var golden = goldens[lang].replace(/`([A-Z]{3})/g, function (_, lbl) { - return (lbl == 'END' - ? '<\/span>' - : ''); + /** + * Convert golden from abbreviated form back to original text + * + * @param {string} golden + * @return {string} + */ + function expandGolden(golden) { + return golden.replace(/`([A-Z]{3})/g, function (_, lbl) { + // convert abbreviations that start with ` + return (lbl === 'END' ? '<\/span>' : + ''); }) - // Line numbers + // line numbers .replace(/`#(?![0-9])/, '
  • ') - .replace(/`#([0-9])/g, '
  • '); - var actual = normalizedInnerHtml(container); - if (golden !== actual) { // test failed - // write out - var pre = commonPrefix(golden, actual); - var post = commonSuffix(golden, actual, pre); - - ++failures; - htmlOut.push( - '

    ' - + html(lang) + '<\/a> Failed<\/h2>'); - htmlOut.push( - '' + html(golden.substring(0, pre)) + - '»' + - html(golden.substring(pre, golden.length - post)) + - '<\/span>«' + - html(golden.substring(golden.length - post)) + - - '
    !==
    ' + + .replace(/`#([0-9])/g, '<\/li>
  • '); + } - html(actual.substring(0, pre)) + - '»' + - html(actual.substring(pre, actual.length - post)) + - '<\/span>«' + - html(actual.substring(actual.length - post)) + '<\/tt>'); - } else { - htmlOut.push( - '

    ' + html(lang) + '<\/a> OK<\/h2>'); + /** + * Compare tests results against expected outcomes. + * + * @param {Object} goldens + * @return {{html: Array, pass: integer, fail: integer}} HTML report + */ + function runComparison(goldens) { + var out = []; + var npass = 0; + var nfail = 0; + for (var id in goldens) { + // compare actual against expexted + var golden = expandGolden(goldens[id]); + var actual = normalizedInnerHtml(document.getElementById(id)); + var diff = golden !== actual; + out.push('
    ' + (diff ? 'FAIL' : 'PASS') + + ': ' + id + '<\/a><\/div>'); + if (diff) { + ++nfail; + // write out difference + out.push( + diffTexts(golden, actual).replace(/<br>/g, '<br>\n')); + } else { + ++npass; + } } + out.unshift( + '

    \u2714 ' + npass + ' passing<\/p>', + '

    \u2718 ' + nfail + ' failing<\/p>'); + out.push('

    Tests ' + + (nfail ? 'failed' : 'passed') + '<\/h3>'); + return { + html: out, + pass: npass, + fail: nfail + }; } - var summary = ( - failures - ? (failures + ' test' + (failures === 1 ? '' : 's') + ' failed') - : 'Tests Passed'); - var summaryStr = '

    ' + summary + '<\/h2>'; - htmlOut.push(summaryStr); - htmlOut.splice(0, 0, summaryStr); - document.title += ' \u2014 ' + summary; - document.getElementById('errorReport').innerHTML = - htmlOut.join('').replace(/<br>/g, '<br>\n'); -} -var startTime = null; -function startClock() { - startTime = (new Date).getTime(); -} + // for more accurate timing, no continuation. + // This file must be loaded after prettify.js for this to work. + window.PR_SHOULD_USE_CONTINUATION = false; + + // time syntax highlighting + var t = now(); // tic + PR.prettyPrint(function () { + t = now() - t; // toc -function stopClock() { - var delta = (new Date).getTime() - startTime; - startTime = null; - document.getElementById('timing').innerHTML = 'Took ' + delta + ' ms'; + // verify results against golden and write HTML report + var report = runComparison(goldens); + document.title += (' \u2014 ' + (report.fail ? 'FAIL' : 'PASS')); + report.html.unshift('

    Took ' + t + ' ms<\/p>'); + document.getElementById('report').innerHTML = report.html.join('\n'); + }); } diff --git a/tests/test_in_node b/tests/test_in_node index c4df8b4b..1cd5c625 100755 --- a/tests/test_in_node +++ b/tests/test_in_node @@ -1,99 +1,89 @@ #!/usr/bin/env node -var Path = require("path"); -var Url = require("url"); +var path = require('path'); +var Browser = require('zombie'); +var htmlToText = require('html-to-text'); -var proc = Path.basename(process.argv[1]); +var optsZombie = { + debug: false, + silent: false, + waitDuration: '10s', + runScripts: true +}; +var optsHTT = { + wordwrap: 80, // process.stdout.columns + tables: true, + ignoreHref: true, + preserveNewlines: true, + singleNewLineParagraphs: true +}; + +var jobs = process.argv.slice(2); +var returnCode = 0; +var browser = null; -var modules_failed = []; +// start processing pages +startBrowser(); -var please_require = function(module) { - try { - return require(module); - } catch(error) { - console.error("%s: %s, %s", proc, error.name, error.message); - modules_failed.push(module); - return null; +function startBrowser() { + // close any previous browser sessions + if (browser) { + //browser.window.close(); + browser.destroy(); } -} -var Browser = please_require("zombie"); -var htmlToText = please_require("html-to-text"); + // next URL + var url = jobs.shift(); + if (url === undefined) { + console.log('>> Complete'); + process.exit(returnCode); + return; + } else if (!/^(?:https?|ftp):/.test(url)) { + // rewrite local path as a file:// URL + url = encodeURI('file://' + path.resolve(url).replace(/\\/g, '/')); + } -if(modules_failed.length !== 0) { - console.log("%s: You probably need to run:", proc); - modules_failed.forEach(function(module) { - console.log("%s: npm install %s", proc, module); - }); - process.exit(2); + // load page + console.log('>> Loading %s ...', url); + browser = new Browser(optsZombie); + if (optsZombie.debug) { browser.debug(); } + browser.visit(url).then(checkCb).catch(problemCb); } -var zombie_opts = { debug: false }; -var htt_opts = { wordwrap: (process.stdout.columns || 120) }; - -var showSection = function(sectionName, sectionHtml) { - console.log("%s: ######## %s ########", proc, sectionName); - var plainText = htmlToText.fromString(sectionHtml, htt_opts); - console.log(plainText); +function problemCb(err) { + // log error, and process next page + console.warn('>> ' + err); + returnCode = 1; + startBrowser(); } -var jobs = process.argv.slice(2); +function checkCb() { + var done = false; -var return_code = 0; -var browser = null; -var check_cb = null; -var problem_cb = null; + // check for errors + function onProb(err) { + console.warn('>> ' + err); + returnCode = 1; + done = true; + } + (browser.errors || []).forEach(onProb); + (browser.document.errors || []).forEach(onProb); -var startBrowser = function() { - if(browser) { - browser.close(); - } - var url = jobs.shift(); - if(url === undefined) { - console.log("%s: complete", proc); - process.exit(return_code); - return; - } - var url_obj = Url.parse(url); - if(!url_obj.protocol) { - url_obj.protocol = "file"; - url = Url.format(url_obj); - } - console.log("%s: Loading %s ...", proc, url); - browser = new Browser(); - browser.visit(url, zombie_opts, null).then(check_cb).fail(problem_cb); -}; + // retrieve and log results + var report = browser.html('#report'); + if (report && report.length) { + done = true; + //console.log(browser.text('#report')); + console.log(htmlToText.fromString( + // HACK: replace

    tags with

    + // https://github.com/werk85/node-html-to-text/issues/71 + report.replace(/(<\/?)div/ig, '$1p'), optsHTT)); + } -problem_cb = function(error) { - return_code = 1; - console.warn("Test failed: ", error); + // process next page if done, otherwise wait for page to complete loading + if (done) { startBrowser(); + } else { + browser.wait().then(checkCb).catch(problemCb); + } } - -check_cb = function() { - var done = false; - var one_prob = function(err_obj) { - console.warn("%s: %s, %s; %s", proc, err_obj.type, - err_obj.message, err_obj.data.error); - return_code = 1; - done = true; - }; - (browser.errors || []).forEach(one_prob); - (browser.document.errors || []).forEach(one_prob); - var report = browser.html("#errorReport"); - if(report.match(/Test results/i)) { - done = true; - showSection("TEST RESULTS", report); - } - var timing = browser.html("#timing"); - if(timing) { - showSection("TIMING", timing); - } - if(done) { - startBrowser(); - } else { - browser.wait().then(check_cb).fail(problem_cb); - } -} - -startBrowser(); diff --git a/tests/test_modules.css b/tests/test_modules.css new file mode 100644 index 00000000..ecc8141e --- /dev/null +++ b/tests/test_modules.css @@ -0,0 +1,90 @@ +/* tests table */ +table { + border-collapse: collapse; + border-spacing: 0; +} +table, th, td { + border: 1px solid black; +} +td, th { + padding: 2px; +} +tr { + vertical-align: top; +} +th { + background-color: #FFD; +} +td { + font-family: monospace; +} + +/* tests */ +.input, .golden, .actual, .decorations { + white-space: pre; +} + +/* results */ +.ok { + background-color: #DFD; +} +.failure, .error { + background-color: #FDD; +} +.ok:after { + color: green; + content: '\a[PASS]'; + font-weight: bold; +} +.failure:after { + color: red; + content: '\a[FAIL]'; + font-weight: bold; +} +.error:after { + color: #AF7817; + content: '\a[ERROR]'; + font-weight: bold; +} + +/* used in extractSourceSpans_test.html */ +.break { + padding-left: 2px; + border-right-style: dotted !important; +} +.odd, .even { + border-style: solid; + border-width: 1px; +} +.even { + background-color: #fff; + border-color: #888; +} +.odd { + background-color: #ddd; + border-color: #000; +} + +/* log */ +#report { + margin-left: 1em; +} +.pass { + color: green; +} +.fail, .err { + color: red; +} + +/* diff tables */ +table.diff { + table-layout: fixed; + max-width: 100%; +} +.diff th { + width: 50px; +} +.diff td { + white-space: pre-wrap; + word-wrap: break-word; +} diff --git a/tests/test_styles.css b/tests/test_styles.css index 7df16a5f..47e4b369 100644 --- a/tests/test_styles.css +++ b/tests/test_styles.css @@ -6,7 +6,7 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -15,8 +15,47 @@ * limitations under the License. */ -/* Used by error reporting code in test_base.js */ -.mismatch { background: #fee; font-weight: bold } -span.annot { margin:2px 2px 2px 3em; border:1px dotted #88f; background:#eef; - padding: 0 2px 0 2px } -.nocode { background: #f8f8f8 } +/* used by test_base.js */ +#report { + margin-left: 1em; +} +.pass { + color: green; +} +.fail { + color: red; +} +.mismatch { + background-color: #faa; + font-weight: bold; +} + +/* diff tables */ +table.diff { + border-collapse: collapse; + border-spacing: 0; + table-layout: fixed; + width: 100%; +} +.diff th, .diff td { + border: 1px solid black; +} +.diff th { + background-color: #FFD; + width: 50px; +} +.diff td { + white-space: pre-wrap; + word-wrap: break-word; +} + +/* used in prettify_test.html issue 22 */ +.annot { + background-color: #eef; + border: 1px dotted #88f; + margin: 2px 2px 2px 3em; + padding: 0 2px 0 2px; +} +.nocode { + background-color: #f8f8f8; +} diff --git a/tools/closure-compiler/COPYING b/tools/closure-compiler/COPYING deleted file mode 100644 index d6456956..00000000 --- a/tools/closure-compiler/COPYING +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/tools/closure-compiler/README.md b/tools/closure-compiler/README.md deleted file mode 100644 index cbb22775..00000000 --- a/tools/closure-compiler/README.md +++ /dev/null @@ -1,503 +0,0 @@ -# [Google Closure Compiler](https://developers.google.com/closure/compiler/) - -[![Build Status](https://travis-ci.org/google/closure-compiler.svg?branch=master)](https://travis-ci.org/google/closure-compiler) - -The [Closure Compiler](https://developers.google.com/closure/compiler/) is a tool for making JavaScript download and run faster. It is a true compiler for JavaScript. Instead of compiling from a source language to machine code, it compiles from JavaScript to better JavaScript. It parses your JavaScript, analyzes it, removes dead code and rewrites and minimizes what's left. It also checks syntax, variable references, and types, and warns about common JavaScript pitfalls. - -## Getting Started - * [Download the latest version](http://dl.google.com/closure-compiler/compiler-latest.zip) ([Release details here](https://github.com/google/closure-compiler/wiki/Releases)) - * [Download a specific version](https://github.com/google/closure-compiler/wiki/Binary-Downloads). Also available via: - - [Maven](https://github.com/google/closure-compiler/wiki/Maven) - - [NPM](https://www.npmjs.com/package/google-closure-compiler) - * See the [Google Developers Site](https://developers.google.com/closure/compiler/docs/gettingstarted_app) for documentation including instructions for running the compiler from the command line. - -## Options for Getting Help -1. Post in the [Closure Compiler Discuss Group](https://groups.google.com/forum/#!forum/closure-compiler-discuss) -2. Ask a question on [Stack Overflow](http://stackoverflow.com/questions/tagged/google-closure-compiler) -3. Consult the [FAQ](https://github.com/google/closure-compiler/wiki/FAQ) - -## Building it Yourself - -Note: The Closure Compiler requires [Java 7 or higher](http://www.java.com/). - -### Using [Maven](http://maven.apache.org/) - -1. Download [Maven](http://maven.apache.org/download.cgi). - -2. Run `mvn -DskipTests` (omit the `-DskipTests` if you want to run all the -unit tests too). - - This will produce a jar file called `target/closure-compiler-1.0-SNAPSHOT.jar`. - -### Using [Eclipse](http://www.eclipse.org/) - -1. Download and open the [Eclipse IDE](http://www.eclipse.org/). -2. Navigate to ```File > New > Project ...``` and create a Java Project. Give - the project a name. -3. Select ```Create project from existing source``` and choose the root of the - checked-out source tree as the existing directory. -3. Navigate to the ```build.xml``` file. You will see all the build rules in - the Outline pane. Run the ```jar``` rule to build the compiler in - ```build/compiler.jar```. - -## Running - -On the command line, at the root of this project, type - -``` -java -jar build/compiler.jar -``` - -This starts the compiler in interactive mode. Type - -```javascript -var x = 17 + 25; -``` - -then hit "Enter", then hit "Ctrl-Z" (on Windows) or "Ctrl-D" (on Mac or Linux) -and "Enter" again. The Compiler will respond: - -```javascript -var x=42; -``` - -The Closure Compiler has many options for reading input from a file, writing -output to a file, checking your code, and running optimizations. To learn more, -type - -``` -java -jar compiler.jar --help -``` - -More detailed information about running the Closure Compiler is available in the -[documentation](http://code.google.com/closure/compiler/docs/gettingstarted_app.html). - -## Compiling Multiple Scripts - -If you have multiple scripts, you should compile them all together with one -compile command. - -```bash -java -jar compiler.jar --js_output_file=out.js in1.js in2.js in3.js ... -``` - -You can also use minimatch-style globs. - -```bash -# Recursively include all js files in subdirs -java -jar compiler.jar --js_output_file=out.js 'src/**.js' - -# Recursively include all js files in subdirs, exclusing test files. -# Use single-quotes, so that bash doesn't try to expand the '!' -java -jar compiler.jar --js_output_file=out.js 'src/**.js' '!**_test.js' -``` - -The Closure Compiler will concatenate the files in the order they're passed at -the command line. - -If you're using globs or many files, you may start to run into -problems with managing dependencies between scripts. In this case, you should -use the [Closure Library](https://developers.google.com/closure/library/). It -contains functions for enforcing dependencies between scripts, and Closure Compiler -will re-order the inputs automatically. - -## How to Contribute -### Reporting a bug -1. First make sure that it is really a bug and not simply the way that Closure Compiler works (especially true for ADVANCED_OPTIMIZATIONS). - * Check the [official documentation](https://developers.google.com/closure/compiler/) - * Consult the [FAQ](https://github.com/google/closure-compiler/wiki/FAQ) - * Search on [Stack Overflow](http://stackoverflow.com/questions/tagged/google-closure-compiler) and in the [Closure Compiler Discuss Group](https://groups.google.com/forum/#!forum/closure-compiler-discuss) -2. If you still think you have found a bug, make sure someone hasn't already reported it. See the list of [known issues](https://github.com/google/closure-compiler/issues). -3. If it hasn't been reported yet, post a new issue. Make sure to add enough detail so that the bug can be recreated. The smaller the reproduction code, the better. - -### Suggesting a Feature -1. Consult the [FAQ](https://github.com/google/closure-compiler/wiki/FAQ) to make sure that the behaviour you would like isn't specifically excluded (such as string inlining). -2. Make sure someone hasn't requested the same thing. See the list of [known issues](https://github.com/google/closure-compiler/issues). -3. Read up on [what type of feature requests are accepted](https://github.com/google/closure-compiler/wiki/FAQ#how-do-i-submit-a-feature-request-for-a-new-type-of-optimization). -4. Submit your reqest as an issue. - -### Submitting patches -1. All contributors must sign a contributor license agreement (CLA). - A CLA basically says that you own the rights to any code you contribute, - and that you give us permission to use that code in Closure Compiler. - You maintain the copyright on that code. - If you own all the rights to your code, you can fill out an - [individual CLA](http://code.google.com/legal/individual-cla-v1.0.html). - If your employer has any rights to your code, then they also need to fill out - a [corporate CLA](http://code.google.com/legal/corporate-cla-v1.0.html). - If you don't know if your employer has any rights to your code, you should - ask before signing anything. - By default, anyone with an @google.com email address already has a CLA - signed for them. -2. To make sure your changes are of the type that will be accepted, ask about your patch on the [Closure Compiler Discuss Group](https://groups.google.com/forum/#!forum/closure-compiler-discuss) -3. Fork the repository. -4. Make your changes. -5. Submit a pull request for your changes. A project developer will review your work and then merge your request into the project. - -## Closure Compiler License - -Copyright 2009 The Closure Compiler Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0. - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - -## Dependency Licenses - -### Rhino - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Code Path - src/com/google/javascript/rhino, test/com/google/javascript/rhino -
    URLhttp://www.mozilla.org/rhino
    Version1.5R3, with heavy modifications
    LicenseNetscape Public License and MPL / GPL dual license
    DescriptionA partial copy of Mozilla Rhino. Mozilla Rhino is an -implementation of JavaScript for the JVM. The JavaScript -parse tree data structures were extracted and modified -significantly for use by Google's JavaScript compiler.
    Local ModificationsThe packages have been renamespaced. All code not -relevant to the parse tree has been removed. A JsDoc parser and static typing -system have been added.
    - -### Args4j - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Code Pathlib/args4j.jar
    URLhttps://args4j.dev.java.net/
    Version2.0.26
    LicenseMIT
    Descriptionargs4j is a small Java class library that makes it easy to parse command line -options/arguments in your CUI application.
    Local ModificationsNone
    - -### Guava Libraries - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Code Pathlib/guava.jar
    URLhttps://github.com/google/guava
    Version18.0
    LicenseApache License 2.0
    DescriptionGoogle's core Java libraries.
    Local ModificationsNone
    - -### JSR 305 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Code Pathlib/jsr305.jar
    URLhttp://code.google.com/p/jsr-305/
    Versionsvn revision 47
    LicenseBSD License
    DescriptionAnnotations for software defect detection.
    Local ModificationsNone
    - -### JUnit - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Code Pathlib/junit.jar
    URLhttp://sourceforge.net/projects/junit/
    Version4.11
    LicenseCommon Public License 1.0
    DescriptionA framework for writing and running automated tests in Java.
    Local ModificationsNone
    - -### Protocol Buffers - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Code Pathlib/protobuf-java.jar
    URLhttps://github.com/google/protobuf
    Version2.5.0
    LicenseNew BSD License
    DescriptionSupporting libraries for protocol buffers, -an encoding of structured data.
    Local ModificationsNone
    - -### Truth - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Code Pathlib/truth.jar
    URLhttps://github.com/google/truth
    Version0.24
    LicenseApache License 2.0
    DescriptionAssertion/Proposition framework for Java unit tests
    Local ModificationsNone
    - -### Ant - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Code Path - lib/ant.jar, lib/ant-launcher.jar -
    URLhttp://ant.apache.org/bindownload.cgi
    Version1.8.1
    LicenseApache License 2.0
    DescriptionAnt is a Java based build tool. In theory it is kind of like "make" -without make's wrinkles and with the full portability of pure java code.
    Local ModificationsNone
    - -### GSON - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Code Pathlib/gson.jar
    URLhttps://github.com/google/gson
    Version2.2.4
    LicenseApache license 2.0
    DescriptionA Java library to convert JSON to Java objects and vice-versa
    Local ModificationsNone
    - -### Node.js Closure Compiler Externs - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Code Pathcontrib/nodejs
    URLhttps://github.com/dcodeIO/node.js-closure-compiler-externs
    Versione891b4fbcf5f466cc4307b0fa842a7d8163a073a
    LicenseApache 2.0 license
    DescriptionType contracts for NodeJS APIs
    Local ModificationsSubstantial changes to make them compatible with NpmCommandLineRunner.
    diff --git a/tools/closure-compiler/compiler.jar b/tools/closure-compiler/compiler.jar deleted file mode 100644 index 9cae6957..00000000 Binary files a/tools/closure-compiler/compiler.jar and /dev/null differ diff --git a/tools/lang-handler-aliases.sh b/tools/lang-handler-aliases.sh deleted file mode 100755 index 32ccd63b..00000000 --- a/tools/lang-handler-aliases.sh +++ /dev/null @@ -1,69 +0,0 @@ -#!/bin/bash - -LANG_DIR="$1" -shift - -HAS_LANG_FILES=1 -if echo "$LANG_DIR"/lang-*.js | egrep -q "[*]" >& /dev/null; then - HAS_LANG_FILES=0 -fi - -if [ -n "$*" ] || [ -z "$LANG_DIR" ] || ! (( $HAS_LANG_FILES )); then - echo "Usage: $0 " - echo - echo "Dumps lines of the form" - echo " $LANG_DIR/lang-foo.js $LANG_DIR/lang-.js" - echo "where the first element is a path name under LANG_DIR" - echo "and the second is the name of a language extension for which" - echo "it registers an extension." - exit -1 -fi - -if [ -z "$JS_INTERPRETER" ]; then - JS_INTERPRETER="$(which v8)" - if ! [ -x "$JS_INTERPRETER" ]; then - JS_INTERPRETER="js17" - fi -fi - -if ! which "$JS_INTERPRETER" >& /dev/null; then - echo "\$JS_INTERPRETER ( '$JS_INTERPRETER' ) is not on the \$PATH." - echo "It should be an executable that loads each argument as a JS file" - echo "and runs them in a context where the print function dumps a string" - echo "to stdout." - exit -1 -fi - -for JS in "$LANG_DIR"/lang-*.js; do - # Run the language handler in a context where PR.registerLangHandler - # dumps out the handler names without doing anything else, and - # then use a perl script that prepends each handler with the basename - # of the JS file. - # The JS interpreter is run with STDIN of /dev/null so that it does not - # hand waiting for REPL input. - ("$JS_INTERPRETER" \ - -e ' - - var window = this; - var PR = { - registerLangHandler: function (_, exts) { - for (var i = 0, n = exts.length; i < n; ++i) { - var handler = String(exts[i]); - if (/^\w+$/.test(handler)) { - print(handler); - } - } - }, - createSimpleLexer: function () {}, - sourceDecorator: function () {} - }; - - ' \ - -f "$JS" \ - < /dev/null \ - || echo "Failed to execute $JS" 1>&2 ) \ - | perl -e '$JS=shift;' \ - -e 'use File::Basename; $DIR=dirname($JS);' \ - -e 'while () { s/^\w+$/$JS $DIR\/lang-$&.js/; print; }' \ - "$JS" -done diff --git a/tools/yui-compressor/LICENSE.TXT b/tools/yui-compressor/LICENSE.TXT deleted file mode 100644 index fc34134a..00000000 --- a/tools/yui-compressor/LICENSE.TXT +++ /dev/null @@ -1,54 +0,0 @@ -YUI Compressor Copyright License Agreement (BSD License) - -Copyright (c) 2009, Yahoo! Inc. -All rights reserved. - -Redistribution and use of this software in source and binary forms, -with or without modification, are permitted provided that the following -conditions are met: - -* Redistributions of source code must retain the above - copyright notice, this list of conditions and the - following disclaimer. - -* Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the - following disclaimer in the documentation and/or other - materials provided with the distribution. - -* Neither the name of Yahoo! Inc. nor the names of its - contributors may be used to endorse or promote products - derived from this software without specific prior - written permission of Yahoo! Inc. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -This software also requires access to software from the following sources: - -The Jarg Library v 1.0 ( http://jargs.sourceforge.net/ ) is available -under a BSD License – Copyright (c) 2001-2003 Steve Purcell, -Copyright (c) 2002 Vidar Holen, Copyright (c) 2002 Michal Ceresna and -Copyright (c) 2005 Ewan Mellor. - -The Rhino Library ( http://www.mozilla.org/rhino/ ) is dually available -under an MPL 1.1/GPL 2.0 license, with portions subject to a BSD license. - -Additionally, this software contains modified versions of the following -component files from the Rhino Library: - -[org/mozilla/javascript/Decompiler.java] -[org/mozilla/javascript/Parser.java] -[org/mozilla/javascript/Token.java] -[org/mozilla/javascript/TokenStream.java] - -The modified versions of these files are distributed under the MPL v 1.1 -( http://www.mozilla.org/MPL/MPL-1.1.html ) diff --git a/tools/yui-compressor/README b/tools/yui-compressor/README deleted file mode 100644 index c2b5751c..00000000 --- a/tools/yui-compressor/README +++ /dev/null @@ -1,145 +0,0 @@ -============================================================================== -YUI Compressor -============================================================================== - -NAME - - YUI Compressor - The Yahoo! JavaScript and CSS Compressor - -SYNOPSIS - - Usage: java -jar yuicompressor-x.y.z.jar [options] [input file] - - Global Options - -h, --help Displays this information - --type Specifies the type of the input file - --charset Read the input file using - --line-break Insert a line break after the specified column number - -v, --verbose Display informational messages and warnings - -o Place the output into or a file pattern. - Defaults to stdout. - - JavaScript Options - --nomunge Minify only, do not obfuscate - --preserve-semi Preserve all semicolons - --disable-optimizations Disable all micro optimizations - -DESCRIPTION - - The YUI Compressor is a JavaScript compressor which, in addition to removing - comments and white-spaces, obfuscates local variables using the smallest - possible variable name. This obfuscation is safe, even when using constructs - such as 'eval' or 'with' (although the compression is not optimal is those - cases) Compared to jsmin, the average savings is around 20%. - - The YUI Compressor is also able to safely compress CSS files. The decision - on which compressor is being used is made on the file extension (js or css) - -GLOBAL OPTIONS - - -h, --help - Prints help on how to use the YUI Compressor - - --line-break - Some source control tools don't like files containing lines longer than, - say 8000 characters. The linebreak option is used in that case to split - long lines after a specific column. It can also be used to make the code - more readable, easier to debug (especially with the MS Script Debugger) - Specify 0 to get a line break after each semi-colon in JavaScript, and - after each rule in CSS. - - --type js|css - The type of compressor (JavaScript or CSS) is chosen based on the - extension of the input file name (.js or .css) This option is required - if no input file has been specified. Otherwise, this option is only - required if the input file extension is neither 'js' nor 'css'. - - --charset character-set - If a supported character set is specified, the YUI Compressor will use it - to read the input file. Otherwise, it will assume that the platform's - default character set is being used. The output file is encoded using - the same character set. - - -o outfile - - Place output in file outfile. If not specified, the YUI Compressor will - default to the standard output, which you can redirect to a file. - Supports a filter syntax for expressing the output pattern when there are - multiple input files. ex: - java -jar yuicompressor.jar -o '.css$:-min.css' *.css - ... will minify all .css files and save them as -min.css - - -v, --verbose - Display informational messages and warnings. - -JAVASCRIPT ONLY OPTIONS - - --nomunge - Minify only. Do not obfuscate local symbols. - - --preserve-semi - Preserve unnecessary semicolons (such as right before a '}') This option - is useful when compressed code has to be run through JSLint (which is the - case of YUI for example) - - --disable-optimizations - Disable all the built-in micro optimizations. - -NOTES - - + If no input file is specified, it defaults to stdin. - - + Supports wildcards for specifying multiple input files. - - + The YUI Compressor requires Java version >= 1.4. - - + It is possible to prevent a local variable, nested function or function - argument from being obfuscated by using "hints". A hint is a string that - is located at the very beginning of a function body like so: - - function fn (arg1, arg2, arg3) { - "arg2:nomunge, localVar:nomunge, nestedFn:nomunge"; - - ... - var localVar; - ... - - function nestedFn () { - .... - } - - ... - } - - The hint itself disappears from the compressed file. - - + C-style comments starting with /*! are preserved. This is useful with - comments containing copyright/license information. For example: - - /*! - * TERMS OF USE - EASING EQUATIONS - * Open source under the BSD License. - * Copyright 2001 Robert Penner All rights reserved. - */ - - becomes: - - /* - * TERMS OF USE - EASING EQUATIONS - * Open source under the BSD License. - * Copyright 2001 Robert Penner All rights reserved. - */ - -MODIFIED RHINO FILES - - YUI Compressor uses a modified version of the Rhino library - (http://www.mozilla.org/rhino/) The changes were made to support - JScript conditional comments, preserved comments, unescaped slash - characters in regular expressions, and to allow for the optimization - of escaped quotes in string literals. - -COPYRIGHT AND LICENSE - - Copyright (c) 2010 Yahoo! Inc. All rights reserved. - The copyrights embodied in the content of this file are licensed - by Yahoo! Inc. under the BSD (revised) open source license. diff --git a/tools/yui-compressor/yuicompressor-2.4.8.jar b/tools/yui-compressor/yuicompressor-2.4.8.jar deleted file mode 100644 index a1cf0a09..00000000 Binary files a/tools/yui-compressor/yuicompressor-2.4.8.jar and /dev/null differ