├── Makefile ├── README.md ├── assets ├── drawing.svg └── stroke.svg ├── docs ├── google-code-prettify │ ├── lang-Splus.js │ ├── lang-aea.js │ ├── lang-agc.js │ ├── lang-apollo.js │ ├── lang-basic.js │ ├── lang-cbm.js │ ├── lang-cl.js │ ├── lang-clj.js │ ├── lang-css.js │ ├── lang-dart.js │ ├── lang-el.js │ ├── lang-erl.js │ ├── lang-erlang.js │ ├── lang-fs.js │ ├── lang-go.js │ ├── lang-hs.js │ ├── lang-lasso.js │ ├── lang-lassoscript.js │ ├── lang-latex.js │ ├── lang-lgt.js │ ├── lang-lisp.js │ ├── lang-ll.js │ ├── lang-llvm.js │ ├── lang-logtalk.js │ ├── lang-ls.js │ ├── lang-lsp.js │ ├── lang-lua.js │ ├── lang-matlab.js │ ├── lang-ml.js │ ├── lang-mumps.js │ ├── lang-n.js │ ├── lang-nemerle.js │ ├── lang-pascal.js │ ├── lang-proto.js │ ├── lang-r.js │ ├── lang-rd.js │ ├── lang-rkt.js │ ├── lang-rust.js │ ├── lang-s.js │ ├── lang-scala.js │ ├── lang-scm.js │ ├── lang-sql.js │ ├── lang-ss.js │ ├── lang-swift.js │ ├── lang-tcl.js │ ├── lang-tex.js │ ├── lang-vb.js │ ├── lang-vbs.js │ ├── lang-vhd.js │ ├── lang-vhdl.js │ ├── lang-wiki.js │ ├── lang-xq.js │ ├── lang-xquery.js │ ├── lang-yaml.js │ ├── lang-yml.js │ ├── prettify.css │ ├── prettify.js │ └── run_prettify.js ├── img │ ├── circle-drawing.gif │ ├── circle-fail.gif │ ├── function-3d-1.png │ ├── function-extrema.png │ ├── function-not-continuous.png │ ├── inverse-transform.png │ ├── ipad-notes.gif │ ├── line-drawing.gif │ ├── rect-drawing.gif │ ├── rect-model.png │ └── stroke.png ├── index.html ├── katex │ ├── README.md │ ├── contrib │ │ ├── auto-render.js │ │ ├── auto-render.min.js │ │ ├── auto-render.mjs │ │ ├── copy-tex.css │ │ ├── copy-tex.js │ │ ├── copy-tex.min.css │ │ ├── copy-tex.min.js │ │ ├── copy-tex.mjs │ │ ├── mathtex-script-type.js │ │ ├── mathtex-script-type.min.js │ │ ├── mathtex-script-type.mjs │ │ ├── mhchem.js │ │ ├── mhchem.min.js │ │ ├── mhchem.mjs │ │ ├── render-a11y-string.js │ │ ├── render-a11y-string.min.js │ │ └── render-a11y-string.mjs │ ├── fonts │ │ ├── KaTeX_AMS-Regular.ttf │ │ ├── KaTeX_AMS-Regular.woff │ │ ├── KaTeX_AMS-Regular.woff2 │ │ ├── KaTeX_Caligraphic-Bold.ttf │ │ ├── KaTeX_Caligraphic-Bold.woff │ │ ├── KaTeX_Caligraphic-Bold.woff2 │ │ ├── KaTeX_Caligraphic-Regular.ttf │ │ ├── KaTeX_Caligraphic-Regular.woff │ │ ├── KaTeX_Caligraphic-Regular.woff2 │ │ ├── KaTeX_Fraktur-Bold.ttf │ │ ├── KaTeX_Fraktur-Bold.woff │ │ ├── KaTeX_Fraktur-Bold.woff2 │ │ ├── KaTeX_Fraktur-Regular.ttf │ │ ├── KaTeX_Fraktur-Regular.woff │ │ ├── KaTeX_Fraktur-Regular.woff2 │ │ ├── KaTeX_Main-Bold.ttf │ │ ├── KaTeX_Main-Bold.woff │ │ ├── KaTeX_Main-Bold.woff2 │ │ ├── KaTeX_Main-BoldItalic.ttf │ │ ├── KaTeX_Main-BoldItalic.woff │ │ ├── KaTeX_Main-BoldItalic.woff2 │ │ ├── KaTeX_Main-Italic.ttf │ │ ├── KaTeX_Main-Italic.woff │ │ ├── KaTeX_Main-Italic.woff2 │ │ ├── KaTeX_Main-Regular.ttf │ │ ├── KaTeX_Main-Regular.woff │ │ ├── KaTeX_Main-Regular.woff2 │ │ ├── KaTeX_Math-BoldItalic.ttf │ │ ├── KaTeX_Math-BoldItalic.woff │ │ ├── KaTeX_Math-BoldItalic.woff2 │ │ ├── KaTeX_Math-Italic.ttf │ │ ├── KaTeX_Math-Italic.woff │ │ ├── KaTeX_Math-Italic.woff2 │ │ ├── KaTeX_SansSerif-Bold.ttf │ │ ├── KaTeX_SansSerif-Bold.woff │ │ ├── KaTeX_SansSerif-Bold.woff2 │ │ ├── KaTeX_SansSerif-Italic.ttf │ │ ├── KaTeX_SansSerif-Italic.woff │ │ ├── KaTeX_SansSerif-Italic.woff2 │ │ ├── KaTeX_SansSerif-Regular.ttf │ │ ├── KaTeX_SansSerif-Regular.woff │ │ ├── KaTeX_SansSerif-Regular.woff2 │ │ ├── KaTeX_Script-Regular.ttf │ │ ├── KaTeX_Script-Regular.woff │ │ ├── KaTeX_Script-Regular.woff2 │ │ ├── KaTeX_Size1-Regular.ttf │ │ ├── KaTeX_Size1-Regular.woff │ │ ├── KaTeX_Size1-Regular.woff2 │ │ ├── KaTeX_Size2-Regular.ttf │ │ ├── KaTeX_Size2-Regular.woff │ │ ├── KaTeX_Size2-Regular.woff2 │ │ ├── KaTeX_Size3-Regular.ttf │ │ ├── KaTeX_Size3-Regular.woff │ │ ├── KaTeX_Size3-Regular.woff2 │ │ ├── KaTeX_Size4-Regular.ttf │ │ ├── KaTeX_Size4-Regular.woff │ │ ├── KaTeX_Size4-Regular.woff2 │ │ ├── KaTeX_Typewriter-Regular.ttf │ │ ├── KaTeX_Typewriter-Regular.woff │ │ └── KaTeX_Typewriter-Regular.woff2 │ ├── katex.css │ ├── katex.js │ ├── katex.min.css │ ├── katex.min.js │ └── katex.mjs ├── math.html ├── src │ ├── assist.js │ ├── draw.js │ ├── index.html │ └── math.js ├── styles │ ├── fonts │ │ ├── firamono_latin.woff2 │ │ └── firamono_latin_ext.woff2 │ ├── main.css │ └── prettify-theme.css └── template.html ├── index.lit ├── math.lit └── template.lit /Makefile: -------------------------------------------------------------------------------- 1 | 2 | .PHONY: clean all 3 | 4 | all: docs/index.html docs/math.html docs/src/main.js docs/src/math.js 5 | 6 | docs/google-code-prettify docs/katex: 7 | srcweave-format-init -m docs 8 | 9 | docs/src/main.js docs/src/math.js: index.lit template.lit math.lit 10 | srcweave --tangle ./docs/src/ $^ 11 | 12 | # separate weaving of tutorial and libraries so they have 13 | # separate TOCs# 14 | 15 | docs/index.html: index.lit 16 | srcweave --weave ./docs/ --formatter srcweave-format $^ 17 | 18 | docs/math.html docs/template.html: template.lit math.lit 19 | srcweave --weave ./docs/ --formatter srcweave-format $^ 20 | 21 | clean: 22 | rm -f docs/src/main.js 23 | rm -f docs/*.html 24 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Why Train When You Can Optimize? 2 | 3 | [READ HERE](https://justinmeiners.github.io/why-train-when-you-can-optimize/) 4 | 5 | Here is the [final source](docs/src). 6 | 7 | ## Edits 8 | 9 | This project uses the [srcweave](https://github.com/justinmeiners/srcweave) literate programming system. 10 | If you want to contribute a fix without using this system, feel free to make a PR anyway. 11 | 12 | ## License 13 | 14 | [CC BY-NC-SA 4.0](https://creativecommons.org/licenses/by-nc-sa/4.0/) applies to the article and figures. 15 | 16 | MIT applies to all code. 17 | 18 | MIT License 19 | 20 | Copyright (c) 2022 Justin Meiners 21 | 22 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 23 | 24 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 25 | 26 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 27 | -------------------------------------------------------------------------------- /assets/drawing.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 22 | 24 | 32 | 37 | 38 | 46 | 51 | 52 | 53 | 71 | 73 | 74 | 76 | image/svg+xml 77 | 79 | 80 | 81 | 82 | 83 | 87 | 90 | 97 | 109 | 121 | 133 | 145 | 146 | 149 | 156 | 168 | 180 | 192 | 204 | 205 | 210 | 211 | 212 | -------------------------------------------------------------------------------- /assets/stroke.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 22 | 24 | 42 | 44 | 45 | 47 | image/svg+xml 48 | 50 | 51 | 52 | 53 | 54 | 58 | 63 | 75 | 87 | 99 | 111 | 123 | 124 | 125 | -------------------------------------------------------------------------------- /docs/google-code-prettify/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)(?![\w.])/],["lit",/^0[Xx][\dA-Fa-f]+([Pp]\d+)?[Li]?/],["lit",/^[+-]?(\d+(\.\d+)?|\.\d+)([Ee][+-]?\d+)?[Li]?/],["lit",/^(?:NULL|NA(?:_(?:integer|real|complex|character)_)?|Inf|TRUE|FALSE|NaN|\.\.(?:\.|\d+))(?![\w.])/], 18 | ["pun",/^(?:<>?|-|==|<=|>=|<|>|&&?|!=|\|\|?|[!*+/^]|%.*?%|[$=@~]|:{1,3}|[(),;?[\]{}])/],["pln",/^(?:[A-Za-z]+[\w.]*|\.[^\W\d][\w.]*)(?![\w.])/],["str",/^`.+`/]]),["r","s","R","S","Splus"]); 19 | -------------------------------------------------------------------------------- /docs/google-code-prettify/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",/^#[^\n\r]*/,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|[ES]?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|\\[!-~])(?:[\w-]*|\\[!-~])[!=?]?)?/],["pln",/^-*(?:[!-z]|\\[!-~])(?:[\w-]*|\\[!-~])[!=?]?/],["pun",/^[^\w\t\n\r "'-);\\\xa0]+/]]),["apollo","agc","aea"]); 19 | -------------------------------------------------------------------------------- /docs/google-code-prettify/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",/^#[^\n\r]*/,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|[ES]?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|\\[!-~])(?:[\w-]*|\\[!-~])[!=?]?)?/],["pln",/^-*(?:[!-z]|\\[!-~])(?:[\w-]*|\\[!-~])[!=?]?/],["pun",/^[^\w\t\n\r "'-);\\\xa0]+/]]),["apollo","agc","aea"]); 19 | -------------------------------------------------------------------------------- /docs/google-code-prettify/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",/^#[^\n\r]*/,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|[ES]?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|\\[!-~])(?:[\w-]*|\\[!-~])[!=?]?)?/],["pln",/^-*(?:[!-z]|\\[!-~])(?:[\w-]*|\\[!-~])[!=?]?/],["pun",/^[^\w\t\n\r "'-);\\\xa0]+/]]),["apollo","agc","aea"]); 19 | -------------------------------------------------------------------------------- /docs/google-code-prettify/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 | var a=null; 18 | PR.registerLangHandler(PR.createSimpleLexer([["str",/^"(?:[^\n\r"\\]|\\.)*(?:"|$)/,a,'"'],["pln",/^\s+/,a," \r\n\t\u00a0"]],[["com",/^REM[^\n\r]*/,a],["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/,a],["pln",/^[a-z][^\W_]?(?:\$|%)?/i,a],["lit",/^(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?/i,a,"0123456789"],["pun", 19 | /^.[^\s\w"$%.]*/,a]]),["basic","cbm"]); 20 | -------------------------------------------------------------------------------- /docs/google-code-prettify/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 | var a=null; 18 | PR.registerLangHandler(PR.createSimpleLexer([["str",/^"(?:[^\n\r"\\]|\\.)*(?:"|$)/,a,'"'],["pln",/^\s+/,a," \r\n\t\u00a0"]],[["com",/^REM[^\n\r]*/,a],["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/,a],["pln",/^[a-z][^\W_]?(?:\$|%)?/i,a],["lit",/^(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?/i,a,"0123456789"],["pun", 19 | /^.[^\s\w"$%.]*/,a]]),["basic","cbm"]); 20 | -------------------------------------------------------------------------------- /docs/google-code-prettify/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 | var a=null; 18 | PR.registerLangHandler(PR.createSimpleLexer([["opn",/^\(+/,a,"("],["clo",/^\)+/,a,")"],["com",/^;[^\n\r]*/,a,";"],["pln",/^[\t\n\r \xa0]+/,a,"\t\n\r \u00a0"],["str",/^"(?:[^"\\]|\\[\S\s])*(?:"|$)/,a,'"']],[["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/,a], 19 | ["lit",/^[+-]?(?:[#0]x[\da-f]+|\d+\/\d+|(?:\.\d+|\d+(?:\.\d*)?)(?:[de][+-]?\d+)?)/i],["lit",/^'(?:-*(?:\w|\\[!-~])(?:[\w-]*|\\[!-~])[!=?]?)?/],["pln",/^-*(?:[_a-z]|\\[!-~])(?:[\w-]*|\\[!-~])[!=?]?/i],["pun",/^[^\w\t\n\r "'-);\\\xa0]+/]]),["cl","el","lisp","lsp","scm","ss","rkt"]); 20 | -------------------------------------------------------------------------------- /docs/google-code-prettify/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 | var a=null; 17 | PR.registerLangHandler(PR.createSimpleLexer([["opn",/^[([{]+/,a,"([{"],["clo",/^[)\]}]+/,a,")]}"],["com",/^;[^\n\r]*/,a,";"],["pln",/^[\t\n\r \xa0]+/,a,"\t\n\r \u00a0"],["str",/^"(?:[^"\\]|\\[\S\s])*(?:"|$)/,a,'"']],[["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/,a], 18 | ["typ",/^:[\dA-Za-z-]+/]]),["clj"]); 19 | -------------------------------------------------------------------------------- /docs/google-code-prettify/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\n\f\r ]+/,null," \t\r\n\u000c"]],[["str",/^"(?:[^\n\f\r"\\]|\\(?:\r\n?|\n|\f)|\\[\S\s])*"/,null],["str",/^'(?:[^\n\f\r'\\]|\\(?:\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]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*)\s*:/i],["com",/^\/\*[^*]*\*+(?:[^*/][^*]*\*+)*\//], 18 | ["com",/^(?:<\!--|--\>)/],["lit",/^(?:\d+|\d*\.\d+)(?:%|[a-z]+)?/i],["lit",/^#[\da-f]{3,6}\b/i],["pln",/^-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*/i],["pun",/^[^\s\w"']+/]]),["css"]);PR.registerLangHandler(PR.createSimpleLexer([],[["kwd",/^-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*/i]]),["css-kw"]);PR.registerLangHandler(PR.createSimpleLexer([],[["str",/^[^"')]+/]]),["css-str"]); 19 | -------------------------------------------------------------------------------- /docs/google-code-prettify/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?'''[\S\s]*?[^\\]'''/],["str",/^r?"""[\S\s]*?[^\\]"""/],["str",/^r?'('|[^\n\f\r]*?[^\\]')/],["str",/^r?"("|[^\n\f\r]*?[^\\]")/],["typ",/^[A-Z]\w*/],["pln",/^[$_a-z]\w*/i],["pun",/^[!%&*+/:<-?^|~-]/],["lit",/^\b0x[\da-f]+/i],["lit",/^\b\d+(?:\.\d*)?(?:e[+-]?\d+)?/i],["lit",/^\b\.\d+(?:e[+-]?\d+)?/i], 19 | ["pun",/^[(),.;[\]{}]/]]),["dart"]); 20 | -------------------------------------------------------------------------------- /docs/google-code-prettify/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 | var a=null; 18 | PR.registerLangHandler(PR.createSimpleLexer([["opn",/^\(+/,a,"("],["clo",/^\)+/,a,")"],["com",/^;[^\n\r]*/,a,";"],["pln",/^[\t\n\r \xa0]+/,a,"\t\n\r \u00a0"],["str",/^"(?:[^"\\]|\\[\S\s])*(?:"|$)/,a,'"']],[["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/,a], 19 | ["lit",/^[+-]?(?:[#0]x[\da-f]+|\d+\/\d+|(?:\.\d+|\d+(?:\.\d*)?)(?:[de][+-]?\d+)?)/i],["lit",/^'(?:-*(?:\w|\\[!-~])(?:[\w-]*|\\[!-~])[!=?]?)?/],["pln",/^-*(?:[_a-z]|\\[!-~])(?:[\w-]*|\\[!-~])[!=?]?/i],["pun",/^[^\w\t\n\r "'-);\\\xa0]+/]]),["cl","el","lisp","lsp","scm","ss","rkt"]); 20 | -------------------------------------------------------------------------------- /docs/google-code-prettify/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-\r ]+/,null,"\t\n\u000b\u000c\r "],["str",/^"(?:[^\n\f\r"\\]|\\[\S\s])*(?:"|$)/,null,'"'],["lit",/^[a-z]\w*/],["lit",/^'(?:[^\n\f\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_]\w*/],["pun",/^[,.;]/]]),["erlang","erl"]); 19 | -------------------------------------------------------------------------------- /docs/google-code-prettify/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-\r ]+/,null,"\t\n\u000b\u000c\r "],["str",/^"(?:[^\n\f\r"\\]|\\[\S\s])*(?:"|$)/,null,'"'],["lit",/^[a-z]\w*/],["lit",/^'(?:[^\n\f\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_]\w*/],["pun",/^[,.;]/]]),["erlang","erl"]); 19 | -------------------------------------------------------------------------------- /docs/google-code-prettify/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']*|``[^\t\n\r`]*(?:``|$))|else|endif|light)/i,null,"#"],["str",/^(?:"(?:[^"\\]|\\[\S\s])*(?:"|$)|'(?:[^'\\]|\\[\S\s])(?:'|$))/,null,"\"'"]],[["com",/^(?:\/\/[^\n\r]*|\(\*[\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']*[!#?]?|``[^\t\n\r`]*(?:``|$))/i],["pun",/^[^\w\t\n\r "'\xa0]+/]]),["fs","ml"]); 19 | -------------------------------------------------------------------------------- /docs/google-code-prettify/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",/^(?:\/\/[^\n\r]*|\/\*[\S\s]*?\*\/)/],["pln",/^(?:[^"'/`]|\/(?![*/]))+/]]),["go"]); 18 | -------------------------------------------------------------------------------- /docs/google-code-prettify/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-\r ]+/,null,"\t\n\u000b\u000c\r "],["str",/^"(?:[^\n\f\r"\\]|\\[\S\s])*(?:"|$)/,null,'"'],["str",/^'(?:[^\n\f\r'\\]|\\[^&])'?/,null,"'"],["lit",/^(?:0o[0-7]+|0x[\da-f]+|\d+(?:\.\d+)?(?:e[+-]?\d+)?)/i,null,"0123456789"]],[["com",/^(?:--+[^\n\f\r]*|{-(?:[^-]|-+[^}-])*-})/],["kwd",/^(?:case|class|data|default|deriving|do|else|if|import|in|infix|infixl|infixr|instance|let|module|newtype|of|then|type|where|_)(?=[^\d'A-Za-z]|$)/, 18 | null],["pln",/^(?:[A-Z][\w']*\.)*[A-Za-z][\w']*/],["pun",/^[^\d\t-\r "'A-Za-z]+/]]),["hs"]); 19 | -------------------------------------------------------------------------------- /docs/google-code-prettify/lang-lasso.js: -------------------------------------------------------------------------------- 1 | var a=null; 2 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xa0]+/,a,"\t\n\r \u00a0"],["str",/^'(?:[^'\\]|\\[\S\s])*(?:'|$)/,a,"'"],["str",/^"(?:[^"\\]|\\[\S\s])*(?:"|$)/,a,'"'],["str",/^`[^`]*(?:`|$)/,a,"`"],["lit",/^0x[\da-f]+|\d+/i,a,"0123456789"],["atn",/^#\d+|[#$][_a-z][\w.]*|#![\S ]+lasso9\b/i,a,"#$"]],[["tag",/^[[\]]|<\?(?:lasso(?:script)?|=)|\?>|noprocess\b|no_square_brackets\b/i],["com",/^\/\/[^\n\r]*|\/\*[\S\s]*?\*\//],["atn", 3 | /^-(?!infinity)[_a-z][\w.]*|\.\s*'[_a-z][\w.]*'/i],["lit",/^\d*\.\d+(?:e[+-]?\d+)?|infinity\b|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],["kwd",/^(?:error_code|error_msg|error_pop|error_push|error_reset|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|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], 4 | ["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],["pln",/^[_a-z][\w.]*(?:=\s*(?=\())?/i],["pun",/^:=|[!%&*+/<-?\\|-]/]]),["lasso","ls","lassoscript"]); 5 | -------------------------------------------------------------------------------- /docs/google-code-prettify/lang-lassoscript.js: -------------------------------------------------------------------------------- 1 | var a=null; 2 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xa0]+/,a,"\t\n\r \u00a0"],["str",/^'(?:[^'\\]|\\[\S\s])*(?:'|$)/,a,"'"],["str",/^"(?:[^"\\]|\\[\S\s])*(?:"|$)/,a,'"'],["str",/^`[^`]*(?:`|$)/,a,"`"],["lit",/^0x[\da-f]+|\d+/i,a,"0123456789"],["atn",/^#\d+|[#$][_a-z][\w.]*|#![\S ]+lasso9\b/i,a,"#$"]],[["tag",/^[[\]]|<\?(?:lasso(?:script)?|=)|\?>|noprocess\b|no_square_brackets\b/i],["com",/^\/\/[^\n\r]*|\/\*[\S\s]*?\*\//],["atn", 3 | /^-(?!infinity)[_a-z][\w.]*|\.\s*'[_a-z][\w.]*'/i],["lit",/^\d*\.\d+(?:e[+-]?\d+)?|infinity\b|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],["kwd",/^(?:error_code|error_msg|error_pop|error_push|error_reset|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|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], 4 | ["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],["pln",/^[_a-z][\w.]*(?:=\s*(?=\())?/i],["pun",/^:=|[!%&*+/<-?\\|-]/]]),["lasso","ls","lassoscript"]); 5 | -------------------------------------------------------------------------------- /docs/google-code-prettify/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",/^%[^\n\r]*/,null,"%"]],[["kwd",/^\\[@-Za-z]+/],["kwd",/^\\./],["typ",/^[$&]/],["lit",/[+-]?(?:\.\d+|\d+(?:\.\d*)?)(cm|em|ex|in|pc|pt|bp|mm)/i],["pun",/^[()=[\]{}]+/]]),["latex","tex"]); 18 | -------------------------------------------------------------------------------- /docs/google-code-prettify/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\f\r"\\]|\\[\S\s])*(?:"|$)/,null,'"'],["lit",/^[a-z]\w*/],["lit",/^'(?:[^\n\f\r'\\]|\\[^&])+'?/,null,"'"],["lit",/^(?:0'.|0b[01]+|0o[0-7]+|0x[\da-f]+|\d+(?:\.\d+)?(?:e[+-]?\d+)?)/i,null,"0123456789"]],[["com",/^%[^\n\r]*/,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_]\w*/],["pun",/^[!#*-/:-?\\^{}]/]]),["logtalk","lgt"]); 19 | -------------------------------------------------------------------------------- /docs/google-code-prettify/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 | var a=null; 18 | PR.registerLangHandler(PR.createSimpleLexer([["opn",/^\(+/,a,"("],["clo",/^\)+/,a,")"],["com",/^;[^\n\r]*/,a,";"],["pln",/^[\t\n\r \xa0]+/,a,"\t\n\r \u00a0"],["str",/^"(?:[^"\\]|\\[\S\s])*(?:"|$)/,a,'"']],[["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/,a], 19 | ["lit",/^[+-]?(?:[#0]x[\da-f]+|\d+\/\d+|(?:\.\d+|\d+(?:\.\d*)?)(?:[de][+-]?\d+)?)/i],["lit",/^'(?:-*(?:\w|\\[!-~])(?:[\w-]*|\\[!-~])[!=?]?)?/],["pln",/^-*(?:[_a-z]|\\[!-~])(?:[\w-]*|\\[!-~])[!=?]?/i],["pun",/^[^\w\t\n\r "'-);\\\xa0]+/]]),["cl","el","lisp","lsp","scm","ss","rkt"]); 20 | -------------------------------------------------------------------------------- /docs/google-code-prettify/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",/^;[^\n\r]*/,null,";"]],[["pln",/^[!%@](?:[$\-.A-Z_a-z][\w$\-.]*|\d+)/],["kwd",/^[^\W\d]\w*/,null],["lit",/^\d+\.\d+/],["lit",/^(?:\d+|0[Xx][\dA-Fa-f]+)/],["pun",/^[(-*,:<->[\]{}]|\.\.\.$/]]),["llvm","ll"]); 18 | -------------------------------------------------------------------------------- /docs/google-code-prettify/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",/^;[^\n\r]*/,null,";"]],[["pln",/^[!%@](?:[$\-.A-Z_a-z][\w$\-.]*|\d+)/],["kwd",/^[^\W\d]\w*/,null],["lit",/^\d+\.\d+/],["lit",/^(?:\d+|0[Xx][\dA-Fa-f]+)/],["pun",/^[(-*,:<->[\]{}]|\.\.\.$/]]),["llvm","ll"]); 18 | -------------------------------------------------------------------------------- /docs/google-code-prettify/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\f\r"\\]|\\[\S\s])*(?:"|$)/,null,'"'],["lit",/^[a-z]\w*/],["lit",/^'(?:[^\n\f\r'\\]|\\[^&])+'?/,null,"'"],["lit",/^(?:0'.|0b[01]+|0o[0-7]+|0x[\da-f]+|\d+(?:\.\d+)?(?:e[+-]?\d+)?)/i,null,"0123456789"]],[["com",/^%[^\n\r]*/,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_]\w*/],["pun",/^[!#*-/:-?\\^{}]/]]),["logtalk","lgt"]); 19 | -------------------------------------------------------------------------------- /docs/google-code-prettify/lang-ls.js: -------------------------------------------------------------------------------- 1 | var a=null; 2 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xa0]+/,a,"\t\n\r \u00a0"],["str",/^'(?:[^'\\]|\\[\S\s])*(?:'|$)/,a,"'"],["str",/^"(?:[^"\\]|\\[\S\s])*(?:"|$)/,a,'"'],["str",/^`[^`]*(?:`|$)/,a,"`"],["lit",/^0x[\da-f]+|\d+/i,a,"0123456789"],["atn",/^#\d+|[#$][_a-z][\w.]*|#![\S ]+lasso9\b/i,a,"#$"]],[["tag",/^[[\]]|<\?(?:lasso(?:script)?|=)|\?>|noprocess\b|no_square_brackets\b/i],["com",/^\/\/[^\n\r]*|\/\*[\S\s]*?\*\//],["atn", 3 | /^-(?!infinity)[_a-z][\w.]*|\.\s*'[_a-z][\w.]*'/i],["lit",/^\d*\.\d+(?:e[+-]?\d+)?|infinity\b|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],["kwd",/^(?:error_code|error_msg|error_pop|error_push|error_reset|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|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], 4 | ["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],["pln",/^[_a-z][\w.]*(?:=\s*(?=\())?/i],["pun",/^:=|[!%&*+/<-?\\|-]/]]),["lasso","ls","lassoscript"]); 5 | -------------------------------------------------------------------------------- /docs/google-code-prettify/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 | var a=null; 18 | PR.registerLangHandler(PR.createSimpleLexer([["opn",/^\(+/,a,"("],["clo",/^\)+/,a,")"],["com",/^;[^\n\r]*/,a,";"],["pln",/^[\t\n\r \xa0]+/,a,"\t\n\r \u00a0"],["str",/^"(?:[^"\\]|\\[\S\s])*(?:"|$)/,a,'"']],[["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/,a], 19 | ["lit",/^[+-]?(?:[#0]x[\da-f]+|\d+\/\d+|(?:\.\d+|\d+(?:\.\d*)?)(?:[de][+-]?\d+)?)/i],["lit",/^'(?:-*(?:\w|\\[!-~])(?:[\w-]*|\\[!-~])[!=?]?)?/],["pln",/^-*(?:[_a-z]|\\[!-~])(?:[\w-]*|\\[!-~])[!=?]?/i],["pun",/^[^\w\t\n\r "'-);\\\xa0]+/]]),["cl","el","lisp","lsp","scm","ss","rkt"]); 20 | -------------------------------------------------------------------------------- /docs/google-code-prettify/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]|$)|[^\n\r]*)/],["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 | -------------------------------------------------------------------------------- /docs/google-code-prettify/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']*|``[^\t\n\r`]*(?:``|$))|else|endif|light)/i,null,"#"],["str",/^(?:"(?:[^"\\]|\\[\S\s])*(?:"|$)|'(?:[^'\\]|\\[\S\s])(?:'|$))/,null,"\"'"]],[["com",/^(?:\/\/[^\n\r]*|\(\*[\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']*[!#?]?|``[^\t\n\r`]*(?:``|$))/i],["pun",/^[^\w\t\n\r "'\xa0]+/]]),["fs","ml"]); 19 | -------------------------------------------------------------------------------- /docs/google-code-prettify/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",/^;[^\n\r]*/,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][^\W_]*/i],["pun",/^[^\w\t\n\r"$%;^\xa0]|_/]]),["mumps"]); 19 | -------------------------------------------------------------------------------- /docs/google-code-prettify/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 | var a=null; 18 | PR.registerLangHandler(PR.createSimpleLexer([["str",/^(?:'(?:[^\n\r'\\]|\\.)*'|"(?:[^\n\r"\\]|\\.)*(?:"|$))/,a,'"'],["com",/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\n\r]*)/,a,"#"],["pln",/^\s+/,a," \r\n\t\u00a0"]],[["str",/^@"(?:[^"]|"")*(?:"|$)/,a],["str",/^<#[^#>]*(?:#>|$)/,a],["str",/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,a],["com",/^\/\/[^\n\r]*/,a],["com",/^\/\*[\S\s]*?(?:\*\/|$)/, 19 | a],["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/, 20 | a],["typ",/^(?:array|bool|byte|char|decimal|double|float|int|list|long|object|sbyte|short|string|ulong|uint|ufloat|ulong|ushort|void)\b/,a],["lit",/^@[$_a-z][\w$@]*/i,a],["typ",/^@[A-Z]+[a-z][\w$@]*/,a],["pln",/^'?[$_a-z][\w$@]*/i,a],["lit",/^(?:0x[\da-f]+|(?:\d(?:_\d+)*\d*(?:\.\d*)?|\.\d\+)(?:e[+-]?\d+)?)[a-z]*/i,a,"0123456789"],["pun",/^.[^\s\w"-$'./@`]*/,a]]),["n","nemerle"]); 21 | -------------------------------------------------------------------------------- /docs/google-code-prettify/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 | var a=null; 18 | PR.registerLangHandler(PR.createSimpleLexer([["str",/^(?:'(?:[^\n\r'\\]|\\.)*'|"(?:[^\n\r"\\]|\\.)*(?:"|$))/,a,'"'],["com",/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\n\r]*)/,a,"#"],["pln",/^\s+/,a," \r\n\t\u00a0"]],[["str",/^@"(?:[^"]|"")*(?:"|$)/,a],["str",/^<#[^#>]*(?:#>|$)/,a],["str",/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,a],["com",/^\/\/[^\n\r]*/,a],["com",/^\/\*[\S\s]*?(?:\*\/|$)/, 19 | a],["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/, 20 | a],["typ",/^(?:array|bool|byte|char|decimal|double|float|int|list|long|object|sbyte|short|string|ulong|uint|ufloat|ulong|ushort|void)\b/,a],["lit",/^@[$_a-z][\w$@]*/i,a],["typ",/^@[A-Z]+[a-z][\w$@]*/,a],["pln",/^'?[$_a-z][\w$@]*/i,a],["lit",/^(?:0x[\da-f]+|(?:\d(?:_\d+)*\d*(?:\.\d*)?|\.\d\+)(?:e[+-]?\d+)?)[a-z]*/i,a,"0123456789"],["pun",/^.[^\s\w"-$'./@`]*/,a]]),["n","nemerle"]); 21 | -------------------------------------------------------------------------------- /docs/google-code-prettify/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 | var a=null; 18 | PR.registerLangHandler(PR.createSimpleLexer([["str",/^'(?:[^\n\r'\\]|\\.)*(?:'|$)/,a,"'"],["pln",/^\s+/,a," \r\n\t\u00a0"]],[["com",/^\(\*[\S\s]*?(?:\*\)|$)|^{[\S\s]*?(?:}|$)/,a],["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,a], 19 | ["lit",/^(?:true|false|self|nil)/i,a],["pln",/^[a-z][^\W_]*/i,a],["lit",/^(?:\$[\da-f]+|(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?)/i,a,"0123456789"],["pun",/^.[^\s\w$'./@]*/,a]]),["pascal"]); 20 | -------------------------------------------------------------------------------- /docs/google-code-prettify/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 | -------------------------------------------------------------------------------- /docs/google-code-prettify/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)(?![\w.])/],["lit",/^0[Xx][\dA-Fa-f]+([Pp]\d+)?[Li]?/],["lit",/^[+-]?(\d+(\.\d+)?|\.\d+)([Ee][+-]?\d+)?[Li]?/],["lit",/^(?:NULL|NA(?:_(?:integer|real|complex|character)_)?|Inf|TRUE|FALSE|NaN|\.\.(?:\.|\d+))(?![\w.])/], 18 | ["pun",/^(?:<>?|-|==|<=|>=|<|>|&&?|!=|\|\|?|[!*+/^]|%.*?%|[$=@~]|:{1,3}|[(),;?[\]{}])/],["pln",/^(?:[A-Za-z]+[\w.]*|\.[^\W\d][\w.]*)(?![\w.])/],["str",/^`.+`/]]),["r","s","R","S","Splus"]); 19 | -------------------------------------------------------------------------------- /docs/google-code-prettify/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",/^%[^\n\r]*/,null,"%"]],[["lit",/^\\(?:cr|l?dots|R|tab)\b/],["kwd",/^\\[@-Za-z]+/],["kwd",/^#(?:ifn?def|endif)/],["pln",/^\\[{}]/],["pun",/^[()[\]{}]+/]]),["Rd","rd"]); 18 | -------------------------------------------------------------------------------- /docs/google-code-prettify/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 | var a=null; 18 | PR.registerLangHandler(PR.createSimpleLexer([["opn",/^\(+/,a,"("],["clo",/^\)+/,a,")"],["com",/^;[^\n\r]*/,a,";"],["pln",/^[\t\n\r \xa0]+/,a,"\t\n\r \u00a0"],["str",/^"(?:[^"\\]|\\[\S\s])*(?:"|$)/,a,'"']],[["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/,a], 19 | ["lit",/^[+-]?(?:[#0]x[\da-f]+|\d+\/\d+|(?:\.\d+|\d+(?:\.\d*)?)(?:[de][+-]?\d+)?)/i],["lit",/^'(?:-*(?:\w|\\[!-~])(?:[\w-]*|\\[!-~])[!=?]?)?/],["pln",/^-*(?:[_a-z]|\\[!-~])(?:[\w-]*|\\[!-~])[!=?]?/i],["pun",/^[^\w\t\n\r "'-);\\\xa0]+/]]),["cl","el","lisp","lsp","scm","ss","rkt"]); 20 | -------------------------------------------------------------------------------- /docs/google-code-prettify/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|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[\d_]*(?:[iu](?:size|8|16|32|64))?/],["lit",/^0x[\dA-F_a-f]+(?:[iu](?:size|8|16|32|64))?/],["lit",/^0o[0-7_]+(?:[iu](?:size|8|16|32|64))?/],["lit",/^0b[01_]+(?:[iu](?:size|8|16|32|64))?/],["lit",/^\d[\d_]*\.(?![^\s\d.])/],["lit",/^\d[\d_]*\.\d[\d_]*(?:[Ee][+-]?[\d_]+)?(?:f32|f64)?/],["lit",/^\d[\d_]*(?:\.\d[\d_]*)?[Ee][+-]?[\d_]+(?:f32|f64)?/],["lit",/^\d[\d_]*(?:\.\d[\d_]*)?(?:[Ee][+-]?[\d_]+)?(?:f32|f64)/],["atn", 20 | /^[_a-z]\w*!/i],["pln",/^[_a-z]\w*/i],["atv",/^#!?\[[\S\s]*?]/],["pun",/^[!%&(-/:-?[\]^{-}]/],["pln",/./]]),["rust"]); 21 | -------------------------------------------------------------------------------- /docs/google-code-prettify/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)(?![\w.])/],["lit",/^0[Xx][\dA-Fa-f]+([Pp]\d+)?[Li]?/],["lit",/^[+-]?(\d+(\.\d+)?|\.\d+)([Ee][+-]?\d+)?[Li]?/],["lit",/^(?:NULL|NA(?:_(?:integer|real|complex|character)_)?|Inf|TRUE|FALSE|NaN|\.\.(?:\.|\d+))(?![\w.])/], 18 | ["pun",/^(?:<>?|-|==|<=|>=|<|>|&&?|!=|\|\|?|[!*+/^]|%.*?%|[$=@~]|:{1,3}|[(),;?[\]{}])/],["pln",/^(?:[A-Za-z]+[\w.]*|\.[^\W\d][\w.]*)(?![\w.])/],["str",/^`.+`/]]),["r","s","R","S","Splus"]); 19 | -------------------------------------------------------------------------------- /docs/google-code-prettify/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}|(?:[^\n\r"\\]|\\.)*"?)/,null,'"'],["lit",/^`(?:[^\n\r\\`]|\\.)*`?/,null,"`"],["pun",/^[!#%&(--:-@[-^{-~]+/,null,"!#%&()*+,-:;<=>?@[\\]^{|}~"]],[["str",/^'(?:[^\n\r'\\]|\\(?:'|[^\n\r']+))'/],["lit",/^'[$A-Z_a-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[\da-f]+)l?|(?:0|[1-9]\d*)(?:(?:\.\d+)?(?:e[+-]?\d+)?f?|l?)|\\.\d+(?:e[+-]?\d+)?f?)/i],["typ",/^[$_]*[A-Z][\d$A-Z_]*[a-z][\w$]*/],["pln",/^[$A-Z_a-z][\w$]*/],["com",/^\/(?:\/.*|\*(?:\/|\**[^*/])*(?:\*+\/?)?)/],["pun",/^(?:\.+|\/)/]]),["scala"]); 19 | -------------------------------------------------------------------------------- /docs/google-code-prettify/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 | var a=null; 18 | PR.registerLangHandler(PR.createSimpleLexer([["opn",/^\(+/,a,"("],["clo",/^\)+/,a,")"],["com",/^;[^\n\r]*/,a,";"],["pln",/^[\t\n\r \xa0]+/,a,"\t\n\r \u00a0"],["str",/^"(?:[^"\\]|\\[\S\s])*(?:"|$)/,a,'"']],[["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/,a], 19 | ["lit",/^[+-]?(?:[#0]x[\da-f]+|\d+\/\d+|(?:\.\d+|\d+(?:\.\d*)?)(?:[de][+-]?\d+)?)/i],["lit",/^'(?:-*(?:\w|\\[!-~])(?:[\w-]*|\\[!-~])[!=?]?)?/],["pln",/^-*(?:[_a-z]|\\[!-~])(?:[\w-]*|\\[!-~])[!=?]?/i],["pun",/^[^\w\t\n\r "'-);\\\xa0]+/]]),["cl","el","lisp","lsp","scm","ss","rkt"]); 20 | -------------------------------------------------------------------------------- /docs/google-code-prettify/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",/^(?:--[^\n\r]*|\/\*[\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 | -------------------------------------------------------------------------------- /docs/google-code-prettify/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 | var a=null; 18 | PR.registerLangHandler(PR.createSimpleLexer([["opn",/^\(+/,a,"("],["clo",/^\)+/,a,")"],["com",/^;[^\n\r]*/,a,";"],["pln",/^[\t\n\r \xa0]+/,a,"\t\n\r \u00a0"],["str",/^"(?:[^"\\]|\\[\S\s])*(?:"|$)/,a,'"']],[["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/,a], 19 | ["lit",/^[+-]?(?:[#0]x[\da-f]+|\d+\/\d+|(?:\.\d+|\d+(?:\.\d*)?)(?:[de][+-]?\d+)?)/i],["lit",/^'(?:-*(?:\w|\\[!-~])(?:[\w-]*|\\[!-~])[!=?]?)?/],["pln",/^-*(?:[_a-z]|\\[!-~])(?:[\w-]*|\\[!-~])[!=?]?/i],["pun",/^[^\w\t\n\r "'-);\\\xa0]+/]]),["cl","el","lisp","lsp","scm","ss","rkt"]); 20 | -------------------------------------------------------------------------------- /docs/google-code-prettify/lang-swift.js: -------------------------------------------------------------------------------- 1 | var a=null; 2 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\0\t-\r ]+/,a," \n\r\t\u000b\u000c\0"],["str",/^"(?:[^"\\]|\\.|\\\((?:[^")\\]|\\.)*\))*"/,a,'"']],[["lit",/^(?:0x[\dA-Fa-f][\dA-F_a-f]*\.[\dA-Fa-f][\dA-F_a-f]*[Pp]?|\d[\d_]*\.\d[\d_]*[Ee]?)[+-]?\d[\d_]*/,a],["lit",/^-?(?:0(?:b[01][01_]*|o[0-7][0-7_]*|x[\dA-Fa-f][\dA-F_a-f]*)|\d[\d_]*)/,a],["lit",/^(?:true|false|nil)\b/,a],["kwd",/^\b(?:__COLUMN__|__FILE__|__FUNCTION__|__LINE__|#available|#else|#elseif|#endif|#if|#line|arch|arm|arm64|associativity|as|break|case|catch|class|continue|convenience|default|defer|deinit|didSet|do|dynamic|dynamicType|else|enum|fallthrough|final|for|func|get|import|indirect|infix|init|inout|internal|i386|if|in|iOS|iOSApplicationExtension|is|lazy|left|let|mutating|none|nonmutating|operator|optional|OSX|OSXApplicationExtension|override|postfix|precedence|prefix|private|protocol|Protocol|public|required|rethrows|return|right|safe|self|set|static|struct|subscript|super|switch|throw|try|Type|typealias|unowned|unsafe|var|weak|watchOS|while|willSet|x86_64)\b/,a], 3 | ["com",/^\/\/.*?[\n\r]/,a],["com",/^\/\*[\S\s]*?(?:\*\/|$)/,a],["pun",/^<<=|<=|<<|>>=|>=|>>|===|==|\.\.\.|&&=|\.\.<|!==|!=|&=|~=|[#(),.:;@[\]{}~]|\|\|=|\?\?|\|\||&&|&\*|&\+|&-|&=|\+=|-=|\/=|\*=|\^=|%=|\|=|->|`|==|\+\+|--|[!%&*+/<-?^_|-]/,a],["typ",/^\b(?:[@_]?[A-Z]+[a-z][\w$@]*|\w+_t\b)/,a]]),["swift"]); 4 | -------------------------------------------------------------------------------- /docs/google-code-prettify/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 | var a=null; 18 | PR.registerLangHandler(PR.createSimpleLexer([["opn",/^{+/,a,"{"],["clo",/^}+/,a,"}"],["com",/^#[^\n\r]*/,a,"#"],["pln",/^[\t\n\r \xa0]+/,a,"\t\n\r \u00a0"],["str",/^"(?:[^"\\]|\\[\S\s])*(?:"|$)/,a,'"']],[["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/,a],["lit",/^[+-]?(?:[#0]x[\da-f]+|\d+\/\d+|(?:\.\d+|\d+(?:\.\d*)?)(?:[de][+-]?\d+)?)/i],["lit", 19 | /^'(?:-*(?:\w|\\[!-~])(?:[\w-]*|\\[!-~])[!=?]?)?/],["pln",/^-*(?:[_a-z]|\\[!-~])(?:[\w-]*|\\[!-~])[!=?]?/i],["pun",/^[^\w\t\n\r "'-);\\\xa0]+/]]),["tcl"]); 20 | -------------------------------------------------------------------------------- /docs/google-code-prettify/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",/^%[^\n\r]*/,null,"%"]],[["kwd",/^\\[@-Za-z]+/],["kwd",/^\\./],["typ",/^[$&]/],["lit",/[+-]?(?:\.\d+|\d+(?:\.\d*)?)(cm|em|ex|in|pc|pt|bp|mm)/i],["pun",/^[()=[\]{}]+/]]),["latex","tex"]); 18 | -------------------------------------------------------------------------------- /docs/google-code-prettify/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]?)|[^\n\r_\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.*/i],["lit",/^(?:true\b|false\b|nothing\b|\d+(?:e[+-]?\d+[dfr]?|[dfilrs])?|(?:&h[\da-f]+|&o[0-7]+)[ils]?|\d*\.\d+(?:e[+-]?\d+)?[dfr]?|#\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","vbs"]); 19 | -------------------------------------------------------------------------------- /docs/google-code-prettify/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]?)|[^\n\r_\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.*/i],["lit",/^(?:true\b|false\b|nothing\b|\d+(?:e[+-]?\d+[dfr]?|[dfilrs])?|(?:&h[\da-f]+|&o[0-7]+)[ils]?|\d*\.\d+(?:e[+-]?\d+)?[dfr]?|#\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","vbs"]); 19 | -------------------------------------------------------------------------------- /docs/google-code-prettify/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",/^--[^\n\r]*/],["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 | -------------------------------------------------------------------------------- /docs/google-code-prettify/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",/^--[^\n\r]*/],["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 | -------------------------------------------------------------------------------- /docs/google-code-prettify/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",/^[\d\t a-gi-z\xa0]+/,null,"\t \u00a0abcdefgijklmnopqrstuvwxyz0123456789"],["pun",/^[*=[\]^~]+/,null,"=*~^[]"]],[["lang-wiki.meta",/(?:^^|\r\n?|\n)(#[a-z]+)\b/],["lit",/^[A-Z][a-z][\da-z]+[A-Z][a-z][^\W_]+\b/],["lang-",/^{{{([\S\s]+?)}}}/],["lang-",/^`([^\n\r`]+)`/],["str",/^https?:\/\/[^\s#/?]*(?:\/[^\s#?]*)?(?:\?[^\s#]*)?(?:#\S*)?/i],["pln",/^(?:\r\n|[\S\s])[^\n\r#*=A-[^`h{~]*/]]),["wiki"]); 18 | PR.registerLangHandler(PR.createSimpleLexer([["kwd",/^#[a-z]+/i,null,"#"]],[]),["wiki.meta"]); 19 | -------------------------------------------------------------------------------- /docs/google-code-prettify/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 | var a=null; 18 | PR.registerLangHandler(PR.createSimpleLexer([["pun",/^[:>?|]+/,a,":|>?"],["dec",/^%(?:YAML|TAG)[^\n\r#]+/,a,"%"],["typ",/^&\S+/,a,"&"],["typ",/^!\S*/,a,"!"],["str",/^"(?:[^"\\]|\\.)*(?:"|$)/,a,'"'],["str",/^'(?:[^']|'')*(?:'|$)/,a,"'"],["com",/^#[^\n\r]*/,a,"#"],["pln",/^\s+/,a," \t\r\n"]],[["dec",/^(?:---|\.\.\.)(?:[\n\r]|$)/],["pun",/^-/],["kwd",/^[\w-]+:[\n\r ]/],["pln",/^\w+/]]),["yaml","yml"]); 19 | -------------------------------------------------------------------------------- /docs/google-code-prettify/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 | var a=null; 18 | PR.registerLangHandler(PR.createSimpleLexer([["pun",/^[:>?|]+/,a,":|>?"],["dec",/^%(?:YAML|TAG)[^\n\r#]+/,a,"%"],["typ",/^&\S+/,a,"&"],["typ",/^!\S*/,a,"!"],["str",/^"(?:[^"\\]|\\.)*(?:"|$)/,a,'"'],["str",/^'(?:[^']|'')*(?:'|$)/,a,"'"],["com",/^#[^\n\r]*/,a,"#"],["pln",/^\s+/,a," \t\r\n"]],[["dec",/^(?:---|\.\.\.)(?:[\n\r]|$)/],["pun",/^-/],["kwd",/^[\w-]+:[\n\r ]/],["pln",/^\w+/]]),["yaml","yml"]); 19 | -------------------------------------------------------------------------------- /docs/google-code-prettify/prettify.css: -------------------------------------------------------------------------------- 1 | .pln{color:#000}@media screen{.str{color:#080}.kwd{color:#008}.com{color:#800}.typ{color:#606}.lit{color:#066}.pun,.opn,.clo{color:#660}.tag{color:#008}.atn{color:#606}.atv{color:#080}.dec,.var{color:#606}.fun{color:red}}@media print,projection{.str{color:#060}.kwd{color:#006;font-weight:bold}.com{color:#600;font-style:italic}.typ{color:#404;font-weight:bold}.lit{color:#044}.pun,.opn,.clo{color:#440}.tag{color:#006;font-weight:bold}.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} -------------------------------------------------------------------------------- /docs/img/circle-drawing.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justinmeiners/why-train-when-you-can-optimize/e06e036a2e09f08e29ecab60ed4e24c7286544f1/docs/img/circle-drawing.gif -------------------------------------------------------------------------------- /docs/img/circle-fail.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justinmeiners/why-train-when-you-can-optimize/e06e036a2e09f08e29ecab60ed4e24c7286544f1/docs/img/circle-fail.gif -------------------------------------------------------------------------------- /docs/img/function-3d-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justinmeiners/why-train-when-you-can-optimize/e06e036a2e09f08e29ecab60ed4e24c7286544f1/docs/img/function-3d-1.png -------------------------------------------------------------------------------- /docs/img/function-extrema.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justinmeiners/why-train-when-you-can-optimize/e06e036a2e09f08e29ecab60ed4e24c7286544f1/docs/img/function-extrema.png -------------------------------------------------------------------------------- /docs/img/function-not-continuous.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justinmeiners/why-train-when-you-can-optimize/e06e036a2e09f08e29ecab60ed4e24c7286544f1/docs/img/function-not-continuous.png -------------------------------------------------------------------------------- /docs/img/inverse-transform.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justinmeiners/why-train-when-you-can-optimize/e06e036a2e09f08e29ecab60ed4e24c7286544f1/docs/img/inverse-transform.png -------------------------------------------------------------------------------- /docs/img/ipad-notes.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justinmeiners/why-train-when-you-can-optimize/e06e036a2e09f08e29ecab60ed4e24c7286544f1/docs/img/ipad-notes.gif -------------------------------------------------------------------------------- /docs/img/line-drawing.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justinmeiners/why-train-when-you-can-optimize/e06e036a2e09f08e29ecab60ed4e24c7286544f1/docs/img/line-drawing.gif -------------------------------------------------------------------------------- /docs/img/rect-drawing.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justinmeiners/why-train-when-you-can-optimize/e06e036a2e09f08e29ecab60ed4e24c7286544f1/docs/img/rect-drawing.gif -------------------------------------------------------------------------------- /docs/img/rect-model.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justinmeiners/why-train-when-you-can-optimize/e06e036a2e09f08e29ecab60ed4e24c7286544f1/docs/img/rect-model.png -------------------------------------------------------------------------------- /docs/img/stroke.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justinmeiners/why-train-when-you-can-optimize/e06e036a2e09f08e29ecab60ed4e24c7286544f1/docs/img/stroke.png -------------------------------------------------------------------------------- /docs/katex/README.md: -------------------------------------------------------------------------------- 1 | # [KaTeX](https://katex.org/) 2 | [![npm](https://img.shields.io/npm/v/katex.svg)](https://www.npmjs.com/package/katex) 3 | [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release) 4 | [![CI](https://github.com/KaTeX/KaTeX/workflows/CI/badge.svg?branch=main&event=push)](https://github.com/KaTeX/KaTeX/actions?query=workflow%3ACI) 5 | [![codecov](https://codecov.io/gh/KaTeX/KaTeX/branch/main/graph/badge.svg)](https://codecov.io/gh/KaTeX/KaTeX) 6 | [![Discussions](https://img.shields.io/badge/Discussions-join-brightgreen)](https://github.com/KaTeX/KaTeX/discussions) 7 | [![jsDelivr](https://data.jsdelivr.com/v1/package/npm/katex/badge?style=rounded)](https://www.jsdelivr.com/package/npm/katex) 8 | ![katex.min.js size](https://img.badgesize.io/https://unpkg.com/katex/dist/katex.min.js?compression=gzip) 9 | [![Gitpod ready-to-code](https://img.shields.io/badge/Gitpod-ready--to--code-blue?logo=gitpod)](https://gitpod.io/#https://github.com/KaTeX/KaTeX) 10 | [![Financial Contributors on Open Collective](https://opencollective.com/katex/all/badge.svg?label=financial+contributors)](https://opencollective.com/katex) 11 | 12 | KaTeX is a fast, easy-to-use JavaScript library for TeX math rendering on the web. 13 | 14 | * **Fast:** KaTeX renders its math synchronously and doesn't need to reflow the page. See how it compares to a competitor in [this speed test](http://www.intmath.com/cg5/katex-mathjax-comparison.php). 15 | * **Print quality:** KaTeX's layout is based on Donald Knuth's TeX, the gold standard for math typesetting. 16 | * **Self contained:** KaTeX has no dependencies and can easily be bundled with your website resources. 17 | * **Server side rendering:** KaTeX produces the same output regardless of browser or environment, so you can pre-render expressions using Node.js and send them as plain HTML. 18 | 19 | KaTeX is compatible with all major browsers, including Chrome, Safari, Firefox, Opera, Edge, and IE 11. 20 | 21 | KaTeX supports much (but not all) of LaTeX and many LaTeX packages. See the [list of supported functions](https://katex.org/docs/supported.html). 22 | 23 | Try out KaTeX [on the demo page](https://katex.org/#demo)! 24 | 25 | ## Getting started 26 | 27 | ### Starter template 28 | 29 | ```html 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 42 | 43 | ... 44 | 45 | ``` 46 | 47 | You can also [download KaTeX](https://github.com/KaTeX/KaTeX/releases) and host it yourself. 48 | 49 | For details on how to configure auto-render extension, refer to [the documentation](https://katex.org/docs/autorender.html). 50 | 51 | ### API 52 | 53 | Call `katex.render` to render a TeX expression directly into a DOM element. 54 | For example: 55 | 56 | ```js 57 | katex.render("c = \\pm\\sqrt{a^2 + b^2}", element, { 58 | throwOnError: false 59 | }); 60 | ``` 61 | 62 | Call `katex.renderToString` to generate an HTML string of the rendered math, 63 | e.g., for server-side rendering. For example: 64 | 65 | ```js 66 | var html = katex.renderToString("c = \\pm\\sqrt{a^2 + b^2}", { 67 | throwOnError: false 68 | }); 69 | // '...' 70 | ``` 71 | 72 | Make sure to include the CSS and font files in both cases. 73 | If you are doing all rendering on the server, there is no need to include the 74 | JavaScript on the client. 75 | 76 | The examples above use the `throwOnError: false` option, which renders invalid 77 | inputs as the TeX source code in red (by default), with the error message as 78 | hover text. For other available options, see the 79 | [API documentation](https://katex.org/docs/api.html), 80 | [options documentation](https://katex.org/docs/options.html), and 81 | [handling errors documentation](https://katex.org/docs/error.html). 82 | 83 | ## Demo and Documentation 84 | 85 | Learn more about using KaTeX [on the website](https://katex.org)! 86 | 87 | ## Contributors 88 | 89 | ### Code Contributors 90 | 91 | This project exists thanks to all the people who contribute code. If you'd like to help, see [our guide to contributing code](CONTRIBUTING.md). 92 | Code contributors 93 | 94 | ### Financial Contributors 95 | 96 | Become a financial contributor and help us sustain our community. 97 | 98 | #### Individuals 99 | 100 | Contribute on Open Collective 101 | 102 | #### Organizations 103 | 104 | Support this project with your organization. Your logo will show up here with a link to your website. 105 | 106 | Organization 1 107 | Organization 2 108 | Organization 3 109 | Organization 4 110 | Organization 5 111 | Organization 6 112 | Organization 7 113 | Organization 8 114 | Organization 9 115 | Organization 10 116 | 117 | ## License 118 | 119 | KaTeX is licensed under the [MIT License](http://opensource.org/licenses/MIT). 120 | -------------------------------------------------------------------------------- /docs/katex/contrib/auto-render.js: -------------------------------------------------------------------------------- 1 | (function webpackUniversalModuleDefinition(root, factory) { 2 | if(typeof exports === 'object' && typeof module === 'object') 3 | module.exports = factory(require("katex")); 4 | else if(typeof define === 'function' && define.amd) 5 | define(["katex"], factory); 6 | else if(typeof exports === 'object') 7 | exports["renderMathInElement"] = factory(require("katex")); 8 | else 9 | root["renderMathInElement"] = factory(root["katex"]); 10 | })((typeof self !== 'undefined' ? self : this), function(__WEBPACK_EXTERNAL_MODULE__771__) { 11 | return /******/ (function() { // webpackBootstrap 12 | /******/ "use strict"; 13 | /******/ var __webpack_modules__ = ({ 14 | 15 | /***/ 771: 16 | /***/ (function(module) { 17 | 18 | module.exports = __WEBPACK_EXTERNAL_MODULE__771__; 19 | 20 | /***/ }) 21 | 22 | /******/ }); 23 | /************************************************************************/ 24 | /******/ // The module cache 25 | /******/ var __webpack_module_cache__ = {}; 26 | /******/ 27 | /******/ // The require function 28 | /******/ function __webpack_require__(moduleId) { 29 | /******/ // Check if module is in cache 30 | /******/ var cachedModule = __webpack_module_cache__[moduleId]; 31 | /******/ if (cachedModule !== undefined) { 32 | /******/ return cachedModule.exports; 33 | /******/ } 34 | /******/ // Create a new module (and put it into the cache) 35 | /******/ var module = __webpack_module_cache__[moduleId] = { 36 | /******/ // no module.id needed 37 | /******/ // no module.loaded needed 38 | /******/ exports: {} 39 | /******/ }; 40 | /******/ 41 | /******/ // Execute the module function 42 | /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); 43 | /******/ 44 | /******/ // Return the exports of the module 45 | /******/ return module.exports; 46 | /******/ } 47 | /******/ 48 | /************************************************************************/ 49 | /******/ /* webpack/runtime/compat get default export */ 50 | /******/ !function() { 51 | /******/ // getDefaultExport function for compatibility with non-harmony modules 52 | /******/ __webpack_require__.n = function(module) { 53 | /******/ var getter = module && module.__esModule ? 54 | /******/ function() { return module['default']; } : 55 | /******/ function() { return module; }; 56 | /******/ __webpack_require__.d(getter, { a: getter }); 57 | /******/ return getter; 58 | /******/ }; 59 | /******/ }(); 60 | /******/ 61 | /******/ /* webpack/runtime/define property getters */ 62 | /******/ !function() { 63 | /******/ // define getter functions for harmony exports 64 | /******/ __webpack_require__.d = function(exports, definition) { 65 | /******/ for(var key in definition) { 66 | /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { 67 | /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); 68 | /******/ } 69 | /******/ } 70 | /******/ }; 71 | /******/ }(); 72 | /******/ 73 | /******/ /* webpack/runtime/hasOwnProperty shorthand */ 74 | /******/ !function() { 75 | /******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); } 76 | /******/ }(); 77 | /******/ 78 | /************************************************************************/ 79 | var __webpack_exports__ = {}; 80 | // This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk. 81 | !function() { 82 | 83 | // EXPORTS 84 | __webpack_require__.d(__webpack_exports__, { 85 | "default": function() { return /* binding */ auto_render; } 86 | }); 87 | 88 | // EXTERNAL MODULE: external "katex" 89 | var external_katex_ = __webpack_require__(771); 90 | var external_katex_default = /*#__PURE__*/__webpack_require__.n(external_katex_); 91 | ;// CONCATENATED MODULE: ./contrib/auto-render/splitAtDelimiters.js 92 | /* eslint no-constant-condition:0 */ 93 | var findEndOfMath = function findEndOfMath(delimiter, text, startIndex) { 94 | // Adapted from 95 | // https://github.com/Khan/perseus/blob/master/src/perseus-markdown.jsx 96 | var index = startIndex; 97 | var braceLevel = 0; 98 | var delimLength = delimiter.length; 99 | 100 | while (index < text.length) { 101 | var character = text[index]; 102 | 103 | if (braceLevel <= 0 && text.slice(index, index + delimLength) === delimiter) { 104 | return index; 105 | } else if (character === "\\") { 106 | index++; 107 | } else if (character === "{") { 108 | braceLevel++; 109 | } else if (character === "}") { 110 | braceLevel--; 111 | } 112 | 113 | index++; 114 | } 115 | 116 | return -1; 117 | }; 118 | 119 | var escapeRegex = function escapeRegex(string) { 120 | return string.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&"); 121 | }; 122 | 123 | var amsRegex = /^\\begin{/; 124 | 125 | var splitAtDelimiters = function splitAtDelimiters(text, delimiters) { 126 | var index; 127 | var data = []; 128 | var regexLeft = new RegExp("(" + delimiters.map(function (x) { 129 | return escapeRegex(x.left); 130 | }).join("|") + ")"); 131 | 132 | while (true) { 133 | index = text.search(regexLeft); 134 | 135 | if (index === -1) { 136 | break; 137 | } 138 | 139 | if (index > 0) { 140 | data.push({ 141 | type: "text", 142 | data: text.slice(0, index) 143 | }); 144 | text = text.slice(index); // now text starts with delimiter 145 | } // ... so this always succeeds: 146 | 147 | 148 | var i = delimiters.findIndex(function (delim) { 149 | return text.startsWith(delim.left); 150 | }); 151 | index = findEndOfMath(delimiters[i].right, text, delimiters[i].left.length); 152 | 153 | if (index === -1) { 154 | break; 155 | } 156 | 157 | var rawData = text.slice(0, index + delimiters[i].right.length); 158 | var math = amsRegex.test(rawData) ? rawData : text.slice(delimiters[i].left.length, index); 159 | data.push({ 160 | type: "math", 161 | data: math, 162 | rawData: rawData, 163 | display: delimiters[i].display 164 | }); 165 | text = text.slice(index + delimiters[i].right.length); 166 | } 167 | 168 | if (text !== "") { 169 | data.push({ 170 | type: "text", 171 | data: text 172 | }); 173 | } 174 | 175 | return data; 176 | }; 177 | 178 | /* harmony default export */ var auto_render_splitAtDelimiters = (splitAtDelimiters); 179 | ;// CONCATENATED MODULE: ./contrib/auto-render/auto-render.js 180 | /* eslint no-console:0 */ 181 | 182 | 183 | /* Note: optionsCopy is mutated by this method. If it is ever exposed in the 184 | * API, we should copy it before mutating. 185 | */ 186 | 187 | var renderMathInText = function renderMathInText(text, optionsCopy) { 188 | var data = auto_render_splitAtDelimiters(text, optionsCopy.delimiters); 189 | 190 | if (data.length === 1 && data[0].type === 'text') { 191 | // There is no formula in the text. 192 | // Let's return null which means there is no need to replace 193 | // the current text node with a new one. 194 | return null; 195 | } 196 | 197 | var fragment = document.createDocumentFragment(); 198 | 199 | for (var i = 0; i < data.length; i++) { 200 | if (data[i].type === "text") { 201 | fragment.appendChild(document.createTextNode(data[i].data)); 202 | } else { 203 | var span = document.createElement("span"); 204 | var math = data[i].data; // Override any display mode defined in the settings with that 205 | // defined by the text itself 206 | 207 | optionsCopy.displayMode = data[i].display; 208 | 209 | try { 210 | if (optionsCopy.preProcess) { 211 | math = optionsCopy.preProcess(math); 212 | } 213 | 214 | external_katex_default().render(math, span, optionsCopy); 215 | } catch (e) { 216 | if (!(e instanceof (external_katex_default()).ParseError)) { 217 | throw e; 218 | } 219 | 220 | optionsCopy.errorCallback("KaTeX auto-render: Failed to parse `" + data[i].data + "` with ", e); 221 | fragment.appendChild(document.createTextNode(data[i].rawData)); 222 | continue; 223 | } 224 | 225 | fragment.appendChild(span); 226 | } 227 | } 228 | 229 | return fragment; 230 | }; 231 | 232 | var renderElem = function renderElem(elem, optionsCopy) { 233 | for (var i = 0; i < elem.childNodes.length; i++) { 234 | var childNode = elem.childNodes[i]; 235 | 236 | if (childNode.nodeType === 3) { 237 | // Text node 238 | var frag = renderMathInText(childNode.textContent, optionsCopy); 239 | 240 | if (frag) { 241 | i += frag.childNodes.length - 1; 242 | elem.replaceChild(frag, childNode); 243 | } 244 | } else if (childNode.nodeType === 1) { 245 | (function () { 246 | // Element node 247 | var className = ' ' + childNode.className + ' '; 248 | var shouldRender = optionsCopy.ignoredTags.indexOf(childNode.nodeName.toLowerCase()) === -1 && optionsCopy.ignoredClasses.every(function (x) { 249 | return className.indexOf(' ' + x + ' ') === -1; 250 | }); 251 | 252 | if (shouldRender) { 253 | renderElem(childNode, optionsCopy); 254 | } 255 | })(); 256 | } // Otherwise, it's something else, and ignore it. 257 | 258 | } 259 | }; 260 | 261 | var renderMathInElement = function renderMathInElement(elem, options) { 262 | if (!elem) { 263 | throw new Error("No element provided to render"); 264 | } 265 | 266 | var optionsCopy = {}; // Object.assign(optionsCopy, option) 267 | 268 | for (var option in options) { 269 | if (options.hasOwnProperty(option)) { 270 | optionsCopy[option] = options[option]; 271 | } 272 | } // default options 273 | 274 | 275 | optionsCopy.delimiters = optionsCopy.delimiters || [{ 276 | left: "$$", 277 | right: "$$", 278 | display: true 279 | }, { 280 | left: "\\(", 281 | right: "\\)", 282 | display: false 283 | }, // LaTeX uses $…$, but it ruins the display of normal `$` in text: 284 | // {left: "$", right: "$", display: false}, 285 | // $ must come after $$ 286 | // Render AMS environments even if outside $$…$$ delimiters. 287 | { 288 | left: "\\begin{equation}", 289 | right: "\\end{equation}", 290 | display: true 291 | }, { 292 | left: "\\begin{align}", 293 | right: "\\end{align}", 294 | display: true 295 | }, { 296 | left: "\\begin{alignat}", 297 | right: "\\end{alignat}", 298 | display: true 299 | }, { 300 | left: "\\begin{gather}", 301 | right: "\\end{gather}", 302 | display: true 303 | }, { 304 | left: "\\begin{CD}", 305 | right: "\\end{CD}", 306 | display: true 307 | }, { 308 | left: "\\[", 309 | right: "\\]", 310 | display: true 311 | }]; 312 | optionsCopy.ignoredTags = optionsCopy.ignoredTags || ["script", "noscript", "style", "textarea", "pre", "code", "option"]; 313 | optionsCopy.ignoredClasses = optionsCopy.ignoredClasses || []; 314 | optionsCopy.errorCallback = optionsCopy.errorCallback || console.error; // Enable sharing of global macros defined via `\gdef` between different 315 | // math elements within a single call to `renderMathInElement`. 316 | 317 | optionsCopy.macros = optionsCopy.macros || {}; 318 | renderElem(elem, optionsCopy); 319 | }; 320 | 321 | /* harmony default export */ var auto_render = (renderMathInElement); 322 | }(); 323 | __webpack_exports__ = __webpack_exports__["default"]; 324 | /******/ return __webpack_exports__; 325 | /******/ })() 326 | ; 327 | }); -------------------------------------------------------------------------------- /docs/katex/contrib/auto-render.min.js: -------------------------------------------------------------------------------- 1 | !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("katex")):"function"==typeof define&&define.amd?define(["katex"],t):"object"==typeof exports?exports.renderMathInElement=t(require("katex")):e.renderMathInElement=t(e.katex)}("undefined"!=typeof self?self:this,(function(e){return function(){"use strict";var t={771:function(t){t.exports=e}},r={};function n(e){var a=r[e];if(void 0!==a)return a.exports;var i=r[e]={exports:{}};return t[e](i,i.exports,n),i.exports}n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,{a:t}),t},n.d=function(e,t){for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)};var a={};return function(){n.d(a,{default:function(){return s}});var e=n(771),t=n.n(e),r=function(e,t,r){for(var n=r,a=0,i=e.length;n0&&(a.push({type:"text",data:e.slice(0,n)}),e=e.slice(n));var l=t.findIndex((function(t){return e.startsWith(t.left)}));if(-1===(n=r(t[l].right,e,t[l].left.length)))break;var d=e.slice(0,n+t[l].right.length),s=i.test(d)?d:e.slice(t[l].left.length,n);a.push({type:"math",data:s,rawData:d,display:t[l].display}),e=e.slice(n+t[l].right.length)}return""!==e&&a.push({type:"text",data:e}),a},l=function(e,r){var n=o(e,r.delimiters);if(1===n.length&&"text"===n[0].type)return null;for(var a=document.createDocumentFragment(),i=0;i escapeRegex(x.left)).join("|") + ")"); 40 | 41 | while (true) { 42 | index = text.search(regexLeft); 43 | 44 | if (index === -1) { 45 | break; 46 | } 47 | 48 | if (index > 0) { 49 | data.push({ 50 | type: "text", 51 | data: text.slice(0, index) 52 | }); 53 | text = text.slice(index); // now text starts with delimiter 54 | } // ... so this always succeeds: 55 | 56 | 57 | var i = delimiters.findIndex(delim => text.startsWith(delim.left)); 58 | index = findEndOfMath(delimiters[i].right, text, delimiters[i].left.length); 59 | 60 | if (index === -1) { 61 | break; 62 | } 63 | 64 | var rawData = text.slice(0, index + delimiters[i].right.length); 65 | var math = amsRegex.test(rawData) ? rawData : text.slice(delimiters[i].left.length, index); 66 | data.push({ 67 | type: "math", 68 | data: math, 69 | rawData, 70 | display: delimiters[i].display 71 | }); 72 | text = text.slice(index + delimiters[i].right.length); 73 | } 74 | 75 | if (text !== "") { 76 | data.push({ 77 | type: "text", 78 | data: text 79 | }); 80 | } 81 | 82 | return data; 83 | }; 84 | 85 | /* eslint no-console:0 */ 86 | /* Note: optionsCopy is mutated by this method. If it is ever exposed in the 87 | * API, we should copy it before mutating. 88 | */ 89 | 90 | var renderMathInText = function renderMathInText(text, optionsCopy) { 91 | var data = splitAtDelimiters(text, optionsCopy.delimiters); 92 | 93 | if (data.length === 1 && data[0].type === 'text') { 94 | // There is no formula in the text. 95 | // Let's return null which means there is no need to replace 96 | // the current text node with a new one. 97 | return null; 98 | } 99 | 100 | var fragment = document.createDocumentFragment(); 101 | 102 | for (var i = 0; i < data.length; i++) { 103 | if (data[i].type === "text") { 104 | fragment.appendChild(document.createTextNode(data[i].data)); 105 | } else { 106 | var span = document.createElement("span"); 107 | var math = data[i].data; // Override any display mode defined in the settings with that 108 | // defined by the text itself 109 | 110 | optionsCopy.displayMode = data[i].display; 111 | 112 | try { 113 | if (optionsCopy.preProcess) { 114 | math = optionsCopy.preProcess(math); 115 | } 116 | 117 | katex.render(math, span, optionsCopy); 118 | } catch (e) { 119 | if (!(e instanceof katex.ParseError)) { 120 | throw e; 121 | } 122 | 123 | optionsCopy.errorCallback("KaTeX auto-render: Failed to parse `" + data[i].data + "` with ", e); 124 | fragment.appendChild(document.createTextNode(data[i].rawData)); 125 | continue; 126 | } 127 | 128 | fragment.appendChild(span); 129 | } 130 | } 131 | 132 | return fragment; 133 | }; 134 | 135 | var renderElem = function renderElem(elem, optionsCopy) { 136 | for (var i = 0; i < elem.childNodes.length; i++) { 137 | var childNode = elem.childNodes[i]; 138 | 139 | if (childNode.nodeType === 3) { 140 | // Text node 141 | var frag = renderMathInText(childNode.textContent, optionsCopy); 142 | 143 | if (frag) { 144 | i += frag.childNodes.length - 1; 145 | elem.replaceChild(frag, childNode); 146 | } 147 | } else if (childNode.nodeType === 1) { 148 | (function () { 149 | // Element node 150 | var className = ' ' + childNode.className + ' '; 151 | var shouldRender = optionsCopy.ignoredTags.indexOf(childNode.nodeName.toLowerCase()) === -1 && optionsCopy.ignoredClasses.every(x => className.indexOf(' ' + x + ' ') === -1); 152 | 153 | if (shouldRender) { 154 | renderElem(childNode, optionsCopy); 155 | } 156 | })(); 157 | } // Otherwise, it's something else, and ignore it. 158 | 159 | } 160 | }; 161 | 162 | var renderMathInElement = function renderMathInElement(elem, options) { 163 | if (!elem) { 164 | throw new Error("No element provided to render"); 165 | } 166 | 167 | var optionsCopy = {}; // Object.assign(optionsCopy, option) 168 | 169 | for (var option in options) { 170 | if (options.hasOwnProperty(option)) { 171 | optionsCopy[option] = options[option]; 172 | } 173 | } // default options 174 | 175 | 176 | optionsCopy.delimiters = optionsCopy.delimiters || [{ 177 | left: "$$", 178 | right: "$$", 179 | display: true 180 | }, { 181 | left: "\\(", 182 | right: "\\)", 183 | display: false 184 | }, // LaTeX uses $…$, but it ruins the display of normal `$` in text: 185 | // {left: "$", right: "$", display: false}, 186 | // $ must come after $$ 187 | // Render AMS environments even if outside $$…$$ delimiters. 188 | { 189 | left: "\\begin{equation}", 190 | right: "\\end{equation}", 191 | display: true 192 | }, { 193 | left: "\\begin{align}", 194 | right: "\\end{align}", 195 | display: true 196 | }, { 197 | left: "\\begin{alignat}", 198 | right: "\\end{alignat}", 199 | display: true 200 | }, { 201 | left: "\\begin{gather}", 202 | right: "\\end{gather}", 203 | display: true 204 | }, { 205 | left: "\\begin{CD}", 206 | right: "\\end{CD}", 207 | display: true 208 | }, { 209 | left: "\\[", 210 | right: "\\]", 211 | display: true 212 | }]; 213 | optionsCopy.ignoredTags = optionsCopy.ignoredTags || ["script", "noscript", "style", "textarea", "pre", "code", "option"]; 214 | optionsCopy.ignoredClasses = optionsCopy.ignoredClasses || []; 215 | optionsCopy.errorCallback = optionsCopy.errorCallback || console.error; // Enable sharing of global macros defined via `\gdef` between different 216 | // math elements within a single call to `renderMathInElement`. 217 | 218 | optionsCopy.macros = optionsCopy.macros || {}; 219 | renderElem(elem, optionsCopy); 220 | }; 221 | 222 | export { renderMathInElement as default }; 223 | -------------------------------------------------------------------------------- /docs/katex/contrib/copy-tex.css: -------------------------------------------------------------------------------- 1 | /* Force selection of entire .katex/.katex-display blocks, so that we can 2 | * copy/paste the entire source code. If you omit this CSS, partial 3 | * selections of a formula will work, but will copy the ugly HTML 4 | * representation instead of the LaTeX source code. (Full selections will 5 | * still produce the LaTeX source code.) 6 | */ 7 | .katex, 8 | .katex-display { 9 | -webkit-user-select: all; 10 | -moz-user-select: all; 11 | -ms-user-select: all; 12 | user-select: all; 13 | } 14 | 15 | -------------------------------------------------------------------------------- /docs/katex/contrib/copy-tex.js: -------------------------------------------------------------------------------- 1 | (function webpackUniversalModuleDefinition(root, factory) { 2 | if(typeof exports === 'object' && typeof module === 'object') 3 | module.exports = factory(); 4 | else if(typeof define === 'function' && define.amd) 5 | define([], factory); 6 | else { 7 | var a = factory(); 8 | for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i]; 9 | } 10 | })((typeof self !== 'undefined' ? self : this), function() { 11 | return /******/ (function() { // webpackBootstrap 12 | /******/ "use strict"; 13 | var __webpack_exports__ = {}; 14 | 15 | ;// CONCATENATED MODULE: ./contrib/copy-tex/katex2tex.js 16 | // Set these to how you want inline and display math to be delimited. 17 | var defaultCopyDelimiters = { 18 | inline: ['$', '$'], 19 | // alternative: ['\(', '\)'] 20 | display: ['$$', '$$'] // alternative: ['\[', '\]'] 21 | 22 | }; // Replace .katex elements with their TeX source ( element). 23 | // Modifies fragment in-place. Useful for writing your own 'copy' handler, 24 | // as in copy-tex.js. 25 | 26 | var katexReplaceWithTex = function katexReplaceWithTex(fragment, copyDelimiters) { 27 | if (copyDelimiters === void 0) { 28 | copyDelimiters = defaultCopyDelimiters; 29 | } 30 | 31 | // Remove .katex-html blocks that are preceded by .katex-mathml blocks 32 | // (which will get replaced below). 33 | var katexHtml = fragment.querySelectorAll('.katex-mathml + .katex-html'); 34 | 35 | for (var i = 0; i < katexHtml.length; i++) { 36 | var element = katexHtml[i]; 37 | 38 | if (element.remove) { 39 | element.remove(null); 40 | } else { 41 | element.parentNode.removeChild(element); 42 | } 43 | } // Replace .katex-mathml elements with their annotation (TeX source) 44 | // descendant, with inline delimiters. 45 | 46 | 47 | var katexMathml = fragment.querySelectorAll('.katex-mathml'); 48 | 49 | for (var _i = 0; _i < katexMathml.length; _i++) { 50 | var _element = katexMathml[_i]; 51 | 52 | var texSource = _element.querySelector('annotation'); 53 | 54 | if (texSource) { 55 | if (_element.replaceWith) { 56 | _element.replaceWith(texSource); 57 | } else { 58 | _element.parentNode.replaceChild(texSource, _element); 59 | } 60 | 61 | texSource.innerHTML = copyDelimiters.inline[0] + texSource.innerHTML + copyDelimiters.inline[1]; 62 | } 63 | } // Switch display math to display delimiters. 64 | 65 | 66 | var displays = fragment.querySelectorAll('.katex-display annotation'); 67 | 68 | for (var _i2 = 0; _i2 < displays.length; _i2++) { 69 | var _element2 = displays[_i2]; 70 | _element2.innerHTML = copyDelimiters.display[0] + _element2.innerHTML.substr(copyDelimiters.inline[0].length, _element2.innerHTML.length - copyDelimiters.inline[0].length - copyDelimiters.inline[1].length) + copyDelimiters.display[1]; 71 | } 72 | 73 | return fragment; 74 | }; 75 | /* harmony default export */ var katex2tex = (katexReplaceWithTex); 76 | ;// CONCATENATED MODULE: ./contrib/copy-tex/copy-tex.js 77 | // Global copy handler to modify behavior on .katex elements. 78 | 79 | document.addEventListener('copy', function (event) { 80 | var selection = window.getSelection(); 81 | 82 | if (selection.isCollapsed) { 83 | return; // default action OK if selection is empty 84 | } 85 | 86 | var fragment = selection.getRangeAt(0).cloneContents(); 87 | 88 | if (!fragment.querySelector('.katex-mathml')) { 89 | return; // default action OK if no .katex-mathml elements 90 | } // Preserve usual HTML copy/paste behavior. 91 | 92 | 93 | var html = []; 94 | 95 | for (var i = 0; i < fragment.childNodes.length; i++) { 96 | html.push(fragment.childNodes[i].outerHTML); 97 | } 98 | 99 | event.clipboardData.setData('text/html', html.join('')); // Rewrite plain-text version. 100 | 101 | event.clipboardData.setData('text/plain', katex2tex(fragment).textContent); // Prevent normal copy handling. 102 | 103 | event.preventDefault(); 104 | }); 105 | ;// CONCATENATED MODULE: ./contrib/copy-tex/copy-tex.webpack.js 106 | /** 107 | * This is the webpack entry point for KaTeX. As ECMAScript doesn't support 108 | * CSS modules natively, a separate entry point is used. 109 | */ 110 | 111 | 112 | __webpack_exports__ = __webpack_exports__["default"]; 113 | /******/ return __webpack_exports__; 114 | /******/ })() 115 | ; 116 | }); -------------------------------------------------------------------------------- /docs/katex/contrib/copy-tex.min.css: -------------------------------------------------------------------------------- 1 | .katex,.katex-display{-webkit-user-select:all;-moz-user-select:all;-ms-user-select:all;user-select:all} 2 | -------------------------------------------------------------------------------- /docs/katex/contrib/copy-tex.min.js: -------------------------------------------------------------------------------- 1 | !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();for(var l in n)("object"==typeof exports?exports:e)[l]=n[l]}}("undefined"!=typeof self?self:this,(function(){return function(){"use strict";var e={},t={inline:["$","$"],display:["$$","$$"]},n=function(e,n){void 0===n&&(n=t);for(var l=e.querySelectorAll(".katex-mathml + .katex-html"),r=0;r element). 8 | // Modifies fragment in-place. Useful for writing your own 'copy' handler, 9 | // as in copy-tex.js. 10 | 11 | var katexReplaceWithTex = function katexReplaceWithTex(fragment, copyDelimiters) { 12 | if (copyDelimiters === void 0) { 13 | copyDelimiters = defaultCopyDelimiters; 14 | } 15 | 16 | // Remove .katex-html blocks that are preceded by .katex-mathml blocks 17 | // (which will get replaced below). 18 | var katexHtml = fragment.querySelectorAll('.katex-mathml + .katex-html'); 19 | 20 | for (var i = 0; i < katexHtml.length; i++) { 21 | var element = katexHtml[i]; 22 | 23 | if (element.remove) { 24 | element.remove(null); 25 | } else { 26 | element.parentNode.removeChild(element); 27 | } 28 | } // Replace .katex-mathml elements with their annotation (TeX source) 29 | // descendant, with inline delimiters. 30 | 31 | 32 | var katexMathml = fragment.querySelectorAll('.katex-mathml'); 33 | 34 | for (var _i = 0; _i < katexMathml.length; _i++) { 35 | var _element = katexMathml[_i]; 36 | 37 | var texSource = _element.querySelector('annotation'); 38 | 39 | if (texSource) { 40 | if (_element.replaceWith) { 41 | _element.replaceWith(texSource); 42 | } else { 43 | _element.parentNode.replaceChild(texSource, _element); 44 | } 45 | 46 | texSource.innerHTML = copyDelimiters.inline[0] + texSource.innerHTML + copyDelimiters.inline[1]; 47 | } 48 | } // Switch display math to display delimiters. 49 | 50 | 51 | var displays = fragment.querySelectorAll('.katex-display annotation'); 52 | 53 | for (var _i2 = 0; _i2 < displays.length; _i2++) { 54 | var _element2 = displays[_i2]; 55 | _element2.innerHTML = copyDelimiters.display[0] + _element2.innerHTML.substr(copyDelimiters.inline[0].length, _element2.innerHTML.length - copyDelimiters.inline[0].length - copyDelimiters.inline[1].length) + copyDelimiters.display[1]; 56 | } 57 | 58 | return fragment; 59 | }; 60 | 61 | document.addEventListener('copy', function (event) { 62 | var selection = window.getSelection(); 63 | 64 | if (selection.isCollapsed) { 65 | return; // default action OK if selection is empty 66 | } 67 | 68 | var fragment = selection.getRangeAt(0).cloneContents(); 69 | 70 | if (!fragment.querySelector('.katex-mathml')) { 71 | return; // default action OK if no .katex-mathml elements 72 | } // Preserve usual HTML copy/paste behavior. 73 | 74 | 75 | var html = []; 76 | 77 | for (var i = 0; i < fragment.childNodes.length; i++) { 78 | html.push(fragment.childNodes[i].outerHTML); 79 | } 80 | 81 | event.clipboardData.setData('text/html', html.join('')); // Rewrite plain-text version. 82 | 83 | event.clipboardData.setData('text/plain', katexReplaceWithTex(fragment).textContent); // Prevent normal copy handling. 84 | 85 | event.preventDefault(); 86 | }); 87 | -------------------------------------------------------------------------------- /docs/katex/contrib/mathtex-script-type.js: -------------------------------------------------------------------------------- 1 | (function webpackUniversalModuleDefinition(root, factory) { 2 | if(typeof exports === 'object' && typeof module === 'object') 3 | module.exports = factory(require("katex")); 4 | else if(typeof define === 'function' && define.amd) 5 | define(["katex"], factory); 6 | else { 7 | var a = typeof exports === 'object' ? factory(require("katex")) : factory(root["katex"]); 8 | for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i]; 9 | } 10 | })((typeof self !== 'undefined' ? self : this), function(__WEBPACK_EXTERNAL_MODULE__771__) { 11 | return /******/ (function() { // webpackBootstrap 12 | /******/ "use strict"; 13 | /******/ var __webpack_modules__ = ({ 14 | 15 | /***/ 771: 16 | /***/ (function(module) { 17 | 18 | module.exports = __WEBPACK_EXTERNAL_MODULE__771__; 19 | 20 | /***/ }) 21 | 22 | /******/ }); 23 | /************************************************************************/ 24 | /******/ // The module cache 25 | /******/ var __webpack_module_cache__ = {}; 26 | /******/ 27 | /******/ // The require function 28 | /******/ function __webpack_require__(moduleId) { 29 | /******/ // Check if module is in cache 30 | /******/ var cachedModule = __webpack_module_cache__[moduleId]; 31 | /******/ if (cachedModule !== undefined) { 32 | /******/ return cachedModule.exports; 33 | /******/ } 34 | /******/ // Create a new module (and put it into the cache) 35 | /******/ var module = __webpack_module_cache__[moduleId] = { 36 | /******/ // no module.id needed 37 | /******/ // no module.loaded needed 38 | /******/ exports: {} 39 | /******/ }; 40 | /******/ 41 | /******/ // Execute the module function 42 | /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); 43 | /******/ 44 | /******/ // Return the exports of the module 45 | /******/ return module.exports; 46 | /******/ } 47 | /******/ 48 | /************************************************************************/ 49 | /******/ /* webpack/runtime/compat get default export */ 50 | /******/ !function() { 51 | /******/ // getDefaultExport function for compatibility with non-harmony modules 52 | /******/ __webpack_require__.n = function(module) { 53 | /******/ var getter = module && module.__esModule ? 54 | /******/ function() { return module['default']; } : 55 | /******/ function() { return module; }; 56 | /******/ __webpack_require__.d(getter, { a: getter }); 57 | /******/ return getter; 58 | /******/ }; 59 | /******/ }(); 60 | /******/ 61 | /******/ /* webpack/runtime/define property getters */ 62 | /******/ !function() { 63 | /******/ // define getter functions for harmony exports 64 | /******/ __webpack_require__.d = function(exports, definition) { 65 | /******/ for(var key in definition) { 66 | /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { 67 | /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); 68 | /******/ } 69 | /******/ } 70 | /******/ }; 71 | /******/ }(); 72 | /******/ 73 | /******/ /* webpack/runtime/hasOwnProperty shorthand */ 74 | /******/ !function() { 75 | /******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); } 76 | /******/ }(); 77 | /******/ 78 | /************************************************************************/ 79 | var __webpack_exports__ = {}; 80 | // This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk. 81 | !function() { 82 | /* harmony import */ var katex__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(771); 83 | /* harmony import */ var katex__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(katex__WEBPACK_IMPORTED_MODULE_0__); 84 | 85 | var scripts = document.body.getElementsByTagName("script"); 86 | scripts = Array.prototype.slice.call(scripts); 87 | scripts.forEach(function (script) { 88 | if (!script.type || !script.type.match(/math\/tex/i)) { 89 | return -1; 90 | } 91 | 92 | var display = script.type.match(/mode\s*=\s*display(;|\s|\n|$)/) != null; 93 | var katexElement = document.createElement(display ? "div" : "span"); 94 | katexElement.setAttribute("class", display ? "equation" : "inline-equation"); 95 | 96 | try { 97 | katex__WEBPACK_IMPORTED_MODULE_0___default().render(script.text, katexElement, { 98 | displayMode: display 99 | }); 100 | } catch (err) { 101 | //console.error(err); linter doesn't like this 102 | katexElement.textContent = script.text; 103 | } 104 | 105 | script.parentNode.replaceChild(katexElement, script); 106 | }); 107 | }(); 108 | __webpack_exports__ = __webpack_exports__["default"]; 109 | /******/ return __webpack_exports__; 110 | /******/ })() 111 | ; 112 | }); -------------------------------------------------------------------------------- /docs/katex/contrib/mathtex-script-type.min.js: -------------------------------------------------------------------------------- 1 | !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("katex"));else if("function"==typeof define&&define.amd)define(["katex"],t);else{var r="object"==typeof exports?t(require("katex")):t(e.katex);for(var n in r)("object"==typeof exports?exports:e)[n]=r[n]}}("undefined"!=typeof self?self:this,(function(e){return function(){"use strict";var t={771:function(t){t.exports=e}},r={};function n(e){var o=r[e];if(void 0!==o)return o.exports;var i=r[e]={exports:{}};return t[e](i,i.exports,n),i.exports}n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,{a:t}),t},n.d=function(e,t){for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)};var o,i,a,u={};return o=n(771),i=n.n(o),a=document.body.getElementsByTagName("script"),(a=Array.prototype.slice.call(a)).forEach((function(e){if(!e.type||!e.type.match(/math\/tex/i))return-1;var t=null!=e.type.match(/mode\s*=\s*display(;|\s|\n|$)/),r=document.createElement(t?"div":"span");r.setAttribute("class",t?"equation":"inline-equation");try{i().render(e.text,r,{displayMode:t})}catch(t){r.textContent=e.text}e.parentNode.replaceChild(r,e)})),u=u.default}()})); -------------------------------------------------------------------------------- /docs/katex/contrib/mathtex-script-type.mjs: -------------------------------------------------------------------------------- 1 | import katex from '../katex.mjs'; 2 | 3 | var scripts = document.body.getElementsByTagName("script"); 4 | scripts = Array.prototype.slice.call(scripts); 5 | scripts.forEach(function (script) { 6 | if (!script.type || !script.type.match(/math\/tex/i)) { 7 | return -1; 8 | } 9 | 10 | var display = script.type.match(/mode\s*=\s*display(;|\s|\n|$)/) != null; 11 | var katexElement = document.createElement(display ? "div" : "span"); 12 | katexElement.setAttribute("class", display ? "equation" : "inline-equation"); 13 | 14 | try { 15 | katex.render(script.text, katexElement, { 16 | displayMode: display 17 | }); 18 | } catch (err) { 19 | //console.error(err); linter doesn't like this 20 | katexElement.textContent = script.text; 21 | } 22 | 23 | script.parentNode.replaceChild(katexElement, script); 24 | }); 25 | -------------------------------------------------------------------------------- /docs/katex/contrib/render-a11y-string.min.js: -------------------------------------------------------------------------------- 1 | !function(e,r){if("object"==typeof exports&&"object"==typeof module)module.exports=r(require("katex"));else if("function"==typeof define&&define.amd)define(["katex"],r);else{var a="object"==typeof exports?r(require("katex")):r(e.katex);for(var t in a)("object"==typeof exports?exports:e)[t]=a[t]}}("undefined"!=typeof self?self:this,(function(e){return function(){"use strict";var r={771:function(r){r.exports=e}},a={};function t(e){var o=a[e];if(void 0!==o)return o.exports;var n=a[e]={exports:{}};return r[e](n,n.exports,t),n.exports}t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,{a:r}),r},t.d=function(e,r){for(var a in r)t.o(r,a)&&!t.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:r[a]})},t.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)};var o,n,s,i,l,c,u,p,d,b,h,m,f,y,w={};return o=t(771),n=t.n(o),s={"(":"left parenthesis",")":"right parenthesis","[":"open bracket","]":"close bracket","\\{":"left brace","\\}":"right brace","\\lvert":"open vertical bar","\\rvert":"close vertical bar","|":"vertical bar","\\uparrow":"up arrow","\\Uparrow":"up arrow","\\downarrow":"down arrow","\\Downarrow":"down arrow","\\updownarrow":"up down arrow","\\leftarrow":"left arrow","\\Leftarrow":"left arrow","\\rightarrow":"right arrow","\\Rightarrow":"right arrow","\\langle":"open angle","\\rangle":"close angle","\\lfloor":"open floor","\\rfloor":"close floor","\\int":"integral","\\intop":"integral","\\lim":"limit","\\ln":"natural log","\\log":"log","\\sin":"sine","\\cos":"cosine","\\tan":"tangent","\\cot":"cotangent","\\sum":"sum","/":"slash",",":"comma",".":"point","-":"negative","+":"plus","~":"tilde",":":"colon","?":"question mark","'":"apostrophe","\\%":"percent"," ":"space","\\ ":"space","\\$":"dollar sign","\\angle":"angle","\\degree":"degree","\\circ":"circle","\\vec":"vector","\\triangle":"triangle","\\pi":"pi","\\prime":"prime","\\infty":"infinity","\\alpha":"alpha","\\beta":"beta","\\gamma":"gamma","\\omega":"omega","\\theta":"theta","\\sigma":"sigma","\\lambda":"lambda","\\tau":"tau","\\Delta":"delta","\\delta":"delta","\\mu":"mu","\\rho":"rho","\\nabla":"del","\\ell":"ell","\\ldots":"dots","\\hat":"hat","\\acute":"acute"},i={prime:"prime",degree:"degrees",circle:"degrees",2:"squared",3:"cubed"},l={"|":"open vertical bar",".":""},c={"|":"close vertical bar",".":""},u={"+":"plus","-":"minus","\\pm":"plus minus","\\cdot":"dot","*":"times","/":"divided by","\\times":"times","\\div":"divided by","\\circ":"circle","\\bullet":"bullet"},p={"=":"equals","\\approx":"approximately equals","\u2260":"does not equal","\\geq":"is greater than or equal to","\\ge":"is greater than or equal to","\\leq":"is less than or equal to","\\le":"is less than or equal to",">":"is greater than","<":"is less than","\\leftarrow":"left arrow","\\Leftarrow":"left arrow","\\rightarrow":"right arrow","\\Rightarrow":"right arrow",":":"colon"},d={"\\underleftarrow":"left arrow","\\underrightarrow":"right arrow","\\underleftrightarrow":"left-right arrow","\\undergroup":"group","\\underlinesegment":"line segment","\\utilde":"tilde"},b=function(e,r,a){var t;e&&(/^\d+$/.test(t="open"===r?e in l?l[e]:s[e]||e:"close"===r?e in c?c[e]:s[e]||e:"bin"===r?u[e]||e:"rel"===r?p[e]||e:s[e]||e)&&a.length>0&&/^\d+$/.test(a[a.length-1])?a[a.length-1]+=t:t&&a.push(t))},h=function(e,r){var a=[];e.push(a),r(a)},m=function(e,r,a){switch(e.type){case"accent":h(r,(function(r){f(e.base,r,a),r.push("with"),b(e.label,"normal",r),r.push("on top")}));break;case"accentUnder":h(r,(function(r){f(e.base,r,a),r.push("with"),b(d[e.label],"normal",r),r.push("underneath")}));break;case"accent-token":break;case"atom":var t=e.text;switch(e.family){case"bin":b(t,"bin",r);break;case"close":b(t,"close",r);break;case"inner":b(e.text,"inner",r);break;case"open":b(t,"open",r);break;case"punct":b(t,"punct",r);break;case"rel":b(t,"rel",r);break;default:throw e.family,new Error('"'+e.family+'" is not a valid atom type')}break;case"color":var o=e.color.replace(/katex-/,"");h(r,(function(r){r.push("start color "+o),f(e.body,r,a),r.push("end color "+o)}));break;case"color-token":break;case"delimsizing":e.delim&&"."!==e.delim&&b(e.delim,"normal",r);break;case"genfrac":h(r,(function(r){var t=e.leftDelim,o=e.rightDelim;e.hasBarLine?(r.push("start fraction"),t&&b(t,"open",r),f(e.numer,r,a),r.push("divided by"),f(e.denom,r,a),o&&b(o,"close",r),r.push("end fraction")):(r.push("start binomial"),t&&b(t,"open",r),f(e.numer,r,a),r.push("over"),f(e.denom,r,a),o&&b(o,"close",r),r.push("end binomial"))}));break;case"hbox":f(e.body,r,a);break;case"kern":break;case"leftright":h(r,(function(r){b(e.left,"open",r),f(e.body,r,a),b(e.right,"close",r)}));break;case"leftright-right":break;case"lap":f(e.body,r,a);break;case"mathord":b(e.text,"normal",r);break;case"op":var n=e.body,s=e.name;n?f(n,r,a):s&&b(s,"normal",r);break;case"op-token":b(e.text,a,r);break;case"ordgroup":f(e.body,r,a);break;case"overline":h(r,(function(r){r.push("start overline"),f(e.body,r,a),r.push("end overline")}));break;case"phantom":r.push("empty space");break;case"raisebox":f(e.body,r,a);break;case"rule":r.push("rectangle");break;case"sizing":f(e.body,r,a);break;case"spacing":r.push("space");break;case"styling":f(e.body,r,a);break;case"sqrt":h(r,(function(r){var t=e.body,o=e.index;if(o)return"3"===y(f(o,[],a)).join(",")?(r.push("cube root of"),f(t,r,a),void r.push("end cube root")):(r.push("root"),r.push("start index"),f(o,r,a),void r.push("end index"));r.push("square root of"),f(t,r,a),r.push("end square root")}));break;case"supsub":var l=e.base,c=e.sub,u=e.sup,p=!1;if(l&&(f(l,r,a),p="op"===l.type&&"\\log"===l.name),c){var m=p?"base":"subscript";h(r,(function(e){e.push("start "+m),f(c,e,a),e.push("end "+m)}))}u&&h(r,(function(e){var r=y(f(u,[],a)).join(",");r in i?e.push(i[r]):(e.push("start superscript"),f(u,e,a),e.push("end superscript"))}));break;case"text":if("\\textbf"===e.font){h(r,(function(r){r.push("start bold text"),f(e.body,r,a),r.push("end bold text")}));break}h(r,(function(r){r.push("start text"),f(e.body,r,a),r.push("end text")}));break;case"textord":b(e.text,a,r);break;case"smash":f(e.body,r,a);break;case"enclose":if(/cancel/.test(e.label)){h(r,(function(r){r.push("start cancel"),f(e.body,r,a),r.push("end cancel")}));break}if(/box/.test(e.label)){h(r,(function(r){r.push("start box"),f(e.body,r,a),r.push("end box")}));break}if(/sout/.test(e.label)){h(r,(function(r){r.push("start strikeout"),f(e.body,r,a),r.push("end strikeout")}));break}if(/phase/.test(e.label)){h(r,(function(r){r.push("start phase angle"),f(e.body,r,a),r.push("end phase angle")}));break}throw new Error("KaTeX-a11y: enclose node with "+e.label+" not supported yet");case"vcenter":f(e.body,r,a);break;case"vphantom":throw new Error("KaTeX-a11y: vphantom not implemented yet");case"hphantom":throw new Error("KaTeX-a11y: hphantom not implemented yet");case"operatorname":f(e.body,r,a);break;case"array":throw new Error("KaTeX-a11y: array not implemented yet");case"raw":throw new Error("KaTeX-a11y: raw not implemented yet");case"size":break;case"url":throw new Error("KaTeX-a11y: url not implemented yet");case"tag":throw new Error("KaTeX-a11y: tag not implemented yet");case"verb":b("start verbatim","normal",r),b(e.body,"normal",r),b("end verbatim","normal",r);break;case"environment":throw new Error("KaTeX-a11y: environment not implemented yet");case"horizBrace":b("start "+e.label.slice(1),"normal",r),f(e.base,r,a),b("end "+e.label.slice(1),"normal",r);break;case"infix":break;case"includegraphics":throw new Error("KaTeX-a11y: includegraphics not implemented yet");case"font":f(e.body,r,a);break;case"href":throw new Error("KaTeX-a11y: href not implemented yet");case"cr":throw new Error("KaTeX-a11y: cr not implemented yet");case"underline":h(r,(function(r){r.push("start underline"),f(e.body,r,a),r.push("end underline")}));break;case"xArrow":throw new Error("KaTeX-a11y: xArrow not implemented yet");case"cdlabel":throw new Error("KaTeX-a11y: cdlabel not implemented yet");case"cdlabelparent":throw new Error("KaTeX-a11y: cdlabelparent not implemented yet");case"mclass":var w=e.mclass.slice(1);f(e.body,r,w);break;case"mathchoice":f(e.text,r,a);break;case"htmlmathml":f(e.mathml,r,a);break;case"middle":b(e.delim,a,r);break;case"internal":break;case"html":f(e.body,r,a);break;default:throw e.type,new Error("KaTeX a11y un-recognized type: "+e.type)}},f=function e(r,a,t){if(void 0===a&&(a=[]),r instanceof Array)for(var o=0;o total + term * term, 0); 4 | }; 5 | 6 | function lineDistance2(points, line) { 7 | const normal = line.direction.orthogonal(); 8 | const distances = points.map(p => Vec.sub(p, line.origin).dot(normal)); 9 | return sumOfSquares(distances); 10 | }; 11 | function varsToLine(vars) { 12 | return { 13 | origin: new Vec(vars[0], vars[1]), 14 | direction: Vec.fromAngle(vars[2]) 15 | } 16 | } 17 | 18 | function makeLineCost(points) { 19 | return vars => lineDistance2(points, varsToLine(vars)); 20 | }; 21 | 22 | function tryLineFit(points) { 23 | const centroid = Vec.centroid(points); 24 | 25 | const initial = [ centroid.x, centroid.y, 0 ]; 26 | const result = multivarOptimize(initial, makeLineCost(points), { 27 | maxIterations: 1000 28 | }); 29 | 30 | return { 31 | cost: result.cost, 32 | path: lineToDrawing(points, varsToLine(result.vars)) 33 | }; 34 | }; 35 | 36 | function lineToDrawing(points, line) { 37 | const distances = points.map(p => Vec.sub(p, line.origin).dot(line.direction)); 38 | const start = Math.min.apply(Math, distances); 39 | const end = Math.max.apply(Math, distances); 40 | 41 | return [ 42 | Vec.add(line.origin, Vec.scale(line.direction, start)), 43 | Vec.add(line.origin, Vec.scale(line.direction, end)) 44 | ]; 45 | }; 46 | function circleDistance(point, circle) { 47 | var v = Vec.sub(point, circle.origin); 48 | return Math.abs(v.len() - circle.radius); 49 | }; 50 | 51 | function circleDistance2(points, circle) { 52 | return sumOfSquares(points.map(p => circleDistance(p, circle))); 53 | }; 54 | 55 | function varsToCircle(vars) { 56 | return { 57 | origin: new Vec(vars[0], vars[1]), 58 | radius: vars[2] 59 | } 60 | }; 61 | 62 | function makeCircleCost(points) { 63 | return vars => circleDistance2(points, varsToCircle(vars)); 64 | }; 65 | 66 | function tryCircleFit(points) { 67 | const centroid = Vec.centroid(points); 68 | const [minPoint, maxPoint] = Vec.bounds(points); 69 | 70 | const initial = [ 71 | centroid.x, centroid.y, 72 | Math.max(maxPoint.x - minPoint.x, maxPoint.y - minPoint.y) 73 | ]; 74 | const result = multivarOptimize(initial, makeCircleCost(points), { 75 | maxIterations: 1000 76 | }); 77 | 78 | const circle = varsToCircle(result.vars); 79 | if (!circleMatches(points, circle)) return null; 80 | 81 | return { 82 | cost: result.cost, 83 | circle: circle 84 | }; 85 | }; 86 | 87 | function circleMatches(path, circle) { 88 | const circumference = 2.0 * Math.PI * circle.radius; 89 | if (circumference < 10) return false; 90 | 91 | const ratio = Vec.pathLen(path) / circumference; 92 | return Math.abs(ratio - 1.0) < 0.15; 93 | }; 94 | function simpleRectDistance(point, size) { 95 | function classify(x, min, max) { 96 | if (x < min) { 97 | return -1; 98 | } else if (x > max) { 99 | return 1; 100 | } else { 101 | return 0; 102 | } 103 | } 104 | const sideX = classify(point.x, 0, size.x); 105 | const sideY = classify(point.y, 0, size.y); 106 | switch (sideX) { 107 | case -1: 108 | switch (sideY) { 109 | case -1: return point.len(); 110 | case 0: return -point.x; 111 | case 1: return Vec.dist(point, new Vec(0, size.y)); 112 | } 113 | case 0: 114 | switch (sideY) { 115 | case -1: return -point.y; 116 | case 0: return Math.min(point.x, point.y, size.x - point.x, size.y - point.y); 117 | case 1: return point.y - size.y; 118 | } 119 | case 1: 120 | switch (sideY) { 121 | case -1: return Vec.dist(point, new Vec(size.x, 0)); 122 | case 0: return point.x - size.x; 123 | case 1: return Vec.dist(point, size); 124 | } 125 | } 126 | }; 127 | function simpleRectDistances2(points, size) { 128 | return sumOfSquares(points.map(p => simpleRectDistance(p, size))); 129 | }; 130 | 131 | function buildTransform(translate, angle) { 132 | const A = new AffineTransform(); 133 | A.t = translate; 134 | A.m = Matrix.fromAngle(angle); 135 | return A; 136 | }; 137 | 138 | function orientedRectDistances2(points, rect) { 139 | const A = buildTransform(rect.translate, rect.angle); 140 | const B = AffineTransform.inverse(A); 141 | 142 | const localPoints = points.map(p => B.transform(p)); 143 | return simpleRectDistances2(localPoints, rect.size); 144 | }; 145 | 146 | function varsToRect(vars) { 147 | return { 148 | translate: new Vec(vars[0], vars[1]), 149 | size: new Vec(vars[2], vars[3]), 150 | angle: vars[4] 151 | }; 152 | }; 153 | 154 | function makeRectCost(points) { 155 | return vars => orientedRectDistances2(points, varsToRect(vars)); 156 | }; 157 | 158 | function tryRectFit(points) { 159 | const [ minPoint, maxPoint ] = Vec.bounds(points); 160 | 161 | const initial = [ 162 | minPoint.x, minPoint.y, 163 | maxPoint.x - minPoint.x, maxPoint.y - minPoint.y, 164 | 0 165 | ]; 166 | 167 | const result = multivarOptimize(initial, makeRectCost(points), { 168 | maxIterations: 1000 169 | }); 170 | 171 | const rect = varsToRect(result.vars); 172 | if (!rectMatches(points, rect)) return null; 173 | 174 | return { 175 | cost: result.cost, 176 | path: rectToDrawing(rect) 177 | }; 178 | }; 179 | function rectMatches(path, rect) { 180 | if (rect.size.x < 6 || rect.size.y < 6) { 181 | return false; 182 | } 183 | 184 | const length = rect.size.x * 2 + rect.size.y * 2; 185 | const ratio = Vec.pathLen(path) / length; 186 | return Math.abs(ratio - 1.0) < 0.15; 187 | }; 188 | function rectToDrawing(rect) { 189 | const points = [ 190 | new Vec(0, 0), 191 | new Vec(rect.size.x, 0), 192 | new Vec(rect.size.x, rect.size.y), 193 | new Vec(0, rect.size.y), 194 | new Vec(0, 0) 195 | ]; 196 | 197 | const A = buildTransform(rect.translate, rect.angle); 198 | return points.map(p => A.transform(p)); 199 | }; 200 | 201 | var fitFunctions = [ 202 | tryLineFit, 203 | tryCircleFit, 204 | tryRectFit 205 | ]; 206 | 207 | function tryShapeFit(path) { 208 | const results = fitFunctions.map(f => f(path)).filter(x => x); 209 | const best = results.reduce((a, b) => b.cost < a.cost ? b : a); 210 | 211 | function acceptableTolerance(path) { 212 | const perPointTolerance = 6.0; 213 | return path.length * perPointTolerance * perPointTolerance; 214 | } 215 | 216 | if (best.cost < acceptableTolerance(path)) { 217 | return best; 218 | } 219 | }; 220 | -------------------------------------------------------------------------------- /docs/src/draw.js: -------------------------------------------------------------------------------- 1 | // Created by Justin Meiners (2022) 2 | // License: MIT 3 | 4 | "use strict"; 5 | function Sim() { 6 | this.canvas = document.getElementById('main-canvas'); 7 | this.ctx = this.canvas.getContext('2d', { alpha: false }); 8 | 9 | this.canvas.onmousedown = this.mouseDown.bind(this); 10 | this.canvas.onmouseup = this.mouseUp.bind(this); 11 | this.canvas.onmouseout = this.mouseOut.bind(this); 12 | this.canvas.onmousemove = this.mouseMove.bind(this); 13 | 14 | this.shapes = []; 15 | }; 16 | 17 | 18 | document.getElementById("clear-button").onclick = function() { 19 | sim.shapes = []; 20 | drawSim(); 21 | }; 22 | 23 | function getMousePos(canvas, e) { 24 | var rect = canvas.getBoundingClientRect(); 25 | return new Vec(e.clientX - rect.left, e.clientY - rect.top); 26 | } 27 | 28 | Sim.prototype.mouseDown = function(e) { 29 | var mp = getMousePos(this.canvas, e); 30 | this.path = []; 31 | this.path.push(mp); 32 | this.dragging = true; 33 | 34 | e.preventDefault(); 35 | }; 36 | 37 | Sim.prototype.mouseMove = function(e) { 38 | var mp = getMousePos(this.canvas, e); 39 | 40 | if (this.dragging) { 41 | var lp = this.path[this.path.length - 1]; 42 | 43 | if (!mp.inCircle(lp, 6)) { 44 | this.path.push(mp); 45 | drawSim(); 46 | } 47 | } 48 | } 49 | 50 | Sim.prototype.mouseUp = function(e) { 51 | if (!this.dragging) return; 52 | var mp = getMousePos(this.canvas, e); 53 | this.path.push(mp); 54 | this.endDrag(e); 55 | } 56 | 57 | Sim.prototype.mouseOut = function(e) { 58 | if (!this.dragging) return; 59 | this.endDrag(e); 60 | } 61 | 62 | Sim.prototype.endDrag = function(e) { 63 | var corrected = tryShapeFit(this.path); 64 | if (corrected) { 65 | this.shapes.push(corrected); 66 | } else { 67 | this.shapes.push({ 68 | path: this.path 69 | }); 70 | } 71 | 72 | this.path = []; 73 | this.dragging = false; 74 | drawSim(); 75 | } 76 | function drawSim() { 77 | var ctx = sim.ctx; 78 | ctx.lineWidth = 1; 79 | clearCanvas(ctx, sim.canvas); 80 | 81 | ctx.lineWidth = 2; 82 | ctx.strokeStyle = "#000000"; 83 | for (var i = 0; i < sim.shapes.length; ++i) { 84 | var s = sim.shapes[i]; 85 | if (s.path) { 86 | drawPath(ctx, s.path); 87 | } else if (s.circle) { 88 | ctx.beginPath(); 89 | ctx.arc(s.circle.origin.x, s.circle.origin.y, s.circle.radius, 0.0, Math.PI * 2.0); 90 | ctx.closePath(); 91 | ctx.stroke(); 92 | } else if (s.ellipse) { 93 | ctx.beginPath(); 94 | ctx.ellipse(s.ellipse.origin.x, s.ellipse.origin.y, s.ellipse.size.x, s.ellipse.size.y, 0, 0.0, Math.PI * 2.0); 95 | ctx.closePath(); 96 | ctx.stroke(); 97 | } 98 | } 99 | 100 | ctx.lineWidth = 3; 101 | ctx.strokeStyle = "#FF0000"; 102 | if (sim.path) { 103 | drawPath(ctx, sim.path); 104 | } 105 | } 106 | 107 | function clearCanvas(ctx, canvas) { 108 | ctx.fillStyle = '#C1FFC9'; 109 | ctx.beginPath(); 110 | ctx.rect(0, 0, canvas.width, canvas.height); 111 | ctx.closePath(); 112 | return ctx.fill(); 113 | } 114 | 115 | function drawPath(ctx, path) { 116 | if (path.length === 0) return; 117 | ctx.beginPath(); 118 | ctx.moveTo(path[0].x, path[0].y); 119 | for (var i = 1; i < path.length; ++i) { 120 | ctx.lineTo(path[i].x, path[i].y); 121 | } 122 | ctx.stroke(); 123 | } 124 | 125 | var sim = new Sim(); 126 | drawSim(); 127 | -------------------------------------------------------------------------------- /docs/src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Drawing assistant 5 | 6 | 7 | 8 |

