├── assets ├── egua.png └── logo_egua.svg ├── LICENSE ├── css ├── theme.css └── style.css ├── index.html ├── js ├── index.js ├── demos.js └── codeflask.min.js └── README.md /assets/egua.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eguadev/idegua/HEAD/assets/egua.png -------------------------------------------------------------------------------- /assets/logo_egua.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 8 | 9 | 10 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 - present Lucas Pompeu Neves 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /css/theme.css: -------------------------------------------------------------------------------- 1 | .codeflask { 2 | background: #fff; 3 | color: #212121; 4 | font-size: 80px !important; 5 | font-family: "Roboto Mono", monospace; 6 | } 7 | 8 | .codeflask__flatten { 9 | font-size: 17px !important; 10 | } 11 | 12 | .codeflask__lines { 13 | font-size: 17px !important; 14 | z-index: 100 !important; 15 | } 16 | 17 | .codeflask__textarea::selection { 18 | background: rgb(59 130 246); 19 | color: transparent; 20 | } 21 | 22 | .codeflask.codeflask--has-line-numbers:before { 23 | z-index: 100 !important; 24 | } 25 | 26 | .codeflask .token.punctuation { 27 | color: #4a4a4a; 28 | } 29 | 30 | .codeflask .token.keyword { 31 | color: #8500ff; 32 | } 33 | 34 | .codeflask .token.operator { 35 | color: #ff5598; 36 | } 37 | 38 | .codeflask .token.string { 39 | color: rgb(5 150 105); 40 | } 41 | 42 | .codeflask .token.comment { 43 | color: #9badb7; 44 | } 45 | 46 | .codeflask .token.function { 47 | color: rgb(124 58 237); 48 | } 49 | 50 | .codeflask .token.boolean { 51 | color: rgb(124 58 237); 52 | } 53 | 54 | .codeflask .token.number { 55 | color: rgb(124 58 237); 56 | } 57 | 58 | .codeflask .token.selector { 59 | color: rgb(124 58 237); 60 | } 61 | 62 | .codeflask .token.property { 63 | color: rgb(124 58 237); 64 | } 65 | 66 | .codeflask .token.tag { 67 | color: rgb(124 58 237); 68 | } 69 | 70 | .codeflask .token.attr-value { 71 | color: #8500ff; 72 | } 73 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Programar - Linguagem Égua 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 |
21 |
egua
22 | 23 |
24 | 25 |
26 |
27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /js/index.js: -------------------------------------------------------------------------------- 1 | const outputDiv = document.getElementById("output"); 2 | const runButton = document.getElementById("runBtn"); 3 | const demoSelector = document.getElementById("demoSelector"); 4 | 5 | String.prototype.capitalize = function() { 6 | return this.charAt(0).toUpperCase() + this.slice(1); 7 | }; 8 | 9 | function getQueryVariable(variable) { 10 | const query = window.location.search.substring(1); 11 | const vars = query.split("&"); 12 | for (let i = 0; i < vars.length; i++) { 13 | const pair = vars[i].split("="); 14 | if (decodeURIComponent(pair[0]) === variable) { 15 | return decodeURIComponent(pair[1]); 16 | } 17 | } 18 | } 19 | 20 | console.log = console.error = function(msg) { 21 | const p = document.createElement("p"); 22 | p.textContent = msg; 23 | p.classList = " output"; 24 | outputDiv.appendChild(p); 25 | }; 26 | 27 | const clearOutput = function() { 28 | outputDiv.innerHTML = ""; 29 | }; 30 | 31 | const editor = new CodeFlask("#editor", { 32 | language: 'js', 33 | lineNumbers: true, 34 | defaultTheme: false 35 | }); 36 | 37 | clearOutput(); 38 | 39 | const demoKeys = Object.keys(demos); 40 | function loadDemo(name) { 41 | editor.updateCode(demos[name]); 42 | } 43 | 44 | demoKeys.forEach((demo, index) => { 45 | const option = document.createElement("option"); 46 | if (index === 0) { 47 | option.disabled = true; 48 | option.selected = true; 49 | option.hidden = true; 50 | } 51 | 52 | option.textContent = demo.capitalize(); 53 | option.value = demo; 54 | demoSelector.appendChild(option); 55 | }); 56 | 57 | let queryCode = getQueryVariable("code"); 58 | if (queryCode !== undefined) { 59 | editor.updateCode(decodeURI(queryCode)); 60 | demoSelector.value = "custom"; 61 | } else { 62 | loadDemo(demoKeys[0]); 63 | } 64 | 65 | const runCode = function() { 66 | const egua = new Egua.Egua(); 67 | 68 | let code = editor.getCode(); 69 | 70 | egua.runBlock(code); 71 | }; 72 | 73 | demoSelector.addEventListener("change", function() { 74 | loadDemo(demoSelector.value); 75 | }); 76 | 77 | runButton.addEventListener("click", function() { 78 | clearOutput(); 79 | runCode(); 80 | }); 81 | -------------------------------------------------------------------------------- /js/demos.js: -------------------------------------------------------------------------------- 1 | const Exemplos = ''; 2 | 3 | const OlaMundo = 'escreva("Olá, mundo!");'; 4 | 5 | const Operações = `var a = 10; 6 | var b = 4; 7 | 8 | escreva("Valor de A: " + texto(a)); 9 | 10 | escreva("Valor de B: " + texto(b)); 11 | 12 | var soma = a + b; // Soma os dois valores 13 | var sub = a - b; // Subtrai os dois valores 14 | var mult = a * b; // Multiplica os dois valores 15 | var div = a / b; // Divide os dois valores 16 | 17 | escreva("A soma dos números é igual a: " + texto(soma)); // Exibe o resultado da soma 18 | escreva("A subtração dos números é igual a: " + texto(sub)); // Exibe o resultado da subtração 19 | escreva("A multiplicação dos números é igual a: " + texto(mult)); // Exibe o resultado da multiplicação 20 | escreva("A divisão dos números é igual a: " + texto(div)); // Exibe o resultado da divisão` 21 | 22 | const Condicional = `var letra = 'E'; 23 | 24 | // É necessário verificar letras minúsculas e maiúsculas 25 | se 26 | ( 27 | letra == 'A' ou letra == 'E' ou letra == 'I' ou letra == 'O' ou letra == 'U' ou 28 | letra == 'a' ou letra == 'e' ou letra == 'i' ou letra == 'o' ou letra == 'u' 29 | ) 30 | { 31 | escreva("A letra " + letra + " é uma vogal!"); 32 | } 33 | senão 34 | { 35 | escreva("A letra " + letra + " não é uma vogal!"); 36 | }` 37 | 38 | const Repetição = `var contador = 10; 39 | 40 | enquanto (contador > 0) 41 | { 42 | escreva ("Detonação em: " + texto(contador)); 43 | contador = contador - 1; 44 | } 45 | 46 | escreva ("Booom!");` 47 | 48 | const Função = `função mensagem(texto){ 49 | var linha = "-------------------------------"; 50 | 51 | escreva(linha); 52 | 53 | escreva(texto); 54 | 55 | escreva(linha); 56 | } 57 | 58 | função calcular(a, b){ 59 | var resultado = a * a + b * b; 60 | 61 | retorna resultado; 62 | } 63 | 64 | mensagem("Mensagem de texto"); 65 | 66 | escreva("Resultado do primeiro cálculo:"); 67 | escreva(calcular(3, 5)); 68 | 69 | escreva("Resultado do segundo cálculo:"); 70 | escreva(calcular(2, 9));` 71 | 72 | const Classe = `classe Animal { 73 | correr() { 74 | escreva("Correndo Loucamente"); 75 | } 76 | } 77 | classe Cachorro herda Animal { 78 | latir() { 79 | escreva("Au Au Au Au"); 80 | } 81 | } 82 | var nomeDoCachorro = Cachorro(); 83 | nomeDoCachorro.correr(); 84 | nomeDoCachorro.latir();` 85 | 86 | const demos = { 87 | Exemplos, 88 | OlaMundo, 89 | Operações, 90 | Condicional, 91 | Repetição, 92 | Função, 93 | Classe 94 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |
2 |

3 | egua 4 | 5 |

IDEgua

6 | 7 |

8 | IDE Online da Linguagem Égua 9 |
10 |
11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 |

21 |

22 | 23 | ## Introdução 24 | - **Simples e Completa.** Podendo ser usadas por pessoas com ou sem experiência em programação. 25 | - **Totalmente em Português.** Desenvolvida totalmente em português para quebrar a barreira do inglês. 26 | - **Grátis.** Sem planos, sem limitações e sem propaganda. 27 | - **Open-source** Todo código fonte disponível para estudar, modificar e contribuir. 28 | - **Constantes Atualizações.** Junto à nossa comunidade, para trazermos melhorias e inovações. 29 | - **Linguagem Científica.** Apoiamos e encorajamos o desenvolvimento e aprimoramento da ciência e da educação. 30 | 31 | ## Instalação 32 | 33 | - Apenas visite a [IDEgua](https://egua.dev/idegua/) e comece a programar. 34 | 35 | ## Documentação 36 | 37 | - Para acessar nossa documentação, visite o [site de documentação](https://egua.dev/docs). 38 | 39 | ## Contruibuições 40 | 41 | * Para contribuições, por favor, leia o nosso [Guia de Contribuição](https://github.com/eguadev/egua/blob/master/.github/CONTRIBUTING.md) antes de submeter um Pull Request. 42 | 43 | - A linguagem Égua é um projeto open-source que se faz possível com o empenho da nossa apaixonada equipe de desenvolvedores, talentoso colaboradores e apoiadores. Obrigado a todos!! -------------------------------------------------------------------------------- /css/style.css: -------------------------------------------------------------------------------- 1 | html, body, button, select { 2 | font-family: 'Roboto Mono', monospace; 3 | color: black; 4 | } 5 | 6 | #runBtn { 7 | background-color: #ff4b55; 8 | color: white; 9 | border: 2px; 10 | margin-bottom: 3px; 11 | display: inline-block; 12 | border-radius: 9999px; 13 | padding: 15px 20px; 14 | float: right; 15 | margin-right: 10px; 16 | } 17 | 18 | #demoSelector { 19 | background-color: #ff4b55; 20 | color: white; 21 | border: 2px; 22 | margin-bottom: 3px; 23 | display: inline-block; 24 | border-radius: 9999px; 25 | padding: 15px 20px; 26 | border-right: 7px solid transparent; 27 | margin-left: 10px; 28 | } 29 | 30 | #editor { 31 | width: 65%; 32 | height: calc(100% - 65px); 33 | left: 0; 34 | position: fixed; 35 | border-right: 2px solid grey; 36 | border-top: 2px solid grey; 37 | } 38 | 39 | @media only screen and (max-width: 768px) { 40 | 41 | #editor { 42 | width: 100% !important; 43 | height: 70% !important; 44 | position: relative !important; 45 | } 46 | 47 | #output { 48 | width: 100% !important; 49 | height: 29% !important; 50 | position: relative !important; 51 | } 52 | 53 | .output { 54 | font-size: 13px !important; 55 | } 56 | 57 | 58 | #runBtn { 59 | width: 100px; 60 | font-size: 11px; 61 | } 62 | 63 | #demoSelector { 64 | width: 108px; 65 | font-size: 11px; 66 | } 67 | } 68 | 69 | #output { 70 | width: calc(35% - 4px); 71 | height: calc(100% - 65px); 72 | right: 0; 73 | position: fixed; 74 | border-right: 2px solid grey; 75 | border-top: 2px solid grey; 76 | overflow-y: scroll; 77 | } 78 | 79 | .output { 80 | margin: 1px 10px; 81 | padding-top: 0; 82 | font-size: 15px; 83 | } 84 | 85 | * { 86 | margin: 0; 87 | padding: 0; 88 | } 89 | 90 | #container { 91 | height: auto; 92 | width: 100%; 93 | font-size: 0; 94 | margin-bottom: 7px; 95 | margin-top: 7px; 96 | } 97 | 98 | #left, 99 | #middle, 100 | #right { 101 | display: inline-block; 102 | *display: inline; 103 | zoom: 1; 104 | vertical-align: middle; 105 | font-size: 12px; 106 | } 107 | 108 | #left { 109 | width: 25%; 110 | } 111 | 112 | #middle { 113 | width: 50%; 114 | text-align: center; 115 | display: inline-block; 116 | } 117 | 118 | #middle img { 119 | user-select: none; 120 | -webkit-user-drag: none; 121 | } 122 | 123 | #right { 124 | width: 25%; 125 | text-align: center; 126 | } 127 | 128 | .center { 129 | display: block; 130 | margin-left: auto; 131 | margin-right: auto; 132 | width: 25%; 133 | height: 55% 134 | } 135 | -------------------------------------------------------------------------------- /js/codeflask.min.js: -------------------------------------------------------------------------------- 1 | ! function(e, t) { 2 | "object" == typeof exports && "undefined" != typeof module ? module.exports = t() : "function" == typeof define && define.amd ? define(t) : e.CodeFlask = t() 3 | }(this, function() { 4 | "use strict"; 5 | var e, t, n, a = '"SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace', 6 | s = "\n .codeflask {\n position: absolute;\n width: 100%;\n height: 100%;\n overflow: hidden;\n }\n\n .codeflask, .codeflask * {\n box-sizing: border-box;\n }\n\n .codeflask__pre {\n pointer-events: none;\n z-index: 3;\n overflow: hidden;\n }\n\n .codeflask__textarea {\n background: none;\n border: none;\n color: " + (e = "caret-color", t = "#000", ("undefined" != typeof CSS ? CSS.supports(e, t) : "undefined" != typeof document && (n = (n = e).split("-").filter(function(e) { 7 | return !!e 8 | }).map(function(e) { 9 | return e[0].toUpperCase() + e.substr(1) 10 | }).join(""))[0].toLowerCase() + n.substr(1) in document.body.style) ? "#fff" : "#ccc") + ";\n z-index: 1;\n resize: none;\n font-family: " + a + ";\n -webkit-appearance: pre;\n caret-color: #111;\n z-index: 2;\n width: 100%;\n height: 100%;\n }\n\n .codeflask--has-line-numbers .codeflask__textarea {\n width: calc(100% - 40px);\n }\n\n .codeflask__code {\n display: block;\n font-family: " + a + ";\n overflow: hidden;\n }\n\n .codeflask__flatten {\n padding: 10px;\n font-size: 13px;\n line-height: 20px;\n white-space: pre;\n position: absolute;\n top: 0;\n left: 0;\n overflow: auto;\n margin: 0 !important;\n outline: none;\n text-align: left;\n }\n\n .codeflask--has-line-numbers .codeflask__flatten {\n left: 40px;\n }\n\n .codeflask__line-highlight {\n position: absolute;\n top: 10px;\n left: 0;\n width: 100%;\n height: 20px;\n background: rgba(0,0,0,0.1);\n z-index: 1;\n }\n\n .codeflask__lines {\n padding: 10px 4px;\n font-size: 12px;\n line-height: 20px;\n font-family: 'Cousine', monospace;\n position: absolute;\n left: 0;\n top: 0;\n width: 40px;\n height: 100%;\n text-align: right;\n color: #999;\n z-index: 2;\n }\n\n .codeflask__lines__line {\n display: block;\n }\n\n .codeflask.codeflask--has-line-numbers {\n padding-left: 40px;\n }\n\n .codeflask.codeflask--has-line-numbers:before {\n content: '';\n position: absolute;\n left: 0;\n top: 0;\n width: 40px;\n height: 100%;\n background: #eee;\n z-index: 1;\n }\n"; 11 | 12 | function i(e, t, n) { 13 | var a = t || "codeflask-style", 14 | s = n || document.head; 15 | if (!e) return !1; 16 | if (document.getElementById(a)) return !0; 17 | var i = document.createElement("style"); 18 | return i.innerHTML = e, i.id = a, s.appendChild(i), !0 19 | } 20 | var r = { 21 | "&": "&", 22 | "<": "<", 23 | ">": ">", 24 | '"': """, 25 | "'": "'", 26 | "/": "/", 27 | "`": "`", 28 | "=": "=" 29 | }; 30 | 31 | function o(e) { 32 | return String(e).replace(/[&<>"'`=/]/g, function(e) { 33 | return r[e] 34 | }) 35 | } 36 | var l = "undefined" != typeof globalThis ? globalThis : "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof self ? self : {}; 37 | var c, u = (function(e) { 38 | var t = function(e) { 39 | var t = /\blang(?:uage)?-([\w-]+)\b/i, 40 | n = 0, 41 | a = { 42 | manual: e.Prism && e.Prism.manual, 43 | disableWorkerMessageHandler: e.Prism && e.Prism.disableWorkerMessageHandler, 44 | util: { 45 | encode: function(e) { 46 | return e instanceof s ? new s(e.type, a.util.encode(e.content), e.alias) : Array.isArray(e) ? e.map(a.util.encode) : e.replace(/&/g, "&").replace(/ e.length) return; 171 | if (!(v instanceof s)) { 172 | if (f && k != t.length - 1) { 173 | if (p.lastIndex = x, !(S = p.exec(e))) break; 174 | for (var w = S.index + (g ? S[1].length : 0), F = S.index + S[0].length, A = k, C = x, T = t.length; A < T && (C < F || !t[A].type && !t[A - 1].greedy); ++A) w >= (C += t[A].length) && (++k, x = C); 175 | if (t[k] instanceof s) continue; 176 | _ = A - k, v = e.slice(x, C), S.index -= x 177 | } else { 178 | p.lastIndex = 0; 179 | var S = p.exec(v), 180 | _ = 1 181 | } 182 | if (S) { 183 | g && (b = S[1] ? S[1].length : 0); 184 | F = (w = S.index + b) + (S = S[0].slice(b)).length; 185 | var L = v.slice(0, w), 186 | E = v.slice(F), 187 | N = [k, _]; 188 | L && (++k, x += L.length, N.push(L)); 189 | var j = new s(c, h ? a.tokenize(S, h) : S, m, S, f); 190 | if (N.push(j), E && N.push(E), Array.prototype.splice.apply(t, N), 1 != _ && a.matchGrammar(e, t, n, k, x, !0, c), o) break 191 | } else if (o) break 192 | } 193 | } 194 | } 195 | } 196 | }, 197 | tokenize: function(e, t) { 198 | var n = [e], 199 | s = t.rest; 200 | if (s) { 201 | for (var i in s) t[i] = s[i]; 202 | delete t.rest 203 | } 204 | return a.matchGrammar(e, n, t, 0, 0, !1), n 205 | }, 206 | hooks: { 207 | all: {}, 208 | add: function(e, t) { 209 | var n = a.hooks.all; 210 | n[e] = n[e] || [], n[e].push(t) 211 | }, 212 | run: function(e, t) { 213 | var n = a.hooks.all[e]; 214 | if (n && n.length) 215 | for (var s, i = 0; s = n[i++];) s(t) 216 | } 217 | }, 218 | Token: s 219 | }; 220 | 221 | function s(e, t, n, a, s) { 222 | this.type = e, this.content = t, this.alias = n, this.length = 0 | (a || "").length, this.greedy = !!s 223 | } 224 | if (e.Prism = a, s.stringify = function(e, t, n) { 225 | if ("string" == typeof e) return e; 226 | if (Array.isArray(e)) return e.map(function(n) { 227 | return s.stringify(n, t, e) 228 | }).join(""); 229 | var i = { 230 | type: e.type, 231 | content: s.stringify(e.content, t, n), 232 | tag: "span", 233 | classes: ["token", e.type], 234 | attributes: {}, 235 | language: t, 236 | parent: n 237 | }; 238 | if (e.alias) { 239 | var r = Array.isArray(e.alias) ? e.alias : [e.alias]; 240 | Array.prototype.push.apply(i.classes, r) 241 | } 242 | a.hooks.run("wrap", i); 243 | var o = Object.keys(i.attributes).map(function(e) { 244 | return e + '="' + (i.attributes[e] || "").replace(/"/g, """) + '"' 245 | }).join(" "); 246 | return "<" + i.tag + ' class="' + i.classes.join(" ") + '"' + (o ? " " + o : "") + ">" + i.content + "" 247 | }, !e.document) return e.addEventListener ? (a.disableWorkerMessageHandler || e.addEventListener("message", function(t) { 248 | var n = JSON.parse(t.data), 249 | s = n.language, 250 | i = n.code, 251 | r = n.immediateClose; 252 | e.postMessage(a.highlight(i, a.languages[s], s)), r && e.close() 253 | }, !1), a) : a; 254 | var i = document.currentScript || [].slice.call(document.getElementsByTagName("script")).pop(); 255 | return i && (a.filename = i.src, a.manual || i.hasAttribute("data-manual") || ("loading" !== document.readyState ? window.requestAnimationFrame ? window.requestAnimationFrame(a.highlightAll) : window.setTimeout(a.highlightAll, 16) : document.addEventListener("DOMContentLoaded", a.highlightAll))), a 256 | }("undefined" != typeof window ? window : "undefined" != typeof WorkerGlobalScope && self instanceof WorkerGlobalScope ? self : {}); 257 | e.exports && (e.exports = t), void 0 !== l && (l.Prism = t), t.languages.markup = { 258 | comment: //, 259 | prolog: /<\?[\s\S]+?\?>/, 260 | doctype: //i, 261 | cdata: //i, 262 | tag: { 263 | pattern: /<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/i, 264 | greedy: !0, 265 | inside: { 266 | tag: { 267 | pattern: /^<\/?[^\s>\/]+/i, 268 | inside: { 269 | punctuation: /^<\/?/, 270 | namespace: /^[^\s>\/:]+:/ 271 | } 272 | }, 273 | "attr-value": { 274 | pattern: /=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/i, 275 | inside: { 276 | punctuation: [/^=/, { 277 | pattern: /^(\s*)["']|["']$/, 278 | lookbehind: !0 279 | }] 280 | } 281 | }, 282 | punctuation: /\/?>/, 283 | "attr-name": { 284 | pattern: /[^\s>\/]+/, 285 | inside: { 286 | namespace: /^[^\s>\/:]+:/ 287 | } 288 | } 289 | } 290 | }, 291 | entity: /&#?[\da-z]{1,8};/i 292 | }, t.languages.markup.tag.inside["attr-value"].inside.entity = t.languages.markup.entity, t.hooks.add("wrap", function(e) { 293 | "entity" === e.type && (e.attributes.title = e.content.replace(/&/, "&")) 294 | }), Object.defineProperty(t.languages.markup.tag, "addInlined", { 295 | value: function(e, n) { 296 | var a = {}; 297 | a["language-" + n] = { 298 | pattern: /(^$)/i, 299 | lookbehind: !0, 300 | inside: t.languages[n] 301 | }, a.cdata = /^$/i; 302 | var s = { 303 | "included-cdata": { 304 | pattern: //i, 305 | inside: a 306 | } 307 | }; 308 | s["language-" + n] = { 309 | pattern: /[\s\S]+/, 310 | inside: t.languages[n] 311 | }; 312 | var i = {}; 313 | i[e] = { 314 | pattern: RegExp(/(<__[\s\S]*?>)(?:\s*|[\s\S])*?(?=<\/__>)/.source.replace(/__/g, e), "i"), 315 | lookbehind: !0, 316 | greedy: !0, 317 | inside: s 318 | }, t.languages.insertBefore("markup", "cdata", i) 319 | } 320 | }), t.languages.xml = t.languages.extend("markup", {}), t.languages.html = t.languages.markup, t.languages.mathml = t.languages.markup, t.languages.svg = t.languages.markup, 321 | function(e) { 322 | var t = /("|')(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/; 323 | e.languages.css = { 324 | comment: /\/\*[\s\S]*?\*\//, 325 | atrule: { 326 | pattern: /@[\w-]+?[\s\S]*?(?:;|(?=\s*\{))/i, 327 | inside: { 328 | rule: /@[\w-]+/ 329 | } 330 | }, 331 | url: RegExp("url\\((?:" + t.source + "|.*?)\\)", "i"), 332 | selector: RegExp("[^{}\\s](?:[^{};\"']|" + t.source + ")*?(?=\\s*\\{)"), 333 | string: { 334 | pattern: t, 335 | greedy: !0 336 | }, 337 | property: /[-_a-z\xA0-\uFFFF][-\w\xA0-\uFFFF]*(?=\s*:)/i, 338 | important: /!important\b/i, 339 | function: /[-a-z0-9]+(?=\()/i, 340 | punctuation: /[(){};:,]/ 341 | }, e.languages.css.atrule.inside.rest = e.languages.css; 342 | var n = e.languages.markup; 343 | n && (n.tag.addInlined("style", "css"), e.languages.insertBefore("inside", "attr-value", { 344 | "style-attr": { 345 | pattern: /\s*style=("|')(?:\\[\s\S]|(?!\1)[^\\])*\1/i, 346 | inside: { 347 | "attr-name": { 348 | pattern: /^\s*style/i, 349 | inside: n.tag.inside 350 | }, 351 | punctuation: /^\s*=\s*['"]|['"]\s*$/, 352 | "attr-value": { 353 | pattern: /.+/i, 354 | inside: e.languages.css 355 | } 356 | }, 357 | alias: "language-css" 358 | } 359 | }, n.tag)) 360 | }(t), t.languages.clike = { 361 | comment: [{ 362 | pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/, 363 | lookbehind: !0 364 | }, { 365 | pattern: /(^|[^\\:])\/\/.*/, 366 | lookbehind: !0, 367 | greedy: !0 368 | }], 369 | string: { 370 | pattern: /(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/, 371 | greedy: !0 372 | }, 373 | "class-name": { 374 | pattern: /((?:\b(?:class|interface|extends|implements|trait|instanceof|new)\s+)|(?:catch\s+\())[\w.\\]+/i, 375 | lookbehind: !0, 376 | inside: { 377 | punctuation: /[.\\]/ 378 | } 379 | }, 380 | keyword: /\b(?:if|else|while|do|for|return|in|instanceof|function|new|try|throw|catch|finally|null|break|continue)\b/, 381 | boolean: /\b(?:true|false)\b/, 382 | function: /\w+(?=\()/, 383 | number: /\b0x[\da-f]+\b|(?:\b\d+\.?\d*|\B\.\d+)(?:e[+-]?\d+)?/i, 384 | operator: /--?|\+\+?|!=?=?|<=?|>=?|==?=?|&&?|\|\|?|\?|\*|\/|~|\^|%/, 385 | punctuation: /[{}[\];(),.:]/ 386 | }, t.languages.javascript = t.languages.extend("clike", { 387 | "class-name": [t.languages.clike["class-name"], { 388 | pattern: /(^|[^$\w\xA0-\uFFFF])[_$A-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\.(?:prototype|constructor))/, 389 | lookbehind: !0 390 | }], 391 | keyword: [{ 392 | pattern: /((?:^|})\s*)(?:catch|finally)\b/, 393 | lookbehind: !0 394 | }, { 395 | pattern: /(^|[^.])\b(?:as|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield|senão)\b/, 396 | lookbehind: !0 397 | }], 398 | number: /\b(?:(?:0[xX][\dA-Fa-f]+|0[bB][01]+|0[oO][0-7]+)n?|\d+n|NaN|Infinity)\b|(?:\b\d+\.?\d*|\B\.\d+)(?:[Ee][+-]?\d+)?/, 399 | function: /[_$a-zA-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/, 400 | operator: /-[-=]?|\+[+=]?|!=?=?|<>?>?=?|=(?:==?|>)?|&[&=]?|\|[|=]?|\*\*?=?|\/=?|~|\^=?|%=?|\?|\.{3}/ 401 | }), t.languages.javascript["class-name"][0].pattern = /(\b(?:class|interface|extends|implements|instanceof|new)\s+)[\w.\\]+/, t.languages.insertBefore("javascript", "keyword", { 402 | regex: { 403 | pattern: /((?:^|[^$\w\xA0-\uFFFF."'\])\s])\s*)\/(\[(?:[^\]\\\r\n]|\\.)*]|\\.|[^/\\\[\r\n])+\/[gimyu]{0,5}(?=\s*($|[\r\n,.;})\]]))/, 404 | lookbehind: !0, 405 | greedy: !0 406 | }, 407 | "function-variable": { 408 | pattern: /[_$a-zA-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|[_$a-zA-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*)\s*=>))/, 409 | alias: "function" 410 | }, 411 | parameter: [{ 412 | pattern: /(function(?:\s+[_$A-Za-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*)?\s*\(\s*)(?!\s)(?:[^()]|\([^()]*\))+?(?=\s*\))/, 413 | lookbehind: !0, 414 | inside: t.languages.javascript 415 | }, { 416 | pattern: /[_$a-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*=>)/i, 417 | inside: t.languages.javascript 418 | }, { 419 | pattern: /(\(\s*)(?!\s)(?:[^()]|\([^()]*\))+?(?=\s*\)\s*=>)/, 420 | lookbehind: !0, 421 | inside: t.languages.javascript 422 | }, { 423 | pattern: /((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:[_$A-Za-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*\s*)\(\s*)(?!\s)(?:[^()]|\([^()]*\))+?(?=\s*\)\s*\{)/, 424 | lookbehind: !0, 425 | inside: t.languages.javascript 426 | }], 427 | constant: /\b[A-Z](?:[A-Z_]|\dx?)*\b/ 428 | }), t.languages.insertBefore("javascript", "string", { 429 | "template-string": { 430 | pattern: /`(?:\\[\s\S]|\${[^}]+}|[^\\`])*`/, 431 | greedy: !0, 432 | inside: { 433 | interpolation: { 434 | pattern: /\${[^}]+}/, 435 | inside: { 436 | "interpolation-punctuation": { 437 | pattern: /^\${|}$/, 438 | alias: "punctuation" 439 | }, 440 | rest: t.languages.javascript 441 | } 442 | }, 443 | string: /[\s\S]+/ 444 | } 445 | } 446 | }), t.languages.markup && t.languages.markup.tag.addInlined("script", "javascript"), t.languages.js = t.languages.javascript, "undefined" != typeof self && self.Prism && self.document && document.querySelector && (self.Prism.fileHighlight = function(e) { 447 | e = e || document; 448 | var n = { 449 | js: "javascript", 450 | py: "python", 451 | rb: "ruby", 452 | ps1: "powershell", 453 | psm1: "powershell", 454 | sh: "bash", 455 | bat: "batch", 456 | h: "c", 457 | tex: "latex" 458 | }; 459 | Array.prototype.slice.call(e.querySelectorAll("pre[data-src]")).forEach(function(e) { 460 | if (!e.hasAttribute("data-src-loaded")) { 461 | for (var a, s = e.getAttribute("data-src"), i = e, r = /\blang(?:uage)?-([\w-]+)\b/i; i && !r.test(i.className);) i = i.parentNode; 462 | if (i && (a = (e.className.match(r) || [, ""])[1]), !a) { 463 | var o = (s.match(/\.(\w+)$/) || [, ""])[1]; 464 | a = n[o] || o 465 | } 466 | var l = document.createElement("code"); 467 | l.className = "language-" + a, e.textContent = "", l.textContent = "Loading…", e.appendChild(l); 468 | var c = new XMLHttpRequest; 469 | c.open("GET", s, !0), c.onreadystatechange = function() { 470 | 4 == c.readyState && (c.status < 400 && c.responseText ? (l.textContent = c.responseText, t.highlightElement(l), e.setAttribute("data-src-loaded", "")) : c.status >= 400 ? l.textContent = "✖ Error " + c.status + " while fetching file: " + c.statusText : l.textContent = "✖ Error: File does not exist or is empty") 471 | }, c.send(null) 472 | } 473 | }), t.plugins.toolbar && t.plugins.toolbar.registerButton("download-file", function(e) { 474 | var t = e.element.parentNode; 475 | if (t && /pre/i.test(t.nodeName) && t.hasAttribute("data-src") && t.hasAttribute("data-download-link")) { 476 | var n = t.getAttribute("data-src"), 477 | a = document.createElement("a"); 478 | return a.textContent = t.getAttribute("data-download-link-label") || "Download", a.setAttribute("download", ""), a.href = n, a 479 | } 480 | }) 481 | }, document.addEventListener("DOMContentLoaded", function() { 482 | self.Prism.fileHighlight() 483 | })) 484 | }(c = { 485 | exports: {} 486 | }, c.exports), c.exports), 487 | d = function(e, t) { 488 | if (!e) throw Error("CodeFlask expects a parameter which is Element or a String selector"); 489 | if (!t) throw Error("CodeFlask expects an object containing options as second parameter"); 490 | if (e.nodeType) this.editorRoot = e; 491 | else { 492 | var n = document.querySelector(e); 493 | n && (this.editorRoot = n) 494 | } 495 | this.opts = t, this.startEditor() 496 | }; 497 | return d.prototype.startEditor = function() { 498 | if (!i(s, null, this.opts.styleParent)) throw Error("Failed to inject CodeFlask CSS."); 499 | this.createWrapper(), this.createTextarea(), this.createPre(), this.createCode(), this.runOptions(), this.listenTextarea(), this.populateDefault(), this.updateCode(this.code) 500 | }, d.prototype.createWrapper = function() { 501 | this.code = this.editorRoot.innerHTML, this.editorRoot.innerHTML = "", this.elWrapper = this.createElement("div", this.editorRoot), this.elWrapper.classList.add("codeflask") 502 | }, d.prototype.createTextarea = function() { 503 | this.elTextarea = this.createElement("textarea", this.elWrapper), this.elTextarea.classList.add("codeflask__textarea", "codeflask__flatten") 504 | }, d.prototype.createPre = function() { 505 | this.elPre = this.createElement("pre", this.elWrapper), this.elPre.classList.add("codeflask__pre", "codeflask__flatten") 506 | }, d.prototype.createCode = function() { 507 | this.elCode = this.createElement("code", this.elPre), this.elCode.classList.add("codeflask__code", "language-" + (this.opts.language || "html")) 508 | }, d.prototype.createLineNumbers = function() { 509 | this.elLineNumbers = this.createElement("div", this.elWrapper), this.elLineNumbers.classList.add("codeflask__lines"), this.setLineNumber() 510 | }, d.prototype.createElement = function(e, t) { 511 | var n = document.createElement(e); 512 | return t.appendChild(n), n 513 | }, d.prototype.runOptions = function() { 514 | this.opts.rtl = this.opts.rtl || !1, this.opts.tabSize = this.opts.tabSize || 2, this.opts.enableAutocorrect = this.opts.enableAutocorrect || !1, this.opts.lineNumbers = this.opts.lineNumbers || !1, this.opts.defaultTheme = !1 !== this.opts.defaultTheme, this.opts.areaId = this.opts.areaId || null, this.opts.ariaLabelledby = this.opts.ariaLabelledby || null, this.opts.readonly = this.opts.readonly || null, "boolean" != typeof this.opts.handleTabs && (this.opts.handleTabs = !0), "boolean" != typeof this.opts.handleSelfClosingCharacters && (this.opts.handleSelfClosingCharacters = !0), "boolean" != typeof this.opts.handleNewLineIndentation && (this.opts.handleNewLineIndentation = !0), !0 === this.opts.rtl && (this.elTextarea.setAttribute("dir", "rtl"), this.elPre.setAttribute("dir", "rtl")), !1 === this.opts.enableAutocorrect && (this.elTextarea.setAttribute("spellcheck", "false"), this.elTextarea.setAttribute("autocapitalize", "off"), this.elTextarea.setAttribute("autocomplete", "off"), this.elTextarea.setAttribute("autocorrect", "off")), this.opts.lineNumbers && (this.elWrapper.classList.add("codeflask--has-line-numbers"), this.createLineNumbers()), this.opts.defaultTheme && i("\n.codeflask {\n background: #fff;\n color: #4f559c;\n}\n\n.codeflask .token.punctuation {\n color: #4a4a4a;\n}\n\n.codeflask .token.keyword {\n color: #8500ff;\n}\n\n.codeflask .token.operator {\n color: #ff5598;\n}\n\n.codeflask .token.string {\n color: #41ad8f;\n}\n\n.codeflask .token.comment {\n color: #9badb7;\n}\n\n.codeflask .token.function {\n color: #8500ff;\n}\n\n.codeflask .token.boolean {\n color: #8500ff;\n}\n\n.codeflask .token.number {\n color: #8500ff;\n}\n\n.codeflask .token.selector {\n color: #8500ff;\n}\n\n.codeflask .token.property {\n color: #8500ff;\n}\n\n.codeflask .token.tag {\n color: #8500ff;\n}\n\n.codeflask .token.attr-value {\n color: #8500ff;\n}\n", "theme-default", this.opts.styleParent), this.opts.areaId && this.elTextarea.setAttribute("id", this.opts.areaId), this.opts.ariaLabelledby && this.elTextarea.setAttribute("aria-labelledby", this.opts.ariaLabelledby), this.opts.readonly && this.enableReadonlyMode() 515 | }, d.prototype.updateLineNumbersCount = function() { 516 | for (var e = "", t = 1; t <= this.lineNumber; t++) e = e + '' + t + ""; 517 | this.elLineNumbers.innerHTML = e 518 | }, d.prototype.listenTextarea = function() { 519 | var e = this; 520 | this.elTextarea.addEventListener("input", function(t) { 521 | e.code = t.target.value, e.elCode.innerHTML = o(t.target.value), e.highlight(), setTimeout(function() { 522 | e.runUpdate(), e.setLineNumber() 523 | }, 1) 524 | }), this.elTextarea.addEventListener("keydown", function(t) { 525 | e.handleTabs(t), e.handleSelfClosingCharacters(t), e.handleNewLineIndentation(t) 526 | }), this.elTextarea.addEventListener("scroll", function(t) { 527 | e.elPre.style.transform = "translate3d(-" + t.target.scrollLeft + "px, -" + t.target.scrollTop + "px, 0)", e.elLineNumbers && (e.elLineNumbers.style.transform = "translate3d(0, -" + t.target.scrollTop + "px, 0)") 528 | }) 529 | }, d.prototype.handleTabs = function(e) { 530 | if (this.opts.handleTabs) { 531 | if (9 !== e.keyCode) return; 532 | e.preventDefault(); 533 | var t = this.elTextarea, 534 | n = t.selectionDirection, 535 | a = t.selectionStart, 536 | s = t.selectionEnd, 537 | i = t.value, 538 | r = i.substr(0, a), 539 | o = i.substring(a, s), 540 | l = i.substring(s), 541 | c = " ".repeat(this.opts.tabSize); 542 | if (a !== s && o.length >= c.length) { 543 | var u = a - r.split("\n").pop().length, 544 | d = c.length, 545 | p = c.length; 546 | if (e.shiftKey) i.substr(u, c.length) === c ? (d = -d, u > a ? (o = o.substring(0, u) + o.substring(u + c.length), p = 0) : u === a ? (d = 0, p = 0, o = o.substring(c.length)) : (p = -p, r = r.substring(0, u) + r.substring(u + c.length))) : (d = 0, p = 0), o = o.replace(new RegExp("\n" + c.split("").join("\\"), "g"), "\n"); 547 | else r = r.substr(0, u) + c + r.substring(u, a), o = o.replace(/\n/g, "\n" + c); 548 | t.value = r + o + l, t.selectionStart = a + d, t.selectionEnd = a + o.length + p, t.selectionDirection = n 549 | } else t.value = r + c + l, t.selectionStart = a + c.length, t.selectionEnd = a + c.length; 550 | var h = t.value; 551 | this.updateCode(h), this.elTextarea.selectionEnd = s + this.opts.tabSize 552 | } 553 | }, d.prototype.handleSelfClosingCharacters = function(e) { 554 | if (this.opts.handleSelfClosingCharacters) { 555 | var t = e.key; 556 | if (["(", "[", "{", "'", '"'].includes(t) || [")", "]", "}", "'", '"'].includes(t)) switch (t) { 557 | case "(": 558 | case ")": 559 | this.closeCharacter(t); 560 | break; 561 | case "[": 562 | case "]": 563 | this.closeCharacter(t); 564 | break; 565 | case "{": 566 | case "}": 567 | this.closeCharacter(t); 568 | break; 569 | case "<": 570 | case ">": 571 | case "'": 572 | case '"': 573 | this.closeCharacter(t) 574 | } 575 | } 576 | }, d.prototype.setLineNumber = function() { 577 | this.lineNumber = this.code.split("\n").length, this.opts.lineNumbers && this.updateLineNumbersCount() 578 | }, d.prototype.handleNewLineIndentation = function(e) { 579 | if (this.opts.handleNewLineIndentation && 13 === e.keyCode) { 580 | e.preventDefault(); 581 | var t = this.elTextarea, 582 | n = t.selectionStart, 583 | a = t.selectionEnd, 584 | s = t.value, 585 | i = s.substr(0, n), 586 | r = s.substring(a), 587 | o = s.lastIndexOf("\n", n - 1), 588 | l = o + s.slice(o + 1).search(/[^ ]|$/), 589 | c = l > o ? l - o : 0, 590 | u = i + "\n" + " ".repeat(c) + r; 591 | t.value = u, t.selectionStart = n + c + 1, t.selectionEnd = n + c + 1, this.updateCode(t.value) 592 | } 593 | }, d.prototype.closeCharacter = function(e) { 594 | var t = this.elTextarea.selectionStart, 595 | n = this.elTextarea.selectionEnd; 596 | if (this.skipCloseChar(e)) { 597 | var a = this.code.substr(n, 1) === e, 598 | s = a ? n + 1 : n, 599 | i = !a && ["'", '"'].includes(e) ? e : "", 600 | r = "" + this.code.substring(0, t) + i + this.code.substring(s); 601 | this.updateCode(r), this.elTextarea.selectionEnd = ++this.elTextarea.selectionStart 602 | } else { 603 | var o = e; 604 | switch (e) { 605 | case "(": 606 | o = String.fromCharCode(e.charCodeAt() + 1); 607 | break; 608 | case "<": 609 | case "{": 610 | case "[": 611 | o = String.fromCharCode(e.charCodeAt() + 2) 612 | } 613 | var l = this.code.substring(t, n), 614 | c = "" + this.code.substring(0, t) + l + o + this.code.substring(n); 615 | this.updateCode(c) 616 | } 617 | this.elTextarea.selectionEnd = t 618 | }, d.prototype.skipCloseChar = function(e) { 619 | var t = this.elTextarea.selectionStart, 620 | n = this.elTextarea.selectionEnd, 621 | a = Math.abs(n - t) > 0; 622 | return [")", "}", "]", ">"].includes(e) || ["'", '"'].includes(e) && !a 623 | }, d.prototype.updateCode = function(e) { 624 | this.code = e, this.elTextarea.value = e, this.elCode.innerHTML = o(e), this.highlight(), this.setLineNumber(), setTimeout(this.runUpdate.bind(this), 1) 625 | }, d.prototype.updateLanguage = function(e) { 626 | var t = this.opts.language; 627 | this.elCode.classList.remove("language-" + t), this.elCode.classList.add("language-" + e), this.opts.language = e, this.highlight() 628 | }, d.prototype.addLanguage = function(e, t) { 629 | u.languages[e] = t 630 | }, d.prototype.populateDefault = function() { 631 | this.updateCode(this.code) 632 | }, d.prototype.highlight = function() { 633 | u.highlightElement(this.elCode, !1) 634 | }, d.prototype.onUpdate = function(e) { 635 | if (e && "[object Function]" !== {}.toString.call(e)) throw Error("CodeFlask expects callback of type Function"); 636 | this.updateCallBack = e 637 | }, d.prototype.getCode = function() { 638 | return this.code 639 | }, d.prototype.runUpdate = function() { 640 | this.updateCallBack && this.updateCallBack(this.code) 641 | }, d.prototype.enableReadonlyMode = function() { 642 | this.elTextarea.setAttribute("readonly", !0) 643 | }, d.prototype.disableReadonlyMode = function() { 644 | this.elTextarea.removeAttribute("readonly") 645 | }, d 646 | }); --------------------------------------------------------------------------------