├── distrib └── prettify-small.zip ├── tools └── closure-compiler │ ├── console-externs.js │ └── amd-externs.js ├── .gitignore ├── js-modules ├── node_prettify.js ├── regexpPrecederPatterns.js ├── defs.js ├── externs.js ├── extractSourceSpans.js └── regexpPrecederPatterns.pl ├── loader ├── prettify.css ├── skins │ ├── sons-of-obsidian.css │ ├── desert.css │ ├── sunburst.css │ └── doxy.css ├── lang-rd.js ├── lang-tex.js ├── lang-latex.js ├── lang-go.js ├── lang-proto.js ├── lang-ll.js ├── lang-llvm.js ├── lang-yaml.js ├── lang-yml.js ├── lang-basic.js ├── lang-cbm.js ├── lang-lua.js ├── lang-wiki.js ├── lang-erl.js ├── lang-erlang.js ├── lang-hs.js ├── lang-tcl.js ├── lang-pascal.js ├── lang-r.js ├── lang-s.js ├── lang-Splus.js ├── lang-cl.js ├── lang-el.js ├── lang-lisp.js ├── lang-lsp.js ├── lang-rkt.js ├── lang-scm.js ├── lang-ss.js ├── lang-kotlin.js ├── lang-lgt.js ├── lang-logtalk.js ├── lang-clj.js ├── lang-mumps.js ├── lang-css.js ├── lang-scala.js ├── lang-aea.js ├── lang-agc.js ├── lang-apollo.js ├── lang-dart.js ├── lang-fs.js ├── lang-ml.js ├── lang-ex.js ├── lang-exs.js ├── lang-vhd.js ├── lang-vhdl.js ├── lang-n.js ├── lang-nemerle.js ├── lang-swift.js ├── lang-rust.js ├── lang-sql.js ├── lang-vb.js ├── lang-vbs.js ├── lang-ls.js ├── lang-lasso.js └── lang-lassoscript.js ├── bower.json ├── src ├── lang-proto.js ├── lang-yaml.js ├── lang-rd.js ├── lang-tex.js ├── lang-wiki.js ├── lang-basic.js ├── lang-logtalk.js ├── lang-pascal.js ├── prettify.css ├── lang-llvm.js ├── lang-go.js ├── lang-kotlin.js ├── lang-r.js ├── lang-lua.js ├── lang-scala.js ├── lang-apollo.js ├── lang-tcl.js ├── lang-vhdl.js ├── lang-clj.js ├── lang-ml.js ├── lang-n.js ├── lang-dart.js ├── lang-sql.js ├── lang-swift.js ├── lang-erlang.js ├── lang-lisp.js └── lang-rust.js ├── tests ├── test_styles.css ├── test_modules.css ├── run_prettify_test.html ├── test_in_node └── shims.js ├── package.json ├── tasks ├── gcc.js ├── aliases.js └── lib │ └── lang-aliases.js ├── styles ├── desert.css ├── sunburst.css ├── sons-of-obsidian.css ├── doxy.css ├── demo.html └── index.html └── examples └── quine.html /distrib/prettify-small.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googlearchive/code-prettify/HEAD/distrib/prettify-small.zip -------------------------------------------------------------------------------- /tools/closure-compiler/console-externs.js: -------------------------------------------------------------------------------- 1 | var console = {}; 2 | /** 3 | * @param {string} message 4 | */ 5 | console.warn = function (message, var_args) {}; 6 | -------------------------------------------------------------------------------- /tools/closure-compiler/amd-externs.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @param {string} id 3 | * @param {Array.} dependencies 4 | * @param {Function} factory 5 | */ 6 | function define(id, dependencies, factory) {} 7 | /** @type {*} */ 8 | define.amd; 9 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # temporary files 2 | *~ 3 | *.swp 4 | .DS_Store 5 | 6 | # package managers 7 | /node_modules/ 8 | /bower_components/ 9 | npm-debug.log 10 | .bower.json 11 | 12 | # generated files 13 | #/src/prettify.js 14 | #/src/run_prettify.js 15 | #/loader/*.js 16 | #/loader/*.css 17 | #/loader/skins/*.css 18 | #/distrib/*.zip 19 | -------------------------------------------------------------------------------- /js-modules/node_prettify.js: -------------------------------------------------------------------------------- 1 | 2 | var IN_GLOBAL_SCOPE = false; 3 | 4 | /* @include prettify.js */ 5 | 6 | var path = require('path'); 7 | 8 | module.exports = { 9 | prettyPrint: prettyPrint, 10 | prettyPrintOne: prettyPrintOne, 11 | // include paths for css preprocessor support 12 | includePaths: [ 13 | __dirname, 14 | path.resolve(__dirname, '../styles') 15 | ] 16 | }; 17 | -------------------------------------------------------------------------------- /loader/prettify.css: -------------------------------------------------------------------------------- 1 | .pln{color:#000}@media screen{.str{color:#080}.kwd{color:#008}.com{color:#800}.typ{color:#606}.lit{color:#066}.clo,.opn,.pun{color:#660}.tag{color:#008}.atn{color:#606}.atv{color:#080}.dec,.var{color:#606}.fun{color:red}}@media print,projection{.kwd,.tag,.typ{font-weight:700}.str{color:#060}.kwd{color:#006}.com{color:#600;font-style:italic}.typ{color:#404}.lit{color:#044}.clo,.opn,.pun{color:#440}.tag{color:#006}.atn{color:#404}.atv{color:#060}}pre.prettyprint{padding:2px;border:1px solid #888}ol.linenums{margin-top:0;margin-bottom:0}li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{list-style-type:none}li.L1,li.L3,li.L5,li.L7,li.L9{background:#eee} -------------------------------------------------------------------------------- /loader/skins/sons-of-obsidian.css: -------------------------------------------------------------------------------- 1 | .str{color:#EC7600}.kwd{color:#93C763}.com{color:#66747B}.typ{color:#678CB1}.lit{color:#FACD22}.pln,.pun{color:#F1F2F3}.tag{color:#8AC763}.atn{color:#E0E2E4}.atv{color:#EC7600}.dec{color:purple}pre.prettyprint{border:0 solid #888}ol.linenums{margin-top:0;margin-bottom:0}.prettyprint{background:#000}li.L0,li.L1,li.L2,li.L3,li.L4,li.L5,li.L6,li.L7,li.L8,li.L9{color:#555;list-style-type:decimal}li.L1,li.L3,li.L5,li.L7,li.L9{background:#111}@media print{.kwd,.tag,.typ{font-weight:700}.str{color:#060}.kwd{color:#006}.com{color:#600;font-style:italic}.typ{color:#404}.lit{color:#044}.pun{color:#440}.pln{color:#000}.tag{color:#006}.atn{color:#404}.atv{color:#060}} -------------------------------------------------------------------------------- /bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "code-prettify", 3 | "description": "Google Code Prettify", 4 | "authors": [ 5 | "Google" 6 | ], 7 | "license": "Apache-2.0", 8 | "homepage": "https://github.com/google/code-prettify", 9 | "repository": { 10 | "type": "git", 11 | "url": "git+https://github.com/google/code-prettify.git" 12 | }, 13 | "keywords": [ 14 | "syntax", 15 | "highlight", 16 | "highlighting", 17 | "source", 18 | "code", 19 | "prettify", 20 | "google" 21 | ], 22 | "main": [ 23 | "src/prettify.js", 24 | "src/prettify.css" 25 | ], 26 | "moduleType": [ 27 | "globals", 28 | "amd" 29 | ], 30 | "ignore": [ 31 | "**/.*", 32 | "node_modules", 33 | "bower_components", 34 | "distrib", 35 | "js-modules", 36 | "tasks", 37 | "tests", 38 | "tools" 39 | ] 40 | } 41 | -------------------------------------------------------------------------------- /loader/skins/desert.css: -------------------------------------------------------------------------------- 1 | pre .atn,pre .kwd,pre .tag{font-weight:700}pre.prettyprint{display:block;background-color:#333}pre .nocode{background-color:none;color:#000}pre .str{color:#ffa0a0}pre .kwd{color:khaki}pre .com{color:#87ceeb}pre .typ{color:#98fb98}pre .lit{color:#cd5c5c}pre .pln,pre .pun{color:#fff}pre .tag{color:khaki}pre .atn{color:#bdb76b}pre .atv{color:#ffa0a0}pre .dec{color:#98fb98}ol.linenums{margin-top:0;margin-bottom:0;color:#AEAEAE}li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{list-style-type:none}@media print{pre.prettyprint{background-color:none}code .str,pre .str{color:#060}code .kwd,pre .kwd{color:#006;font-weight:700}code .com,pre .com{color:#600;font-style:italic}code .typ,pre .typ{color:#404;font-weight:700}code .lit,pre .lit{color:#044}code .pun,pre .pun{color:#440}code .pln,pre .pln{color:#000}code .tag,pre .tag{color:#006;font-weight:700}code .atn,pre .atn{color:#404}code .atv,pre .atv{color:#060}} -------------------------------------------------------------------------------- /loader/lang-rd.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2012 Jeffrey Arnold 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"],["com",/^%[^\r\n]*/,null,"%"]],[["lit",/^\\(?:cr|l?dots|R|tab)\b/],["kwd",/^\\[a-zA-Z@]+/],["kwd",/^#(?:ifn?def|endif)/],["pln",/^\\[{}]/],["pun",/^[{}()\[\]]+/]]),["Rd","rd"]); 18 | -------------------------------------------------------------------------------- /loader/lang-tex.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2011 Martin S. 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"],["com",/^%[^\r\n]*/,null,"%"]],[["kwd",/^\\[a-zA-Z@]+/],["kwd",/^\\./],["typ",/^[$&]/],["lit",/[+-]?(?:\.\d+|\d+(?:\.\d*)?)(cm|em|ex|in|pc|pt|bp|mm)/i],["pun",/^[{}()\[\]=]+/]]),["latex","tex"]); 18 | -------------------------------------------------------------------------------- /loader/lang-latex.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2011 Martin S. 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"],["com",/^%[^\r\n]*/,null,"%"]],[["kwd",/^\\[a-zA-Z@]+/],["kwd",/^\\./],["typ",/^[$&]/],["lit",/[+-]?(?:\.\d+|\d+(?:\.\d*)?)(cm|em|ex|in|pc|pt|bp|mm)/i],["pun",/^[{}()\[\]=]+/]]),["latex","tex"]); 18 | -------------------------------------------------------------------------------- /loader/lang-go.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2010 Google Inc. 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"],["pln",/^(?:\"(?:[^\"\\]|\\[\s\S])*(?:\"|$)|\'(?:[^\'\\]|\\[\s\S])+(?:\'|$)|`[^`]*(?:`|$))/,null,"\"'"]],[["com",/^(?:\/\/[^\r\n]*|\/\*[\s\S]*?\*\/)/],["pln",/^(?:[^\/\"\'`]|\/(?![\/\*]))+/i]]),["go"]); 18 | -------------------------------------------------------------------------------- /loader/lang-proto.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2006 Google Inc. 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.sourceDecorator({keywords:"bytes,default,double,enum,extend,extensions,false,group,import,max,message,option,optional,package,repeated,required,returns,rpc,service,syntax,to,true",types:/^(bool|(double|s?fixed|[su]?int)(32|64)|float|string)\b/,cStyleComments:!0}),["proto"]); 18 | -------------------------------------------------------------------------------- /loader/skins/sunburst.css: -------------------------------------------------------------------------------- 1 | code .str,pre .str{color:#65B042}code .kwd,pre .kwd{color:#E28964}code .com,pre .com{color:#AEAEAE;font-style:italic}code .typ,pre .typ{color:#89bdff}code .lit,pre .lit{color:#3387CC}code .pln,code .pun,pre .pln,pre .pun{color:#fff}code .tag,pre .tag{color:#89bdff}code .atn,pre .atn{color:#bdb76b}code .atv,pre .atv{color:#65B042}code .dec,pre .dec{color:#3387CC}code.prettyprint,pre.prettyprint{background-color:#000;border-radius:8px}pre.prettyprint{width:95%;margin:1em auto;padding:1em;white-space:pre-wrap}ol.linenums{margin-top:0;margin-bottom:0;color:#AEAEAE}li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{list-style-type:none}@media print{code .str,pre .str{color:#060}code .kwd,pre .kwd{color:#006;font-weight:700}code .com,pre .com{color:#600;font-style:italic}code .typ,pre .typ{color:#404;font-weight:700}code .lit,pre .lit{color:#044}code .pun,pre .pun{color:#440}code .pln,pre .pln{color:#000}code .tag,pre .tag{color:#006;font-weight:700}code .atn,pre .atn{color:#404}code .atv,pre .atv{color:#060}} -------------------------------------------------------------------------------- /loader/lang-ll.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2013 Nikhil Dabas 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"],["str",/^!?\"(?:[^\"\\]|\\[\s\S])*(?:\"|$)/,null,'"'],["com",/^;[^\r\n]*/,null,";"]],[["pln",/^[%@!](?:[-a-zA-Z$._][-a-zA-Z$._0-9]*|\d+)/],["kwd",/^[A-Za-z_][0-9A-Za-z_]*/,null],["lit",/^\d+\.\d+/],["lit",/^(?:\d+|0[xX][a-fA-F0-9]+)/],["pun",/^[()\[\]{},=*<>:]|\.\.\.$/]]),["llvm","ll"]); 18 | -------------------------------------------------------------------------------- /loader/lang-llvm.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2013 Nikhil Dabas 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"],["str",/^!?\"(?:[^\"\\]|\\[\s\S])*(?:\"|$)/,null,'"'],["com",/^;[^\r\n]*/,null,";"]],[["pln",/^[%@!](?:[-a-zA-Z$._][-a-zA-Z$._0-9]*|\d+)/],["kwd",/^[A-Za-z_][0-9A-Za-z_]*/,null],["lit",/^\d+\.\d+/],["lit",/^(?:\d+|0[xX][a-fA-F0-9]+)/],["pun",/^[()\[\]{},=*<>:]|\.\.\.$/]]),["llvm","ll"]); 18 | -------------------------------------------------------------------------------- /loader/lang-yaml.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2015 ribrdb @ code.google.com 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["pun",/^[:|>?]+/,null,":|>?"],["dec",/^%(?:YAML|TAG)[^#\r\n]+/,null,"%"],["typ",/^[&]\S+/,null,"&"],["typ",/^!\S*/,null,"!"],["str",/^"(?:[^\\"]|\\.)*(?:"|$)/,null,'"'],["str",/^'(?:[^']|'')*(?:'|$)/,null,"'"],["com",/^#[^\r\n]*/,null,"#"],["pln",/^\s+/,null," \t\r\n"]],[["dec",/^(?:---|\.\.\.)(?:[\r\n]|$)/],["pun",/^-/],["kwd",/^[\w-]+:[ \r\n]/],["pln", 18 | /^\w+/]]),["yaml","yml"]); 19 | -------------------------------------------------------------------------------- /loader/lang-yml.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2015 ribrdb @ code.google.com 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["pun",/^[:|>?]+/,null,":|>?"],["dec",/^%(?:YAML|TAG)[^#\r\n]+/,null,"%"],["typ",/^[&]\S+/,null,"&"],["typ",/^!\S*/,null,"!"],["str",/^"(?:[^\\"]|\\.)*(?:"|$)/,null,'"'],["str",/^'(?:[^']|'')*(?:'|$)/,null,"'"],["com",/^#[^\r\n]*/,null,"#"],["pln",/^\s+/,null," \t\r\n"]],[["dec",/^(?:---|\.\.\.)(?:[\r\n]|$)/],["pun",/^-/],["kwd",/^[\w-]+:[ \r\n]/],["pln", 18 | /^\w+/]]),["yaml","yml"]); 19 | -------------------------------------------------------------------------------- /loader/lang-basic.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2013 Peter Kofler 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["str",/^(?:"(?:[^\\"\r\n]|\\.)*(?:"|$))/,null,'"'],["pln",/^\s+/,null," \r\n\t\u00a0"]],[["com",/^REM[^\r\n]*/,null],["kwd",/^\b(?:AND|CLOSE|CLR|CMD|CONT|DATA|DEF ?FN|DIM|END|FOR|GET|GOSUB|GOTO|IF|INPUT|LET|LIST|LOAD|NEW|NEXT|NOT|ON|OPEN|OR|POKE|PRINT|READ|RESTORE|RETURN|RUN|SAVE|STEP|STOP|SYS|THEN|TO|VERIFY|WAIT)\b/,null],["pln",/^[A-Z][A-Z0-9]?(?:\$|%)?/i,null],["lit",/^(?:\d+(?:\.\d*)?|\.\d+)(?:e[+\-]?\d+)?/i, 18 | null,"0123456789"],["pun",/^.[^\s\w\.$%"]*/,null]]),["basic","cbm"]); 19 | -------------------------------------------------------------------------------- /loader/lang-cbm.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2013 Peter Kofler 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["str",/^(?:"(?:[^\\"\r\n]|\\.)*(?:"|$))/,null,'"'],["pln",/^\s+/,null," \r\n\t\u00a0"]],[["com",/^REM[^\r\n]*/,null],["kwd",/^\b(?:AND|CLOSE|CLR|CMD|CONT|DATA|DEF ?FN|DIM|END|FOR|GET|GOSUB|GOTO|IF|INPUT|LET|LIST|LOAD|NEW|NEXT|NOT|ON|OPEN|OR|POKE|PRINT|READ|RESTORE|RETURN|RUN|SAVE|STEP|STOP|SYS|THEN|TO|VERIFY|WAIT)\b/,null],["pln",/^[A-Z][A-Z0-9]?(?:\$|%)?/i,null],["lit",/^(?:\d+(?:\.\d*)?|\.\d+)(?:e[+\-]?\d+)?/i, 18 | null,"0123456789"],["pun",/^.[^\s\w\.$%"]*/,null]]),["basic","cbm"]); 19 | -------------------------------------------------------------------------------- /loader/lang-lua.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2008 Google Inc. 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"],["str",/^(?:\"(?:[^\"\\]|\\[\s\S])*(?:\"|$)|\'(?:[^\'\\]|\\[\s\S])*(?:\'|$))/,null,"\"'"]],[["com",/^--(?:\[(=*)\[[\s\S]*?(?:\]\1\]|$)|[^\r\n]*)/],["str",/^\[(=*)\[[\s\S]*?(?:\]\1\]|$)/],["kwd",/^(?:and|break|do|else|elseif|end|false|for|function|if|in|local|nil|not|or|repeat|return|then|true|until|while)\b/,null],["lit",/^[+-]?(?:0x[\da-f]+|(?:(?:\.\d+|\d+(?:\.\d*)?)(?:e[+\-]?\d+)?))/i], 18 | ["pln",/^[a-z_]\w*/i],["pun",/^[^\w\t\n\r \xA0][^\w\t\n\r \xA0\"\'\-\+=]*/]]),["lua"]); 19 | -------------------------------------------------------------------------------- /loader/lang-wiki.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2009 Google Inc. 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t \xA0a-gi-z0-9]+/,null,"\t \u00a0abcdefgijklmnopqrstuvwxyz0123456789"],["pun",/^[=*~\^\[\]]+/,null,"=*~^[]"]],[["lang-wiki.meta",/(?:^^|\r\n?|\n)(#[a-z]+)\b/],["lit",/^(?:[A-Z][a-z][a-z0-9]+[A-Z][a-z][a-zA-Z0-9]+)\b/],["lang-",/^\{\{\{([\s\S]+?)\}\}\}/],["lang-",/^`([^\r\n`]+)`/],["str",/^https?:\/\/[^\/?#\s]*(?:\/[^?#\s]*)?(?:\?[^#\s]*)?(?:#\S*)?/i],["pln",/^(?:\r\n|[\s\S])[^#=*~^A-Zh\{`\[\r\n]*/]]),["wiki"]); 18 | PR.registerLangHandler(PR.createSimpleLexer([["kwd",/^#[a-z]+/i,null,"#"]],[]),["wiki.meta"]); 19 | -------------------------------------------------------------------------------- /loader/lang-erl.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2013 Andrew Allen 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\x0B\x0C\r ]+/,null,"\t\n\x0B\f\r "],["str",/^\"(?:[^\"\\\n\x0C\r]|\\[\s\S])*(?:\"|$)/,null,'"'],["lit",/^[a-z][a-zA-Z0-9_]*/],["lit",/^\'(?:[^\'\\\n\x0C\r]|\\[^&])+\'?/,null,"'"],["lit",/^\?[^ \t\n({]+/,null,"?"],["lit",/^(?:0o[0-7]+|0x[\da-f]+|\d+(?:\.\d+)?(?:e[+\-]?\d+)?)/i,null,"0123456789"]],[["com",/^%[^\n]*/],["kwd",/^(?:module|attributes|do|let|in|letrec|apply|call|primop|case|of|end|when|fun|try|catch|receive|after|char|integer|float,atom,string,var)\b/], 18 | ["kwd",/^-[a-z_]+/],["typ",/^[A-Z_][a-zA-Z0-9_]*/],["pun",/^[.,;]/]]),["erlang","erl"]); 19 | -------------------------------------------------------------------------------- /loader/lang-erlang.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2013 Andrew Allen 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\x0B\x0C\r ]+/,null,"\t\n\x0B\f\r "],["str",/^\"(?:[^\"\\\n\x0C\r]|\\[\s\S])*(?:\"|$)/,null,'"'],["lit",/^[a-z][a-zA-Z0-9_]*/],["lit",/^\'(?:[^\'\\\n\x0C\r]|\\[^&])+\'?/,null,"'"],["lit",/^\?[^ \t\n({]+/,null,"?"],["lit",/^(?:0o[0-7]+|0x[\da-f]+|\d+(?:\.\d+)?(?:e[+\-]?\d+)?)/i,null,"0123456789"]],[["com",/^%[^\n]*/],["kwd",/^(?:module|attributes|do|let|in|letrec|apply|call|primop|case|of|end|when|fun|try|catch|receive|after|char|integer|float,atom,string,var)\b/], 18 | ["kwd",/^-[a-z_]+/],["typ",/^[A-Z_][a-zA-Z0-9_]*/],["pun",/^[.,;]/]]),["erlang","erl"]); 19 | -------------------------------------------------------------------------------- /loader/lang-hs.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2009 Google Inc. 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\x0B\x0C\r ]+/,null,"\t\n\x0B\f\r "],["str",/^\"(?:[^\"\\\n\x0C\r]|\\[\s\S])*(?:\"|$)/,null,'"'],["str",/^\'(?:[^\'\\\n\x0C\r]|\\[^&])\'?/,null,"'"],["lit",/^(?:0o[0-7]+|0x[\da-f]+|\d+(?:\.\d+)?(?:e[+\-]?\d+)?)/i,null,"0123456789"]],[["com",/^(?:(?:--+(?:[^\r\n\x0C]*)?)|(?:\{-(?:[^-]|-+[^-\}])*-\}))/],["kwd",/^(?:case|class|data|default|deriving|do|else|if|import|in|infix|infixl|infixr|instance|let|module|newtype|of|then|type|where|_)(?=[^a-zA-Z0-9\']|$)/, 18 | null],["pln",/^(?:[A-Z][\w\']*\.)*[a-zA-Z][\w\']*/],["pun",/^[^\t\n\x0B\x0C\r a-zA-Z0-9\'\"]+/]]),["hs"]); 19 | -------------------------------------------------------------------------------- /loader/lang-tcl.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2012 Pyrios 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["opn",/^\{+/,null,"{"],["clo",/^\}+/,null,"}"],["com",/^#[^\r\n]*/,null,"#"],["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"],["str",/^\"(?:[^\"\\]|\\[\s\S])*(?:\"|$)/,null,'"']],[["kwd",/^(?:after|append|apply|array|break|case|catch|continue|error|eval|exec|exit|expr|for|foreach|if|incr|info|proc|return|set|switch|trace|uplevel|upvar|while)\b/,null],["lit",/^[+\-]?(?:[0#]x[0-9a-f]+|\d+\/\d+|(?:\.\d+|\d+(?:\.\d*)?)(?:[ed][+\-]?\d+)?)/i], 18 | ["lit",/^\'(?:-*(?:\w|\\[\x21-\x7e])(?:[\w-]*|\\[\x21-\x7e])[=!?]?)?/],["pln",/^-*(?:[a-z_]|\\[\x21-\x7e])(?:[\w-]*|\\[\x21-\x7e])[=!?]?/i],["pun",/^[^\w\t\n\r \xA0()\"\\\';]+/]]),["tcl"]); 19 | -------------------------------------------------------------------------------- /loader/lang-pascal.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2013 Peter Kofler 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["str",/^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$))/,null,"'"],["pln",/^\s+/,null," \r\n\t\u00a0"]],[["com",/^\(\*[\s\S]*?(?:\*\)|$)|^\{[\s\S]*?(?:\}|$)/,null],["kwd",/^(?:ABSOLUTE|AND|ARRAY|ASM|ASSEMBLER|BEGIN|CASE|CONST|CONSTRUCTOR|DESTRUCTOR|DIV|DO|DOWNTO|ELSE|END|EXTERNAL|FOR|FORWARD|FUNCTION|GOTO|IF|IMPLEMENTATION|IN|INLINE|INTERFACE|INTERRUPT|LABEL|MOD|NOT|OBJECT|OF|OR|PACKED|PROCEDURE|PROGRAM|RECORD|REPEAT|SET|SHL|SHR|THEN|TO|TYPE|UNIT|UNTIL|USES|VAR|VIRTUAL|WHILE|WITH|XOR)\b/i, 18 | null],["lit",/^(?:true|false|self|nil)/i,null],["pln",/^[a-z][a-z0-9]*/i,null],["lit",/^(?:\$[a-f0-9]+|(?:\d+(?:\.\d*)?|\.\d+)(?:e[+\-]?\d+)?)/i,null,"0123456789"],["pun",/^.[^\s\w\.$@\'\/]*/,null]]),["pascal"]); 19 | -------------------------------------------------------------------------------- /loader/lang-r.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2012 Jeffrey B. Arnold 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"],["str",/^\"(?:[^\"\\]|\\[\s\S])*(?:\"|$)/,null,'"'],["str",/^\'(?:[^\'\\]|\\[\s\S])*(?:\'|$)/,null,"'"]],[["com",/^#.*/],["kwd",/^(?:if|else|for|while|repeat|in|next|break|return|switch|function)(?![A-Za-z0-9_.])/],["lit",/^0[xX][a-fA-F0-9]+([pP][0-9]+)?[Li]?/],["lit",/^[+-]?([0-9]+(\.[0-9]+)?|\.[0-9]+)([eE][+-]?[0-9]+)?[Li]?/],["lit",/^(?:NULL|NA(?:_(?:integer|real|complex|character)_)?|Inf|TRUE|FALSE|NaN|\.\.(?:\.|[0-9]+))(?![A-Za-z0-9_.])/], 18 | ["pun",/^(?:<>?|-|==|<=|>=|<|>|&&?|!=|\|\|?|\*|\+|\^|\/|!|%.*?%|=|~|\$|@|:{1,3}|[\[\](){};,?])/],["pln",/^(?:[A-Za-z]+[A-Za-z0-9_.]*|\.[a-zA-Z_][0-9a-zA-Z\._]*)(?![A-Za-z0-9_.])/],["str",/^`.+`/]]),["r","s","R","S","Splus"]); 19 | -------------------------------------------------------------------------------- /loader/lang-s.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2012 Jeffrey B. Arnold 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"],["str",/^\"(?:[^\"\\]|\\[\s\S])*(?:\"|$)/,null,'"'],["str",/^\'(?:[^\'\\]|\\[\s\S])*(?:\'|$)/,null,"'"]],[["com",/^#.*/],["kwd",/^(?:if|else|for|while|repeat|in|next|break|return|switch|function)(?![A-Za-z0-9_.])/],["lit",/^0[xX][a-fA-F0-9]+([pP][0-9]+)?[Li]?/],["lit",/^[+-]?([0-9]+(\.[0-9]+)?|\.[0-9]+)([eE][+-]?[0-9]+)?[Li]?/],["lit",/^(?:NULL|NA(?:_(?:integer|real|complex|character)_)?|Inf|TRUE|FALSE|NaN|\.\.(?:\.|[0-9]+))(?![A-Za-z0-9_.])/], 18 | ["pun",/^(?:<>?|-|==|<=|>=|<|>|&&?|!=|\|\|?|\*|\+|\^|\/|!|%.*?%|=|~|\$|@|:{1,3}|[\[\](){};,?])/],["pln",/^(?:[A-Za-z]+[A-Za-z0-9_.]*|\.[a-zA-Z_][0-9a-zA-Z\._]*)(?![A-Za-z0-9_.])/],["str",/^`.+`/]]),["r","s","R","S","Splus"]); 19 | -------------------------------------------------------------------------------- /loader/lang-Splus.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2012 Jeffrey B. Arnold 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"],["str",/^\"(?:[^\"\\]|\\[\s\S])*(?:\"|$)/,null,'"'],["str",/^\'(?:[^\'\\]|\\[\s\S])*(?:\'|$)/,null,"'"]],[["com",/^#.*/],["kwd",/^(?:if|else|for|while|repeat|in|next|break|return|switch|function)(?![A-Za-z0-9_.])/],["lit",/^0[xX][a-fA-F0-9]+([pP][0-9]+)?[Li]?/],["lit",/^[+-]?([0-9]+(\.[0-9]+)?|\.[0-9]+)([eE][+-]?[0-9]+)?[Li]?/],["lit",/^(?:NULL|NA(?:_(?:integer|real|complex|character)_)?|Inf|TRUE|FALSE|NaN|\.\.(?:\.|[0-9]+))(?![A-Za-z0-9_.])/], 18 | ["pun",/^(?:<>?|-|==|<=|>=|<|>|&&?|!=|\|\|?|\*|\+|\^|\/|!|%.*?%|=|~|\$|@|:{1,3}|[\[\](){};,?])/],["pln",/^(?:[A-Za-z]+[A-Za-z0-9_.]*|\.[a-zA-Z_][0-9a-zA-Z\._]*)(?![A-Za-z0-9_.])/],["str",/^`.+`/]]),["r","s","R","S","Splus"]); 19 | -------------------------------------------------------------------------------- /loader/lang-cl.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2008 Google Inc. 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["opn",/^\(+/,null,"("],["clo",/^\)+/,null,")"],["com",/^;[^\r\n]*/,null,";"],["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"],["str",/^\"(?:[^\"\\]|\\[\s\S])*(?:\"|$)/,null,'"']],[["kwd",/^(?:block|c[ad]+r|catch|con[ds]|def(?:ine|un)|do|eq|eql|equal|equalp|eval-when|flet|format|go|if|labels|lambda|let|load-time-value|locally|macrolet|multiple-value-call|nil|progn|progv|quote|require|return-from|setq|symbol-macrolet|t|tagbody|the|throw|unwind)\b/, 18 | null],["lit",/^[+\-]?(?:[0#]x[0-9a-f]+|\d+\/\d+|(?:\.\d+|\d+(?:\.\d*)?)(?:[ed][+\-]?\d+)?)/i],["lit",/^\'(?:-*(?:\w|\\[\x21-\x7e])(?:[\w-]*|\\[\x21-\x7e])[=!?]?)?/],["pln",/^-*(?:[a-z_]|\\[\x21-\x7e])(?:[\w-]*|\\[\x21-\x7e])[=!?]?/i],["pun",/^[^\w\t\n\r \xA0()\"\\\';]+/]]),"cl el lisp lsp scm ss rkt".split(" ")); 19 | -------------------------------------------------------------------------------- /loader/lang-el.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2008 Google Inc. 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["opn",/^\(+/,null,"("],["clo",/^\)+/,null,")"],["com",/^;[^\r\n]*/,null,";"],["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"],["str",/^\"(?:[^\"\\]|\\[\s\S])*(?:\"|$)/,null,'"']],[["kwd",/^(?:block|c[ad]+r|catch|con[ds]|def(?:ine|un)|do|eq|eql|equal|equalp|eval-when|flet|format|go|if|labels|lambda|let|load-time-value|locally|macrolet|multiple-value-call|nil|progn|progv|quote|require|return-from|setq|symbol-macrolet|t|tagbody|the|throw|unwind)\b/, 18 | null],["lit",/^[+\-]?(?:[0#]x[0-9a-f]+|\d+\/\d+|(?:\.\d+|\d+(?:\.\d*)?)(?:[ed][+\-]?\d+)?)/i],["lit",/^\'(?:-*(?:\w|\\[\x21-\x7e])(?:[\w-]*|\\[\x21-\x7e])[=!?]?)?/],["pln",/^-*(?:[a-z_]|\\[\x21-\x7e])(?:[\w-]*|\\[\x21-\x7e])[=!?]?/i],["pun",/^[^\w\t\n\r \xA0()\"\\\';]+/]]),"cl el lisp lsp scm ss rkt".split(" ")); 19 | -------------------------------------------------------------------------------- /loader/lang-lisp.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2008 Google Inc. 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["opn",/^\(+/,null,"("],["clo",/^\)+/,null,")"],["com",/^;[^\r\n]*/,null,";"],["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"],["str",/^\"(?:[^\"\\]|\\[\s\S])*(?:\"|$)/,null,'"']],[["kwd",/^(?:block|c[ad]+r|catch|con[ds]|def(?:ine|un)|do|eq|eql|equal|equalp|eval-when|flet|format|go|if|labels|lambda|let|load-time-value|locally|macrolet|multiple-value-call|nil|progn|progv|quote|require|return-from|setq|symbol-macrolet|t|tagbody|the|throw|unwind)\b/, 18 | null],["lit",/^[+\-]?(?:[0#]x[0-9a-f]+|\d+\/\d+|(?:\.\d+|\d+(?:\.\d*)?)(?:[ed][+\-]?\d+)?)/i],["lit",/^\'(?:-*(?:\w|\\[\x21-\x7e])(?:[\w-]*|\\[\x21-\x7e])[=!?]?)?/],["pln",/^-*(?:[a-z_]|\\[\x21-\x7e])(?:[\w-]*|\\[\x21-\x7e])[=!?]?/i],["pun",/^[^\w\t\n\r \xA0()\"\\\';]+/]]),"cl el lisp lsp scm ss rkt".split(" ")); 19 | -------------------------------------------------------------------------------- /loader/lang-lsp.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2008 Google Inc. 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["opn",/^\(+/,null,"("],["clo",/^\)+/,null,")"],["com",/^;[^\r\n]*/,null,";"],["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"],["str",/^\"(?:[^\"\\]|\\[\s\S])*(?:\"|$)/,null,'"']],[["kwd",/^(?:block|c[ad]+r|catch|con[ds]|def(?:ine|un)|do|eq|eql|equal|equalp|eval-when|flet|format|go|if|labels|lambda|let|load-time-value|locally|macrolet|multiple-value-call|nil|progn|progv|quote|require|return-from|setq|symbol-macrolet|t|tagbody|the|throw|unwind)\b/, 18 | null],["lit",/^[+\-]?(?:[0#]x[0-9a-f]+|\d+\/\d+|(?:\.\d+|\d+(?:\.\d*)?)(?:[ed][+\-]?\d+)?)/i],["lit",/^\'(?:-*(?:\w|\\[\x21-\x7e])(?:[\w-]*|\\[\x21-\x7e])[=!?]?)?/],["pln",/^-*(?:[a-z_]|\\[\x21-\x7e])(?:[\w-]*|\\[\x21-\x7e])[=!?]?/i],["pun",/^[^\w\t\n\r \xA0()\"\\\';]+/]]),"cl el lisp lsp scm ss rkt".split(" ")); 19 | -------------------------------------------------------------------------------- /loader/lang-rkt.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2008 Google Inc. 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["opn",/^\(+/,null,"("],["clo",/^\)+/,null,")"],["com",/^;[^\r\n]*/,null,";"],["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"],["str",/^\"(?:[^\"\\]|\\[\s\S])*(?:\"|$)/,null,'"']],[["kwd",/^(?:block|c[ad]+r|catch|con[ds]|def(?:ine|un)|do|eq|eql|equal|equalp|eval-when|flet|format|go|if|labels|lambda|let|load-time-value|locally|macrolet|multiple-value-call|nil|progn|progv|quote|require|return-from|setq|symbol-macrolet|t|tagbody|the|throw|unwind)\b/, 18 | null],["lit",/^[+\-]?(?:[0#]x[0-9a-f]+|\d+\/\d+|(?:\.\d+|\d+(?:\.\d*)?)(?:[ed][+\-]?\d+)?)/i],["lit",/^\'(?:-*(?:\w|\\[\x21-\x7e])(?:[\w-]*|\\[\x21-\x7e])[=!?]?)?/],["pln",/^-*(?:[a-z_]|\\[\x21-\x7e])(?:[\w-]*|\\[\x21-\x7e])[=!?]?/i],["pun",/^[^\w\t\n\r \xA0()\"\\\';]+/]]),"cl el lisp lsp scm ss rkt".split(" ")); 19 | -------------------------------------------------------------------------------- /loader/lang-scm.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2008 Google Inc. 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["opn",/^\(+/,null,"("],["clo",/^\)+/,null,")"],["com",/^;[^\r\n]*/,null,";"],["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"],["str",/^\"(?:[^\"\\]|\\[\s\S])*(?:\"|$)/,null,'"']],[["kwd",/^(?:block|c[ad]+r|catch|con[ds]|def(?:ine|un)|do|eq|eql|equal|equalp|eval-when|flet|format|go|if|labels|lambda|let|load-time-value|locally|macrolet|multiple-value-call|nil|progn|progv|quote|require|return-from|setq|symbol-macrolet|t|tagbody|the|throw|unwind)\b/, 18 | null],["lit",/^[+\-]?(?:[0#]x[0-9a-f]+|\d+\/\d+|(?:\.\d+|\d+(?:\.\d*)?)(?:[ed][+\-]?\d+)?)/i],["lit",/^\'(?:-*(?:\w|\\[\x21-\x7e])(?:[\w-]*|\\[\x21-\x7e])[=!?]?)?/],["pln",/^-*(?:[a-z_]|\\[\x21-\x7e])(?:[\w-]*|\\[\x21-\x7e])[=!?]?/i],["pun",/^[^\w\t\n\r \xA0()\"\\\';]+/]]),"cl el lisp lsp scm ss rkt".split(" ")); 19 | -------------------------------------------------------------------------------- /loader/lang-ss.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2008 Google Inc. 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["opn",/^\(+/,null,"("],["clo",/^\)+/,null,")"],["com",/^;[^\r\n]*/,null,";"],["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"],["str",/^\"(?:[^\"\\]|\\[\s\S])*(?:\"|$)/,null,'"']],[["kwd",/^(?:block|c[ad]+r|catch|con[ds]|def(?:ine|un)|do|eq|eql|equal|equalp|eval-when|flet|format|go|if|labels|lambda|let|load-time-value|locally|macrolet|multiple-value-call|nil|progn|progv|quote|require|return-from|setq|symbol-macrolet|t|tagbody|the|throw|unwind)\b/, 18 | null],["lit",/^[+\-]?(?:[0#]x[0-9a-f]+|\d+\/\d+|(?:\.\d+|\d+(?:\.\d*)?)(?:[ed][+\-]?\d+)?)/i],["lit",/^\'(?:-*(?:\w|\\[\x21-\x7e])(?:[\w-]*|\\[\x21-\x7e])[=!?]?)?/],["pln",/^-*(?:[a-z_]|\\[\x21-\x7e])(?:[\w-]*|\\[\x21-\x7e])[=!?]?/i],["pun",/^[^\w\t\n\r \xA0()\"\\\';]+/]]),"cl el lisp lsp scm ss rkt".split(" ")); 19 | -------------------------------------------------------------------------------- /loader/lang-kotlin.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2017 Micha?? B??czkowski 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"],["pun",/^[.!%&()*+,\-;<=>?\[\\\]^{|}:]+/,null,".!%&()*+,-;<=>?[\\]^{|}:"]],[["kwd",/^\b(package|public|protected|private|open|abstract|constructor|final|override|import|for|while|as|typealias|get|set|((data|enum|annotation|sealed) )?class|this|super|val|var|fun|is|in|throw|return|break|continue|(companion )?object|if|try|else|do|when|init|interface|typeof)\b/],["lit",/^(?:true|false|null)\b/], 18 | ["lit",/^(0[xX][0-9a-fA-F_]+L?|0[bB][0-1]+L?|[0-9_.]+([eE]-?[0-9]+)?[fFL]?)/],["typ",/^(\b[A-Z]+[a-z][a-zA-Z0-9_$@]*|`.*`)/,null],["com",/^\/\/.*/],["com",/^\/\*[\s\S]*?(?:\*\/|$)/],["str",/'.'/],["str",/^"([^"\\]|\\[\s\S])*"/],["str",/^"{3}[\s\S]*?[^\\]"{3}/],["lit",/^@([a-zA-Z0-9_$@]*|`.*`)/],["lit",/^[a-zA-Z0-9_]+@/]]),["kotlin"]); 19 | -------------------------------------------------------------------------------- /src/lang-proto.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @license 3 | * Copyright (C) 2006 Google Inc. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | /** 19 | * @fileoverview 20 | * Registers a language handler for Protocol Buffers as described at 21 | * http://code.google.com/p/protobuf/. 22 | * 23 | * Based on the lexical grammar at 24 | * http://research.microsoft.com/fsharp/manual/spec2.aspx#_Toc202383715 25 | * 26 | * @author mikesamuel@gmail.com 27 | */ 28 | 29 | PR['registerLangHandler'](PR['sourceDecorator']({ 30 | 'keywords': ( 31 | 'bytes,default,double,enum,extend,extensions,false,' 32 | + 'group,import,max,message,option,' 33 | + 'optional,package,repeated,required,returns,rpc,service,' 34 | + 'syntax,to,true'), 35 | 'types': /^(bool|(double|s?fixed|[su]?int)(32|64)|float|string)\b/, 36 | 'cStyleComments': true 37 | }), ['proto']); 38 | -------------------------------------------------------------------------------- /loader/lang-lgt.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2014 Paulo Moura 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["str",/^\"(?:[^\"\\\n\x0C\r]|\\[\s\S])*(?:\"|$)/,null,'"'],["lit",/^[a-z][a-zA-Z0-9_]*/],["lit",/^\'(?:[^\'\\\n\x0C\r]|\\[^&])+\'?/,null,"'"],["lit",/^(?:0'.|0b[0-1]+|0o[0-7]+|0x[\da-f]+|\d+(?:\.\d+)?(?:e[+\-]?\d+)?)/i,null,"0123456789"]],[["com",/^%[^\r\n]*/,null,"%"],["com",/^\/\*[\s\S]*?\*\//],["kwd",/^\s*:-\s(c(a(lls|tegory)|oinductive)|p(ublic|r(ot(ocol|ected)|ivate))|e(l(if|se)|n(coding|sure_loaded)|xport)|i(f|n(clude|itialization|fo))|alias|d(ynamic|iscontiguous)|m(eta_(non_terminal|predicate)|od(e|ule)|ultifile)|reexport|s(et_(logtalk|prolog)_flag|ynchronized)|o(bject|p)|use(s|_module))/], 18 | ["kwd",/^\s*:-\s(e(lse|nd(if|_(category|object|protocol)))|built_in|dynamic|synchronized|threaded)/],["typ",/^[A-Z_][a-zA-Z0-9_]*/],["pun",/^[.,;{}:^<>=\\/+*?#!-]/]]),["logtalk","lgt"]); 19 | -------------------------------------------------------------------------------- /loader/lang-logtalk.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2014 Paulo Moura 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["str",/^\"(?:[^\"\\\n\x0C\r]|\\[\s\S])*(?:\"|$)/,null,'"'],["lit",/^[a-z][a-zA-Z0-9_]*/],["lit",/^\'(?:[^\'\\\n\x0C\r]|\\[^&])+\'?/,null,"'"],["lit",/^(?:0'.|0b[0-1]+|0o[0-7]+|0x[\da-f]+|\d+(?:\.\d+)?(?:e[+\-]?\d+)?)/i,null,"0123456789"]],[["com",/^%[^\r\n]*/,null,"%"],["com",/^\/\*[\s\S]*?\*\//],["kwd",/^\s*:-\s(c(a(lls|tegory)|oinductive)|p(ublic|r(ot(ocol|ected)|ivate))|e(l(if|se)|n(coding|sure_loaded)|xport)|i(f|n(clude|itialization|fo))|alias|d(ynamic|iscontiguous)|m(eta_(non_terminal|predicate)|od(e|ule)|ultifile)|reexport|s(et_(logtalk|prolog)_flag|ynchronized)|o(bject|p)|use(s|_module))/], 18 | ["kwd",/^\s*:-\s(e(lse|nd(if|_(category|object|protocol)))|built_in|dynamic|synchronized|threaded)/],["typ",/^[A-Z_][a-zA-Z0-9_]*/],["pun",/^[.,;{}:^<>=\\/+*?#!-]/]]),["logtalk","lgt"]); 19 | -------------------------------------------------------------------------------- /loader/skins/doxy.css: -------------------------------------------------------------------------------- 1 | a,code.prettyprint a,pre.prettyprint a{text-decoration:none}code .str,pre .str{color:#fec243}code .kwd,pre .kwd{color:#8470FF}code .com,pre .com{color:#32cd32;font-style:italic}code .typ,pre .typ{color:#6ecbcc}code .lit,pre .lit{color:#d06}code .pun,pre .pun{color:#8B8970}code .pln,pre .pln{color:#f0f0f0}code .tag,pre .tag{color:#9c9cff}code .htm,pre .htm{color:plum}code .xsl,pre .xsl{color:#d0a0d0}code .atn,pre .atn{color:#46eeee;font-weight:400}code .atv,pre .atv{color:#EEB4B4}code .dec,pre .dec{color:#3387CC}code.prettyprint,pre.prettyprint{font-family:'Droid Sans Mono','CPMono_v07 Bold','Droid Sans';font-weight:700;font-size:9pt;background-color:#0f0f0f;-moz-border-radius:8px;-webkit-border-radius:8px;-o-border-radius:8px;-ms-border-radius:8px;-khtml-border-radius:8px;border-radius:8px}pre.prettyprint{width:95%;margin:1em auto;padding:1em;white-space:pre-wrap}ol.linenums{margin-top:0;margin-bottom:0;color:#8B8970}li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{list-style-type:none}@media print{code.prettyprint,pre.prettyprint{background-color:#fff}code .str,pre .str{color:#088}code .kwd,pre .kwd{color:#006;font-weight:700}code .com,pre .com{color:#oc3;font-style:italic}code .typ,pre .typ{color:#404;font-weight:700}code .lit,pre .lit{color:#044}code .pun,pre .pun{color:#440}code .pln,pre .pln{color:#000}code .tag,pre .tag{color:#b66ff7;font-weight:700}code .htm,code .xsl,pre .htm,pre .xsl{color:#606;font-weight:700}code .atn,pre .atn{color:#c71585;font-weight:400}code .atv,pre .atv{color:#088;font-weight:400}} -------------------------------------------------------------------------------- /loader/lang-clj.js: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2011 Google Inc. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | PR.registerLangHandler(PR.createSimpleLexer([["opn",/^[\(\{\[]+/,null,"([{"],["clo",/^[\)\}\]]+/,null,")]}"],["com",/^;[^\r\n]*/,null,";"],["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"],["str",/^\"(?:[^\"\\]|\\[\s\S])*(?:\"|$)/,null,'"']],[["kwd",/^(?:def|if|do|let|quote|var|fn|loop|recur|throw|try|monitor-enter|monitor-exit|defmacro|defn|defn-|macroexpand|macroexpand-1|for|doseq|dosync|dotimes|and|or|when|not|assert|doto|proxy|defstruct|first|rest|cons|defprotocol|deftype|defrecord|reify|defmulti|defmethod|meta|with-meta|ns|in-ns|create-ns|import|intern|refer|alias|namespace|resolve|ref|deref|refset|new|set!|memfn|to-array|into-array|aset|gen-class|reduce|map|filter|find|nil?|empty?|hash-map|hash-set|vec|vector|seq|flatten|reverse|assoc|dissoc|list|list?|disj|get|union|difference|intersection|extend|extend-type|extend-protocol|prn)\b/, 17 | null],["typ",/^:[0-9a-zA-Z\-]+/]]),["clj"]); 18 | -------------------------------------------------------------------------------- /loader/lang-mumps.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2011 Kitware Inc. 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"],["str",/^(?:"(?:[^"]|\\.)*")/,null,'"']],[["com",/^;[^\r\n]*/,null,";"],["dec",/^(?:\$(?:D|DEVICE|EC|ECODE|ES|ESTACK|ET|ETRAP|H|HOROLOG|I|IO|J|JOB|K|KEY|P|PRINCIPAL|Q|QUIT|ST|STACK|S|STORAGE|SY|SYSTEM|T|TEST|TL|TLEVEL|TR|TRESTART|X|Y|Z[A-Z]*|A|ASCII|C|CHAR|D|DATA|E|EXTRACT|F|FIND|FN|FNUMBER|G|GET|J|JUSTIFY|L|LENGTH|NA|NAME|O|ORDER|P|PIECE|QL|QLENGTH|QS|QSUBSCRIPT|Q|QUERY|R|RANDOM|RE|REVERSE|S|SELECT|ST|STACK|T|TEXT|TR|TRANSLATE|NaN))\b/i, 18 | null],["kwd",/^(?:[^\$]B|BREAK|C|CLOSE|D|DO|E|ELSE|F|FOR|G|GOTO|H|HALT|H|HANG|I|IF|J|JOB|K|KILL|L|LOCK|M|MERGE|N|NEW|O|OPEN|Q|QUIT|R|READ|S|SET|TC|TCOMMIT|TRE|TRESTART|TRO|TROLLBACK|TS|TSTART|U|USE|V|VIEW|W|WRITE|X|XECUTE)\b/i,null],["lit",/^[+-]?(?:(?:\.\d+|\d+(?:\.\d*)?)(?:E[+\-]?\d+)?)/i],["pln",/^[a-z][a-zA-Z0-9]*/i],["pun",/^[^\w\t\n\r\xA0\"\$;%\^]|_/]]),["mumps"]); 19 | -------------------------------------------------------------------------------- /tests/test_styles.css: -------------------------------------------------------------------------------- 1 | /** 2 | * @license 3 | * Copyright (C) 2015 Google Inc. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | /* used by test_base.js */ 19 | #report { 20 | margin-left: 1em; 21 | } 22 | .pass { 23 | color: green; 24 | } 25 | .fail { 26 | color: red; 27 | } 28 | .mismatch { 29 | background-color: #faa; 30 | font-weight: bold; 31 | } 32 | 33 | /* diff tables */ 34 | table.diff { 35 | border-collapse: collapse; 36 | border-spacing: 0; 37 | table-layout: fixed; 38 | width: 100%; 39 | } 40 | .diff th, .diff td { 41 | border: 1px solid black; 42 | } 43 | .diff th { 44 | background-color: #FFD; 45 | width: 50px; 46 | } 47 | .diff td { 48 | white-space: pre-wrap; 49 | word-wrap: break-word; 50 | } 51 | 52 | /* used in prettify_test.html issue 22 */ 53 | .annot { 54 | background-color: #eef; 55 | border: 1px dotted #88f; 56 | margin: 2px 2px 2px 3em; 57 | padding: 0 2px 0 2px; 58 | } 59 | .nocode { 60 | background-color: #f8f8f8; 61 | } 62 | -------------------------------------------------------------------------------- /loader/lang-css.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2009 Google Inc. 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[ \t\r\n\f]+/,null," \t\r\n\f"]],[["str",/^\"(?:[^\n\r\f\\\"]|\\(?:\r\n?|\n|\f)|\\[\s\S])*\"/,null],["str",/^\'(?:[^\n\r\f\\\']|\\(?:\r\n?|\n|\f)|\\[\s\S])*\'/,null],["lang-css-str",/^url\(([^\)\"\']+)\)/i],["kwd",/^(?:url|rgb|\!important|@import|@page|@media|@charset|inherit)(?=[^\-\w]|$)/i,null],["lang-css-kw",/^(-?(?:[_a-z]|(?:\\[0-9a-f]+ ?))(?:[_a-z0-9\-]|\\(?:\\[0-9a-f]+ ?))*)\s*:/i],["com",/^\/\*[^*]*\*+(?:[^\/*][^*]*\*+)*\//], 18 | ["com",/^(?:\x3c!--|--\x3e)/],["lit",/^(?:\d+|\d*\.\d+)(?:%|[a-z]+)?/i],["lit",/^#(?:[0-9a-f]{3}){1,2}\b/i],["pln",/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i],["pun",/^[^\s\w\'\"]+/]]),["css"]);PR.registerLangHandler(PR.createSimpleLexer([],[["kwd",/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i]]),["css-kw"]);PR.registerLangHandler(PR.createSimpleLexer([],[["str",/^[^\)\"\']+/]]),["css-str"]); 19 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "code-prettify", 3 | "version": "1.0.0", 4 | "description": "Google Code Prettify", 5 | "license": "Apache-2.0", 6 | "homepage": "https://github.com/google/code-prettify", 7 | "repository": { 8 | "type": "git", 9 | "url": "git+https://github.com/google/code-prettify.git" 10 | }, 11 | "bugs": { 12 | "url": "https://github.com/google/code-prettify/issues" 13 | }, 14 | "keywords": [ 15 | "syntax", 16 | "highlight", 17 | "highlighting", 18 | "source", 19 | "code", 20 | "prettify", 21 | "google" 22 | ], 23 | "author": "Google", 24 | "maintainers": [ 25 | "Mike Samuel " 26 | ], 27 | "contributors": [ 28 | "Amro " 29 | ], 30 | "main": "src/node_prettify.js", 31 | "directories": { 32 | "lib": "src", 33 | "doc": "docs", 34 | "example": "examples", 35 | "test": "tests" 36 | }, 37 | "files": [ 38 | "loader/", 39 | "src/", 40 | "styles/*.css", 41 | "COPYING" 42 | ], 43 | "scripts": { 44 | "grunt": "grunt", 45 | "test": "echo \"Error: no test specified\" && exit 1" 46 | }, 47 | "devDependencies": { 48 | "google-closure-compiler": "^20161201.0.0", 49 | "grunt": "^1.0.1", 50 | "grunt-contrib-clean": "^1.0.0", 51 | "grunt-contrib-compress": "^1.3.0", 52 | "grunt-contrib-copy": "^1.0.0", 53 | "grunt-contrib-cssmin": "^1.0.2", 54 | "grunt-contrib-uglify": "^2.0.0", 55 | "grunt-preprocess": "^5.1.0", 56 | "html-to-text": "^3.0.0", 57 | "zombie": "^5.0.5" 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /loader/lang-scala.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2010 Google Inc. 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"],["str",/^(?:"(?:(?:""(?:""?(?!")|[^\\"]|\\.)*"{0,3})|(?:[^"\r\n\\]|\\.)*"?))/,null,'"'],["lit",/^`(?:[^\r\n\\`]|\\.)*`?/,null,"`"],["pun",/^[!#%&()*+,\-:;<=>?@\[\\\]^{|}~]+/,null,"!#%&()*+,-:;<=>?@[\\]^{|}~"]],[["str",/^'(?:[^\r\n\\']|\\(?:'|[^\r\n']+))'/],["lit",/^'[a-zA-Z_$][\w$]*(?!['$\w])/],["kwd",/^(?:abstract|case|catch|class|def|do|else|extends|final|finally|for|forSome|if|implicit|import|lazy|match|new|object|override|package|private|protected|requires|return|sealed|super|throw|trait|try|type|val|var|while|with|yield)\b/], 18 | ["lit",/^(?:true|false|null|this)\b/],["lit",/^(?:(?:0(?:[0-7]+|X[0-9A-F]+))L?|(?:(?:0|[1-9][0-9]*)(?:(?:\.[0-9]+)?(?:E[+\-]?[0-9]+)?F?|L?))|\\.[0-9]+(?:E[+\-]?[0-9]+)?F?)/i],["typ",/^[$_]*[A-Z][_$A-Z0-9]*[a-z][\w$]*/],["pln",/^[$a-zA-Z_][\w$]*/],["com",/^\/(?:\/.*|\*(?:\/|\**[^*/])*(?:\*+\/?)?)/],["pun",/^(?:\.+|\/)/]]),["scala"]); 19 | -------------------------------------------------------------------------------- /tests/test_modules.css: -------------------------------------------------------------------------------- 1 | /* tests table */ 2 | table { 3 | border-collapse: collapse; 4 | border-spacing: 0; 5 | } 6 | table, th, td { 7 | border: 1px solid black; 8 | } 9 | td, th { 10 | padding: 2px; 11 | } 12 | tr { 13 | vertical-align: top; 14 | } 15 | th { 16 | background-color: #FFD; 17 | } 18 | td { 19 | font-family: monospace; 20 | } 21 | 22 | /* tests */ 23 | .input, .golden, .actual, .decorations { 24 | white-space: pre; 25 | } 26 | 27 | /* results */ 28 | .ok { 29 | background-color: #DFD; 30 | } 31 | .failure, .error { 32 | background-color: #FDD; 33 | } 34 | .ok:after { 35 | color: green; 36 | content: '\a[PASS]'; 37 | font-weight: bold; 38 | } 39 | .failure:after { 40 | color: red; 41 | content: '\a[FAIL]'; 42 | font-weight: bold; 43 | } 44 | .error:after { 45 | color: #AF7817; 46 | content: '\a[ERROR]'; 47 | font-weight: bold; 48 | } 49 | 50 | /* used in extractSourceSpans_test.html */ 51 | .break { 52 | padding-left: 2px; 53 | border-right-style: dotted !important; 54 | } 55 | .odd, .even { 56 | border-style: solid; 57 | border-width: 1px; 58 | } 59 | .even { 60 | background-color: #fff; 61 | border-color: #888; 62 | } 63 | .odd { 64 | background-color: #ddd; 65 | border-color: #000; 66 | } 67 | 68 | /* log */ 69 | #report { 70 | margin-left: 1em; 71 | } 72 | .pass { 73 | color: green; 74 | } 75 | .fail, .err { 76 | color: red; 77 | } 78 | 79 | /* diff tables */ 80 | table.diff { 81 | table-layout: fixed; 82 | max-width: 100%; 83 | } 84 | .diff th { 85 | width: 50px; 86 | } 87 | .diff td { 88 | white-space: pre-wrap; 89 | word-wrap: break-word; 90 | } 91 | -------------------------------------------------------------------------------- /js-modules/regexpPrecederPatterns.js: -------------------------------------------------------------------------------- 1 | 2 | // Regex pattern below is automatically generated by regexpPrecederPatterns.pl 3 | // Do not modify, your changes will be erased. 4 | 5 | // CAVEAT: this does not properly handle the case where a regular 6 | // expression immediately follows another since a regular expression may 7 | // have flags for case-sensitivity and the like. Having regexp tokens 8 | // adjacent is not valid in any language I'm aware of, so I'm punting. 9 | // TODO: maybe style special characters inside a regexp as punctuation. 10 | 11 | /** 12 | * A set of tokens that can precede a regular expression literal in 13 | * javascript 14 | * http://web.archive.org/web/20070717142515/http://www.mozilla.org/js/language/js20/rationale/syntax.html 15 | * has the full list, but I've removed ones that might be problematic when 16 | * seen in languages that don't support regular expression literals. 17 | * 18 | * Specifically, I've removed any keywords that can't precede a regexp 19 | * literal in a syntactically legal javascript program, and I've removed the 20 | * "in" keyword since it's not a keyword in many languages, and might be used 21 | * as a count of inches. 22 | * 23 | * The link above does not accurately describe EcmaScript rules since 24 | * it fails to distinguish between (a=++/b/i) and (a++/b/i) but it works 25 | * very well in practice. 26 | * 27 | * @private 28 | * @const 29 | */ 30 | var REGEXP_PRECEDER_PATTERN = '(?:^^\\.?|[+-]|[!=]=?=?|\\#|%=?|&&?=?|\\(|\\*=?|[+\\-]=|->|\\/=?|::?|<>?>?=?|,|;|\\?|@|\\[|~|{|\\^\\^?=?|\\|\\|?=?|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*'; 31 | -------------------------------------------------------------------------------- /loader/lang-aea.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2009 Onno Hommes. 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["com",/^#[^\r\n]*/,null,"#"],["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"],["str",/^\"(?:[^\"\\]|\\[\s\S])*(?:\"|$)/,null,'"']],[["kwd",/^(?:ADS|AD|AUG|BZF|BZMF|CAE|CAF|CA|CCS|COM|CS|DAS|DCA|DCOM|DCS|DDOUBL|DIM|DOUBLE|DTCB|DTCF|DV|DXCH|EDRUPT|EXTEND|INCR|INDEX|NDX|INHINT|LXCH|MASK|MSK|MP|MSU|NOOP|OVSK|QXCH|RAND|READ|RELINT|RESUME|RETURN|ROR|RXOR|SQUARE|SU|TCR|TCAA|OVSK|TCF|TC|TS|WAND|WOR|WRITE|XCH|XLQ|XXALQ|ZL|ZQ|ADD|ADZ|SUB|SUZ|MPY|MPR|MPZ|DVP|COM|ABS|CLA|CLZ|LDQ|STO|STQ|ALS|LLS|LRS|TRA|TSQ|TMI|TOV|AXT|TIX|DLY|INP|OUT)\s/, 18 | null],["typ",/^(?:-?GENADR|=MINUS|2BCADR|VN|BOF|MM|-?2CADR|-?[1-6]DNADR|ADRES|BBCON|[SE]?BANK\=?|BLOCK|BNKSUM|E?CADR|COUNT\*?|2?DEC\*?|-?DNCHAN|-?DNPTR|EQUALS|ERASE|MEMORY|2?OCT|REMADR|SETLOC|SUBRO|ORG|BSS|BES|SYN|EQU|DEFINE|END)\s/,null],["lit",/^\'(?:-*(?:\w|\\[\x21-\x7e])(?:[\w-]*|\\[\x21-\x7e])[=!?]?)?/],["pln",/^-*(?:[!-z_]|\\[\x21-\x7e])(?:[\w-]*|\\[\x21-\x7e])[=!?]?/i],["pun",/^[^\w\t\n\r \xA0()\"\\\';]+/]]),["apollo","agc","aea"]); 19 | -------------------------------------------------------------------------------- /loader/lang-agc.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2009 Onno Hommes. 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["com",/^#[^\r\n]*/,null,"#"],["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"],["str",/^\"(?:[^\"\\]|\\[\s\S])*(?:\"|$)/,null,'"']],[["kwd",/^(?:ADS|AD|AUG|BZF|BZMF|CAE|CAF|CA|CCS|COM|CS|DAS|DCA|DCOM|DCS|DDOUBL|DIM|DOUBLE|DTCB|DTCF|DV|DXCH|EDRUPT|EXTEND|INCR|INDEX|NDX|INHINT|LXCH|MASK|MSK|MP|MSU|NOOP|OVSK|QXCH|RAND|READ|RELINT|RESUME|RETURN|ROR|RXOR|SQUARE|SU|TCR|TCAA|OVSK|TCF|TC|TS|WAND|WOR|WRITE|XCH|XLQ|XXALQ|ZL|ZQ|ADD|ADZ|SUB|SUZ|MPY|MPR|MPZ|DVP|COM|ABS|CLA|CLZ|LDQ|STO|STQ|ALS|LLS|LRS|TRA|TSQ|TMI|TOV|AXT|TIX|DLY|INP|OUT)\s/, 18 | null],["typ",/^(?:-?GENADR|=MINUS|2BCADR|VN|BOF|MM|-?2CADR|-?[1-6]DNADR|ADRES|BBCON|[SE]?BANK\=?|BLOCK|BNKSUM|E?CADR|COUNT\*?|2?DEC\*?|-?DNCHAN|-?DNPTR|EQUALS|ERASE|MEMORY|2?OCT|REMADR|SETLOC|SUBRO|ORG|BSS|BES|SYN|EQU|DEFINE|END)\s/,null],["lit",/^\'(?:-*(?:\w|\\[\x21-\x7e])(?:[\w-]*|\\[\x21-\x7e])[=!?]?)?/],["pln",/^-*(?:[!-z_]|\\[\x21-\x7e])(?:[\w-]*|\\[\x21-\x7e])[=!?]?/i],["pun",/^[^\w\t\n\r \xA0()\"\\\';]+/]]),["apollo","agc","aea"]); 19 | -------------------------------------------------------------------------------- /loader/lang-apollo.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2009 Onno Hommes. 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["com",/^#[^\r\n]*/,null,"#"],["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"],["str",/^\"(?:[^\"\\]|\\[\s\S])*(?:\"|$)/,null,'"']],[["kwd",/^(?:ADS|AD|AUG|BZF|BZMF|CAE|CAF|CA|CCS|COM|CS|DAS|DCA|DCOM|DCS|DDOUBL|DIM|DOUBLE|DTCB|DTCF|DV|DXCH|EDRUPT|EXTEND|INCR|INDEX|NDX|INHINT|LXCH|MASK|MSK|MP|MSU|NOOP|OVSK|QXCH|RAND|READ|RELINT|RESUME|RETURN|ROR|RXOR|SQUARE|SU|TCR|TCAA|OVSK|TCF|TC|TS|WAND|WOR|WRITE|XCH|XLQ|XXALQ|ZL|ZQ|ADD|ADZ|SUB|SUZ|MPY|MPR|MPZ|DVP|COM|ABS|CLA|CLZ|LDQ|STO|STQ|ALS|LLS|LRS|TRA|TSQ|TMI|TOV|AXT|TIX|DLY|INP|OUT)\s/, 18 | null],["typ",/^(?:-?GENADR|=MINUS|2BCADR|VN|BOF|MM|-?2CADR|-?[1-6]DNADR|ADRES|BBCON|[SE]?BANK\=?|BLOCK|BNKSUM|E?CADR|COUNT\*?|2?DEC\*?|-?DNCHAN|-?DNPTR|EQUALS|ERASE|MEMORY|2?OCT|REMADR|SETLOC|SUBRO|ORG|BSS|BES|SYN|EQU|DEFINE|END)\s/,null],["lit",/^\'(?:-*(?:\w|\\[\x21-\x7e])(?:[\w-]*|\\[\x21-\x7e])[=!?]?)?/],["pln",/^-*(?:[!-z_]|\\[\x21-\x7e])(?:[\w-]*|\\[\x21-\x7e])[=!?]?/i],["pun",/^[^\w\t\n\r \xA0()\"\\\';]+/]]),["apollo","agc","aea"]); 19 | -------------------------------------------------------------------------------- /src/lang-yaml.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @license 3 | * Copyright (C) 2015 ribrdb @ code.google.com 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | 19 | // Contributed by ribrdb @ code.google.com 20 | 21 | /** 22 | * @fileoverview 23 | * Registers a language handler for YAML. 24 | * 25 | * @author ribrdb 26 | */ 27 | 28 | PR['registerLangHandler']( 29 | PR['createSimpleLexer']( 30 | [ 31 | [PR['PR_PUNCTUATION'], /^[:|>?]+/, null, ':|>?'], 32 | [PR['PR_DECLARATION'], /^%(?:YAML|TAG)[^#\r\n]+/, null, '%'], 33 | [PR['PR_TYPE'], /^[&]\S+/, null, '&'], 34 | [PR['PR_TYPE'], /^!\S*/, null, '!'], 35 | [PR['PR_STRING'], /^"(?:[^\\"]|\\.)*(?:"|$)/, null, '"'], 36 | [PR['PR_STRING'], /^'(?:[^']|'')*(?:'|$)/, null, "'"], 37 | [PR['PR_COMMENT'], /^#[^\r\n]*/, null, '#'], 38 | [PR['PR_PLAIN'], /^\s+/, null, ' \t\r\n'] 39 | ], 40 | [ 41 | [PR['PR_DECLARATION'], /^(?:---|\.\.\.)(?:[\r\n]|$)/], 42 | [PR['PR_PUNCTUATION'], /^-/], 43 | [PR['PR_KEYWORD'], /^[\w-]+:[ \r\n]/], 44 | [PR['PR_PLAIN'], /^\w+/] 45 | ]), ['yaml', 'yml']); 46 | -------------------------------------------------------------------------------- /loader/lang-dart.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2013 Google Inc. 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"]],[["com",/^#!(?:.*)/],["kwd",/^\b(?:import|library|part of|part|as|show|hide)\b/i],["com",/^\/\/(?:.*)/],["com",/^\/\*[^*]*\*+(?:[^\/*][^*]*\*+)*\//],["kwd",/^\b(?:class|interface)\b/i],["kwd",/^\b(?:assert|async|await|break|case|catch|continue|default|do|else|finally|for|if|in|is|new|return|super|switch|sync|this|throw|try|while)\b/i],["kwd",/^\b(?:abstract|const|extends|factory|final|get|implements|native|operator|set|static|typedef|var)\b/i], 18 | ["typ",/^\b(?:bool|double|Dynamic|int|num|Object|String|void)\b/i],["kwd",/^\b(?:false|null|true)\b/i],["str",/^r?[\']{3}[\s|\S]*?[^\\][\']{3}/],["str",/^r?[\"]{3}[\s|\S]*?[^\\][\"]{3}/],["str",/^r?\'(\'|(?:[^\n\r\f])*?[^\\]\')/],["str",/^r?\"(\"|(?:[^\n\r\f])*?[^\\]\")/],["typ",/^[A-Z]\w*/],["pln",/^[a-z_$][a-z0-9_]*/i],["pun",/^[~!%^&*+=|?:<>/-]/],["lit",/^\b0x[0-9a-f]+/i],["lit",/^\b\d+(?:\.\d*)?(?:e[+-]?\d+)?/i],["lit", 19 | /^\b\.\d+(?:e[+-]?\d+)?/i],["pun",/^[(){}\[\],.;]/]]),["dart"]); 20 | -------------------------------------------------------------------------------- /loader/lang-fs.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2008 Google Inc. 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"],["com",/^#(?:if[\t\n\r \xA0]+(?:[a-z_$][\w\']*|``[^\r\n\t`]*(?:``|$))|else|endif|light)/i,null,"#"],["str",/^(?:\"(?:[^\"\\]|\\[\s\S])*(?:\"|$)|\'(?:[^\'\\]|\\[\s\S])(?:\'|$))/,null,"\"'"]],[["com",/^(?:\/\/[^\r\n]*|\(\*[\s\S]*?\*\))/],["kwd",/^(?:abstract|and|as|assert|begin|class|default|delegate|do|done|downcast|downto|elif|else|end|exception|extern|false|finally|for|fun|function|if|in|inherit|inline|interface|internal|lazy|let|match|member|module|mutable|namespace|new|null|of|open|or|override|private|public|rec|return|static|struct|then|to|true|try|type|upcast|use|val|void|when|while|with|yield|asr|land|lor|lsl|lsr|lxor|mod|sig|atomic|break|checked|component|const|constraint|constructor|continue|eager|event|external|fixed|functor|global|include|method|mixin|object|parallel|process|protected|pure|sealed|trait|virtual|volatile)\b/], 18 | ["lit",/^[+\-]?(?:0x[\da-f]+|(?:(?:\.\d+|\d+(?:\.\d*)?)(?:e[+\-]?\d+)?))/i],["pln",/^(?:[a-z_][\w']*[!?#]?|``[^\r\n\t`]*(?:``|$))/i],["pun",/^[^\t\n\r \xA0\"\'\w]+/]]),["fs","ml"]); 19 | -------------------------------------------------------------------------------- /loader/lang-ml.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2008 Google Inc. 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"],["com",/^#(?:if[\t\n\r \xA0]+(?:[a-z_$][\w\']*|``[^\r\n\t`]*(?:``|$))|else|endif|light)/i,null,"#"],["str",/^(?:\"(?:[^\"\\]|\\[\s\S])*(?:\"|$)|\'(?:[^\'\\]|\\[\s\S])(?:\'|$))/,null,"\"'"]],[["com",/^(?:\/\/[^\r\n]*|\(\*[\s\S]*?\*\))/],["kwd",/^(?:abstract|and|as|assert|begin|class|default|delegate|do|done|downcast|downto|elif|else|end|exception|extern|false|finally|for|fun|function|if|in|inherit|inline|interface|internal|lazy|let|match|member|module|mutable|namespace|new|null|of|open|or|override|private|public|rec|return|static|struct|then|to|true|try|type|upcast|use|val|void|when|while|with|yield|asr|land|lor|lsl|lsr|lxor|mod|sig|atomic|break|checked|component|const|constraint|constructor|continue|eager|event|external|fixed|functor|global|include|method|mixin|object|parallel|process|protected|pure|sealed|trait|virtual|volatile)\b/], 18 | ["lit",/^[+\-]?(?:0x[\da-f]+|(?:(?:\.\d+|\d+(?:\.\d*)?)(?:e[+\-]?\d+)?))/i],["pln",/^(?:[a-z_][\w']*[!?#]?|``[^\r\n\t`]*(?:``|$))/i],["pun",/^[^\t\n\r \xA0\"\'\w]+/]]),["fs","ml"]); 19 | -------------------------------------------------------------------------------- /js-modules/defs.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @typedef {!Array.} 3 | * Alternating indices and the decorations that should be inserted there. 4 | * The indices are monotonically increasing. 5 | */ 6 | var DecorationsT; 7 | 8 | /** 9 | * @typedef {!{ 10 | * sourceNode: !Element, 11 | * pre: !(number|boolean), 12 | * langExtension: ?string, 13 | * numberLines: ?(number|boolean), 14 | * sourceCode: ?string, 15 | * spans: ?(Array.), 16 | * basePos: ?number, 17 | * decorations: ?DecorationsT 18 | * }} 19 | *
20 | *
sourceNode
the element containing the source 21 | *
sourceCode
source as plain text 22 | *
pre
truthy if white-space in text nodes 23 | * should be considered significant. 24 | *
spans
alternating span start indices into source 25 | * and the text node or element (e.g. {@code
}) corresponding to that 26 | * span. 27 | *
decorations
an array of style classes preceded 28 | * by the position at which they start in job.sourceCode in order 29 | *
basePos
integer position of this.sourceCode in the larger chunk of 30 | * source. 31 | *
32 | */ 33 | var JobT; 34 | 35 | /** 36 | * @typedef {!{ 37 | * sourceCode: string, 38 | * spans: !(Array.) 39 | * }} 40 | *
41 | *
sourceCode
source as plain text 42 | *
spans
alternating span start indices into source 43 | * and the text node or element (e.g. {@code
}) corresponding to that 44 | * span. 45 | *
46 | */ 47 | var SourceSpansT; 48 | 49 | /** @define {boolean} */ 50 | /* @ifndef RUN_PRETTIFY */ 51 | var IN_GLOBAL_SCOPE = true; 52 | /* @endif */ 53 | /* @ifdef RUN_PRETTIFY */ 54 | var IN_GLOBAL_SCOPE = false; 55 | /* @endif */ 56 | -------------------------------------------------------------------------------- /tasks/gcc.js: -------------------------------------------------------------------------------- 1 | /** 2 | * google-code-prettify 3 | * https://github.com/google/code-prettify 4 | * 5 | * @author Amro 6 | * @license Apache-2.0 7 | */ 8 | 9 | module.exports = function (grunt) { 10 | 'use strict'; 11 | 12 | /* 13 | * HACK: Custom task to override "closure-compiler:langs" since all lang-* 14 | * files are compiled in parallel, launching too many Java processes at once 15 | * which easily runs out of memory! This task programmatically creates 16 | * separate targets (one file per target) so that lang files are compiled 17 | * sequentially (sync) instead of in parallel (async). 18 | */ 19 | grunt.registerMultiTask('gcc', 'Override closure-compiler', function () { 20 | // closure-compiler:langs 21 | var task = 'closure-compiler'; 22 | var target = this.target; 23 | if (!grunt.task.exists(task)) { 24 | grunt.fail.warn(grunt.util.error('Require task "' + task + '".')); 25 | } 26 | 27 | // create new targets for each file (one file per target) 28 | var count = 0; 29 | var opts = this.options(); 30 | this.files.forEach(function (file, idx) { 31 | // simple target config with only: src, dest, and options 32 | delete file.orig; 33 | file.options = opts; 34 | 35 | // configure new target 36 | grunt.config.set([task, target + idx], file); 37 | grunt.verbose.writeln('New target ' + (task + ':' + target + idx).cyan); 38 | count++; 39 | }); 40 | grunt.log.ok('Configured ' + count.toString().cyan + ' lang targets'); 41 | 42 | // remove original multi-file target 43 | grunt.config.set([task, target], {}); 44 | 45 | // enqueue modified task to run 46 | //console.log(grunt.config.get(task)); 47 | grunt.task.run(task); 48 | }); 49 | }; 50 | -------------------------------------------------------------------------------- /styles/desert.css: -------------------------------------------------------------------------------- 1 | /* desert scheme ported from vim to google prettify */ 2 | pre.prettyprint { display: block; background-color: #333 } 3 | pre .nocode { background-color: none; color: #000 } 4 | pre .str { color: #ffa0a0 } /* string - pink */ 5 | pre .kwd { color: #f0e68c; font-weight: bold } 6 | pre .com { color: #87ceeb } /* comment - skyblue */ 7 | pre .typ { color: #98fb98 } /* type - lightgreen */ 8 | pre .lit { color: #cd5c5c } /* literal - darkred */ 9 | pre .pun { color: #fff } /* punctuation */ 10 | pre .pln { color: #fff } /* plaintext */ 11 | pre .tag { color: #f0e68c; font-weight: bold } /* html/xml tag - lightyellow */ 12 | pre .atn { color: #bdb76b; font-weight: bold } /* attribute name - khaki */ 13 | pre .atv { color: #ffa0a0 } /* attribute value - pink */ 14 | pre .dec { color: #98fb98 } /* decimal - lightgreen */ 15 | 16 | /* Specify class=linenums on a pre to get line numbering */ 17 | ol.linenums { margin-top: 0; margin-bottom: 0; color: #AEAEAE } /* IE indents via margin-left */ 18 | li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8 { list-style-type: none } 19 | /* Alternate shading for lines */ 20 | li.L1,li.L3,li.L5,li.L7,li.L9 { } 21 | 22 | @media print { 23 | pre.prettyprint { background-color: none } 24 | pre .str, code .str { color: #060 } 25 | pre .kwd, code .kwd { color: #006; font-weight: bold } 26 | pre .com, code .com { color: #600; font-style: italic } 27 | pre .typ, code .typ { color: #404; font-weight: bold } 28 | pre .lit, code .lit { color: #044 } 29 | pre .pun, code .pun { color: #440 } 30 | pre .pln, code .pln { color: #000 } 31 | pre .tag, code .tag { color: #006; font-weight: bold } 32 | pre .atn, code .atn { color: #404 } 33 | pre .atv, code .atv { color: #060 } 34 | } 35 | -------------------------------------------------------------------------------- /loader/lang-ex.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2017 Jacek Kr??likowski 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"],["com",/^#.*/,null,"#"],["lit",/^'(?:[^'\\]|\\(?:.|\n|\r))*'?/,null,"'"],["atn",/^@\w+/,null,"@"],["pun",/^[!%&()*+,\-;<=>?\[\\\]^{|}]+/,null,"!%&()*+,-;<=>?[\\]^{|}"],["lit",/^(?:0o[0-7](?:[0-7]|_[0-7])*|0x[\da-fA-F](?:[\da-fA-F]|_[\da-fA-F])*|\d(?:\d|_\d)*(?:\.\d(?:\d|_\d)*)?(?:[eE][+\-]?\d(?:\d|_\d)*)?)/,null,"0123456789"]],[["atn",/^iex(?:\(\d+\))?> /], 18 | ["pun",/^::/],["lit",/^:(?:\w+[\!\?\@]?|"(?:[^"\\]|\\.)*"?)/],["atn",/^(?:__(?:CALLER|ENV|MODULE|DIR)__)/],["kwd",/^(?:alias|case|catch|def(?:delegate|exception|impl|macrop?|module|overridable|p?|protocol|struct)|do|else|end|fn|for|if|in|import|quote|raise|require|rescue|super|throw|try|unless|unquote(?:_splicing)?|use|when|with|yield)\b/],["lit",/^(?:true|false|nil)\b/],["lit",/^(?:\w+[\!\?\@]?|"(?:[^"\\]|\\.)*"):(?!:)/],["str",/^"""\s*(\r|\n)+(?:""?(?!")|[^\\"]|\\(?:.|\n|\r))*"{0,3}/], 19 | ["str",/^"(?:[^"\\]|\\(?:.|\n|\r))*"?(?!")/],["typ",/^[A-Z]\w*/],["com",/^_\w*/],["pln",/^[$a-z]\w*[\!\?]?/],["atv",/^~[A-Z](?:\/(?:[^\/\r\n\\]|\\.)+\/|\|(?:[^\|\r\n\\]|\\.)+\||"(?:[^"\r\n\\]|\\.)+"|'(?:[^'\r\n\\]|\\.)+')[A-Z]*/i],["atv",/^~[A-Z](?:\((?:[^\)\r\n\\]|\\.)+\)|\[(?:[^\]\r\n\\]|\\.)+\]|\{(?:[^\}\r\n\\]|\\.)+\}|\<(?:[^\>\r\n\\]|\\.)+\>)[A-Z]*/i],["pun",/^(?:\.+|\/|[:~])/]]),["ex","exs"]); 20 | -------------------------------------------------------------------------------- /loader/lang-exs.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2017 Jacek Kr??likowski 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"],["com",/^#.*/,null,"#"],["lit",/^'(?:[^'\\]|\\(?:.|\n|\r))*'?/,null,"'"],["atn",/^@\w+/,null,"@"],["pun",/^[!%&()*+,\-;<=>?\[\\\]^{|}]+/,null,"!%&()*+,-;<=>?[\\]^{|}"],["lit",/^(?:0o[0-7](?:[0-7]|_[0-7])*|0x[\da-fA-F](?:[\da-fA-F]|_[\da-fA-F])*|\d(?:\d|_\d)*(?:\.\d(?:\d|_\d)*)?(?:[eE][+\-]?\d(?:\d|_\d)*)?)/,null,"0123456789"]],[["atn",/^iex(?:\(\d+\))?> /], 18 | ["pun",/^::/],["lit",/^:(?:\w+[\!\?\@]?|"(?:[^"\\]|\\.)*"?)/],["atn",/^(?:__(?:CALLER|ENV|MODULE|DIR)__)/],["kwd",/^(?:alias|case|catch|def(?:delegate|exception|impl|macrop?|module|overridable|p?|protocol|struct)|do|else|end|fn|for|if|in|import|quote|raise|require|rescue|super|throw|try|unless|unquote(?:_splicing)?|use|when|with|yield)\b/],["lit",/^(?:true|false|nil)\b/],["lit",/^(?:\w+[\!\?\@]?|"(?:[^"\\]|\\.)*"):(?!:)/],["str",/^"""\s*(\r|\n)+(?:""?(?!")|[^\\"]|\\(?:.|\n|\r))*"{0,3}/], 19 | ["str",/^"(?:[^"\\]|\\(?:.|\n|\r))*"?(?!")/],["typ",/^[A-Z]\w*/],["com",/^_\w*/],["pln",/^[$a-z]\w*[\!\?]?/],["atv",/^~[A-Z](?:\/(?:[^\/\r\n\\]|\\.)+\/|\|(?:[^\|\r\n\\]|\\.)+\||"(?:[^"\r\n\\]|\\.)+"|'(?:[^'\r\n\\]|\\.)+')[A-Z]*/i],["atv",/^~[A-Z](?:\((?:[^\)\r\n\\]|\\.)+\)|\[(?:[^\]\r\n\\]|\\.)+\]|\{(?:[^\}\r\n\\]|\\.)+\}|\<(?:[^\>\r\n\\]|\\.)+\>)[A-Z]*/i],["pun",/^(?:\.+|\/|[:~])/]]),["ex","exs"]); 20 | -------------------------------------------------------------------------------- /src/lang-rd.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @license 3 | * Copyright (C) 2012 Jeffrey Arnold 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | /** 19 | * @fileoverview 20 | * Support for R documentation (Rd) files 21 | * 22 | * Minimal highlighting or Rd files, basically just highlighting 23 | * macros. It does not try to identify verbatim or R-like regions of 24 | * macros as that is too complicated for a lexer. Descriptions of the 25 | * Rd format can be found 26 | * http://cran.r-project.org/doc/manuals/R-exts.html and 27 | * http://developer.r-project.org/parseRd.pdf. 28 | * 29 | * @author Jeffrey Arnold 30 | */ 31 | PR['registerLangHandler']( 32 | PR['createSimpleLexer']( 33 | [ 34 | // whitespace 35 | [PR['PR_PLAIN'], /^[\t\n\r \xA0]+/, null, '\t\n\r \xA0'], 36 | // all comments begin with '%' 37 | [PR['PR_COMMENT'], /^%[^\r\n]*/, null, '%'] 38 | ], 39 | [// special macros with no args 40 | [PR['PR_LITERAL'], /^\\(?:cr|l?dots|R|tab)\b/], 41 | // macros 42 | [PR['PR_KEYWORD'], /^\\[a-zA-Z@]+/], 43 | // highlighted as macros, since technically they are 44 | [PR['PR_KEYWORD'], /^#(?:ifn?def|endif)/ ], 45 | // catch escaped brackets 46 | [PR['PR_PLAIN'], /^\\[{}]/], 47 | // punctuation 48 | [PR['PR_PUNCTUATION'], /^[{}()\[\]]+/] 49 | ]), 50 | ['Rd', 'rd']); 51 | -------------------------------------------------------------------------------- /styles/sunburst.css: -------------------------------------------------------------------------------- 1 | /* Pretty printing styles. Used with prettify.js. */ 2 | /* Vim sunburst theme by David Leibovic */ 3 | 4 | pre .str, code .str { color: #65B042; } /* string - green */ 5 | pre .kwd, code .kwd { color: #E28964; } /* keyword - dark pink */ 6 | pre .com, code .com { color: #AEAEAE; font-style: italic; } /* comment - gray */ 7 | pre .typ, code .typ { color: #89bdff; } /* type - light blue */ 8 | pre .lit, code .lit { color: #3387CC; } /* literal - blue */ 9 | pre .pun, code .pun { color: #fff; } /* punctuation - white */ 10 | pre .pln, code .pln { color: #fff; } /* plaintext - white */ 11 | pre .tag, code .tag { color: #89bdff; } /* html/xml tag - light blue */ 12 | pre .atn, code .atn { color: #bdb76b; } /* html/xml attribute name - khaki */ 13 | pre .atv, code .atv { color: #65B042; } /* html/xml attribute value - green */ 14 | pre .dec, code .dec { color: #3387CC; } /* decimal - blue */ 15 | 16 | pre.prettyprint, code.prettyprint { 17 | background-color: #000; 18 | border-radius: 8px; 19 | } 20 | 21 | pre.prettyprint { 22 | width: 95%; 23 | margin: 1em auto; 24 | padding: 1em; 25 | white-space: pre-wrap; 26 | } 27 | 28 | 29 | /* Specify class=linenums on a pre to get line numbering */ 30 | ol.linenums { margin-top: 0; margin-bottom: 0; color: #AEAEAE; } /* IE indents via margin-left */ 31 | li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8 { list-style-type: none } 32 | /* Alternate shading for lines */ 33 | li.L1,li.L3,li.L5,li.L7,li.L9 { } 34 | 35 | @media print { 36 | pre .str, code .str { color: #060; } 37 | pre .kwd, code .kwd { color: #006; font-weight: bold; } 38 | pre .com, code .com { color: #600; font-style: italic; } 39 | pre .typ, code .typ { color: #404; font-weight: bold; } 40 | pre .lit, code .lit { color: #044; } 41 | pre .pun, code .pun { color: #440; } 42 | pre .pln, code .pln { color: #000; } 43 | pre .tag, code .tag { color: #006; font-weight: bold; } 44 | pre .atn, code .atn { color: #404; } 45 | pre .atv, code .atv { color: #060; } 46 | } 47 | -------------------------------------------------------------------------------- /js-modules/externs.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @license 3 | * Copyright (C) 2015 Google Inc. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | 19 | /** 20 | * 21 | * @fileoverview 22 | * This file allows separate compilation of language handlers and the 23 | * core library. 24 | * @externs 25 | */ 26 | 27 | 28 | var PR = {}; 29 | 30 | /** 31 | * @param {function (Object)} handler 32 | * @param {Array.} fileExtensions 33 | */ 34 | PR.registerLangHandler = function registerLangHandler(handler, fileExtensions) {}; 35 | 36 | /** 37 | * @param {Array} shortcutStylePatterns 38 | * @param {Array} fallthroughStylePatterns 39 | * @return {function (Object)} 40 | */ 41 | PR.createSimpleLexer = function createSimpleLexer( 42 | shortcutStylePatterns, fallthroughStylePatterns) {}; 43 | 44 | /** 45 | * @param {Object} options a set of optional parameters. 46 | * @return {function (Object)} a function that examines the source code 47 | * in the input job and builds the decoration list. 48 | */ 49 | PR.sourceDecorator = function sourceDecorator(options) {}; 50 | 51 | 52 | PR.PR_ATTRIB_NAME = 'atn'; 53 | PR.PR_ATTRIB_VALUE = 'atv'; 54 | PR.PR_COMMENT = 'com'; 55 | PR.PR_DECLARATION = 'dec'; 56 | PR.PR_KEYWORD = 'kwd'; 57 | PR.PR_LITERAL = 'lit'; 58 | PR.PR_NOCODE = 'nocode'; 59 | PR.PR_PLAIN = 'pln'; 60 | PR.PR_PUNCTUATION = 'pun'; 61 | PR.PR_SOURCE = 'src'; 62 | PR.PR_STRING = 'str'; 63 | PR.PR_TAG = 'tag'; 64 | PR.PR_TYPE = 'typ'; 65 | 66 | -------------------------------------------------------------------------------- /loader/lang-vhd.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2010 benoit@ryder.fr 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"]],[["str",/^(?:[BOX]?"(?:[^\"]|"")*"|'.')/i],["com",/^--[^\r\n]*/],["kwd",/^(?:abs|access|after|alias|all|and|architecture|array|assert|attribute|begin|block|body|buffer|bus|case|component|configuration|constant|disconnect|downto|else|elsif|end|entity|exit|file|for|function|generate|generic|group|guarded|if|impure|in|inertial|inout|is|label|library|linkage|literal|loop|map|mod|nand|new|next|nor|not|null|of|on|open|or|others|out|package|port|postponed|procedure|process|pure|range|record|register|reject|rem|report|return|rol|ror|select|severity|shared|signal|sla|sll|sra|srl|subtype|then|to|transport|type|unaffected|units|until|use|variable|wait|when|while|with|xnor|xor)(?=[^\w-]|$)/i, 18 | null],["typ",/^(?:bit|bit_vector|character|boolean|integer|real|time|string|severity_level|positive|natural|signed|unsigned|line|text|std_u?logic(?:_vector)?)(?=[^\w-]|$)/i,null],["typ",/^\'(?:ACTIVE|ASCENDING|BASE|DELAYED|DRIVING|DRIVING_VALUE|EVENT|HIGH|IMAGE|INSTANCE_NAME|LAST_ACTIVE|LAST_EVENT|LAST_VALUE|LEFT|LEFTOF|LENGTH|LOW|PATH_NAME|POS|PRED|QUIET|RANGE|REVERSE_RANGE|RIGHT|RIGHTOF|SIMPLE_NAME|STABLE|SUCC|TRANSACTION|VAL|VALUE)(?=[^\w-]|$)/i,null],["lit",/^\d+(?:_\d+)*(?:#[\w\\.]+#(?:[+\-]?\d+(?:_\d+)*)?|(?:\.\d+(?:_\d+)*)?(?:E[+\-]?\d+(?:_\d+)*)?)/i], 19 | ["pln",/^(?:[a-z]\w*|\\[^\\]*\\)/i],["pun",/^[^\w\t\n\r \xA0\"\'][^\w\t\n\r \xA0\-\"\']*/]]),["vhdl","vhd"]); 20 | -------------------------------------------------------------------------------- /loader/lang-vhdl.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2010 benoit@ryder.fr 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"]],[["str",/^(?:[BOX]?"(?:[^\"]|"")*"|'.')/i],["com",/^--[^\r\n]*/],["kwd",/^(?:abs|access|after|alias|all|and|architecture|array|assert|attribute|begin|block|body|buffer|bus|case|component|configuration|constant|disconnect|downto|else|elsif|end|entity|exit|file|for|function|generate|generic|group|guarded|if|impure|in|inertial|inout|is|label|library|linkage|literal|loop|map|mod|nand|new|next|nor|not|null|of|on|open|or|others|out|package|port|postponed|procedure|process|pure|range|record|register|reject|rem|report|return|rol|ror|select|severity|shared|signal|sla|sll|sra|srl|subtype|then|to|transport|type|unaffected|units|until|use|variable|wait|when|while|with|xnor|xor)(?=[^\w-]|$)/i, 18 | null],["typ",/^(?:bit|bit_vector|character|boolean|integer|real|time|string|severity_level|positive|natural|signed|unsigned|line|text|std_u?logic(?:_vector)?)(?=[^\w-]|$)/i,null],["typ",/^\'(?:ACTIVE|ASCENDING|BASE|DELAYED|DRIVING|DRIVING_VALUE|EVENT|HIGH|IMAGE|INSTANCE_NAME|LAST_ACTIVE|LAST_EVENT|LAST_VALUE|LEFT|LEFTOF|LENGTH|LOW|PATH_NAME|POS|PRED|QUIET|RANGE|REVERSE_RANGE|RIGHT|RIGHTOF|SIMPLE_NAME|STABLE|SUCC|TRANSACTION|VAL|VALUE)(?=[^\w-]|$)/i,null],["lit",/^\d+(?:_\d+)*(?:#[\w\\.]+#(?:[+\-]?\d+(?:_\d+)*)?|(?:\.\d+(?:_\d+)*)?(?:E[+\-]?\d+(?:_\d+)*)?)/i], 19 | ["pln",/^(?:[a-z]\w*|\\[^\\]*\\)/i],["pun",/^[^\w\t\n\r \xA0\"\'][^\w\t\n\r \xA0\-\"\']*/]]),["vhdl","vhd"]); 20 | -------------------------------------------------------------------------------- /loader/lang-n.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2011 Zimin A.V. 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["str",/^(?:\'(?:[^\\\'\r\n]|\\.)*\'|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,null,'"'],["com",/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\r\n]*)/,null,"#"],["pln",/^\s+/,null," \r\n\t\u00a0"]],[["str",/^@\"(?:[^\"]|\"\")*(?:\"|$)/,null],["str",/^<#(?:[^#>])*(?:#>|$)/,null],["str",/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,null],["com",/^\/\/[^\r\n]*/, 18 | null],["com",/^\/\*[\s\S]*?(?:\*\/|$)/,null],["kwd",/^(?:abstract|and|as|base|catch|class|def|delegate|enum|event|extern|false|finally|fun|implements|interface|internal|is|macro|match|matches|module|mutable|namespace|new|null|out|override|params|partial|private|protected|public|ref|sealed|static|struct|syntax|this|throw|true|try|type|typeof|using|variant|virtual|volatile|when|where|with|assert|assert2|async|break|checked|continue|do|else|ensures|for|foreach|if|late|lock|new|nolate|otherwise|regexp|repeat|requires|return|surroundwith|unchecked|unless|using|while|yield)\b/, 19 | null],["typ",/^(?:array|bool|byte|char|decimal|double|float|int|list|long|object|sbyte|short|string|ulong|uint|ufloat|ulong|ushort|void)\b/,null],["lit",/^@[a-z_$][a-z_$@0-9]*/i,null],["typ",/^@[A-Z]+[a-z][A-Za-z_$@0-9]*/,null],["pln",/^'?[A-Za-z_$][a-z_$@0-9]*/i,null],["lit",/^(?:0x[a-f0-9]+|(?:\d(?:_\d+)*\d*(?:\.\d*)?|\.\d\+)(?:e[+\-]?\d+)?)[a-z]*/i,null,"0123456789"],["pun",/^.[^\s\w\.$@\'\"\`\/\#]*/,null]]),["n","nemerle"]); 20 | -------------------------------------------------------------------------------- /loader/lang-nemerle.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2011 Zimin A.V. 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["str",/^(?:\'(?:[^\\\'\r\n]|\\.)*\'|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,null,'"'],["com",/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\r\n]*)/,null,"#"],["pln",/^\s+/,null," \r\n\t\u00a0"]],[["str",/^@\"(?:[^\"]|\"\")*(?:\"|$)/,null],["str",/^<#(?:[^#>])*(?:#>|$)/,null],["str",/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,null],["com",/^\/\/[^\r\n]*/, 18 | null],["com",/^\/\*[\s\S]*?(?:\*\/|$)/,null],["kwd",/^(?:abstract|and|as|base|catch|class|def|delegate|enum|event|extern|false|finally|fun|implements|interface|internal|is|macro|match|matches|module|mutable|namespace|new|null|out|override|params|partial|private|protected|public|ref|sealed|static|struct|syntax|this|throw|true|try|type|typeof|using|variant|virtual|volatile|when|where|with|assert|assert2|async|break|checked|continue|do|else|ensures|for|foreach|if|late|lock|new|nolate|otherwise|regexp|repeat|requires|return|surroundwith|unchecked|unless|using|while|yield)\b/, 19 | null],["typ",/^(?:array|bool|byte|char|decimal|double|float|int|list|long|object|sbyte|short|string|ulong|uint|ufloat|ulong|ushort|void)\b/,null],["lit",/^@[a-z_$][a-z_$@0-9]*/i,null],["typ",/^@[A-Z]+[a-z][A-Za-z_$@0-9]*/,null],["pln",/^'?[A-Za-z_$][a-z_$@0-9]*/i,null],["lit",/^(?:0x[a-f0-9]+|(?:\d(?:_\d+)*\d*(?:\.\d*)?|\.\d\+)(?:e[+\-]?\d+)?)[a-z]*/i,null,"0123456789"],["pun",/^.[^\s\w\.$@\'\"\`\/\#]*/,null]]),["n","nemerle"]); 20 | -------------------------------------------------------------------------------- /src/lang-tex.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @license 3 | * Copyright (C) 2011 Martin S. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | /** 19 | * @fileoverview 20 | * Support for tex highlighting as discussed on 21 | * meta.tex.stackexchange.com. 22 | * 23 | * @author Martin S. 24 | */ 25 | 26 | PR['registerLangHandler']( 27 | PR['createSimpleLexer']( 28 | [ 29 | // whitespace 30 | [PR['PR_PLAIN'], /^[\t\n\r \xA0]+/, null, '\t\n\r \xA0'], 31 | // all comments begin with '%' 32 | [PR['PR_COMMENT'], /^%[^\r\n]*/, null, '%'] 33 | ], 34 | [ 35 | //[PR['PR_DECLARATION'], /^\\([egx]?def|(new|renew|provide)(command|environment))\b/], 36 | // any command starting with a \ and contains 37 | // either only letters (a-z,A-Z), '@' (internal macros) 38 | [PR['PR_KEYWORD'], /^\\[a-zA-Z@]+/], 39 | // or contains only one character 40 | [PR['PR_KEYWORD'], /^\\./], 41 | // Highlight dollar for math mode and ampersam for tabular 42 | [PR['PR_TYPE'], /^[$&]/], 43 | // numeric measurement values with attached units 44 | [PR['PR_LITERAL'], 45 | /[+-]?(?:\.\d+|\d+(?:\.\d*)?)(cm|em|ex|in|pc|pt|bp|mm)/i], 46 | // punctuation usually occurring within commands 47 | [PR['PR_PUNCTUATION'], /^[{}()\[\]=]+/] 48 | ]), 49 | ['latex', 'tex']); 50 | -------------------------------------------------------------------------------- /src/lang-wiki.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @license 3 | * Copyright (C) 2009 Google Inc. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | /** 19 | * @fileoverview 20 | * Registers a language handler for Wiki pages. 21 | * 22 | * Based on WikiSyntax at http://code.google.com/p/support/wiki/WikiSyntax 23 | * 24 | * @author mikesamuel@gmail.com 25 | */ 26 | 27 | PR['registerLangHandler']( 28 | PR['createSimpleLexer']( 29 | [ 30 | // Whitespace 31 | [PR['PR_PLAIN'], /^[\t \xA0a-gi-z0-9]+/, null, 32 | '\t \xA0abcdefgijklmnopqrstuvwxyz0123456789'], 33 | // Wiki formatting 34 | [PR['PR_PUNCTUATION'], /^[=*~\^\[\]]+/, null, '=*~^[]'] 35 | ], 36 | [ 37 | // Meta-info like #summary, #labels, etc. 38 | ['lang-wiki.meta', /(?:^^|\r\n?|\n)(#[a-z]+)\b/], 39 | // A WikiWord 40 | [PR['PR_LITERAL'], /^(?:[A-Z][a-z][a-z0-9]+[A-Z][a-z][a-zA-Z0-9]+)\b/ 41 | ], 42 | // A preformatted block in an unknown language 43 | ['lang-', /^\{\{\{([\s\S]+?)\}\}\}/], 44 | // A block of source code in an unknown language 45 | ['lang-', /^`([^\r\n`]+)`/], 46 | // An inline URL. 47 | [PR['PR_STRING'], 48 | /^https?:\/\/[^\/?#\s]*(?:\/[^?#\s]*)?(?:\?[^#\s]*)?(?:#\S*)?/i], 49 | [PR['PR_PLAIN'], /^(?:\r\n|[\s\S])[^#=*~^A-Zh\{`\[\r\n]*/] 50 | ]), 51 | ['wiki']); 52 | 53 | PR['registerLangHandler']( 54 | PR['createSimpleLexer']([[PR['PR_KEYWORD'], /^#[a-z]+/i, null, '#']], []), 55 | ['wiki.meta']); 56 | -------------------------------------------------------------------------------- /styles/sons-of-obsidian.css: -------------------------------------------------------------------------------- 1 | /* 2 | * Derived from einaros's Sons of Obsidian theme at 3 | * http://studiostyl.es/schemes/son-of-obsidian by 4 | * Alex Ford of CodeTunnel: 5 | * http://CodeTunnel.com/blog/post/71/google-code-prettify-obsidian-theme 6 | */ 7 | 8 | .str 9 | { 10 | color: #EC7600; 11 | } 12 | .kwd 13 | { 14 | color: #93C763; 15 | } 16 | .com 17 | { 18 | color: #66747B; 19 | } 20 | .typ 21 | { 22 | color: #678CB1; 23 | } 24 | .lit 25 | { 26 | color: #FACD22; 27 | } 28 | .pun 29 | { 30 | color: #F1F2F3; 31 | } 32 | .pln 33 | { 34 | color: #F1F2F3; 35 | } 36 | .tag 37 | { 38 | color: #8AC763; 39 | } 40 | .atn 41 | { 42 | color: #E0E2E4; 43 | } 44 | .atv 45 | { 46 | color: #EC7600; 47 | } 48 | .dec 49 | { 50 | color: purple; 51 | } 52 | pre.prettyprint 53 | { 54 | border: 0px solid #888; 55 | } 56 | ol.linenums 57 | { 58 | margin-top: 0; 59 | margin-bottom: 0; 60 | } 61 | .prettyprint { 62 | background: #000; 63 | } 64 | li.L0, li.L1, li.L2, li.L3, li.L4, li.L5, li.L6, li.L7, li.L8, li.L9 65 | { 66 | color: #555; 67 | list-style-type: decimal; 68 | } 69 | li.L1, li.L3, li.L5, li.L7, li.L9 { 70 | background: #111; 71 | } 72 | @media print 73 | { 74 | .str 75 | { 76 | color: #060; 77 | } 78 | .kwd 79 | { 80 | color: #006; 81 | font-weight: bold; 82 | } 83 | .com 84 | { 85 | color: #600; 86 | font-style: italic; 87 | } 88 | .typ 89 | { 90 | color: #404; 91 | font-weight: bold; 92 | } 93 | .lit 94 | { 95 | color: #044; 96 | } 97 | .pun 98 | { 99 | color: #440; 100 | } 101 | .pln 102 | { 103 | color: #000; 104 | } 105 | .tag 106 | { 107 | color: #006; 108 | font-weight: bold; 109 | } 110 | .atn 111 | { 112 | color: #404; 113 | } 114 | .atv 115 | { 116 | color: #060; 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /tests/run_prettify_test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Run_Prettify Test 6 | 9 | 59 | 60 | 61 | 62 | 63 |

run_prettify test

64 |

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

66 | 67 |

Test

68 |
69 | <div style="color: #f00">
70 |   Hello, World!
71 | </div>
72 | 
73 | 74 |

Log

75 |
76 | 77 | 78 | 79 | -------------------------------------------------------------------------------- /src/lang-basic.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @license 3 | * Copyright (C) 2013 Peter Kofler 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | // Contributed by peter dot kofler at code minus cop dot org 19 | 20 | /** 21 | * @fileoverview 22 | * Registers a language handler for Basic. 23 | * 24 | * To use, include prettify.js and this file in your HTML page. 25 | * Then put your code in an HTML tag like 26 | *
(my BASIC code)
27 | * 28 | * @author peter dot kofler at code minus cop dot org 29 | */ 30 | 31 | PR.registerLangHandler( 32 | PR.createSimpleLexer( 33 | [ // shortcutStylePatterns 34 | // "single-line-string" 35 | [PR.PR_STRING, /^(?:"(?:[^\\"\r\n]|\\.)*(?:"|$))/, null, '"'], 36 | // Whitespace 37 | [PR.PR_PLAIN, /^\s+/, null, ' \r\n\t\xA0'] 38 | ], 39 | [ // fallthroughStylePatterns 40 | // A line comment that starts with REM 41 | [PR.PR_COMMENT, /^REM[^\r\n]*/, null], 42 | [PR.PR_KEYWORD, /^\b(?:AND|CLOSE|CLR|CMD|CONT|DATA|DEF ?FN|DIM|END|FOR|GET|GOSUB|GOTO|IF|INPUT|LET|LIST|LOAD|NEW|NEXT|NOT|ON|OPEN|OR|POKE|PRINT|READ|RESTORE|RETURN|RUN|SAVE|STEP|STOP|SYS|THEN|TO|VERIFY|WAIT)\b/, null], 43 | [PR.PR_PLAIN, /^[A-Z][A-Z0-9]?(?:\$|%)?/i, null], 44 | // Literals .0, 0, 0.0 0E13 45 | [PR.PR_LITERAL, /^(?:\d+(?:\.\d*)?|\.\d+)(?:e[+\-]?\d+)?/i, null, '0123456789'], 46 | [PR.PR_PUNCTUATION, /^.[^\s\w\.$%"]*/, null] 47 | // [PR.PR_PUNCTUATION, /^[-,:;!<>=\+^\/\*]+/] 48 | ]), 49 | ['basic','cbm']); 50 | -------------------------------------------------------------------------------- /loader/lang-swift.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2015 Google Inc. 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[ \n\r\t\v\f\0]+/,null," \n\r\t\v\f\x00"],["str",/^"(?:[^"\\]|(?:\\.)|(?:\\\((?:[^"\\)]|\\.)*\)))*"/,null,'"']],[["lit",/^(?:(?:0x[\da-fA-F][\da-fA-F_]*\.[\da-fA-F][\da-fA-F_]*[pP]?)|(?:\d[\d_]*\.\d[\d_]*[eE]?))[+-]?\d[\d_]*/,null],["lit",/^-?(?:(?:0(?:(?:b[01][01_]*)|(?:o[0-7][0-7_]*)|(?:x[\da-fA-F][\da-fA-F_]*)))|(?:\d[\d_]*))/,null],["lit",/^(?:_|Any|true|false|nil)\b/,null],["kwd",/^\b(?:__COLUMN__|__FILE__|__FUNCTION__|__LINE__|#available|#colorLiteral|#column|#else|#elseif|#endif|#file|#fileLiteral|#function|#if|#imageLiteral|#line|#selector|#sourceLocation|arch|arm|arm64|associatedtype|associativity|as|break|case|catch|class|continue|convenience|default|defer|deinit|didSet|do|dynamic|dynamicType|else|enum|extension|fallthrough|fileprivate|final|for|func|get|guard|import|indirect|infix|init|inout|internal|i386|if|in|iOS|iOSApplicationExtension|is|lazy|left|let|mutating|none|nonmutating|open|operator|optional|OSX|OSXApplicationExtension|override|postfix|precedence|prefix|private|protocol|Protocol|public|repeat|required|rethrows|return|right|safe|Self|self|set|static|struct|subscript|super|switch|throw|throws|try|Type|typealias|unowned|unsafe|var|weak|watchOS|where|while|willSet|x86_64)\b/, 18 | null],["com",/^\/\/.*?[\n\r]/,null],["com",/^\/\*[\s\S]*?(?:\*\/|$)/,null],["pun",/^<<=|<=|<<|>>=|>=|>>|===|==|\.\.\.|&&=|\.\.<|!==|!=|&=|~=|~|\(|\)|\[|\]|{|}|@|#|;|\.|,|:|\|\|=|\?\?|\|\||&&|&\*|&\+|&-|&=|\+=|-=|\/=|\*=|\^=|%=|\|=|->|`|==|\+\+|--|\/|\+|!|\*|%|<|>|&|\||\^|\?|=|-|_/,null],["typ",/^\b(?:[@_]?[A-Z]+[a-z][A-Za-z_$@0-9]*|\w+_t\b)/,null]]),["swift"]); 19 | -------------------------------------------------------------------------------- /tasks/aliases.js: -------------------------------------------------------------------------------- 1 | /** 2 | * google-code-prettify 3 | * https://github.com/google/code-prettify 4 | * 5 | * @author Amro 6 | * @license Apache-2.0 7 | */ 8 | 9 | module.exports = function (grunt) { 10 | 'use strict'; 11 | 12 | var fs = require('fs'); 13 | var runLanguageHandler = require('./lib/lang-aliases'); 14 | 15 | /** 16 | * Copy timestamp from source to destination file. 17 | * @param {string} src 18 | * @param {string} dest 19 | * @param {boolean} timestamp 20 | */ 21 | function syncTimestamp(src, dest, timestamp) { 22 | if (timestamp) { 23 | var stat = fs.lstatSync(src); 24 | var fd = fs.openSync(dest, process.platform === 'win32' ? 'r+' : 'r'); 25 | fs.futimesSync(fd, stat.atime, stat.mtime); 26 | fs.closeSync(fd); 27 | } 28 | } 29 | 30 | /** 31 | * Copy file mode from source to destination. 32 | * @param {string} src 33 | * @param {string} dest 34 | * @param {boolean|number} mode 35 | */ 36 | function syncMod(src, dest, mode) { 37 | if (mode !== false) { 38 | fs.chmodSync(dest, (mode === true) ? fs.lstatSync(src).mode : mode); 39 | } 40 | } 41 | 42 | // Create copies of language handler files under all registered aliases 43 | grunt.registerMultiTask('aliases', 'Create language aliases', function () { 44 | var opts = this.options({ 45 | timestamp: false, 46 | mode: false 47 | }); 48 | 49 | var count = 0; 50 | this.filesSrc.forEach(function (src) { 51 | // run language handler in sandbox 52 | grunt.verbose.subhead('Running ' + src.cyan + ' in sandbox...'); 53 | var exts = runLanguageHandler(src); 54 | grunt.verbose.ok(); 55 | 56 | // go over collected extensions 57 | exts.forEach(function (ext) { 58 | // copy file 59 | var dest = src.replace(/\blang-\w+\b/, 'lang-' + ext); 60 | grunt.verbose.writeln('Copying ' + src.cyan + ' -> ' + dest.cyan); 61 | grunt.file.copy(src, dest); 62 | 63 | // sync timestamp and file mode 64 | syncTimestamp(src, dest, opts.timestamp); 65 | syncMod(src, dest, opts.mode); 66 | count++; 67 | }); 68 | }); 69 | grunt.log.ok('Copied ' + count.toString().cyan + 70 | grunt.util.pluralize(count, ' file/ files')); 71 | }); 72 | }; 73 | -------------------------------------------------------------------------------- /examples/quine.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Making Quines Prettier 6 | 8 | 9 | 13 | 14 | 15 | 16 |

Making Quines Prettier

17 | 18 |

19 | Below is the content of this page prettified. The <pre> 20 | element is prettified because it has class="prettyprint" and 21 | because the sourced script loads a JavaScript library that styles source 22 | code. 23 |

24 | 25 |

26 | The line numbers to the left appear because the preceding comment 27 | <?prettify lang=html linenums=true?> turns on 28 | line-numbering and the 29 | stylesheet 30 | (see skin=sunburst in the <script src>) 31 | specifies that every fifth line should be numbered. 32 |

33 | 34 | 35 | 36 |

37 | 
38 | 
63 | 
64 | 
65 | 
66 | 


--------------------------------------------------------------------------------
/loader/lang-rust.js:
--------------------------------------------------------------------------------
 1 | /*
 2 | 
 3 |  Copyright (C) 2015 Chris Morgan
 4 | 
 5 |  Licensed under the Apache License, Version 2.0 (the "License");
 6 |  you may not use this file except in compliance with the License.
 7 |  You may obtain a copy of the License at
 8 | 
 9 |     http://www.apache.org/licenses/LICENSE-2.0
10 | 
11 |  Unless required by applicable law or agreed to in writing, software
12 |  distributed under the License is distributed on an "AS IS" BASIS,
13 |  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 |  See the License for the specific language governing permissions and
15 |  limitations under the License.
16 | */
17 | PR.registerLangHandler(PR.createSimpleLexer([],[["pln",/^[\t\n\r \xA0]+/],["com",/^\/\/.*/],["com",/^\/\*[\s\S]*?(?:\*\/|$)/],["str",/^b"(?:[^\\]|\\(?:.|x[\da-fA-F]{2}))*?"/],["str",/^"(?:[^\\]|\\(?:.|x[\da-fA-F]{2}|u\{\[\da-fA-F]{1,6}\}))*?"/],["str",/^b?r(#*)\"[\s\S]*?\"\1/],["str",/^b'([^\\]|\\(.|x[\da-fA-F]{2}))'/],["str",/^'([^\\]|\\(.|x[\da-fA-F]{2}|u\{[\da-fA-F]{1,6}\}))'/],["tag",/^'\w+?\b/],["kwd",/^(?:match|if|else|as|break|box|continue|extern|fn|for|in|if|impl|let|loop|pub|return|super|unsafe|where|while|use|mod|trait|struct|enum|type|move|mut|ref|static|const|crate)\b/],
18 | ["kwd",/^(?:alignof|become|do|offsetof|priv|pure|sizeof|typeof|unsized|yield|abstract|virtual|final|override|macro)\b/],["typ",/^(?:[iu](8|16|32|64|128|size)|char|bool|f32|f64|str|Self)\b/],["typ",/^(?:Copy|Send|Sized|Sync|Drop|Fn|FnMut|FnOnce|Box|ToOwned|Clone|PartialEq|PartialOrd|Eq|Ord|AsRef|AsMut|Into|From|Default|Iterator|Extend|IntoIterator|DoubleEndedIterator|ExactSizeIterator|Option|Some|None|Result|Ok|Err|SliceConcatExt|String|ToString|Vec)\b/],["lit",/^(self|true|false|null)\b/],
19 | ["lit",/^\d[0-9_]*(?:[iu](?:size|8|16|32|64|128))?/],["lit",/^0x[a-fA-F0-9_]+(?:[iu](?:size|8|16|32|64|128))?/],["lit",/^0o[0-7_]+(?:[iu](?:size|8|16|32|64|128))?/],["lit",/^0b[01_]+(?:[iu](?:size|8|16|32|64|128))?/],["lit",/^\d[0-9_]*\.(?![^\s\d.])/],["lit",/^\d[0-9_]*(?:\.\d[0-9_]*)(?:[eE][+-]?[0-9_]+)?(?:f32|f64)?/],["lit",/^\d[0-9_]*(?:\.\d[0-9_]*)?(?:[eE][+-]?[0-9_]+)(?:f32|f64)?/],["lit",/^\d[0-9_]*(?:\.\d[0-9_]*)?(?:[eE][+-]?[0-9_]+)?(?:f32|f64)/],
20 | ["atn",/^[a-z_]\w*!/i],["pln",/^[a-z_]\w*/i],["atv",/^#!?\[[\s\S]*?\]/],["pun",/^[+\-/*=^&|!<>%[\](){}?:.,;]/],["pln",/./]]),["rust"]);
21 | 


--------------------------------------------------------------------------------
/src/lang-logtalk.js:
--------------------------------------------------------------------------------
 1 | /**
 2 |  * @license
 3 |  * Copyright (C) 2014 Paulo Moura
 4 |  *
 5 |  * Licensed under the Apache License, Version 2.0 (the "License");
 6 |  * you may not use this file except in compliance with the License.
 7 |  * You may obtain a copy of the License at
 8 |  *
 9 |  *    http://www.apache.org/licenses/LICENSE-2.0
10 |  *
11 |  * Unless required by applicable law or agreed to in writing, software
12 |  * distributed under the License is distributed on an "AS IS" BASIS,
13 |  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 |  * See the License for the specific language governing permissions and
15 |  * limitations under the License.
16 |  */
17 | 
18 | /**
19 |  * @fileoverview
20 |  * Registers a language handler for Logtalk.
21 |  * http://logtalk.org/
22 |  * @author Paulo Moura
23 |  */
24 | 
25 | PR['registerLangHandler'](
26 |     PR['createSimpleLexer'](
27 |         [
28 |           // double-quoted strings.
29 |           [PR['PR_STRING'], /^\"(?:[^\"\\\n\x0C\r]|\\[\s\S])*(?:\"|$)/, null, '"'],
30 |           // atoms (don't break on underscores!)
31 |           [PR['PR_LITERAL'], /^[a-z][a-zA-Z0-9_]*/],
32 |           // quoted atoms
33 |           [PR['PR_LITERAL'], /^\'(?:[^\'\\\n\x0C\r]|\\[^&])+\'?/, null, "'"],
34 |           // numbers
35 |           [PR['PR_LITERAL'], /^(?:0'.|0b[0-1]+|0o[0-7]+|0x[\da-f]+|\d+(?:\.\d+)?(?:e[+\-]?\d+)?)/i, null, '0123456789']
36 |         ],
37 |         [
38 |           // single-line comments begin with %
39 |           [PR['PR_COMMENT'], /^%[^\r\n]*/, null, '%'],
40 |           // block comments are delimited by /* and */
41 |           [PR['PR_COMMENT'], /^\/\*[\s\S]*?\*\//],
42 |           // directives
43 |           [PR['PR_KEYWORD'], /^\s*:-\s(c(a(lls|tegory)|oinductive)|p(ublic|r(ot(ocol|ected)|ivate))|e(l(if|se)|n(coding|sure_loaded)|xport)|i(f|n(clude|itialization|fo))|alias|d(ynamic|iscontiguous)|m(eta_(non_terminal|predicate)|od(e|ule)|ultifile)|reexport|s(et_(logtalk|prolog)_flag|ynchronized)|o(bject|p)|use(s|_module))/],
44 |           [PR['PR_KEYWORD'], /^\s*:-\s(e(lse|nd(if|_(category|object|protocol)))|built_in|dynamic|synchronized|threaded)/],
45 |           // variables
46 |           [PR['PR_TYPE'], /^[A-Z_][a-zA-Z0-9_]*/],
47 |           // operators
48 |           [PR['PR_PUNCTUATION'], /^[.,;{}:^<>=\\/+*?#!-]/]
49 |         ]),
50 |     ['logtalk', 'lgt']);
51 | 


--------------------------------------------------------------------------------
/src/lang-pascal.js:
--------------------------------------------------------------------------------
 1 | /**
 2 |  * @license
 3 |  * Copyright (C) 2013 Peter Kofler
 4 |  *
 5 |  * Licensed under the Apache License, Version 2.0 (the "License");
 6 |  * you may not use this file except in compliance with the License.
 7 |  * You may obtain a copy of the License at
 8 |  *
 9 |  *    http://www.apache.org/licenses/LICENSE-2.0
10 |  *
11 |  * Unless required by applicable law or agreed to in writing, software
12 |  * distributed under the License is distributed on an "AS IS" BASIS,
13 |  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 |  * See the License for the specific language governing permissions and
15 |  * limitations under the License.
16 |  */
17 | 
18 | // Contributed by peter dot kofler at code minus cop dot org
19 | 
20 | /**
21 |  * @fileoverview
22 |  * Registers a language handler for (Turbo) Pascal.
23 |  *
24 |  * To use, include prettify.js and this file in your HTML page.
25 |  * Then put your code in an HTML tag like
26 |  *      
(my Pascal code)
27 | * 28 | * @author peter dot kofler at code minus cop dot org 29 | */ 30 | 31 | PR.registerLangHandler( 32 | PR.createSimpleLexer( 33 | [ // shortcutStylePatterns 34 | // 'single-line-string' 35 | [PR.PR_STRING, /^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$))/, null, '\''], 36 | // Whitespace 37 | [PR.PR_PLAIN, /^\s+/, null, ' \r\n\t\xA0'] 38 | ], 39 | [ // fallthroughStylePatterns 40 | // A cStyleComments comment (* *) or {} 41 | [PR.PR_COMMENT, /^\(\*[\s\S]*?(?:\*\)|$)|^\{[\s\S]*?(?:\}|$)/, null], 42 | [PR.PR_KEYWORD, /^(?:ABSOLUTE|AND|ARRAY|ASM|ASSEMBLER|BEGIN|CASE|CONST|CONSTRUCTOR|DESTRUCTOR|DIV|DO|DOWNTO|ELSE|END|EXTERNAL|FOR|FORWARD|FUNCTION|GOTO|IF|IMPLEMENTATION|IN|INLINE|INTERFACE|INTERRUPT|LABEL|MOD|NOT|OBJECT|OF|OR|PACKED|PROCEDURE|PROGRAM|RECORD|REPEAT|SET|SHL|SHR|THEN|TO|TYPE|UNIT|UNTIL|USES|VAR|VIRTUAL|WHILE|WITH|XOR)\b/i, null], 43 | [PR.PR_LITERAL, /^(?:true|false|self|nil)/i, null], 44 | [PR.PR_PLAIN, /^[a-z][a-z0-9]*/i, null], 45 | // Literals .0, 0, 0.0 0E13 46 | [PR.PR_LITERAL, /^(?:\$[a-f0-9]+|(?:\d+(?:\.\d*)?|\.\d+)(?:e[+\-]?\d+)?)/i, null, '0123456789'], 47 | [PR.PR_PUNCTUATION, /^.[^\s\w\.$@\'\/]*/, null] 48 | ]), 49 | ['pascal']); 50 | -------------------------------------------------------------------------------- /loader/lang-sql.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2008 Google Inc. 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"],["str",/^(?:"(?:[^\"\\]|\\.)*"|'(?:[^\'\\]|\\.)*')/,null,"\"'"]],[["com",/^(?:--[^\r\n]*|\/\*[\s\S]*?(?:\*\/|$))/],["kwd",/^(?:ADD|ALL|ALTER|AND|ANY|APPLY|AS|ASC|AUTHORIZATION|BACKUP|BEGIN|BETWEEN|BREAK|BROWSE|BULK|BY|CASCADE|CASE|CHECK|CHECKPOINT|CLOSE|CLUSTERED|COALESCE|COLLATE|COLUMN|COMMIT|COMPUTE|CONNECT|CONSTRAINT|CONTAINS|CONTAINSTABLE|CONTINUE|CONVERT|CREATE|CROSS|CURRENT|CURRENT_DATE|CURRENT_TIME|CURRENT_TIMESTAMP|CURRENT_USER|CURSOR|DATABASE|DBCC|DEALLOCATE|DECLARE|DEFAULT|DELETE|DENY|DESC|DISK|DISTINCT|DISTRIBUTED|DOUBLE|DROP|DUMMY|DUMP|ELSE|END|ERRLVL|ESCAPE|EXCEPT|EXEC|EXECUTE|EXISTS|EXIT|FETCH|FILE|FILLFACTOR|FOLLOWING|FOR|FOREIGN|FREETEXT|FREETEXTTABLE|FROM|FULL|FUNCTION|GOTO|GRANT|GROUP|HAVING|HOLDLOCK|IDENTITY|IDENTITYCOL|IDENTITY_INSERT|IF|IN|INDEX|INNER|INSERT|INTERSECT|INTO|IS|JOIN|KEY|KILL|LEFT|LIKE|LINENO|LOAD|MATCH|MATCHED|MERGE|NATURAL|NATIONAL|NOCHECK|NONCLUSTERED|NOCYCLE|NOT|NULL|NULLIF|OF|OFF|OFFSETS|ON|OPEN|OPENDATASOURCE|OPENQUERY|OPENROWSET|OPENXML|OPTION|OR|ORDER|OUTER|OVER|PARTITION|PERCENT|PIVOT|PLAN|PRECEDING|PRECISION|PRIMARY|PRINT|PROC|PROCEDURE|PUBLIC|RAISERROR|READ|READTEXT|RECONFIGURE|REFERENCES|REPLICATION|RESTORE|RESTRICT|RETURN|REVOKE|RIGHT|ROLLBACK|ROWCOUNT|ROWGUIDCOL|ROWS?|RULE|SAVE|SCHEMA|SELECT|SESSION_USER|SET|SETUSER|SHUTDOWN|SOME|START|STATISTICS|SYSTEM_USER|TABLE|TEXTSIZE|THEN|TO|TOP|TRAN|TRANSACTION|TRIGGER|TRUNCATE|TSEQUAL|UNBOUNDED|UNION|UNIQUE|UNPIVOT|UPDATE|UPDATETEXT|USE|USER|USING|VALUES|VARYING|VIEW|WAITFOR|WHEN|WHERE|WHILE|WITH|WITHIN|WRITETEXT|XML)(?=[^\w-]|$)/i, 18 | null],["lit",/^[+-]?(?:0x[\da-f]+|(?:(?:\.\d+|\d+(?:\.\d*)?)(?:e[+\-]?\d+)?))/i],["pln",/^[a-z_][\w-]*/i],["pun",/^[^\w\t\n\r \xA0\"\'][^\w\t\n\r \xA0+\-\"\']*/]]),["sql"]); 19 | -------------------------------------------------------------------------------- /loader/lang-vb.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2009 Google Inc. 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xA0\u2028\u2029]+/,null,"\t\n\r \u00a0\u2028\u2029"],["str",/^(?:[\"\u201C\u201D](?:[^\"\u201C\u201D]|[\"\u201C\u201D]{2})(?:[\"\u201C\u201D]c|$)|[\"\u201C\u201D](?:[^\"\u201C\u201D]|[\"\u201C\u201D]{2})*(?:[\"\u201C\u201D]|$))/i,null,'"\u201c\u201d'],["com",/^[\'\u2018\u2019](?:_(?:\r\n?|[^\r]?)|[^\r\n_\u2028\u2029])*/,null,"'\u2018\u2019"]],[["kwd",/^(?:AddHandler|AddressOf|Alias|And|AndAlso|Ansi|As|Assembly|Auto|Boolean|ByRef|Byte|ByVal|Call|Case|Catch|CBool|CByte|CChar|CDate|CDbl|CDec|Char|CInt|Class|CLng|CObj|Const|CShort|CSng|CStr|CType|Date|Decimal|Declare|Default|Delegate|Dim|DirectCast|Do|Double|Each|Else|ElseIf|End|EndIf|Enum|Erase|Error|Event|Exit|Finally|For|Friend|Function|Get|GetType|GoSub|GoTo|Handles|If|Implements|Imports|In|Inherits|Integer|Interface|Is|Let|Lib|Like|Long|Loop|Me|Mod|Module|MustInherit|MustOverride|MyBase|MyClass|Namespace|New|Next|Not|NotInheritable|NotOverridable|Object|On|Option|Optional|Or|OrElse|Overloads|Overridable|Overrides|ParamArray|Preserve|Private|Property|Protected|Public|RaiseEvent|ReadOnly|ReDim|RemoveHandler|Resume|Return|Select|Set|Shadows|Shared|Short|Single|Static|Step|Stop|String|Structure|Sub|SyncLock|Then|Throw|To|Try|TypeOf|Unicode|Until|Variant|Wend|When|While|With|WithEvents|WriteOnly|Xor|EndIf|GoSub|Let|Variant|Wend)\b/i, 18 | null],["com",/^REM\b[^\r\n\u2028\u2029]*/i],["lit",/^(?:True\b|False\b|Nothing\b|\d+(?:E[+\-]?\d+[FRD]?|[FRDSIL])?|(?:&H[0-9A-F]+|&O[0-7]+)[SIL]?|\d*\.\d+(?:E[+\-]?\d+)?[FRD]?|#\s+(?:\d+[\-\/]\d+[\-\/]\d+(?:\s+\d+:\d+(?::\d+)?(\s*(?:AM|PM))?)?|\d+:\d+(?::\d+)?(\s*(?:AM|PM))?)\s+#)/i],["pln",/^(?:(?:[a-z]|_\w)\w*(?:\[[%&@!#]+\])?|\[(?:[a-z]|_\w)\w*\])/i],["pun",/^[^\w\t\n\r \"\'\[\]\xA0\u2018\u2019\u201C\u201D\u2028\u2029]+/],["pun",/^(?:\[|\])/]]),["vb", 19 | "vbs"]); 20 | -------------------------------------------------------------------------------- /loader/lang-vbs.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2009 Google Inc. 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xA0\u2028\u2029]+/,null,"\t\n\r \u00a0\u2028\u2029"],["str",/^(?:[\"\u201C\u201D](?:[^\"\u201C\u201D]|[\"\u201C\u201D]{2})(?:[\"\u201C\u201D]c|$)|[\"\u201C\u201D](?:[^\"\u201C\u201D]|[\"\u201C\u201D]{2})*(?:[\"\u201C\u201D]|$))/i,null,'"\u201c\u201d'],["com",/^[\'\u2018\u2019](?:_(?:\r\n?|[^\r]?)|[^\r\n_\u2028\u2029])*/,null,"'\u2018\u2019"]],[["kwd",/^(?:AddHandler|AddressOf|Alias|And|AndAlso|Ansi|As|Assembly|Auto|Boolean|ByRef|Byte|ByVal|Call|Case|Catch|CBool|CByte|CChar|CDate|CDbl|CDec|Char|CInt|Class|CLng|CObj|Const|CShort|CSng|CStr|CType|Date|Decimal|Declare|Default|Delegate|Dim|DirectCast|Do|Double|Each|Else|ElseIf|End|EndIf|Enum|Erase|Error|Event|Exit|Finally|For|Friend|Function|Get|GetType|GoSub|GoTo|Handles|If|Implements|Imports|In|Inherits|Integer|Interface|Is|Let|Lib|Like|Long|Loop|Me|Mod|Module|MustInherit|MustOverride|MyBase|MyClass|Namespace|New|Next|Not|NotInheritable|NotOverridable|Object|On|Option|Optional|Or|OrElse|Overloads|Overridable|Overrides|ParamArray|Preserve|Private|Property|Protected|Public|RaiseEvent|ReadOnly|ReDim|RemoveHandler|Resume|Return|Select|Set|Shadows|Shared|Short|Single|Static|Step|Stop|String|Structure|Sub|SyncLock|Then|Throw|To|Try|TypeOf|Unicode|Until|Variant|Wend|When|While|With|WithEvents|WriteOnly|Xor|EndIf|GoSub|Let|Variant|Wend)\b/i, 18 | null],["com",/^REM\b[^\r\n\u2028\u2029]*/i],["lit",/^(?:True\b|False\b|Nothing\b|\d+(?:E[+\-]?\d+[FRD]?|[FRDSIL])?|(?:&H[0-9A-F]+|&O[0-7]+)[SIL]?|\d*\.\d+(?:E[+\-]?\d+)?[FRD]?|#\s+(?:\d+[\-\/]\d+[\-\/]\d+(?:\s+\d+:\d+(?::\d+)?(\s*(?:AM|PM))?)?|\d+:\d+(?::\d+)?(\s*(?:AM|PM))?)\s+#)/i],["pln",/^(?:(?:[a-z]|_\w)\w*(?:\[[%&@!#]+\])?|\[(?:[a-z]|_\w)\w*\])/i],["pun",/^[^\w\t\n\r \"\'\[\]\xA0\u2018\u2019\u201C\u201D\u2028\u2029]+/],["pun",/^(?:\[|\])/]]),["vb", 19 | "vbs"]); 20 | -------------------------------------------------------------------------------- /tests/test_in_node: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | var path = require('path'); 4 | var Browser = require('zombie'); 5 | var htmlToText = require('html-to-text'); 6 | 7 | var optsZombie = { 8 | debug: false, 9 | silent: false, 10 | waitDuration: '10s', 11 | runScripts: true 12 | }; 13 | var optsHTT = { 14 | wordwrap: 80, // process.stdout.columns 15 | tables: true, 16 | ignoreHref: true, 17 | preserveNewlines: true, 18 | singleNewLineParagraphs: true 19 | }; 20 | 21 | var jobs = process.argv.slice(2); 22 | var returnCode = 0; 23 | var browser = null; 24 | 25 | // start processing pages 26 | startBrowser(); 27 | 28 | function startBrowser() { 29 | // close any previous browser sessions 30 | if (browser) { 31 | //browser.window.close(); 32 | browser.destroy(); 33 | } 34 | 35 | // next URL 36 | var url = jobs.shift(); 37 | if (url === undefined) { 38 | console.log('>> Complete'); 39 | process.exit(returnCode); 40 | return; 41 | } else if (!/^(?:https?|ftp):/.test(url)) { 42 | // rewrite local path as a file:// URL 43 | url = encodeURI('file://' + path.resolve(url).replace(/\\/g, '/')); 44 | } 45 | 46 | // load page 47 | console.log('>> Loading %s ...', url); 48 | browser = new Browser(optsZombie); 49 | if (optsZombie.debug) { browser.debug(); } 50 | browser.visit(url).then(checkCb).catch(problemCb); 51 | } 52 | 53 | function problemCb(err) { 54 | // log error, and process next page 55 | console.warn('>> ' + err); 56 | returnCode = 1; 57 | startBrowser(); 58 | } 59 | 60 | function checkCb() { 61 | var done = false; 62 | 63 | // check for errors 64 | function onProb(err) { 65 | console.warn('>> ' + err); 66 | returnCode = 1; 67 | done = true; 68 | } 69 | (browser.errors || []).forEach(onProb); 70 | (browser.document.errors || []).forEach(onProb); 71 | 72 | // retrieve and log results 73 | var report = browser.html('#report'); 74 | if (report && report.length) { 75 | done = true; 76 | //console.log(browser.text('#report')); 77 | console.log(htmlToText.fromString( 78 | // HACK: replace
tags with

79 | // https://github.com/werk85/node-html-to-text/issues/71 80 | report.replace(/(<\/?)div/ig, '$1p'), optsHTT)); 81 | } 82 | 83 | // process next page if done, otherwise wait for page to complete loading 84 | if (done) { 85 | startBrowser(); 86 | } else { 87 | browser.wait().then(checkCb).catch(problemCb); 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /src/prettify.css: -------------------------------------------------------------------------------- 1 | /** 2 | * @license 3 | * Copyright (C) 2015 Google Inc. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | /* Pretty printing styles. Used with prettify.js. */ 19 | 20 | 21 | /* SPAN elements with the classes below are added by prettyprint. */ 22 | .pln { color: #000 } /* plain text */ 23 | 24 | @media screen { 25 | .str { color: #080 } /* string content */ 26 | .kwd { color: #008 } /* a keyword */ 27 | .com { color: #800 } /* a comment */ 28 | .typ { color: #606 } /* a type name */ 29 | .lit { color: #066 } /* a literal value */ 30 | /* punctuation, lisp open bracket, lisp close bracket */ 31 | .pun, .opn, .clo { color: #660 } 32 | .tag { color: #008 } /* a markup tag name */ 33 | .atn { color: #606 } /* a markup attribute name */ 34 | .atv { color: #080 } /* a markup attribute value */ 35 | .dec, .var { color: #606 } /* a declaration; a variable name */ 36 | .fun { color: red } /* a function name */ 37 | } 38 | 39 | /* Use higher contrast and text-weight for printable form. */ 40 | @media print, projection { 41 | .str { color: #060 } 42 | .kwd { color: #006; font-weight: bold } 43 | .com { color: #600; font-style: italic } 44 | .typ { color: #404; font-weight: bold } 45 | .lit { color: #044 } 46 | .pun, .opn, .clo { color: #440 } 47 | .tag { color: #006; font-weight: bold } 48 | .atn { color: #404 } 49 | .atv { color: #060 } 50 | } 51 | 52 | /* Put a border around prettyprinted code snippets. */ 53 | pre.prettyprint { padding: 2px; border: 1px solid #888 } 54 | 55 | /* Specify class=linenums on a pre to get line numbering */ 56 | ol.linenums { margin-top: 0; margin-bottom: 0 } /* IE indents via margin-left */ 57 | li.L0, 58 | li.L1, 59 | li.L2, 60 | li.L3, 61 | li.L5, 62 | li.L6, 63 | li.L7, 64 | li.L8 { list-style-type: none } 65 | /* Alternate shading for lines */ 66 | li.L1, 67 | li.L3, 68 | li.L5, 69 | li.L7, 70 | li.L9 { background: #eee } 71 | -------------------------------------------------------------------------------- /src/lang-llvm.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @license 3 | * Copyright (C) 2013 Nikhil Dabas 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | /** 19 | * @fileoverview 20 | * Registers a language handler for LLVM. 21 | * From https://gist.github.com/ndabas/2850418 22 | * 23 | * 24 | * To use, include prettify.js and this file in your HTML page. 25 | * Then put your code in an HTML tag like 26 | *

(my LLVM code)
27 | * 28 | * 29 | * The regular expressions were adapted from: 30 | * https://github.com/hansstimer/llvm.tmbundle/blob/76fedd8f50fd6108b1780c51d79fbe3223de5f34/Syntaxes/LLVM.tmLanguage 31 | * 32 | * http://llvm.org/docs/LangRef.html#constants describes the language grammar. 33 | * 34 | * @author Nikhil Dabas 35 | */ 36 | PR['registerLangHandler']( 37 | PR['createSimpleLexer']( 38 | [ 39 | // Whitespace 40 | [PR['PR_PLAIN'], /^[\t\n\r \xA0]+/, null, '\t\n\r \xA0'], 41 | // A double quoted, possibly multi-line, string. 42 | [PR['PR_STRING'], /^!?\"(?:[^\"\\]|\\[\s\S])*(?:\"|$)/, null, '"'], 43 | // comment.llvm 44 | [PR['PR_COMMENT'], /^;[^\r\n]*/, null, ';'] 45 | ], 46 | [ 47 | // variable.llvm 48 | [PR['PR_PLAIN'], /^[%@!](?:[-a-zA-Z$._][-a-zA-Z$._0-9]*|\d+)/], 49 | 50 | // According to http://llvm.org/docs/LangRef.html#well-formedness 51 | // These reserved words cannot conflict with variable names, because none of them start with a prefix character ('%' or '@'). 52 | [PR['PR_KEYWORD'], /^[A-Za-z_][0-9A-Za-z_]*/, null], 53 | 54 | // constant.numeric.float.llvm 55 | [PR['PR_LITERAL'], /^\d+\.\d+/], 56 | 57 | // constant.numeric.integer.llvm 58 | [PR['PR_LITERAL'], /^(?:\d+|0[xX][a-fA-F0-9]+)/], 59 | 60 | // punctuation 61 | [PR['PR_PUNCTUATION'], /^[()\[\]{},=*<>:]|\.\.\.$/] 62 | ]), 63 | ['llvm', 'll']); 64 | -------------------------------------------------------------------------------- /src/lang-go.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @license 3 | * Copyright (C) 2010 Google Inc. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | /** 19 | * @fileoverview 20 | * Registers a language handler for the Go language.. 21 | *

22 | * Based on the lexical grammar at 23 | * http://golang.org/doc/go_spec.html#Lexical_elements 24 | *

25 | * Go uses a minimal style for highlighting so the below does not distinguish 26 | * strings, keywords, literals, etc. by design. 27 | * From a discussion with the Go designers: 28 | *

29 |  * On Thursday, July 22, 2010, Mike Samuel <...> wrote:
30 |  * > On Thu, Jul 22, 2010, Rob 'Commander' Pike <...> wrote:
31 |  * >> Personally, I would vote for the subdued style godoc presents at http://golang.org
32 |  * >>
33 |  * >> Not as fancy as some like, but a case can be made it's the official style.
34 |  * >> If people want more colors, I wouldn't fight too hard, in the interest of
35 |  * >> encouragement through familiarity, but even then I would ask to shy away
36 |  * >> from technicolor starbursts.
37 |  * >
38 |  * > Like http://golang.org/pkg/go/scanner/ where comments are blue and all
39 |  * > other content is black?  I can do that.
40 |  * 
41 | * 42 | * @author mikesamuel@gmail.com 43 | */ 44 | 45 | PR['registerLangHandler']( 46 | PR['createSimpleLexer']( 47 | [ 48 | // Whitespace is made up of spaces, tabs and newline characters. 49 | [PR['PR_PLAIN'], /^[\t\n\r \xA0]+/, null, '\t\n\r \xA0'], 50 | // Not escaped as a string. See note on minimalism above. 51 | [PR['PR_PLAIN'], /^(?:\"(?:[^\"\\]|\\[\s\S])*(?:\"|$)|\'(?:[^\'\\]|\\[\s\S])+(?:\'|$)|`[^`]*(?:`|$))/, null, '"\''] 52 | ], 53 | [ 54 | // Block comments are delimited by /* and */. 55 | // Single-line comments begin with // and extend to the end of a line. 56 | [PR['PR_COMMENT'], /^(?:\/\/[^\r\n]*|\/\*[\s\S]*?\*\/)/], 57 | [PR['PR_PLAIN'], /^(?:[^\/\"\'`]|\/(?![\/\*]))+/i] 58 | ]), 59 | ['go']); 60 | -------------------------------------------------------------------------------- /src/lang-kotlin.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @license 3 | * Copyright (C) 2017 Michał Bączkowski 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | /** 19 | * @fileoverview 20 | * Registers a language handler for Kotlin. 21 | * 22 | * Limitations: 23 | * - doesn't support string interpolation ("$var") 24 | * - doesn't support labels if there is no space between the keyword (break@loop, loop@for) 25 | * 26 | * @author mibac138@gmail.com 27 | */ 28 | 29 | PR['registerLangHandler']( 30 | PR['createSimpleLexer']( 31 | [ 32 | [PR['PR_PLAIN'], /^[\t\n\r \xA0]+/, null, '\t\n\r \xA0'], 33 | [PR['PR_PUNCTUATION'], /^[.!%&()*+,\-;<=>?\[\\\]^{|}:]+/, null, '.!%&()*+,-;<=>?[\\]^{|}:'] 34 | ], 35 | [ 36 | // keywords 37 | [PR['PR_KEYWORD'], 38 | /^\b(package|public|protected|private|open|abstract|constructor|final|override|import|for|while|as|typealias|get|set|((data|enum|annotation|sealed) )?class|this|super|val|var|fun|is|in|throw|return|break|continue|(companion )?object|if|try|else|do|when|init|interface|typeof)\b/], 39 | [PR['PR_LITERAL'], /^(?:true|false|null)\b/], 40 | // number literals 41 | [PR['PR_LITERAL'], /^(0[xX][0-9a-fA-F_]+L?|0[bB][0-1]+L?|[0-9_.]+([eE]-?[0-9]+)?[fFL]?)/], 42 | [PR['PR_TYPE'], /^(\b[A-Z]+[a-z][a-zA-Z0-9_$@]*|`.*`)/, null], 43 | //double slash comments 44 | [PR['PR_COMMENT'], /^\/\/.*/], 45 | //slash star comments and documentation 46 | [PR['PR_COMMENT'], /^\/\*[\s\S]*?(?:\*\/|$)/], 47 | // char 48 | [PR['PR_STRING'], /'.'/], 49 | // string 50 | [PR['PR_STRING'], /^"([^"\\]|\\[\s\S])*"/], 51 | // multiline string 52 | [PR['PR_STRING'], /^"{3}[\s\S]*?[^\\]"{3}/], 53 | // annotation (and label) 54 | [PR['PR_LITERAL'], /^@([a-zA-Z0-9_$@]*|`.*`)/], 55 | // label definition 56 | [PR['PR_LITERAL'], /^[a-zA-Z0-9_]+@/] 57 | ]), 58 | ['kotlin']); 59 | -------------------------------------------------------------------------------- /src/lang-r.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @license 3 | * Copyright (C) 2012 Jeffrey B. Arnold 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | /** 19 | * @fileoverview 20 | * Registers a language handler for S, S-plus, and R source code. 21 | * 22 | * 23 | * To use, include prettify.js and this file in your HTML page. 24 | * Then put your code in an HTML tag like 25 | *
 code 
26 | * 27 | * Language definition from 28 | * http://cran.r-project.org/doc/manuals/R-lang.html. 29 | * Many of the regexes are shared with the pygments SLexer, 30 | * http://pygments.org/. 31 | * 32 | * Original: https://raw.github.com/jrnold/prettify-lang-r-bugs/master/lang-r.js 33 | * 34 | * @author jeffrey.arnold@gmail.com 35 | */ 36 | PR['registerLangHandler']( 37 | PR['createSimpleLexer']( 38 | [ 39 | [PR['PR_PLAIN'], /^[\t\n\r \xA0]+/, null, '\t\n\r \xA0'], 40 | [PR['PR_STRING'], /^\"(?:[^\"\\]|\\[\s\S])*(?:\"|$)/, null, '"'], 41 | [PR['PR_STRING'], /^\'(?:[^\'\\]|\\[\s\S])*(?:\'|$)/, null, "'"] 42 | ], 43 | [ 44 | [PR['PR_COMMENT'], /^#.*/], 45 | [PR['PR_KEYWORD'], /^(?:if|else|for|while|repeat|in|next|break|return|switch|function)(?![A-Za-z0-9_.])/], 46 | // hex numbes 47 | [PR['PR_LITERAL'], /^0[xX][a-fA-F0-9]+([pP][0-9]+)?[Li]?/], 48 | // Decimal numbers 49 | [PR['PR_LITERAL'], /^[+-]?([0-9]+(\.[0-9]+)?|\.[0-9]+)([eE][+-]?[0-9]+)?[Li]?/], 50 | // builtin symbols 51 | [PR['PR_LITERAL'], /^(?:NULL|NA(?:_(?:integer|real|complex|character)_)?|Inf|TRUE|FALSE|NaN|\.\.(?:\.|[0-9]+))(?![A-Za-z0-9_.])/], 52 | // assignment, operators, and parens, etc. 53 | [PR['PR_PUNCTUATION'], /^(?:<>?|-|==|<=|>=|<|>|&&?|!=|\|\|?|\*|\+|\^|\/|!|%.*?%|=|~|\$|@|:{1,3}|[\[\](){};,?])/], 54 | // valid variable names 55 | [PR['PR_PLAIN'], /^(?:[A-Za-z]+[A-Za-z0-9_.]*|\.[a-zA-Z_][0-9a-zA-Z\._]*)(?![A-Za-z0-9_.])/], 56 | // string backtick 57 | [PR['PR_STRING'], /^`.+`/] 58 | ]), 59 | ['r', 's', 'R', 'S', 'Splus']); 60 | -------------------------------------------------------------------------------- /src/lang-lua.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @license 3 | * Copyright (C) 2008 Google Inc. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | /** 19 | * @fileoverview 20 | * Registers a language handler for Lua. 21 | * 22 | * 23 | * To use, include prettify.js and this file in your HTML page. 24 | * Then put your code in an HTML tag like 25 | *
(my Lua code)
26 | * 27 | * 28 | * I used http://www.lua.org/manual/5.1/manual.html#2.1 29 | * Because of the long-bracket concept used in strings and comments, Lua does 30 | * not have a regular lexical grammar, but luckily it fits within the space 31 | * of irregular grammars supported by javascript regular expressions. 32 | * 33 | * @author mikesamuel@gmail.com 34 | */ 35 | 36 | PR['registerLangHandler']( 37 | PR['createSimpleLexer']( 38 | [ 39 | // Whitespace 40 | [PR['PR_PLAIN'], /^[\t\n\r \xA0]+/, null, '\t\n\r \xA0'], 41 | // A double or single quoted, possibly multi-line, string. 42 | [PR['PR_STRING'], /^(?:\"(?:[^\"\\]|\\[\s\S])*(?:\"|$)|\'(?:[^\'\\]|\\[\s\S])*(?:\'|$))/, null, '"\''] 43 | ], 44 | [ 45 | // A comment is either a line comment that starts with two dashes, or 46 | // two dashes preceding a long bracketed block. 47 | [PR['PR_COMMENT'], /^--(?:\[(=*)\[[\s\S]*?(?:\]\1\]|$)|[^\r\n]*)/], 48 | // A long bracketed block not preceded by -- is a string. 49 | [PR['PR_STRING'], /^\[(=*)\[[\s\S]*?(?:\]\1\]|$)/], 50 | [PR['PR_KEYWORD'], /^(?:and|break|do|else|elseif|end|false|for|function|if|in|local|nil|not|or|repeat|return|then|true|until|while)\b/, null], 51 | // A number is a hex integer literal, a decimal real literal, or in 52 | // scientific notation. 53 | [PR['PR_LITERAL'], 54 | /^[+-]?(?:0x[\da-f]+|(?:(?:\.\d+|\d+(?:\.\d*)?)(?:e[+\-]?\d+)?))/i], 55 | // An identifier 56 | [PR['PR_PLAIN'], /^[a-z_]\w*/i], 57 | // A run of punctuation 58 | [PR['PR_PUNCTUATION'], /^[^\w\t\n\r \xA0][^\w\t\n\r \xA0\"\'\-\+=]*/] 59 | ]), 60 | ['lua']); 61 | -------------------------------------------------------------------------------- /loader/lang-ls.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2013 Eric Knibbe 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"],["str",/^\'[^\'\\]*(?:\\[\s\S][^\'\\]*)*(?:\'|$)/,null,"'"],["str",/^\"[^\"\\]*(?:\\[\s\S][^\"\\]*)*(?:\"|$)/,null,'"'],["str",/^\`[^\`]*(?:\`|$)/,null,"`"],["lit",/^0x[\da-f]+|\d+/i,null,"0123456789"],["atn",/^[#$][a-z_][\w.]*|#\d+\b|#![ \S]+lasso9\b/i,null,"#$"]],[["tag",/^[[\]]|<\?(?:lasso(?:script)?|=)|\?>|(no_square_brackets|noprocess)\b/i],["com", 18 | /^\/\/[^\r\n]*|\/\*[\s\S]*?\*\//],["atn",/^-(?!infinity)[a-z_][\w.]*|\.\s*'[a-z_][\w.]*'|\.{3}/i],["lit",/^\d*\.\d+(?:e[-+]?\d+)?|(infinity|NaN)\b/i],["atv",/^::\s*[a-z_][\w.]*/i],["lit",/^(?:true|false|none|minimal|full|all|void|and|or|not|bw|nbw|ew|new|cn|ncn|lt|lte|gt|gte|eq|neq|rx|nrx|ft)\b/i],["typ",/^(?:array|date|decimal|duration|integer|map|pair|string|tag|xml|null|boolean|bytes|keyword|list|locale|queue|set|stack|staticarray|local|var|variable|global|data|self|inherited|currentcapture|givenblock)\b|^\.\.?/i], 19 | ["kwd",/^(?:cache|database_names|database_schemanames|database_tablenames|define_tag|define_type|email_batch|encode_set|html_comment|handle|handle_error|header|if|inline|iterate|ljax_target|link|link_currentaction|link_currentgroup|link_currentrecord|link_detail|link_firstgroup|link_firstrecord|link_lastgroup|link_lastrecord|link_nextgroup|link_nextrecord|link_prevgroup|link_prevrecord|log|loop|namespace_using|output_none|portal|private|protect|records|referer|referrer|repeating|resultset|rows|search_args|search_arguments|select|sort_args|sort_arguments|thread_atomic|value_list|while|abort|case|else|fail_if|fail_ifnot|fail|if_empty|if_false|if_null|if_true|loop_abort|loop_continue|loop_count|params|params_up|return|return_value|run_children|soap_definetag|soap_lastrequest|soap_lastresponse|tag_name|ascending|average|by|define|descending|do|equals|frozen|group|handle_failure|import|in|into|join|let|match|max|min|on|order|parent|protected|provide|public|require|returnhome|skip|split_thread|sum|take|thread|to|trait|type|where|with|yield|yieldhome)\b/i], 20 | ["pln",/^[a-z_][\w.]*(?:=\s*(?=\())?/i],["pun",/^:=|[-+*\/%=<>&|!?\\]+/]]),["lasso","ls","lassoscript"]); 21 | -------------------------------------------------------------------------------- /loader/lang-lasso.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2013 Eric Knibbe 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"],["str",/^\'[^\'\\]*(?:\\[\s\S][^\'\\]*)*(?:\'|$)/,null,"'"],["str",/^\"[^\"\\]*(?:\\[\s\S][^\"\\]*)*(?:\"|$)/,null,'"'],["str",/^\`[^\`]*(?:\`|$)/,null,"`"],["lit",/^0x[\da-f]+|\d+/i,null,"0123456789"],["atn",/^[#$][a-z_][\w.]*|#\d+\b|#![ \S]+lasso9\b/i,null,"#$"]],[["tag",/^[[\]]|<\?(?:lasso(?:script)?|=)|\?>|(no_square_brackets|noprocess)\b/i],["com", 18 | /^\/\/[^\r\n]*|\/\*[\s\S]*?\*\//],["atn",/^-(?!infinity)[a-z_][\w.]*|\.\s*'[a-z_][\w.]*'|\.{3}/i],["lit",/^\d*\.\d+(?:e[-+]?\d+)?|(infinity|NaN)\b/i],["atv",/^::\s*[a-z_][\w.]*/i],["lit",/^(?:true|false|none|minimal|full|all|void|and|or|not|bw|nbw|ew|new|cn|ncn|lt|lte|gt|gte|eq|neq|rx|nrx|ft)\b/i],["typ",/^(?:array|date|decimal|duration|integer|map|pair|string|tag|xml|null|boolean|bytes|keyword|list|locale|queue|set|stack|staticarray|local|var|variable|global|data|self|inherited|currentcapture|givenblock)\b|^\.\.?/i], 19 | ["kwd",/^(?:cache|database_names|database_schemanames|database_tablenames|define_tag|define_type|email_batch|encode_set|html_comment|handle|handle_error|header|if|inline|iterate|ljax_target|link|link_currentaction|link_currentgroup|link_currentrecord|link_detail|link_firstgroup|link_firstrecord|link_lastgroup|link_lastrecord|link_nextgroup|link_nextrecord|link_prevgroup|link_prevrecord|log|loop|namespace_using|output_none|portal|private|protect|records|referer|referrer|repeating|resultset|rows|search_args|search_arguments|select|sort_args|sort_arguments|thread_atomic|value_list|while|abort|case|else|fail_if|fail_ifnot|fail|if_empty|if_false|if_null|if_true|loop_abort|loop_continue|loop_count|params|params_up|return|return_value|run_children|soap_definetag|soap_lastrequest|soap_lastresponse|tag_name|ascending|average|by|define|descending|do|equals|frozen|group|handle_failure|import|in|into|join|let|match|max|min|on|order|parent|protected|provide|public|require|returnhome|skip|split_thread|sum|take|thread|to|trait|type|where|with|yield|yieldhome)\b/i], 20 | ["pln",/^[a-z_][\w.]*(?:=\s*(?=\())?/i],["pun",/^:=|[-+*\/%=<>&|!?\\]+/]]),["lasso","ls","lassoscript"]); 21 | -------------------------------------------------------------------------------- /loader/lang-lassoscript.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Copyright (C) 2013 Eric Knibbe 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | */ 17 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xA0]+/,null,"\t\n\r \u00a0"],["str",/^\'[^\'\\]*(?:\\[\s\S][^\'\\]*)*(?:\'|$)/,null,"'"],["str",/^\"[^\"\\]*(?:\\[\s\S][^\"\\]*)*(?:\"|$)/,null,'"'],["str",/^\`[^\`]*(?:\`|$)/,null,"`"],["lit",/^0x[\da-f]+|\d+/i,null,"0123456789"],["atn",/^[#$][a-z_][\w.]*|#\d+\b|#![ \S]+lasso9\b/i,null,"#$"]],[["tag",/^[[\]]|<\?(?:lasso(?:script)?|=)|\?>|(no_square_brackets|noprocess)\b/i],["com", 18 | /^\/\/[^\r\n]*|\/\*[\s\S]*?\*\//],["atn",/^-(?!infinity)[a-z_][\w.]*|\.\s*'[a-z_][\w.]*'|\.{3}/i],["lit",/^\d*\.\d+(?:e[-+]?\d+)?|(infinity|NaN)\b/i],["atv",/^::\s*[a-z_][\w.]*/i],["lit",/^(?:true|false|none|minimal|full|all|void|and|or|not|bw|nbw|ew|new|cn|ncn|lt|lte|gt|gte|eq|neq|rx|nrx|ft)\b/i],["typ",/^(?:array|date|decimal|duration|integer|map|pair|string|tag|xml|null|boolean|bytes|keyword|list|locale|queue|set|stack|staticarray|local|var|variable|global|data|self|inherited|currentcapture|givenblock)\b|^\.\.?/i], 19 | ["kwd",/^(?:cache|database_names|database_schemanames|database_tablenames|define_tag|define_type|email_batch|encode_set|html_comment|handle|handle_error|header|if|inline|iterate|ljax_target|link|link_currentaction|link_currentgroup|link_currentrecord|link_detail|link_firstgroup|link_firstrecord|link_lastgroup|link_lastrecord|link_nextgroup|link_nextrecord|link_prevgroup|link_prevrecord|log|loop|namespace_using|output_none|portal|private|protect|records|referer|referrer|repeating|resultset|rows|search_args|search_arguments|select|sort_args|sort_arguments|thread_atomic|value_list|while|abort|case|else|fail_if|fail_ifnot|fail|if_empty|if_false|if_null|if_true|loop_abort|loop_continue|loop_count|params|params_up|return|return_value|run_children|soap_definetag|soap_lastrequest|soap_lastresponse|tag_name|ascending|average|by|define|descending|do|equals|frozen|group|handle_failure|import|in|into|join|let|match|max|min|on|order|parent|protected|provide|public|require|returnhome|skip|split_thread|sum|take|thread|to|trait|type|where|with|yield|yieldhome)\b/i], 20 | ["pln",/^[a-z_][\w.]*(?:=\s*(?=\())?/i],["pun",/^:=|[-+*\/%=<>&|!?\\]+/]]),["lasso","ls","lassoscript"]); 21 | -------------------------------------------------------------------------------- /src/lang-scala.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @license 3 | * Copyright (C) 2010 Google Inc. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | /** 19 | * @fileoverview 20 | * Registers a language handler for Scala. 21 | * 22 | * Derived from http://lampsvn.epfl.ch/svn-repos/scala/scala-documentation/trunk/src/reference/SyntaxSummary.tex 23 | * 24 | * @author mikesamuel@gmail.com 25 | */ 26 | 27 | PR['registerLangHandler']( 28 | PR['createSimpleLexer']( 29 | [ 30 | // Whitespace 31 | [PR['PR_PLAIN'], /^[\t\n\r \xA0]+/, null, '\t\n\r \xA0'], 32 | // A double or single quoted string 33 | // or a triple double-quoted multi-line string. 34 | [PR['PR_STRING'], 35 | /^(?:"(?:(?:""(?:""?(?!")|[^\\"]|\\.)*"{0,3})|(?:[^"\r\n\\]|\\.)*"?))/, 36 | null, '"'], 37 | [PR['PR_LITERAL'], /^`(?:[^\r\n\\`]|\\.)*`?/, null, '`'], 38 | [PR['PR_PUNCTUATION'], /^[!#%&()*+,\-:;<=>?@\[\\\]^{|}~]+/, null, 39 | '!#%&()*+,-:;<=>?@[\\]^{|}~'] 40 | ], 41 | [ 42 | // A symbol literal is a single quote followed by an identifier with no 43 | // single quote following 44 | // A character literal has single quotes on either side 45 | [PR['PR_STRING'], /^'(?:[^\r\n\\']|\\(?:'|[^\r\n']+))'/], 46 | [PR['PR_LITERAL'], /^'[a-zA-Z_$][\w$]*(?!['$\w])/], 47 | [PR['PR_KEYWORD'], /^(?:abstract|case|catch|class|def|do|else|extends|final|finally|for|forSome|if|implicit|import|lazy|match|new|object|override|package|private|protected|requires|return|sealed|super|throw|trait|try|type|val|var|while|with|yield)\b/], 48 | [PR['PR_LITERAL'], /^(?:true|false|null|this)\b/], 49 | [PR['PR_LITERAL'], /^(?:(?:0(?:[0-7]+|X[0-9A-F]+))L?|(?:(?:0|[1-9][0-9]*)(?:(?:\.[0-9]+)?(?:E[+\-]?[0-9]+)?F?|L?))|\\.[0-9]+(?:E[+\-]?[0-9]+)?F?)/i], 50 | // Treat upper camel case identifiers as types. 51 | [PR['PR_TYPE'], /^[$_]*[A-Z][_$A-Z0-9]*[a-z][\w$]*/], 52 | [PR['PR_PLAIN'], /^[$a-zA-Z_][\w$]*/], 53 | [PR['PR_COMMENT'], /^\/(?:\/.*|\*(?:\/|\**[^*/])*(?:\*+\/?)?)/], 54 | [PR['PR_PUNCTUATION'], /^(?:\.+|\/)/] 55 | ]), 56 | ['scala']); 57 | -------------------------------------------------------------------------------- /src/lang-apollo.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @license 3 | * Copyright (C) 2009 Onno Hommes. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | /** 19 | * @fileoverview 20 | * Registers a language handler for the AGC/AEA Assembly Language as described 21 | * at http://virtualagc.googlecode.com 22 | *

23 | * This file could be used by goodle code to allow syntax highlight for 24 | * Virtual AGC SVN repository or if you don't want to commonize 25 | * the header for the agc/aea html assembly listing. 26 | * 27 | * @author ohommes@alumni.cmu.edu 28 | */ 29 | 30 | PR['registerLangHandler']( 31 | PR['createSimpleLexer']( 32 | [ 33 | // A line comment that starts with ; 34 | [PR['PR_COMMENT'], /^#[^\r\n]*/, null, '#'], 35 | // Whitespace 36 | [PR['PR_PLAIN'], /^[\t\n\r \xA0]+/, null, '\t\n\r \xA0'], 37 | // A double quoted, possibly multi-line, string. 38 | [PR['PR_STRING'], /^\"(?:[^\"\\]|\\[\s\S])*(?:\"|$)/, null, '"'] 39 | ], 40 | [ 41 | [PR['PR_KEYWORD'], /^(?:ADS|AD|AUG|BZF|BZMF|CAE|CAF|CA|CCS|COM|CS|DAS|DCA|DCOM|DCS|DDOUBL|DIM|DOUBLE|DTCB|DTCF|DV|DXCH|EDRUPT|EXTEND|INCR|INDEX|NDX|INHINT|LXCH|MASK|MSK|MP|MSU|NOOP|OVSK|QXCH|RAND|READ|RELINT|RESUME|RETURN|ROR|RXOR|SQUARE|SU|TCR|TCAA|OVSK|TCF|TC|TS|WAND|WOR|WRITE|XCH|XLQ|XXALQ|ZL|ZQ|ADD|ADZ|SUB|SUZ|MPY|MPR|MPZ|DVP|COM|ABS|CLA|CLZ|LDQ|STO|STQ|ALS|LLS|LRS|TRA|TSQ|TMI|TOV|AXT|TIX|DLY|INP|OUT)\s/,null], 42 | [PR['PR_TYPE'], /^(?:-?GENADR|=MINUS|2BCADR|VN|BOF|MM|-?2CADR|-?[1-6]DNADR|ADRES|BBCON|[SE]?BANK\=?|BLOCK|BNKSUM|E?CADR|COUNT\*?|2?DEC\*?|-?DNCHAN|-?DNPTR|EQUALS|ERASE|MEMORY|2?OCT|REMADR|SETLOC|SUBRO|ORG|BSS|BES|SYN|EQU|DEFINE|END)\s/,null], 43 | // A single quote possibly followed by a word that optionally ends with 44 | // = ! or ?. 45 | [PR['PR_LITERAL'], 46 | /^\'(?:-*(?:\w|\\[\x21-\x7e])(?:[\w-]*|\\[\x21-\x7e])[=!?]?)?/], 47 | // Any word including labels that optionally ends with = ! or ?. 48 | [PR['PR_PLAIN'], 49 | /^-*(?:[!-z_]|\\[\x21-\x7e])(?:[\w-]*|\\[\x21-\x7e])[=!?]?/i], 50 | // A printable non-space non-special character 51 | [PR['PR_PUNCTUATION'], /^[^\w\t\n\r \xA0()\"\\\';]+/] 52 | ]), 53 | ['apollo', 'agc', 'aea']); 54 | -------------------------------------------------------------------------------- /src/lang-tcl.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @license 3 | * Copyright (C) 2012 Pyrios 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | /** 19 | * @fileoverview 20 | * Registers a language handler for TCL 21 | * 22 | * 23 | * To use, include prettify.js and this file in your HTML page. 24 | * Then put your code in an HTML tag like 25 | *

proc foo {} {puts bar}
26 | * 27 | * I copy-pasted lang-lisp.js, so this is probably not 100% accurate. 28 | * I used http://wiki.tcl.tk/1019 for the keywords, but tried to only 29 | * include as keywords that had more impact on the program flow 30 | * rather than providing convenience. For example, I included 'if' 31 | * since that provides branching, but left off 'open' since that is more 32 | * like a proc. Add more if it makes sense. 33 | * 34 | * @author pyrios@gmail.com 35 | */ 36 | 37 | PR['registerLangHandler']( 38 | PR['createSimpleLexer']( 39 | [ 40 | ['opn', /^\{+/, null, '{'], 41 | ['clo', /^\}+/, null, '}'], 42 | // A line comment that starts with ; 43 | [PR['PR_COMMENT'], /^#[^\r\n]*/, null, '#'], 44 | // Whitespace 45 | [PR['PR_PLAIN'], /^[\t\n\r \xA0]+/, null, '\t\n\r \xA0'], 46 | // A double quoted, possibly multi-line, string. 47 | [PR['PR_STRING'], /^\"(?:[^\"\\]|\\[\s\S])*(?:\"|$)/, null, '"'] 48 | ], 49 | [ 50 | [PR['PR_KEYWORD'], /^(?:after|append|apply|array|break|case|catch|continue|error|eval|exec|exit|expr|for|foreach|if|incr|info|proc|return|set|switch|trace|uplevel|upvar|while)\b/, null], 51 | [PR['PR_LITERAL'], 52 | /^[+\-]?(?:[0#]x[0-9a-f]+|\d+\/\d+|(?:\.\d+|\d+(?:\.\d*)?)(?:[ed][+\-]?\d+)?)/i], 53 | // A single quote possibly followed by a word that optionally ends with 54 | // = ! or ?. 55 | [PR['PR_LITERAL'], 56 | /^\'(?:-*(?:\w|\\[\x21-\x7e])(?:[\w-]*|\\[\x21-\x7e])[=!?]?)?/], 57 | // A word that optionally ends with = ! or ?. 58 | [PR['PR_PLAIN'], 59 | /^-*(?:[a-z_]|\\[\x21-\x7e])(?:[\w-]*|\\[\x21-\x7e])[=!?]?/i], 60 | // A printable non-space non-special character 61 | [PR['PR_PUNCTUATION'], /^[^\w\t\n\r \xA0()\"\\\';]+/] 62 | ]), 63 | ['tcl']); 64 | -------------------------------------------------------------------------------- /tasks/lib/lang-aliases.js: -------------------------------------------------------------------------------- 1 | /** 2 | * google-code-prettify 3 | * https://github.com/google/code-prettify 4 | * 5 | * @author Amro 6 | * @license Apache-2.0 7 | */ 8 | 9 | var fs = require('fs'); 10 | var path = require('path'); 11 | var vm = require('vm'); 12 | 13 | /** 14 | * Returns a mock object PR of the prettify API. This is used to collect 15 | * registered language file extensions. 16 | * 17 | * @return {Object} PR object with an additional `extensions` property. 18 | */ 19 | function createSandbox() { 20 | // collect registered language extensions 21 | var sandbox = {}; 22 | sandbox.extensions = []; 23 | // mock prettify.js API 24 | sandbox.window = {}; 25 | sandbox.window.PR = sandbox.PR = { 26 | registerLangHandler: function (handler, exts) { 27 | sandbox.extensions = sandbox.extensions.concat(exts); 28 | }, 29 | createSimpleLexer: function (sPatterns, fPatterns) { 30 | return function (job) {}; 31 | }, 32 | sourceDecorator: function (options) { 33 | return function (job) {}; 34 | }, 35 | prettyPrintOne: function (src, lang, ln) { 36 | return src; 37 | }, 38 | prettyPrint: function (done, root) {}, 39 | PR_ATTRIB_NAME: 'atn', 40 | PR_ATTRIB_VALUE: 'atv', 41 | PR_COMMENT: 'com', 42 | PR_DECLARATION: 'dec', 43 | PR_KEYWORD: 'kwd', 44 | PR_LITERAL: 'lit', 45 | PR_NOCODE: 'nocode', 46 | PR_PLAIN: 'pln', 47 | PR_PUNCTUATION: 'pun', 48 | PR_SOURCE: 'src', 49 | PR_STRING: 'str', 50 | PR_TAG: 'tag', 51 | PR_TYPE: 'typ' 52 | }; 53 | return sandbox; 54 | } 55 | 56 | /** 57 | * Runs a language handler file under VM to collect extensions. 58 | * 59 | * Given a lang-*.js file, runs the language handler in a fake context where 60 | * PR.registerLangHandler collects handler names without doing anything else. 61 | * This is later used to makes copies of the JS extension under all its 62 | * registered language names lang-.js 63 | * 64 | * @param {string} src path to lang-xxx.js language handler 65 | * @return {Array} registered file extensions 66 | */ 67 | function runLanguageHandler(src) { 68 | // execute source code in an isolated sandbox with a mock PR object 69 | var sandbox = createSandbox(); 70 | vm.runInNewContext(fs.readFileSync(src), sandbox, { 71 | filename: src 72 | }); 73 | 74 | // language name 75 | var lang = path.basename(src, path.extname(src)).replace(/^lang-/, ''); 76 | 77 | // collect and filter extensions 78 | var exts = sandbox.extensions.map(function (ext) { 79 | // case-insensitive names 80 | return ext.toLowerCase(); 81 | }).filter(function (ext) { 82 | // skip self, and internal names like foo-bar-baz or lang.foo 83 | return ext !== lang && !/\W/.test(ext); 84 | }); 85 | exts = exts.filter(function (ext, pos) { 86 | // remove duplicates 87 | return exts.indexOf(ext) === pos; 88 | }); 89 | return exts; 90 | } 91 | 92 | module.exports = runLanguageHandler; 93 | -------------------------------------------------------------------------------- /styles/doxy.css: -------------------------------------------------------------------------------- 1 | /* Doxy pretty-printing styles. Used with prettify.js. */ 2 | 3 | pre .str, code .str { color: #fec243; } /* string - eggyolk gold */ 4 | pre .kwd, code .kwd { color: #8470FF; } /* keyword - light slate blue */ 5 | pre .com, code .com { color: #32cd32; font-style: italic; } /* comment - green */ 6 | pre .typ, code .typ { color: #6ecbcc; } /* type - turq green */ 7 | pre .lit, code .lit { color: #d06; } /* literal - cherry red */ 8 | pre .pun, code .pun { color: #8B8970; } /* punctuation - lemon chiffon4 */ 9 | pre .pln, code .pln { color: #f0f0f0; } /* plaintext - white */ 10 | pre .tag, code .tag { color: #9c9cff; } /* html/xml tag (bluey) */ 11 | pre .htm, code .htm { color: #dda0dd; } /* html tag light purply*/ 12 | pre .xsl, code .xsl { color: #d0a0d0; } /* xslt tag light purply*/ 13 | pre .atn, code .atn { color: #46eeee; font-weight: normal;} /* html/xml attribute name - lt turquoise */ 14 | pre .atv, code .atv { color: #EEB4B4; } /* html/xml attribute value - rosy brown2 */ 15 | pre .dec, code .dec { color: #3387CC; } /* decimal - blue */ 16 | 17 | a { 18 | text-decoration: none; 19 | } 20 | pre.prettyprint, code.prettyprint { 21 | font-family:'Droid Sans Mono','CPMono_v07 Bold','Droid Sans'; 22 | font-weight: bold; 23 | font-size: 9pt; 24 | background-color: #0f0f0f; 25 | -moz-border-radius: 8px; 26 | -webkit-border-radius: 8px; 27 | -o-border-radius: 8px; 28 | -ms-border-radius: 8px; 29 | -khtml-border-radius: 8px; 30 | border-radius: 8px; 31 | } /* background is black (well, just a tad less dark ) */ 32 | 33 | pre.prettyprint { 34 | width: 95%; 35 | margin: 1em auto; 36 | padding: 1em; 37 | white-space: pre-wrap; 38 | } 39 | 40 | pre.prettyprint a, code.prettyprint a { 41 | text-decoration:none; 42 | } 43 | /* Specify class=linenums on a pre to get line numbering; line numbers themselves are the same color as punctuation */ 44 | ol.linenums { margin-top: 0; margin-bottom: 0; color: #8B8970; } /* IE indents via margin-left */ 45 | li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8 { list-style-type: none } 46 | /* Alternate shading for lines */ 47 | li.L1,li.L3,li.L5,li.L7,li.L9 { } 48 | 49 | /* print is mostly unchanged from default at present */ 50 | @media print { 51 | pre.prettyprint, code.prettyprint { background-color: #fff; } 52 | pre .str, code .str { color: #088; } 53 | pre .kwd, code .kwd { color: #006; font-weight: bold; } 54 | pre .com, code .com { color: #0c3; font-style: italic; } 55 | pre .typ, code .typ { color: #404; font-weight: bold; } 56 | pre .lit, code .lit { color: #044; } 57 | pre .pun, code .pun { color: #440; } 58 | pre .pln, code .pln { color: #000; } 59 | pre .tag, code .tag { color: #b66ff7; font-weight: bold; } 60 | pre .htm, code .htm { color: #606; font-weight: bold; } 61 | pre .xsl, code .xsl { color: #606; font-weight: bold; } 62 | pre .atn, code .atn { color: #c71585; font-weight: normal; } 63 | pre .atv, code .atv { color: #088; font-weight: normal; } 64 | } 65 | -------------------------------------------------------------------------------- /js-modules/extractSourceSpans.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Split markup into a string of source code and an array mapping ranges in 3 | * that string to the text nodes in which they appear. 4 | * 5 | *

6 | * The HTML DOM structure:

7 | *
 8 |  * (Element   "p"
 9 |  *   (Element "b"
10 |  *     (Text  "print "))       ; #1
11 |  *   (Text    "'Hello '")      ; #2
12 |  *   (Element "br")            ; #3
13 |  *   (Text    "  + 'World';")) ; #4
14 |  * 
15 | *

16 | * corresponds to the HTML 17 | * {@code

print 'Hello '
+ 'World';

}.

18 | * 19 | *

20 | * It will produce the output:

21 | *
22 |  * {
23 |  *   sourceCode: "print 'Hello '\n  + 'World';",
24 |  *   //                     1          2
25 |  *   //           012345678901234 5678901234567
26 |  *   spans: [0, #1, 6, #2, 14, #3, 15, #4]
27 |  * }
28 |  * 
29 | *

30 | * where #1 is a reference to the {@code "print "} text node above, and so 31 | * on for the other text nodes. 32 | *

33 | * 34 | *

35 | * The {@code} spans array is an array of pairs. Even elements are the start 36 | * indices of substrings, and odd elements are the text nodes (or BR elements) 37 | * that contain the text for those substrings. 38 | * Substrings continue until the next index or the end of the source. 39 | *

40 | * 41 | * @param {Node} node an HTML DOM subtree containing source-code. 42 | * @param {boolean|number} isPreformatted truthy if white-space in 43 | * text nodes should be considered significant. 44 | * @return {SourceSpansT} source code and the nodes in which they occur. 45 | */ 46 | function extractSourceSpans(node, isPreformatted) { 47 | var nocode = /(?:^|\s)nocode(?:\s|$)/; 48 | 49 | var chunks = []; 50 | var length = 0; 51 | var spans = []; 52 | var k = 0; 53 | 54 | function walk(node) { 55 | var type = node.nodeType; 56 | if (type == 1) { // Element 57 | if (nocode.test(node.className)) { return; } 58 | for (var child = node.firstChild; child; child = child.nextSibling) { 59 | walk(child); 60 | } 61 | var nodeName = node.nodeName.toLowerCase(); 62 | if ('br' === nodeName || 'li' === nodeName) { 63 | chunks[k] = '\n'; 64 | spans[k << 1] = length++; 65 | spans[(k++ << 1) | 1] = node; 66 | } 67 | } else if (type == 3 || type == 4) { // Text 68 | var text = node.nodeValue; 69 | if (text.length) { 70 | if (!isPreformatted) { 71 | text = text.replace(/[ \t\r\n]+/g, ' '); 72 | } else { 73 | text = text.replace(/\r\n?/g, '\n'); // Normalize newlines. 74 | } 75 | // TODO: handle tabs here? 76 | chunks[k] = text; 77 | spans[k << 1] = length; 78 | length += text.length; 79 | spans[(k++ << 1) | 1] = node; 80 | } 81 | } 82 | } 83 | 84 | walk(node); 85 | 86 | return { 87 | sourceCode: chunks.join('').replace(/\n$/, ''), 88 | spans: spans 89 | }; 90 | } 91 | -------------------------------------------------------------------------------- /js-modules/regexpPrecederPatterns.pl: -------------------------------------------------------------------------------- 1 | use strict; 2 | 3 | print " 4 | // Regex pattern below is automatically generated by regexpPrecederPatterns.pl 5 | // Do not modify, your changes will be erased. 6 | 7 | // CAVEAT: this does not properly handle the case where a regular 8 | // expression immediately follows another since a regular expression may 9 | // have flags for case-sensitivity and the like. Having regexp tokens 10 | // adjacent is not valid in any language I'm aware of, so I'm punting. 11 | // TODO: maybe style special characters inside a regexp as punctuation. 12 | 13 | /** 14 | * A set of tokens that can precede a regular expression literal in 15 | * javascript 16 | * http://web.archive.org/web/20070717142515/http://www.mozilla.org/js/language/js20/rationale/syntax.html 17 | * has the full list, but I've removed ones that might be problematic when 18 | * seen in languages that don't support regular expression literals. 19 | * 20 | * Specifically, I've removed any keywords that can't precede a regexp 21 | * literal in a syntactically legal javascript program, and I've removed the 22 | * \"in\" keyword since it's not a keyword in many languages, and might be used 23 | * as a count of inches. 24 | * 25 | * The link above does not accurately describe EcmaScript rules since 26 | * it fails to distinguish between (a=++/b/i) and (a++/b/i) but it works 27 | * very well in practice. 28 | * 29 | * \@private 30 | * \@const 31 | */ 32 | var REGEXP_PRECEDER_PATTERN = "; 33 | 34 | my @preceders = ( 35 | "[!=]=?=?", # "!", "!=", "!==", "=", "==", "===", 36 | "\\#", 37 | "%=?", # "%", "%=", 38 | "&&?=?", # "&", "&&", "&&=", "&=", 39 | "\\(", 40 | "\\*=?", # "*", "*=", 41 | "[+\\-]=", # +=, -=. + and - handled below. 42 | "->", 43 | "\\/=?", # "/", "/=", 44 | "::?", # ":", "::", 45 | "<>?>?=?", # ">", ">=", ">>", ">>=", ">>>", ">>>=", 47 | ",", 48 | ";", # ";" 49 | "\\?", 50 | "@", 51 | "\\[", 52 | "~", # handles =~ and !~ 53 | "{", 54 | "\\^\\^?=?", # "^", "^=", "^^", "^^=", 55 | "\\|\\|?=?", # "|", "|=", "||", "||=", 56 | "break", "case", "continue", "delete", 57 | "do", "else", "finally", "instanceof", 58 | "return", "throw", "try", "typeof" 59 | ); 60 | # match at beginning, a dot that is not part of a number, or sign. 61 | my $pattern = "'(?:^^\\\\.?|[+-]"; 62 | foreach my $preceder (@preceders) { 63 | $preceder =~ s/\\/\\\\/g; 64 | $pattern .= "|$preceder"; 65 | } 66 | $pattern .= ")\\\\s*'"; # matches at end, and matches empty string 67 | 68 | print "$pattern;\n"; 69 | -------------------------------------------------------------------------------- /src/lang-vhdl.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @license 3 | * Copyright (C) 2010 benoit@ryder.fr 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | /** 19 | * @fileoverview 20 | * Registers a language handler for VHDL '93. 21 | * 22 | * Based on the lexical grammar and keywords at 23 | * http://www.iis.ee.ethz.ch/~zimmi/download/vhdl93_syntax.html 24 | * 25 | * @author benoit@ryder.fr 26 | */ 27 | 28 | PR['registerLangHandler']( 29 | PR['createSimpleLexer']( 30 | [ 31 | // Whitespace 32 | [PR['PR_PLAIN'], /^[\t\n\r \xA0]+/, null, '\t\n\r \xA0'] 33 | ], 34 | [ 35 | // String, character or bit string 36 | [PR['PR_STRING'], /^(?:[BOX]?"(?:[^\"]|"")*"|'.')/i], 37 | // Comment, from two dashes until end of line. 38 | [PR['PR_COMMENT'], /^--[^\r\n]*/], 39 | [PR['PR_KEYWORD'], /^(?:abs|access|after|alias|all|and|architecture|array|assert|attribute|begin|block|body|buffer|bus|case|component|configuration|constant|disconnect|downto|else|elsif|end|entity|exit|file|for|function|generate|generic|group|guarded|if|impure|in|inertial|inout|is|label|library|linkage|literal|loop|map|mod|nand|new|next|nor|not|null|of|on|open|or|others|out|package|port|postponed|procedure|process|pure|range|record|register|reject|rem|report|return|rol|ror|select|severity|shared|signal|sla|sll|sra|srl|subtype|then|to|transport|type|unaffected|units|until|use|variable|wait|when|while|with|xnor|xor)(?=[^\w-]|$)/i, null], 40 | // Type, predefined or standard 41 | [PR['PR_TYPE'], /^(?:bit|bit_vector|character|boolean|integer|real|time|string|severity_level|positive|natural|signed|unsigned|line|text|std_u?logic(?:_vector)?)(?=[^\w-]|$)/i, null], 42 | // Predefined attributes 43 | [PR['PR_TYPE'], /^\'(?:ACTIVE|ASCENDING|BASE|DELAYED|DRIVING|DRIVING_VALUE|EVENT|HIGH|IMAGE|INSTANCE_NAME|LAST_ACTIVE|LAST_EVENT|LAST_VALUE|LEFT|LEFTOF|LENGTH|LOW|PATH_NAME|POS|PRED|QUIET|RANGE|REVERSE_RANGE|RIGHT|RIGHTOF|SIMPLE_NAME|STABLE|SUCC|TRANSACTION|VAL|VALUE)(?=[^\w-]|$)/i, null], 44 | // Number, decimal or based literal 45 | [PR['PR_LITERAL'], /^\d+(?:_\d+)*(?:#[\w\\.]+#(?:[+\-]?\d+(?:_\d+)*)?|(?:\.\d+(?:_\d+)*)?(?:E[+\-]?\d+(?:_\d+)*)?)/i], 46 | // Identifier, basic or extended 47 | [PR['PR_PLAIN'], /^(?:[a-z]\w*|\\[^\\]*\\)/i], 48 | // Punctuation 49 | [PR['PR_PUNCTUATION'], /^[^\w\t\n\r \xA0\"\'][^\w\t\n\r \xA0\-\"\']*/] 50 | ]), 51 | ['vhdl', 'vhd']); 52 | -------------------------------------------------------------------------------- /src/lang-clj.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @license Copyright (C) 2011 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * @fileoverview 19 | * Registers a language handler for Clojure. 20 | * 21 | * 22 | * To use, include prettify.js and this file in your HTML page. 23 | * Then put your code in an HTML tag like 24 | *
(my lisp code)
25 | * The lang-cl class identifies the language as common lisp. 26 | * This file supports the following language extensions: 27 | * lang-clj - Clojure 28 | * 29 | * 30 | * I used lang-lisp.js as the basis for this adding the clojure specific 31 | * keywords and syntax. 32 | * 33 | * "Name" = 'Clojure' 34 | * "Author" = 'Rich Hickey' 35 | * "Version" = '1.2' 36 | * "About" = 'Clojure is a lisp for the jvm with concurrency primitives and a richer set of types.' 37 | * 38 | * 39 | * I used Clojure.org Reference as 40 | * the basis for the reserved word list. 41 | * 42 | * 43 | * @author jwall@google.com 44 | */ 45 | 46 | PR['registerLangHandler']( 47 | PR['createSimpleLexer']( 48 | [ 49 | // clojure has more paren types than minimal lisp. 50 | ['opn', /^[\(\{\[]+/, null, '([{'], 51 | ['clo', /^[\)\}\]]+/, null, ')]}'], 52 | // A line comment that starts with ; 53 | [PR['PR_COMMENT'], /^;[^\r\n]*/, null, ';'], 54 | // Whitespace 55 | [PR['PR_PLAIN'], /^[\t\n\r \xA0]+/, null, '\t\n\r \xA0'], 56 | // A double quoted, possibly multi-line, string. 57 | [PR['PR_STRING'], /^\"(?:[^\"\\]|\\[\s\S])*(?:\"|$)/, null, '"'] 58 | ], 59 | [ 60 | // clojure has a much larger set of keywords 61 | [PR['PR_KEYWORD'], /^(?:def|if|do|let|quote|var|fn|loop|recur|throw|try|monitor-enter|monitor-exit|defmacro|defn|defn-|macroexpand|macroexpand-1|for|doseq|dosync|dotimes|and|or|when|not|assert|doto|proxy|defstruct|first|rest|cons|defprotocol|deftype|defrecord|reify|defmulti|defmethod|meta|with-meta|ns|in-ns|create-ns|import|intern|refer|alias|namespace|resolve|ref|deref|refset|new|set!|memfn|to-array|into-array|aset|gen-class|reduce|map|filter|find|nil?|empty?|hash-map|hash-set|vec|vector|seq|flatten|reverse|assoc|dissoc|list|list?|disj|get|union|difference|intersection|extend|extend-type|extend-protocol|prn)\b/, null], 62 | [PR['PR_TYPE'], /^:[0-9a-zA-Z\-]+/] 63 | ]), 64 | ['clj']); 65 | -------------------------------------------------------------------------------- /src/lang-ml.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @license 3 | * Copyright (C) 2008 Google Inc. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | /** 19 | * @fileoverview 20 | * Registers a language handler for OCaml, SML, F# and similar languages. 21 | * 22 | * Based on the lexical grammar at 23 | * http://research.microsoft.com/en-us/um/cambridge/projects/fsharp/manual/spec.html#_Toc270597388 24 | * 25 | * @author mikesamuel@gmail.com 26 | */ 27 | 28 | PR['registerLangHandler']( 29 | PR['createSimpleLexer']( 30 | [ 31 | // Whitespace is made up of spaces, tabs and newline characters. 32 | [PR['PR_PLAIN'], /^[\t\n\r \xA0]+/, null, '\t\n\r \xA0'], 33 | // #if ident/#else/#endif directives delimit conditional compilation 34 | // sections 35 | [PR['PR_COMMENT'], 36 | /^#(?:if[\t\n\r \xA0]+(?:[a-z_$][\w\']*|``[^\r\n\t`]*(?:``|$))|else|endif|light)/i, 37 | null, '#'], 38 | // A double or single quoted, possibly multi-line, string. 39 | // F# allows escaped newlines in strings. 40 | [PR['PR_STRING'], /^(?:\"(?:[^\"\\]|\\[\s\S])*(?:\"|$)|\'(?:[^\'\\]|\\[\s\S])(?:\'|$))/, null, '"\''] 41 | ], 42 | [ 43 | // Block comments are delimited by (* and *) and may be 44 | // nested. Single-line comments begin with // and extend to 45 | // the end of a line. 46 | // TODO: (*...*) comments can be nested. This does not handle that. 47 | [PR['PR_COMMENT'], /^(?:\/\/[^\r\n]*|\(\*[\s\S]*?\*\))/], 48 | [PR['PR_KEYWORD'], /^(?:abstract|and|as|assert|begin|class|default|delegate|do|done|downcast|downto|elif|else|end|exception|extern|false|finally|for|fun|function|if|in|inherit|inline|interface|internal|lazy|let|match|member|module|mutable|namespace|new|null|of|open|or|override|private|public|rec|return|static|struct|then|to|true|try|type|upcast|use|val|void|when|while|with|yield|asr|land|lor|lsl|lsr|lxor|mod|sig|atomic|break|checked|component|const|constraint|constructor|continue|eager|event|external|fixed|functor|global|include|method|mixin|object|parallel|process|protected|pure|sealed|trait|virtual|volatile)\b/], 49 | // A number is a hex integer literal, a decimal real literal, or in 50 | // scientific notation. 51 | [PR['PR_LITERAL'], 52 | /^[+\-]?(?:0x[\da-f]+|(?:(?:\.\d+|\d+(?:\.\d*)?)(?:e[+\-]?\d+)?))/i], 53 | [PR['PR_PLAIN'], /^(?:[a-z_][\w']*[!?#]?|``[^\r\n\t`]*(?:``|$))/i], 54 | // A printable non-space non-special character 55 | [PR['PR_PUNCTUATION'], /^[^\t\n\r \xA0\"\'\w]+/] 56 | ]), 57 | ['fs', 'ml']); 58 | -------------------------------------------------------------------------------- /styles/demo.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Demo 5 | 6 | 7 | 12 | 78 | 79 | 80 | 81 | 82 |
83 |
 84 | <!doctype html>
 85 | <html>
 86 | <head>
 87 | <title>HTML Test</title>
 88 | <script type="text/javascript">
 89 | // Say hello world until the user starts questioning
 90 | // the meaningfulness of their existence.
 91 | function helloWorld(world) {
 92 |   for (var i = 42; --i >= 0;) {
 93 |     alert('Hello ' + String(world));
 94 |   }
 95 | }
 96 | </script>
 97 | <style type="text/css">
 98 | p { color: pink }
 99 | b { color: blue }
100 | u { color: "umber" }
101 | </style>
102 | </head>
103 | <body>
104 | <h1>Hello world!</h1>
105 | </body>
106 | </html>
107 | 
108 |
109 | 110 | 111 | 112 | -------------------------------------------------------------------------------- /src/lang-n.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @license 3 | * Copyright (C) 2011 Zimin A.V. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | /** 19 | * @fileoverview 20 | * Registers a language handler for the Nemerle language. 21 | * http://nemerle.org 22 | * @author Zimin A.V. 23 | */ 24 | (function () { 25 | // http://nemerle.org/wiki/index.php?title=Base_keywords 26 | var keywords = 'abstract|and|as|base|catch|class|def|delegate|enum|event|extern|false|finally|' 27 | + 'fun|implements|interface|internal|is|macro|match|matches|module|mutable|namespace|new|' 28 | + 'null|out|override|params|partial|private|protected|public|ref|sealed|static|struct|' 29 | + 'syntax|this|throw|true|try|type|typeof|using|variant|virtual|volatile|when|where|with|' 30 | + 'assert|assert2|async|break|checked|continue|do|else|ensures|for|foreach|if|late|lock|new|nolate|' 31 | + 'otherwise|regexp|repeat|requires|return|surroundwith|unchecked|unless|using|while|yield'; 32 | 33 | PR['registerLangHandler'](PR['createSimpleLexer']( 34 | // shortcutStylePatterns 35 | [ 36 | [PR['PR_STRING'], /^(?:\'(?:[^\\\'\r\n]|\\.)*\'|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/, null, '"'], 37 | [PR['PR_COMMENT'], /^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\r\n]*)/, null, '#'], 38 | [PR['PR_PLAIN'], /^\s+/, null, ' \r\n\t\xA0'] 39 | ], 40 | // fallthroughStylePatterns 41 | [ 42 | [PR['PR_STRING'], /^@\"(?:[^\"]|\"\")*(?:\"|$)/, null], 43 | [PR['PR_STRING'], /^<#(?:[^#>])*(?:#>|$)/, null], 44 | [PR['PR_STRING'], /^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/, null], 45 | [PR['PR_COMMENT'], /^\/\/[^\r\n]*/, null], 46 | [PR['PR_COMMENT'], /^\/\*[\s\S]*?(?:\*\/|$)/, null], 47 | [PR['PR_KEYWORD'], new RegExp('^(?:' + keywords + ')\\b'), null], 48 | [PR['PR_TYPE'], /^(?:array|bool|byte|char|decimal|double|float|int|list|long|object|sbyte|short|string|ulong|uint|ufloat|ulong|ushort|void)\b/, null], 49 | [PR['PR_LITERAL'], /^@[a-z_$][a-z_$@0-9]*/i, null], 50 | [PR['PR_TYPE'], /^@[A-Z]+[a-z][A-Za-z_$@0-9]*/, null], 51 | [PR['PR_PLAIN'], /^'?[A-Za-z_$][a-z_$@0-9]*/i, null], 52 | [PR['PR_LITERAL'], new RegExp( 53 | '^(?:' 54 | // A hex number 55 | + '0x[a-f0-9]+' 56 | // or an octal or decimal number, 57 | + '|(?:\\d(?:_\\d+)*\\d*(?:\\.\\d*)?|\\.\\d\\+)' 58 | // possibly in scientific notation 59 | + '(?:e[+\\-]?\\d+)?' 60 | + ')' 61 | // with an optional modifier like UL for unsigned long 62 | + '[a-z]*', 'i'), null, '0123456789'], 63 | 64 | [PR['PR_PUNCTUATION'], /^.[^\s\w\.$@\'\"\`\/\#]*/, null] 65 | ]), 66 | ['n', 'nemerle']); 67 | })(); 68 | -------------------------------------------------------------------------------- /src/lang-dart.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @license 3 | * Copyright (C) 2013 Google Inc. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | /** 19 | * @fileoverview 20 | * Registers a language handler Dart. 21 | * Loosely structured based on the DartLexer in Pygments: http://pygments.org/. 22 | * 23 | * To use, include prettify.js and this file in your HTML page. 24 | * Then put your code in an HTML tag like 25 | *
(Dart code)
26 | * 27 | * @author armstrong.timothy@gmail.com 28 | */ 29 | 30 | PR['registerLangHandler']( 31 | PR['createSimpleLexer']( 32 | [ 33 | // Whitespace. 34 | [PR['PR_PLAIN'], /^[\t\n\r \xA0]+/, null, '\t\n\r \xA0'] 35 | ], 36 | [ 37 | // Script tag. 38 | [PR['PR_COMMENT'], /^#!(?:.*)/], 39 | 40 | // `import`, `library`, `part of`, `part`, `as`, `show`, and `hide` 41 | // keywords. 42 | [PR['PR_KEYWORD'], /^\b(?:import|library|part of|part|as|show|hide)\b/i], 43 | 44 | // Single-line comments. 45 | [PR['PR_COMMENT'], /^\/\/(?:.*)/], 46 | 47 | // Multiline comments. 48 | [PR['PR_COMMENT'], /^\/\*[^*]*\*+(?:[^\/*][^*]*\*+)*\//], // */ 49 | 50 | // `class` and `interface` keywords. 51 | [PR['PR_KEYWORD'], /^\b(?:class|interface)\b/i], 52 | 53 | // General keywords. 54 | [PR['PR_KEYWORD'], /^\b(?:assert|async|await|break|case|catch|continue|default|do|else|finally|for|if|in|is|new|return|super|switch|sync|this|throw|try|while)\b/i], 55 | 56 | // Declaration keywords. 57 | [PR['PR_KEYWORD'], /^\b(?:abstract|const|extends|factory|final|get|implements|native|operator|set|static|typedef|var)\b/i], 58 | 59 | // Keywords for types. 60 | [PR['PR_TYPE'], /^\b(?:bool|double|Dynamic|int|num|Object|String|void)\b/i], 61 | 62 | // Keywords for constants. 63 | [PR['PR_KEYWORD'], /^\b(?:false|null|true)\b/i], 64 | 65 | // Multiline strings, single- and double-quoted. 66 | [PR['PR_STRING'], /^r?[\']{3}[\s|\S]*?[^\\][\']{3}/], 67 | [PR['PR_STRING'], /^r?[\"]{3}[\s|\S]*?[^\\][\"]{3}/], 68 | 69 | // Normal and raw strings, single- and double-quoted. 70 | [PR['PR_STRING'], /^r?\'(\'|(?:[^\n\r\f])*?[^\\]\')/], 71 | [PR['PR_STRING'], /^r?\"(\"|(?:[^\n\r\f])*?[^\\]\")/], 72 | 73 | // Types are capitalized by convention. 74 | [PR['PR_TYPE'], /^[A-Z]\w*/], 75 | 76 | // Identifiers. 77 | [PR['PR_PLAIN'], /^[a-z_$][a-z0-9_]*/i], 78 | 79 | // Operators. 80 | [PR['PR_PUNCTUATION'], /^[~!%^&*+=|?:<>/-]/], 81 | 82 | // Hex numbers. 83 | [PR['PR_LITERAL'], /^\b0x[0-9a-f]+/i], 84 | 85 | // Decimal numbers. 86 | [PR['PR_LITERAL'], /^\b\d+(?:\.\d*)?(?:e[+-]?\d+)?/i], 87 | [PR['PR_LITERAL'], /^\b\.\d+(?:e[+-]?\d+)?/i], 88 | 89 | // Punctuation. 90 | [PR['PR_PUNCTUATION'], /^[(){}\[\],.;]/] 91 | ]), 92 | ['dart']); 93 | -------------------------------------------------------------------------------- /src/lang-sql.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @license 3 | * Copyright (C) 2008 Google Inc. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | /** 19 | * @fileoverview 20 | * Registers a language handler for SQL. 21 | * 22 | * 23 | * To use, include prettify.js and this file in your HTML page. 24 | * Then put your code in an HTML tag like 25 | *
(my SQL code)
26 | * 27 | * 28 | * http://savage.net.au/SQL/sql-99.bnf.html is the basis for the grammar, and 29 | * http://msdn.microsoft.com/en-us/library/aa238507(SQL.80).aspx and 30 | * http://meta.stackoverflow.com/q/92352/137403 as the bases for the keyword 31 | * list. 32 | * 33 | * @author mikesamuel@gmail.com 34 | */ 35 | 36 | PR['registerLangHandler']( 37 | PR['createSimpleLexer']( 38 | [ 39 | // Whitespace 40 | [PR['PR_PLAIN'], /^[\t\n\r \xA0]+/, null, '\t\n\r \xA0'], 41 | // A double or single quoted, possibly multi-line, string. 42 | [PR['PR_STRING'], /^(?:"(?:[^\"\\]|\\.)*"|'(?:[^\'\\]|\\.)*')/, null, 43 | '"\''] 44 | ], 45 | [ 46 | // A comment is either a line comment that starts with two dashes, or 47 | // two dashes preceding a long bracketed block. 48 | [PR['PR_COMMENT'], /^(?:--[^\r\n]*|\/\*[\s\S]*?(?:\*\/|$))/], 49 | [PR['PR_KEYWORD'], /^(?:ADD|ALL|ALTER|AND|ANY|APPLY|AS|ASC|AUTHORIZATION|BACKUP|BEGIN|BETWEEN|BREAK|BROWSE|BULK|BY|CASCADE|CASE|CHECK|CHECKPOINT|CLOSE|CLUSTERED|COALESCE|COLLATE|COLUMN|COMMIT|COMPUTE|CONNECT|CONSTRAINT|CONTAINS|CONTAINSTABLE|CONTINUE|CONVERT|CREATE|CROSS|CURRENT|CURRENT_DATE|CURRENT_TIME|CURRENT_TIMESTAMP|CURRENT_USER|CURSOR|DATABASE|DBCC|DEALLOCATE|DECLARE|DEFAULT|DELETE|DENY|DESC|DISK|DISTINCT|DISTRIBUTED|DOUBLE|DROP|DUMMY|DUMP|ELSE|END|ERRLVL|ESCAPE|EXCEPT|EXEC|EXECUTE|EXISTS|EXIT|FETCH|FILE|FILLFACTOR|FOLLOWING|FOR|FOREIGN|FREETEXT|FREETEXTTABLE|FROM|FULL|FUNCTION|GOTO|GRANT|GROUP|HAVING|HOLDLOCK|IDENTITY|IDENTITYCOL|IDENTITY_INSERT|IF|IN|INDEX|INNER|INSERT|INTERSECT|INTO|IS|JOIN|KEY|KILL|LEFT|LIKE|LINENO|LOAD|MATCH|MATCHED|MERGE|NATURAL|NATIONAL|NOCHECK|NONCLUSTERED|NOCYCLE|NOT|NULL|NULLIF|OF|OFF|OFFSETS|ON|OPEN|OPENDATASOURCE|OPENQUERY|OPENROWSET|OPENXML|OPTION|OR|ORDER|OUTER|OVER|PARTITION|PERCENT|PIVOT|PLAN|PRECEDING|PRECISION|PRIMARY|PRINT|PROC|PROCEDURE|PUBLIC|RAISERROR|READ|READTEXT|RECONFIGURE|REFERENCES|REPLICATION|RESTORE|RESTRICT|RETURN|REVOKE|RIGHT|ROLLBACK|ROWCOUNT|ROWGUIDCOL|ROWS?|RULE|SAVE|SCHEMA|SELECT|SESSION_USER|SET|SETUSER|SHUTDOWN|SOME|START|STATISTICS|SYSTEM_USER|TABLE|TEXTSIZE|THEN|TO|TOP|TRAN|TRANSACTION|TRIGGER|TRUNCATE|TSEQUAL|UNBOUNDED|UNION|UNIQUE|UNPIVOT|UPDATE|UPDATETEXT|USE|USER|USING|VALUES|VARYING|VIEW|WAITFOR|WHEN|WHERE|WHILE|WITH|WITHIN|WRITETEXT|XML)(?=[^\w-]|$)/i, null], 50 | // A number is a hex integer literal, a decimal real literal, or in 51 | // scientific notation. 52 | [PR['PR_LITERAL'], 53 | /^[+-]?(?:0x[\da-f]+|(?:(?:\.\d+|\d+(?:\.\d*)?)(?:e[+\-]?\d+)?))/i], 54 | // An identifier 55 | [PR['PR_PLAIN'], /^[a-z_][\w-]*/i], 56 | // A run of punctuation 57 | [PR['PR_PUNCTUATION'], /^[^\w\t\n\r \xA0\"\'][^\w\t\n\r \xA0+\-\"\']*/] 58 | ]), 59 | ['sql']); 60 | -------------------------------------------------------------------------------- /src/lang-swift.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @license 3 | * Copyright (C) 2015 Google Inc. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | /** 19 | * @fileoverview 20 | * Registers a language handler for Swift 21 | * 22 | * 23 | * To use, include prettify.js and this file in your HTML page. 24 | * Then put your code in an HTML tag like 25 | *
(my swift code)
26 | * This file supports the following language extensions: 27 | * lang-swift - Swift 28 | * 29 | * I used https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/AboutTheLanguageReference.html 30 | * as the source of truth for this. The revision from 2015-10-21 (Swift 2.1) was used in most recent update. 31 | * 32 | * @author cerech@google.com 33 | */ 34 | 35 | PR['registerLangHandler']( 36 | PR['createSimpleLexer']( 37 | [ 38 | //whitespace 39 | [PR['PR_PLAIN'], /^[ \n\r\t\v\f\0]+/, null, ' \n\r\t\v\f\0'], 40 | //string literals 41 | [PR['PR_STRING'], /^"(?:[^"\\]|(?:\\.)|(?:\\\((?:[^"\\)]|\\.)*\)))*"/, null, '"'] 42 | ], 43 | [ 44 | //floating point literals 45 | [PR['PR_LITERAL'], /^(?:(?:0x[\da-fA-F][\da-fA-F_]*\.[\da-fA-F][\da-fA-F_]*[pP]?)|(?:\d[\d_]*\.\d[\d_]*[eE]?))[+-]?\d[\d_]*/, null], 46 | //integer literals 47 | [PR['PR_LITERAL'], /^-?(?:(?:0(?:(?:b[01][01_]*)|(?:o[0-7][0-7_]*)|(?:x[\da-fA-F][\da-fA-F_]*)))|(?:\d[\d_]*))/, null], 48 | //some other literals 49 | [PR['PR_LITERAL'], /^(?:_|Any|true|false|nil)\b/, null], 50 | //keywords 51 | [PR['PR_KEYWORD'], /^\b(?:__COLUMN__|__FILE__|__FUNCTION__|__LINE__|#available|#colorLiteral|#column|#else|#elseif|#endif|#file|#fileLiteral|#function|#if|#imageLiteral|#line|#selector|#sourceLocation|arch|arm|arm64|associatedtype|associativity|as|break|case|catch|class|continue|convenience|default|defer|deinit|didSet|do|dynamic|dynamicType|else|enum|extension|fallthrough|fileprivate|final|for|func|get|guard|import|indirect|infix|init|inout|internal|i386|if|in|iOS|iOSApplicationExtension|is|lazy|left|let|mutating|none|nonmutating|open|operator|optional|OSX|OSXApplicationExtension|override|postfix|precedence|prefix|private|protocol|Protocol|public|repeat|required|rethrows|return|right|safe|Self|self|set|static|struct|subscript|super|switch|throw|throws|try|Type|typealias|unowned|unsafe|var|weak|watchOS|where|while|willSet|x86_64)\b/, null], 52 | //double slash comments 53 | [PR['PR_COMMENT'], /^\/\/.*?[\n\r]/, null], 54 | //slash star comments 55 | [PR['PR_COMMENT'], /^\/\*[\s\S]*?(?:\*\/|$)/, null], 56 | //punctuation 57 | [PR['PR_PUNCTUATION'], /^<<=|<=|<<|>>=|>=|>>|===|==|\.\.\.|&&=|\.\.<|!==|!=|&=|~=|~|\(|\)|\[|\]|{|}|@|#|;|\.|,|:|\|\|=|\?\?|\|\||&&|&\*|&\+|&-|&=|\+=|-=|\/=|\*=|\^=|%=|\|=|->|`|==|\+\+|--|\/|\+|!|\*|%|<|>|&|\||\^|\?|=|-|_/, null], 58 | [PR['PR_TYPE'], /^\b(?:[@_]?[A-Z]+[a-z][A-Za-z_$@0-9]*|\w+_t\b)/, null] //borrowing the type regex given by the main program for C-family languages 59 | ]), 60 | ['swift']); 61 | -------------------------------------------------------------------------------- /styles/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Prettify Themes Gallery 5 | 9 | 73 | 74 | 75 | 76 | 77 | 78 |

Gallery of themes for 79 | code prettify

80 |

81 | Click on a theme name for a link to the file in revision control. 82 | Print preview this page to see how the themes work on the printed page. 83 |

84 | 85 | 101 | 102 | 103 | 104 | -------------------------------------------------------------------------------- /tests/shims.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Shim for ES5 Date.now 3 | * for older browsers (IE < 9, FF < 3, etc.) 4 | * 5 | * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/now#Polyfill 6 | */ 7 | (function () { 8 | if (!Date.now) { 9 | Date.now = function now() { 10 | return new Date().getTime(); 11 | }; 12 | } 13 | })(); 14 | 15 | /** 16 | * Shim for HTML5 getElementsByClassName 17 | * for older browsers (IE < 9, FF < 3, etc.) 18 | */ 19 | (function () { 20 | if (!document.getElementsByClassName) { 21 | document.getElementsByClassName = function (className) { 22 | className = className.replace(/\s+/g, ' ').replace(/^\s*|\s*$/g, ' '); 23 | var results = []; 24 | function walk(node) { 25 | if (node.nodeType !== 1) { return; } 26 | // This test should be order-insensitive. 27 | if ((' ' + node.className + ' ').indexOf(className) >= 0) { 28 | results[results.length] = node; 29 | } 30 | for (var child = node.firstChild; child; child = child.nextSibling) { 31 | walk(child); 32 | } 33 | } 34 | walk(document.body); 35 | return results; 36 | }; 37 | } 38 | })(); 39 | 40 | /** 41 | * Shim for "fixing" IE's lack of support (IE < 9) for applying slice 42 | * on host objects like NamedNodeMap, NodeList, and HTMLCollection 43 | * (technically, since host objects have been implementation-dependent, 44 | * at least before ES2015, IE hasn't needed to work this way). 45 | * Also works on strings, fixes IE < 9 to allow an explicit undefined 46 | * for the 2nd argument (as in Firefox), and prevents errors when 47 | * called on other DOM objects. 48 | * 49 | * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice#Streamlining_cross-browser_behavior 50 | */ 51 | (function () { 52 | 'use strict'; 53 | var _slice = Array.prototype.slice; 54 | 55 | try { 56 | // Can't be used with DOM elements in IE < 9 57 | _slice.call(document.documentElement); 58 | } catch (e) { // Fails in IE < 9 59 | // This will work for genuine arrays, array-like objects, 60 | // NamedNodeMap (attributes, entities, notations), 61 | // NodeList (e.g., getElementsByTagName), HTMLCollection (e.g., childNodes), 62 | // and will not fail on other DOM objects (as do DOM elements in IE < 9) 63 | Array.prototype.slice = function(begin, end) { 64 | // IE < 9 gets unhappy with an undefined end argument 65 | end = (typeof end !== 'undefined') ? end : this.length; 66 | 67 | // For native Array objects, we use the native slice function 68 | if (Object.prototype.toString.call(this) === '[object Array]') { 69 | return _slice.call(this, begin, end); 70 | } 71 | 72 | // For array like object we handle it ourselves. 73 | var i, cloned = [], 74 | size, len = this.length; 75 | 76 | // Handle negative value for "begin" 77 | var start = begin || 0; 78 | start = (start >= 0) ? start : Math.max(0, len + start); 79 | 80 | // Handle negative value for "end" 81 | var upTo = (typeof end === 'number') ? Math.min(end, len) : len; 82 | if (end < 0) { 83 | upTo = len + end; 84 | } 85 | 86 | // Actual expected size of the slice 87 | size = upTo - start; 88 | 89 | if (size > 0) { 90 | cloned = new Array(size); 91 | if (this.charAt) { 92 | for (i = 0; i < size; i++) { 93 | cloned[i] = this.charAt(start + i); 94 | } 95 | } else { 96 | for (i = 0; i < size; i++) { 97 | cloned[i] = this[start + i]; 98 | } 99 | } 100 | } 101 | 102 | return cloned; 103 | }; 104 | } 105 | }()); 106 | -------------------------------------------------------------------------------- /src/lang-erlang.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @license 3 | * Copyright (C) 2013 Andrew Allen 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | /** 19 | * @fileoverview 20 | * Registers a language handler for Erlang. 21 | * 22 | * Derived from https://raw.github.com/erlang/otp/dev/lib/compiler/src/core_parse.yrl 23 | * Modified from Mike Samuel's Haskell plugin for google-code-prettify 24 | * 25 | * @author achew22@gmail.com 26 | */ 27 | 28 | PR['registerLangHandler']( 29 | PR['createSimpleLexer']( 30 | [ 31 | // Whitespace 32 | // whitechar -> newline | vertab | space | tab | uniWhite 33 | // newline -> return linefeed | return | linefeed | formfeed 34 | [PR['PR_PLAIN'], /^[\t\n\x0B\x0C\r ]+/, null, '\t\n\x0B\x0C\r '], 35 | // Single line double-quoted strings. 36 | [PR['PR_STRING'], /^\"(?:[^\"\\\n\x0C\r]|\\[\s\S])*(?:\"|$)/, 37 | null, '"'], 38 | 39 | // Handle atoms 40 | [PR['PR_LITERAL'], /^[a-z][a-zA-Z0-9_]*/], 41 | // Handle single quoted atoms 42 | [PR['PR_LITERAL'], /^\'(?:[^\'\\\n\x0C\r]|\\[^&])+\'?/, 43 | null, "'"], 44 | 45 | // Handle macros. Just to be extra clear on this one, it detects the ? 46 | // then uses the regexp to end it so be very careful about matching 47 | // all the terminal elements 48 | [PR['PR_LITERAL'], /^\?[^ \t\n({]+/, null, "?"], 49 | 50 | 51 | 52 | // decimal -> digit{digit} 53 | // octal -> octit{octit} 54 | // hexadecimal -> hexit{hexit} 55 | // integer -> decimal 56 | // | 0o octal | 0O octal 57 | // | 0x hexadecimal | 0X hexadecimal 58 | // float -> decimal . decimal [exponent] 59 | // | decimal exponent 60 | // exponent -> (e | E) [+ | -] decimal 61 | [PR['PR_LITERAL'], 62 | /^(?:0o[0-7]+|0x[\da-f]+|\d+(?:\.\d+)?(?:e[+\-]?\d+)?)/i, 63 | null, '0123456789'] 64 | ], 65 | [ 66 | // TODO: catch @declarations inside comments 67 | 68 | // Comments in erlang are started with % and go till a newline 69 | [PR['PR_COMMENT'], /^%[^\n]*/], 70 | 71 | // Catch macros 72 | //[PR['PR_TAG'], /?[^( \n)]+/], 73 | 74 | /** 75 | * %% Keywords (atoms are assumed to always be single-quoted). 76 | * 'module' 'attributes' 'do' 'let' 'in' 'letrec' 77 | * 'apply' 'call' 'primop' 78 | * 'case' 'of' 'end' 'when' 'fun' 'try' 'catch' 'receive' 'after' 79 | */ 80 | [PR['PR_KEYWORD'], /^(?:module|attributes|do|let|in|letrec|apply|call|primop|case|of|end|when|fun|try|catch|receive|after|char|integer|float,atom,string,var)\b/], 81 | 82 | /** 83 | * Catch definitions (usually defined at the top of the file) 84 | * Anything that starts -something 85 | */ 86 | [PR['PR_KEYWORD'], /^-[a-z_]+/], 87 | 88 | // Catch variables 89 | [PR['PR_TYPE'], /^[A-Z_][a-zA-Z0-9_]*/], 90 | 91 | // matches the symbol production 92 | [PR['PR_PUNCTUATION'], /^[.,;]/] 93 | ]), 94 | ['erlang', 'erl']); 95 | -------------------------------------------------------------------------------- /src/lang-lisp.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @license 3 | * Copyright (C) 2008 Google Inc. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | /** 19 | * @fileoverview 20 | * Registers a language handler for Common Lisp and related languages. 21 | * 22 | * 23 | * To use, include prettify.js and this file in your HTML page. 24 | * Then put your code in an HTML tag like 25 | *
(my lisp code)
26 | * The lang-cl class identifies the language as common lisp. 27 | * This file supports the following language extensions: 28 | * lang-cl - Common Lisp 29 | * lang-el - Emacs Lisp 30 | * lang-lisp - Lisp 31 | * lang-scm - Scheme 32 | * lang-lsp - FAT 8.3 filename version of lang-lisp. 33 | * 34 | * 35 | * I used http://www.devincook.com/goldparser/doc/meta-language/grammar-LISP.htm 36 | * as the basis, but added line comments that start with ; and changed the atom 37 | * production to disallow unquoted semicolons. 38 | * 39 | * "Name" = 'LISP' 40 | * "Author" = 'John McCarthy' 41 | * "Version" = 'Minimal' 42 | * "About" = 'LISP is an abstract language that organizes ALL' 43 | * | 'data around "lists".' 44 | * 45 | * "Start Symbol" = [s-Expression] 46 | * 47 | * {Atom Char} = {Printable} - {Whitespace} - [()"\''] 48 | * 49 | * Atom = ( {Atom Char} | '\'{Printable} )+ 50 | * 51 | * [s-Expression] ::= [Quote] Atom 52 | * | [Quote] '(' [Series] ')' 53 | * | [Quote] '(' [s-Expression] '.' [s-Expression] ')' 54 | * 55 | * [Series] ::= [s-Expression] [Series] 56 | * | 57 | * 58 | * [Quote] ::= '' !Quote = do not evaluate 59 | * | 60 | * 61 | * 62 | * I used Practical Common Lisp as 63 | * the basis for the reserved word list. 64 | * 65 | * 66 | * @author mikesamuel@gmail.com 67 | */ 68 | 69 | PR['registerLangHandler']( 70 | PR['createSimpleLexer']( 71 | [ 72 | ['opn', /^\(+/, null, '('], 73 | ['clo', /^\)+/, null, ')'], 74 | // A line comment that starts with ; 75 | [PR['PR_COMMENT'], /^;[^\r\n]*/, null, ';'], 76 | // Whitespace 77 | [PR['PR_PLAIN'], /^[\t\n\r \xA0]+/, null, '\t\n\r \xA0'], 78 | // A double quoted, possibly multi-line, string. 79 | [PR['PR_STRING'], /^\"(?:[^\"\\]|\\[\s\S])*(?:\"|$)/, null, '"'] 80 | ], 81 | [ 82 | [PR['PR_KEYWORD'], /^(?:block|c[ad]+r|catch|con[ds]|def(?:ine|un)|do|eq|eql|equal|equalp|eval-when|flet|format|go|if|labels|lambda|let|load-time-value|locally|macrolet|multiple-value-call|nil|progn|progv|quote|require|return-from|setq|symbol-macrolet|t|tagbody|the|throw|unwind)\b/, null], 83 | [PR['PR_LITERAL'], 84 | /^[+\-]?(?:[0#]x[0-9a-f]+|\d+\/\d+|(?:\.\d+|\d+(?:\.\d*)?)(?:[ed][+\-]?\d+)?)/i], 85 | // A single quote possibly followed by a word that optionally ends with 86 | // = ! or ?. 87 | [PR['PR_LITERAL'], 88 | /^\'(?:-*(?:\w|\\[\x21-\x7e])(?:[\w-]*|\\[\x21-\x7e])[=!?]?)?/], 89 | // A word that optionally ends with = ! or ?. 90 | [PR['PR_PLAIN'], 91 | /^-*(?:[a-z_]|\\[\x21-\x7e])(?:[\w-]*|\\[\x21-\x7e])[=!?]?/i], 92 | // A printable non-space non-special character 93 | [PR['PR_PUNCTUATION'], /^[^\w\t\n\r \xA0()\"\\\';]+/] 94 | ]), 95 | ['cl', 'el', 'lisp', 'lsp', 'scm', 'ss', 'rkt']); 96 | -------------------------------------------------------------------------------- /src/lang-rust.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @license 3 | * Copyright (C) 2015 Chris Morgan 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | /** 19 | * @fileoverview 20 | * Registers a language handler for Rust. 21 | * 22 | * Derived from prior experience implementing similar things in a few environments, 23 | * most especially rust.vim. 24 | * 25 | * @author me@chrismorgan.info 26 | */ 27 | 28 | PR['registerLangHandler']( 29 | PR['createSimpleLexer']([], [ 30 | // Whitespace 31 | [PR['PR_PLAIN'], /^[\t\n\r \xA0]+/], 32 | 33 | // Single line comments 34 | [PR['PR_COMMENT'], /^\/\/.*/], 35 | // Block comments (sadly I do not see how to make this cope with comment nesting as it should) 36 | [PR['PR_COMMENT'], /^\/\*[\s\S]*?(?:\*\/|$)/],//, null], 37 | // String and character literals 38 | [PR['PR_STRING'], /^b"(?:[^\\]|\\(?:.|x[\da-fA-F]{2}))*?"/], // Bytes literal 39 | [PR['PR_STRING'], /^"(?:[^\\]|\\(?:.|x[\da-fA-F]{2}|u\{\[\da-fA-F]{1,6}\}))*?"/], // String literal 40 | [PR['PR_STRING'], /^b?r(#*)\"[\s\S]*?\"\1/], // Raw string/bytes literal 41 | [PR['PR_STRING'], /^b'([^\\]|\\(.|x[\da-fA-F]{2}))'/], // Byte literal 42 | [PR['PR_STRING'], /^'([^\\]|\\(.|x[\da-fA-F]{2}|u\{[\da-fA-F]{1,6}\}))'/], // Character literal 43 | 44 | // Lifetime 45 | [PR['PR_TAG'], /^'\w+?\b/], 46 | 47 | // Keywords, reserved keywords and primitive types 48 | [PR['PR_KEYWORD'], /^(?:match|if|else|as|break|box|continue|extern|fn|for|in|if|impl|dyn|let|loop|pub|return|super|unsafe|where|while|use|mod|trait|struct|enum|type|move|mut|ref|static|const|crate)\b/], 49 | [PR['PR_KEYWORD'], /^(?:alignof|become|do|offsetof|priv|pure|sizeof|typeof|unsized|yield|async|await|try|abstract|virtual|final|override|macro)\b/], 50 | [PR['PR_TYPE'], /^(?:[iu](8|16|32|64|128|size)|char|bool|f32|f64|str|Self)\b/], 51 | 52 | // Rust 1.0 prelude items 53 | [PR['PR_TYPE'], /^(?:Copy|Send|Sized|Sync|Drop|Fn|FnMut|FnOnce|Box|ToOwned|Clone|PartialEq|PartialOrd|Eq|Ord|AsRef|AsMut|Into|From|Default|Iterator|Extend|IntoIterator|DoubleEndedIterator|ExactSizeIterator|Option|Some|None|Result|Ok|Err|SliceConcatExt|String|ToString|Vec)\b/], 54 | 55 | // Literals: 56 | [PR['PR_LITERAL'], /^(self|true|false|null)\b/], 57 | // A number is a hex integer literal, a decimal real literal, or in 58 | // scientific notation. 59 | // Integer literals: decimal, hexadecimal, octal, binary. 60 | [PR['PR_LITERAL'], /^\d[0-9_]*(?:[iu](?:size|8|16|32|64|128))?/], 61 | [PR['PR_LITERAL'], /^0x[a-fA-F0-9_]+(?:[iu](?:size|8|16|32|64|128))?/], 62 | [PR['PR_LITERAL'], /^0o[0-7_]+(?:[iu](?:size|8|16|32|64|128))?/], 63 | [PR['PR_LITERAL'], /^0b[01_]+(?:[iu](?:size|8|16|32|64|128))?/], 64 | // Float literals 65 | [PR['PR_LITERAL'], /^\d[0-9_]*\.(?![^\s\d.])/], 66 | [PR['PR_LITERAL'], /^\d[0-9_]*(?:\.\d[0-9_]*)(?:[eE][+-]?[0-9_]+)?(?:f32|f64)?/], 67 | [PR['PR_LITERAL'], /^\d[0-9_]*(?:\.\d[0-9_]*)?(?:[eE][+-]?[0-9_]+)(?:f32|f64)?/], 68 | [PR['PR_LITERAL'], /^\d[0-9_]*(?:\.\d[0-9_]*)?(?:[eE][+-]?[0-9_]+)?(?:f32|f64)/], 69 | 70 | // Macro invocations (an identifier plus a !) 71 | [PR['PR_ATTRIB_NAME'], /^[a-z_]\w*!/i], 72 | // An identifier (sorry, this should be unicode) 73 | [PR['PR_PLAIN'], /^[a-z_]\w*/i], 74 | // Attributes 75 | [PR['PR_ATTRIB_VALUE'], /^#!?\[[\s\S]*?\]/], 76 | // All the punctuation 77 | [PR['PR_PUNCTUATION'], /^[+\-/*=^&|!<>%[\](){}?:.,;]/], 78 | // Anything else (which is probably illegal, as all the legal stuff should have been covered) can be plain 79 | [PR['PR_PLAIN'], /./] 80 | ]), 81 | ['rust']); 82 | --------------------------------------------------------------------------------