9 | Back to article 10 |

11 | 12 | 13 |

14 | 15 |

16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /docs/src/math.js: -------------------------------------------------------------------------------- 1 | // Created by Justin Meiners (2022) 2 | // License: MIT 3 | "use strict"; 4 | 5 | function lerp(a, b, t) { 6 | return (1 - t) * a + t * b; 7 | }; 8 | 9 | function clamp(low, high, t) { 10 | if (t < low) { 11 | return low; 12 | } else if (t > high) { 13 | return high; 14 | } else { 15 | return t; 16 | } 17 | }; 18 | function Vec(x, y) { 19 | this.x = x; 20 | this.y = y; 21 | }; 22 | 23 | Vec.fromAngle = function(angle) { 24 | return new Vec(Math.cos(angle), Math.sin(angle)); 25 | }; 26 | 27 | Vec.zero = function() { 28 | return new Vec(0, 0); 29 | }; 30 | 31 | Vec.prototype.copy = function() { 32 | return new Vec(this.x, this.y); 33 | }; 34 | 35 | Vec.prototype.dot = function(b) { 36 | return this.x * b.x + this.y * b.y; 37 | }; 38 | 39 | Vec.prototype.lenSqr = function() { 40 | return this.dot(this); 41 | }; 42 | 43 | Vec.prototype.len = function() { 44 | return Math.sqrt(this.lenSqr()); 45 | }; 46 | 47 | Vec.prototype.orthogonal = function() { 48 | return new Vec(-this.y, this.x); 49 | }; 50 | 51 | Vec.prototype.add = function(b) { 52 | this.x += b.x; 53 | this.y += b.y; 54 | return this; 55 | }; 56 | 57 | Vec.prototype.negate = function() { 58 | this.x = -this.x; 59 | this.y = -this.y; 60 | return this; 61 | }; 62 | 63 | Vec.prototype.sub = function(b) { 64 | this.x -= b.x; 65 | this.y -= b.y; 66 | return this; 67 | }; 68 | 69 | Vec.prototype.normalized = function() { 70 | return Vec.scale(this, 1 / this.len()); 71 | }; 72 | 73 | Vec.add = function(a, b) { 74 | return a.copy().add(b); 75 | }; 76 | 77 | Vec.sub = function(a, b) { 78 | return a.copy().sub(b); 79 | }; 80 | 81 | Vec.scale = function(a, s) { 82 | return new Vec(a.x * s, a.y * s); 83 | }; 84 | 85 | Vec.distSqr = function(a, b) { 86 | return Vec.sub(a, b).lenSqr(); 87 | }; 88 | 89 | Vec.dist = function(a, b) { 90 | return Math.sqrt(Vec.distSqr(a, b)); 91 | }; 92 | 93 | Vec.negate = function(v) { 94 | return v.copy().negate(); 95 | }; 96 | 97 | Vec.min = function(a, b) { 98 | return new Vec(Math.min(a.x, b.x), Math.min(a.y, b.y)); 99 | }; 100 | 101 | Vec.max = function(a, b) { 102 | return new Vec(Math.max(a.x, b.x), Math.max(a.y, b.y)); 103 | }; 104 | 105 | Vec.prototype.inBounds = function(min, max) { 106 | return this.x >= min.x && this.y >= min.y && 107 | this.x <= max.x && this.y <= max.y; 108 | }; 109 | 110 | Vec.prototype.inCircle = function(o, r) { 111 | return Vec.distSqr(this, o) < r * r; 112 | }; 113 | 114 | Vec.lerp = function(a, b, t) { 115 | return new Vec(lerp(a.x, b.x, t), lerp(a.y, b.y, t)); 116 | }; 117 | 118 | Vec.centroid = function(points) { 119 | var sum = points.reduce(function(acc, x) { 120 | return Vec.add(acc, x); 121 | }); 122 | 123 | return Vec.scale(sum, 1 / points.length); 124 | }; 125 | 126 | Vec.pathLen = function(path) { 127 | var sum = 0; 128 | for (var i = 1; i < path.length; ++i) { 129 | sum += Vec.dist(path[i], path[i-1]); 130 | } 131 | return sum; 132 | }; 133 | 134 | Vec.bounds = function(points) { 135 | return [points.reduce(Vec.min), points.reduce(Vec.max)]; 136 | }; 137 | function Matrix() { 138 | this.m = new Float64Array(2 * 2); 139 | }; 140 | 141 | Matrix.from = function(a, b, c, d) { 142 | var A = new Matrix(); 143 | A.m[0] = a; A.m[1] = b; 144 | A.m[2] = c; A.m[3] = d; 145 | return A; 146 | }; 147 | 148 | Matrix.fromScale = function(sx, sy) { 149 | return Matrix.from(sx, 0, 0, sy); 150 | }; 151 | 152 | Matrix.fromAngle = function(angle) { 153 | var x = Math.cos(angle); 154 | var y = Math.sin(angle); 155 | return Matrix.from(x, -y, y, x); 156 | }; 157 | 158 | Matrix.prototype.index = function(row, col) { 159 | return row * 2 + col; 160 | }; 161 | 162 | Matrix.prototype.get = function(row, col) { 163 | return this.m[this.index(row, col)]; 164 | }; 165 | 166 | Matrix.prototype.set = function(row, col, x) { 167 | this.m[this.index(row, col)] = x; 168 | }; 169 | 170 | Matrix.prototype.transform = function(v) { 171 | return new Vec( 172 | this.m[0] * v.x + this.m[1] * v.y, 173 | this.m[2] * v.x + this.m[3] * v.y 174 | ); 175 | }; 176 | 177 | Matrix.prototype.add = function(other) { 178 | for (var i = 0; i < 4; ++i) { 179 | this.m[i] += other.m[i]; 180 | }; 181 | return this; 182 | }; 183 | 184 | Matrix.prototype.scale = function(scale) { 185 | for (var i = 0; i < 4; ++i) { 186 | this.m[i] *= scale; 187 | }; 188 | return this; 189 | }; 190 | 191 | Matrix.mul = function(A, B) { 192 | return Matrix.from( 193 | A.m[0] * B.m[0] + A.m[1] * B.m[2], 194 | A.m[0] * B.m[1] + A.m[1] * B.m[3], 195 | A.m[2] * B.m[0] + A.m[3] * B.m[2], 196 | A.m[2] * B.m[1] + A.m[3] * B.m[3] 197 | ); 198 | }; 199 | 200 | Matrix.prototype.det = function() { 201 | return this.m[0] * this.m[3] - this.m[1] * this.m[2]; 202 | }; 203 | 204 | Matrix.inverse = function(A) { 205 | var s = 1.0 / A.det(); 206 | return Matrix.from(A.m[3], -A.m[1], -A.m[2], A.m[0]).scale(s); 207 | }; 208 | 209 | Matrix.prototype.copy = function() { 210 | var copy = new Matrix(); 211 | copy.m.set(this.m); 212 | return copy; 213 | }; 214 | function AffineTransform() { 215 | this.m = Matrix.from(1, 0, 0, 1); 216 | this.t = new Vec(0, 0); 217 | }; 218 | 219 | AffineTransform.prototype.transform = function(v) { 220 | return this.m.transform(v).add(this.t); 221 | }; 222 | 223 | AffineTransform.inverse = function(a) { 224 | var b = new AffineTransform(); 225 | b.m = Matrix.inverse(a.m); 226 | b.t = b.m.transform( a.t.copy().negate()); 227 | return b; 228 | }; 229 | 230 | function makeAckley(a, b, c) { 231 | return function(vars) { 232 | var sumSquares = vars.reduce(function(total, x) { 233 | return total + x * x; 234 | }, 0); 235 | 236 | var sumCos = vars.reduce(function(total, x) { 237 | return total + Math.cos(x * c); 238 | }, 0); 239 | 240 | var n = vars.length; 241 | return -a * Math.exp(-b * Math.sqrt(sumSquares / n)) - Math.exp(sumCos / n) + a + Math.exp(1); 242 | }; 243 | }; 244 | 245 | function testOptimizer() { 246 | var f = makeAckley(20.0, 0.2, 2.0 * Math.PI); 247 | 248 | var options = { 249 | debug: true, 250 | maxIterations: 100, 251 | tolerance: 0.001 252 | }; 253 | 254 | console.log(multivarOptimize([-2.1, -3.04, 4.5], f, options)); 255 | }; 256 | 257 | function multivarOptimize(initial, costFunc, options) { 258 | var maxIterations = options.maxIterations || 10000; 259 | var tolerance = options.tolerance || 0.001; 260 | 261 | function predicate(iterations, image) { 262 | return iterations > maxIterations || image < tolerance; 263 | }; 264 | 265 | var n = initial.length; 266 | 267 | function guessSizes(initial) { 268 | var sizes = new Float64Array(n); 269 | for (var j = 0; j < n; ++j) { 270 | sizes[j] = (0.05 * Math.abs(initial[j])) + 0.00025; 271 | } 272 | return sizes; 273 | }; 274 | 275 | var simplex = new Simplex(n); 276 | simplex.positionAround(initial, guessSizes(initial)); 277 | return simplex.optimize(costFunc, predicate, options); 278 | }; 279 | 280 | function Simplex(n) { 281 | this.dimension = n; 282 | this.vertices = []; 283 | for (var i = 0; i < (n + 1); ++i) { 284 | this.vertices.push(new SimplexVertex(n)); 285 | } 286 | }; 287 | 288 | function SimplexVertex(n) { 289 | this.point = new Float64Array(n); 290 | this.image = 0; 291 | }; 292 | 293 | SimplexVertex.prototype.copyFrom = function(other) { 294 | this.point.set(other.point); 295 | this.image = other.image; 296 | }; 297 | 298 | SimplexVertex.prototype.swapWith = function(other) { 299 | var ptemp = this.point; 300 | var itemp = this.image; 301 | 302 | this.point = other.point; 303 | this.image = other.image; 304 | other.point = ptemp; 305 | other.image = itemp; 306 | }; 307 | 308 | Simplex.prototype.positionAround = function(point, sizes) { 309 | var n = this.dimension; 310 | for (var i = 0; i < (n + 1); ++i) { 311 | for (var j = 0; j < n; ++j) { 312 | this.vertices[i].point[j] = point[j] + ((i - 1 == j) ? sizes[j] : 0.0); 313 | } 314 | } 315 | }; 316 | 317 | Simplex.prototype.sort = function() { 318 | this.vertices.sort(function(a, b) { 319 | return a.image - b.image; 320 | }); 321 | }; 322 | 323 | Simplex.prototype.getCentroid = function(output) { 324 | var n = this.dimension; 325 | // last point is not included 326 | for (var j = 0; j < n; ++j) { 327 | var x = this.vertices[0].point[j]; 328 | for (var i = 1; i < n; ++i) { 329 | x += this.vertices[i].point[j]; 330 | } 331 | output.point[j] = x / n; 332 | } 333 | }; 334 | 335 | Simplex.prototype.getNewPoint = function(centroid, lambda, output) { 336 | var n = this.dimension; 337 | for (var j = 0; j < n; ++j) { 338 | output.point[j] = (1.0 + lambda) * centroid.point[j] - lambda * this.vertices[n].point[j]; 339 | }; 340 | }; 341 | 342 | Simplex.prototype.shrink = function(sigma) { 343 | var n = this.dimension; 344 | for (var i = 1; i < (n + 1); ++i) { 345 | for (var j = 0; j < n; ++j) { 346 | var x = this.vertices[0].point[j]; 347 | this.vertices[i].point[j] = x + sigma * (this.vertices[i].point[j] - x); 348 | } 349 | } 350 | }; 351 | 352 | Simplex.prototype.computeVertexImages = function(costFunc) { 353 | for (var i = 0; i < (this.dimension + 1); ++i) { 354 | this.vertices[i].image = costFunc(this.vertices[i].point); 355 | } 356 | this.sort(); 357 | }; 358 | 359 | Simplex.prototype.optimize = function(costFunc, stopPredicate, options) { 360 | var rho = options.rho || 1.0; // coefficient for "reflect" 361 | var chi = options.chi || 2.0; // coefficient for "expand" 362 | var gamma = options.gamma || 0.5; // coefficient for "contract" 363 | var sigma = options.sigma || 0.5; // coefficient for "shrink" 364 | var debug = options.debug == undefined ? false : options.debug; 365 | 366 | var n = this.dimension; 367 | 368 | var pointR = new SimplexVertex(n); 369 | var pointE = new SimplexVertex(n); 370 | var pointC = new SimplexVertex(n); 371 | var centroid = new SimplexVertex(n); 372 | 373 | this.computeVertexImages(costFunc); 374 | this.getCentroid(centroid); 375 | 376 | var iterations = 1; 377 | 378 | while (!stopPredicate(iterations, this.vertices[0].image)) { 379 | var shrink = false; 380 | this.getNewPoint(centroid, rho, pointR); 381 | pointR.image = costFunc(pointR.point); 382 | 383 | if (pointR.image < this.vertices[0].image) { 384 | this.getNewPoint(centroid, rho * chi, pointE); 385 | pointE.image = costFunc(pointE.point); 386 | 387 | if (pointE.image < pointR.image) { 388 | if (debug) console.log("expand"); 389 | this.vertices[n].copyFrom(pointE); 390 | } else { 391 | if (debug) console.log("reflect"); 392 | this.vertices[n].copyFrom(pointR); 393 | } 394 | } else { 395 | if (pointR.image < this.vertices[n - 1].image) { 396 | if (debug) console.log("reflect"); 397 | this.vertices[n].copyFrom(pointR); 398 | } else { 399 | if (pointR.image < this.vertices[n].image) { 400 | this.getNewPoint(centroid, rho * gamma, pointC); 401 | pointC.image = costFunc(pointC.point); 402 | 403 | if (pointC.image <= pointR.image) { 404 | if (debug) console.log("contract out"); 405 | this.vertices[n].copyFrom(pointC); 406 | } else { 407 | if (debug) console.log("shrink"); 408 | shrink = true; 409 | } 410 | } else { 411 | this.getNewPoint(centroid, -gamma, pointC); 412 | pointC.image = costFunc(pointC.point); 413 | 414 | if (pointC.image < this.vertices[n].image) { 415 | if (debug) console.log("contract inside"); 416 | this.vertices[n].copyFrom(pointC); 417 | } else { 418 | if (debug) console.log("shrink"); 419 | shrink = true; 420 | } 421 | } 422 | } 423 | } 424 | 425 | if (shrink) { 426 | this.shrink(sigma); 427 | this.computeVertexImages(costFunc); 428 | } else { 429 | for (var i = n - 1; i >= 0 && this.vertices[i + 1].image < this.vertices[i].image; i--) { 430 | this.vertices[i + 1].swapWith(this.vertices[i]); 431 | } 432 | 433 | } 434 | this.getCentroid(centroid); 435 | ++iterations; 436 | 437 | if (debug) console.log("best: ", this.vertices[0].point.join(", "), "score: ", this.vertices[0].image); 438 | }; 439 | 440 | return { 441 | vars: this.vertices[0].point, 442 | cost: this.vertices[0].image, 443 | iterations: iterations 444 | }; 445 | }; 446 | -------------------------------------------------------------------------------- /docs/styles/fonts/firamono_latin.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justinmeiners/why-train-when-you-can-optimize/e06e036a2e09f08e29ecab60ed4e24c7286544f1/docs/styles/fonts/firamono_latin.woff2 -------------------------------------------------------------------------------- /docs/styles/fonts/firamono_latin_ext.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/justinmeiners/why-train-when-you-can-optimize/e06e036a2e09f08e29ecab60ed4e24c7286544f1/docs/styles/fonts/firamono_latin_ext.woff2 -------------------------------------------------------------------------------- /docs/styles/main.css: -------------------------------------------------------------------------------- 1 | @font-face { 2 | font-family: 'Fira Mono'; 3 | font-style: normal; 4 | font-weight: 400; 5 | font-display: swap; 6 | src: url('fonts/firamono_latin_ext.woff2') format('woff2'); 7 | unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF; 8 | } 9 | 10 | @font-face { 11 | font-family: 'Fira Mono'; 12 | font-style: normal; 13 | font-weight: 400; 14 | font-display: swap; 15 | src: url('fonts/firamono_latin.woff2') format('woff2'); 16 | unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; 17 | } 18 | 19 | body { 20 | min-width: 200px; 21 | max-width: 850px; 22 | margin: 3rem auto; 23 | padding: 0 2rem; 24 | font-size: 14pt; 25 | } 26 | 27 | h1 { 28 | text-align: center; 29 | } 30 | 31 | p { 32 | line-height: 1.3; 33 | } 34 | 35 | li { 36 | margin-bottom: 0.3rem; 37 | } 38 | 39 | img { 40 | max-width: 100%; 41 | display: block; 42 | margin-left: auto; 43 | margin-right: auto; 44 | } 45 | 46 | pre { 47 | margin: 1rem 0; 48 | } 49 | 50 | pre.prettyprint { 51 | border: none; 52 | } 53 | 54 | blockquote { 55 | margin: 1.5rem 3rem; 56 | } 57 | 58 | /* document links */ 59 | 60 | a { 61 | text-decoration: none; 62 | } 63 | 64 | a:link, .block-link a:visited { 65 | color: #0046b3; 66 | } 67 | 68 | a:hover, a:active { 69 | text-decoration: underline; 70 | color: #4d92ff; 71 | } 72 | 73 | a:visited { 74 | color: #662e99; 75 | } 76 | 77 | /* code blocks */ 78 | 79 | code, .block-header { 80 | font-size: 11pt; 81 | font-family: 'Fira Mono',Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace; 82 | } 83 | 84 | .block-header, .block-header + pre.prettyprint { 85 | background-color: #f9f8f4; 86 | border: 1px solid #c7c4b4; 87 | box-sizing: border-box; 88 | } 89 | 90 | .block-header { 91 | display: inline-block; 92 | 93 | /* allows the header to overlap the code block to hide part of the top border */ 94 | position: relative; 95 | z-index: 6; 96 | 97 | border-top-left-radius: 0.6rem; 98 | border-top-right-radius: 0.6rem; 99 | border-bottom-width: 0; 100 | 101 | padding: 0.4rem 0.6rem; 102 | } 103 | 104 | .block-title { 105 | font-weight: normal; 106 | } 107 | 108 | .block-title a { 109 | /* this causes navigating to a block link to scroll you just a few pixels above the block header */ 110 | margin-top: -1rem; 111 | padding-top: 1rem; 112 | } 113 | 114 | .block-title, .block-header a:link, .block-header a:visited { 115 | color: #262521; 116 | } 117 | 118 | .block-header a:hover, .block-header a:active { 119 | color: #737372; 120 | } 121 | 122 | .code-block pre.prettyprint { 123 | padding: 0.6rem; 124 | white-space: pre-wrap; 125 | border-radius: 0.6rem; 126 | } 127 | 128 | .code-block .block-header + pre.prettyprint { 129 | /* overlap to the top 1px of the code block with the header so that the top border is partially obscured */ 130 | position: relative; 131 | z-index: 5; 132 | margin-top: -1px; 133 | 134 | border-top-left-radius: 0; 135 | } 136 | 137 | .block-usages { 138 | margin-top: -1rem; 139 | } 140 | 141 | .block-usages small { 142 | display: inline-block; 143 | margin: 0.4rem 0.6rem; 144 | font-size: 11pt; 145 | color: #363535; 146 | } 147 | 148 | .block-usages a, .block-usages span { 149 | padding: 0 0.5rem; 150 | margin-left: 0.1rem; 151 | } 152 | 153 | .block-usages a { 154 | background-color: #f9f8f4; 155 | border: 1px solid #c7c6bf; 156 | box-sizing: border-box; 157 | 158 | color: #57554a; 159 | border-radius: 0.3rem; 160 | } 161 | 162 | .block-usages a + *, .block-usages span + * { 163 | margin-left: 0.2rem; 164 | } 165 | 166 | .block-usages a:hover, .block-usages a:active { 167 | text-decoration: none; 168 | background-color: #f9f9f7; 169 | color: #a6a28d; 170 | } 171 | 172 | 173 | h1 + p, h1 + p + p { 174 | text-align: center; 175 | } 176 | -------------------------------------------------------------------------------- /docs/styles/prettify-theme.css: -------------------------------------------------------------------------------- 1 | /*! Color themes for Google Code Prettify | MIT License | github.com/jmblog/color-themes-for-google-code-prettify */ 2 | /* Atelier Dune Light with modifications for srcweave */ 3 | 4 | .prettyprint { 5 | border: none; 6 | } 7 | 8 | .pln { 9 | color: #20201d; 10 | } 11 | 12 | /* Specify class=linenums on a pre to get line numbering */ 13 | ol.linenums { 14 | margin-top: 0; 15 | margin-bottom: 0; 16 | color: #999580; 17 | } 18 | 19 | li.L0, 20 | li.L1, 21 | li.L2, 22 | li.L3, 23 | li.L4, 24 | li.L5, 25 | li.L6, 26 | li.L7, 27 | li.L8, 28 | li.L9 { 29 | padding-left: 1em; 30 | background-color: #fefbec; 31 | list-style-type: decimal; 32 | } 33 | 34 | @media screen { 35 | 36 | /* string content */ 37 | 38 | .str { 39 | color: #60ac39; 40 | } 41 | 42 | /* keyword */ 43 | 44 | .kwd { 45 | color: #b854d4; 46 | } 47 | 48 | /* comment */ 49 | 50 | .com { 51 | color: #999580; 52 | } 53 | 54 | /* type name */ 55 | 56 | .typ { 57 | color: #6684e1; 58 | } 59 | 60 | /* literal value */ 61 | 62 | .lit { 63 | color: #b65611; 64 | } 65 | 66 | /* punctuation */ 67 | 68 | .pun { 69 | color: #20201d; 70 | } 71 | 72 | /* lisp open bracket */ 73 | 74 | .opn { 75 | color: #20201d; 76 | } 77 | 78 | /* lisp close bracket */ 79 | 80 | .clo { 81 | color: #20201d; 82 | } 83 | 84 | /* markup tag name */ 85 | 86 | .tag { 87 | color: #d73737; 88 | } 89 | 90 | /* markup attribute name */ 91 | 92 | .atn { 93 | color: #b65611; 94 | } 95 | 96 | /* markup attribute value */ 97 | 98 | .atv { 99 | color: #1fad83; 100 | } 101 | 102 | /* declaration */ 103 | 104 | .dec { 105 | color: #b65611; 106 | } 107 | 108 | /* variable name */ 109 | 110 | .var { 111 | color: #d73737; 112 | } 113 | 114 | /* function name */ 115 | 116 | .fun { 117 | color: #6684e1; 118 | } 119 | } 120 | -------------------------------------------------------------------------------- /docs/template.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Drawing template 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |

Drawing template

16 | 17 | 18 |

This is the code that sets up the drawing canvas as well as the HTML page.

19 | 20 |
21 | 22 | sim definition 23 |
function Sim() {
 24 |     this.canvas = document.getElementById('main-canvas');
 25 |     this.ctx = this.canvas.getContext('2d', { alpha: false });
 26 | 
 27 |     this.canvas.onmousedown = this.mouseDown.bind(this);
 28 |     this.canvas.onmouseup = this.mouseUp.bind(this);
 29 |     this.canvas.onmouseout = this.mouseOut.bind(this);
 30 |     this.canvas.onmousemove = this.mouseMove.bind(this);
 31 | 
 32 |     this.shapes = [];
 33 | };
 34 | 
 35 | @{sim input}
 36 | 
37 |

Used by 1

38 | 39 | 40 | 41 | 42 |
43 | 44 | sim input 45 |
document.getElementById("clear-button").onclick = function() {
 46 |     sim.shapes = [];
 47 |     drawSim();
 48 | };
 49 | 
 50 | function getMousePos(canvas, e) {
 51 |     var rect = canvas.getBoundingClientRect();
 52 |     return new Vec(e.clientX - rect.left, e.clientY - rect.top);
 53 | }
 54 | 
 55 | Sim.prototype.mouseDown = function(e) {
 56 |     var mp = getMousePos(this.canvas, e);
 57 |     this.path = [];
 58 |     this.path.push(mp);
 59 |     this.dragging = true;
 60 | 
 61 |     e.preventDefault();
 62 | };
 63 | 
 64 | Sim.prototype.mouseMove = function(e) {
 65 |     var mp = getMousePos(this.canvas, e);
 66 | 
 67 |     if (this.dragging) {
 68 |         var lp = this.path[this.path.length - 1];
 69 | 
 70 |         if (!mp.inCircle(lp, 6)) {
 71 |             this.path.push(mp);
 72 |             drawSim();
 73 |         }
 74 |     }
 75 | }
 76 | 
 77 | Sim.prototype.mouseUp = function(e) {
 78 |     if (!this.dragging) return;
 79 |     var mp = getMousePos(this.canvas, e);
 80 |     this.path.push(mp);
 81 |     this.endDrag(e);
 82 | }
 83 | 
 84 | Sim.prototype.mouseOut = function(e) {
 85 |     if (!this.dragging) return;
 86 |     this.endDrag(e);
 87 | }
 88 | 
 89 | Sim.prototype.endDrag = function(e) {
 90 |     var corrected = tryShapeFit(this.path);
 91 |     if (corrected) {
 92 |         this.shapes.push(corrected);
 93 |     } else {
 94 |         this.shapes.push({
 95 |             path: this.path
 96 |         });
 97 |     }
 98 | 
 99 |     this.path = [];
100 |     this.dragging = false;
101 |     drawSim();
102 | }
103 | 
104 |

Used by 1

105 | 106 | 107 | 108 | 109 |
110 | 111 | sim rendering 112 |
function drawSim() {
113 |     var ctx = sim.ctx;
114 |     ctx.lineWidth = 1;
115 |     clearCanvas(ctx, sim.canvas);
116 | 
117 |     ctx.lineWidth = 2;
118 |     ctx.strokeStyle = "#000000";
119 |     for (var i = 0; i < sim.shapes.length; ++i) {
120 |         var s = sim.shapes[i];
121 |         if (s.path) {
122 |             drawPath(ctx, s.path);
123 |         } else if (s.circle) {
124 |             ctx.beginPath();
125 |             ctx.arc(s.circle.origin.x, s.circle.origin.y, s.circle.radius, 0.0, Math.PI * 2.0);
126 |             ctx.closePath();
127 |             ctx.stroke();
128 |         } else if (s.ellipse) {
129 |             ctx.beginPath();
130 |             ctx.ellipse(s.ellipse.origin.x, s.ellipse.origin.y, s.ellipse.size.x, s.ellipse.size.y, 0, 0.0, Math.PI * 2.0);
131 |             ctx.closePath();
132 |             ctx.stroke();
133 |         }
134 |     }
135 | 
136 |     ctx.lineWidth = 3;
137 |     ctx.strokeStyle = "#FF0000";
138 |     if (sim.path) {
139 |         drawPath(ctx, sim.path);
140 |     }
141 | }
142 | 
143 | function clearCanvas(ctx, canvas) {
144 |     ctx.fillStyle = '#C1FFC9';
145 |     ctx.beginPath();
146 |     ctx.rect(0, 0, canvas.width, canvas.height);
147 |     ctx.closePath();
148 |     return ctx.fill();
149 | }
150 | 
151 | function drawPath(ctx, path) {
152 |     if (path.length === 0) return;
153 |     ctx.beginPath();
154 |     ctx.moveTo(path[0].x, path[0].y);
155 |     for (var i = 1; i < path.length; ++i) {
156 |         ctx.lineTo(path[i].x, path[i].y);
157 |     }
158 |     ctx.stroke();
159 | }
160 | 
161 |

Used by 1

162 | 163 | 164 | 165 | 166 |
167 | 168 | /draw.js 169 |
// Created by Justin Meiners (2022)
170 | // License: MIT
171 | 
172 | "use strict";
173 | @{sim definition}
174 | @{sim rendering}
175 | 
176 | var sim = new Sim();
177 | drawSim();
178 | 
179 |
180 | 181 | 182 |

HTML page

183 | 184 |

Here is the HTML page I use.

185 | 186 |
187 | 188 | /index.html 189 |
<!DOCTYPE html>
190 | <html>
191 |     <head>
192 |         <title>Drawing assistant</title>
193 |     </style>
194 |     </head>
195 |     <body>
196 |            <p>
197 |                <a href="../">Back to article</a>
198 |            </p>
199 | 
200 |            <canvas id="main-canvas" width="1024" height="768"></canvas>
201 |            <p>
202 |               <button id="clear-button">Clear</button>
203 |            </p>
204 | 
205 |            <script src="math.js"></script>
206 |            <script src="assist.js"></script>
207 |            <script src="draw.js"></script>
208 |     </body>
209 | </html>
210 | 
211 |
212 | 213 | 214 | 215 | 216 | 217 | -------------------------------------------------------------------------------- /template.lit: -------------------------------------------------------------------------------- 1 | # Drawing template 2 | 3 | This is the code that sets up the drawing canvas as well as the HTML page. 4 | 5 | --- sim definition 6 | function Sim() { 7 | this.canvas = document.getElementById('main-canvas'); 8 | this.ctx = this.canvas.getContext('2d', { alpha: false }); 9 | 10 | this.canvas.onmousedown = this.mouseDown.bind(this); 11 | this.canvas.onmouseup = this.mouseUp.bind(this); 12 | this.canvas.onmouseout = this.mouseOut.bind(this); 13 | this.canvas.onmousemove = this.mouseMove.bind(this); 14 | 15 | this.shapes = []; 16 | }; 17 | 18 | @{sim input} 19 | --- 20 | 21 | --- sim input 22 | 23 | document.getElementById("clear-button").onclick = function() { 24 | sim.shapes = []; 25 | drawSim(); 26 | }; 27 | 28 | function getMousePos(canvas, e) { 29 | var rect = canvas.getBoundingClientRect(); 30 | return new Vec(e.clientX - rect.left, e.clientY - rect.top); 31 | } 32 | 33 | Sim.prototype.mouseDown = function(e) { 34 | var mp = getMousePos(this.canvas, e); 35 | this.path = []; 36 | this.path.push(mp); 37 | this.dragging = true; 38 | 39 | e.preventDefault(); 40 | }; 41 | 42 | Sim.prototype.mouseMove = function(e) { 43 | var mp = getMousePos(this.canvas, e); 44 | 45 | if (this.dragging) { 46 | var lp = this.path[this.path.length - 1]; 47 | 48 | if (!mp.inCircle(lp, 6)) { 49 | this.path.push(mp); 50 | drawSim(); 51 | } 52 | } 53 | } 54 | 55 | Sim.prototype.mouseUp = function(e) { 56 | if (!this.dragging) return; 57 | var mp = getMousePos(this.canvas, e); 58 | this.path.push(mp); 59 | this.endDrag(e); 60 | } 61 | 62 | Sim.prototype.mouseOut = function(e) { 63 | if (!this.dragging) return; 64 | this.endDrag(e); 65 | } 66 | 67 | Sim.prototype.endDrag = function(e) { 68 | var corrected = tryShapeFit(this.path); 69 | if (corrected) { 70 | this.shapes.push(corrected); 71 | } else { 72 | this.shapes.push({ 73 | path: this.path 74 | }); 75 | } 76 | 77 | this.path = []; 78 | this.dragging = false; 79 | drawSim(); 80 | } 81 | --- 82 | 83 | --- sim rendering 84 | function drawSim() { 85 | var ctx = sim.ctx; 86 | ctx.lineWidth = 1; 87 | clearCanvas(ctx, sim.canvas); 88 | 89 | ctx.lineWidth = 2; 90 | ctx.strokeStyle = "#000000"; 91 | for (var i = 0; i < sim.shapes.length; ++i) { 92 | var s = sim.shapes[i]; 93 | if (s.path) { 94 | drawPath(ctx, s.path); 95 | } else if (s.circle) { 96 | ctx.beginPath(); 97 | ctx.arc(s.circle.origin.x, s.circle.origin.y, s.circle.radius, 0.0, Math.PI * 2.0); 98 | ctx.closePath(); 99 | ctx.stroke(); 100 | } else if (s.ellipse) { 101 | ctx.beginPath(); 102 | ctx.ellipse(s.ellipse.origin.x, s.ellipse.origin.y, s.ellipse.size.x, s.ellipse.size.y, 0, 0.0, Math.PI * 2.0); 103 | ctx.closePath(); 104 | ctx.stroke(); 105 | } 106 | } 107 | 108 | ctx.lineWidth = 3; 109 | ctx.strokeStyle = "#FF0000"; 110 | if (sim.path) { 111 | drawPath(ctx, sim.path); 112 | } 113 | } 114 | 115 | function clearCanvas(ctx, canvas) { 116 | ctx.fillStyle = '#C1FFC9'; 117 | ctx.beginPath(); 118 | ctx.rect(0, 0, canvas.width, canvas.height); 119 | ctx.closePath(); 120 | return ctx.fill(); 121 | } 122 | 123 | function drawPath(ctx, path) { 124 | if (path.length === 0) return; 125 | ctx.beginPath(); 126 | ctx.moveTo(path[0].x, path[0].y); 127 | for (var i = 1; i < path.length; ++i) { 128 | ctx.lineTo(path[i].x, path[i].y); 129 | } 130 | ctx.stroke(); 131 | } 132 | --- 133 | 134 | --- /draw.js 135 | // Created by Justin Meiners (2022) 136 | // License: MIT 137 | 138 | "use strict"; 139 | @{sim definition} 140 | @{sim rendering} 141 | 142 | var sim = new Sim(); 143 | drawSim(); 144 | --- 145 | 146 | ### HTML page 147 | 148 | Here is the HTML page I use. 149 | 150 | --- /index.html 151 | 152 | 153 | 154 | Drawing assistant 155 | 156 | 157 | 158 |

159 | Back to article 160 |

161 | 162 | 163 |

164 | 165 |

166 | 167 | 168 | 169 | 170 | 171 | 172 | --- 173 | 174 | --------------------------------------------------------------------------------