about summary refs log tree commit diff stats
path: root/html/playground
diff options
context:
space:
mode:
Diffstat (limited to 'html/playground')
-rw-r--r--html/playground/counter.html262
-rw-r--r--html/playground/index.html435
-rw-r--r--html/playground/little-regex.html728
-rw-r--r--html/playground/regex.html477
-rw-r--r--html/playground/scheme.html123
5 files changed, 1693 insertions, 332 deletions
diff --git a/html/playground/counter.html b/html/playground/counter.html
new file mode 100644
index 0000000..1b16f54
--- /dev/null
+++ b/html/playground/counter.html
@@ -0,0 +1,262 @@
+<html lang="en"><head>
+    <meta charset="UTF-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <title>JavaScript Playground</title>
+    <meta name="description" content="A JavaScript jungle-gym for doing experiments and sharing scrappy fiddles.">
+    <style>
+        body {
+            display: flex;
+            flex-direction: column;
+            align-items: center;
+            background-color: #ddd;
+            padding: 10px;
+            height: 100vh;
+            margin: 0;
+        }
+
+        textarea {
+            width: 100%;
+            height: 64%;
+            font-family: monospace;
+            background-color: #FFFEEC;
+            border: 2px solid #000;
+            scrollbar-width: none;            
+            font-size: 1rem;
+            margin-bottom: 10px;
+            padding: 10px;
+            box-sizing: border-box;
+            resize: none;
+            border-bottom: 12px solid teal;
+            -webkit-user-modify: read-write-plaintext-only;
+        }
+
+        textarea::-webkit-scrollbar {
+            display: none;
+        }
+
+        textarea::selection {
+            background-color: #EFECA7;
+        }
+
+        textarea:focus {
+            outline: none;
+        }
+
+        #console {
+            width: 100%;
+            height: 22%;
+            background-color: #000;
+            color: #0fc;
+            font-family: monospace;
+            font-size: 1rem;
+            overflow-y: auto;
+            padding: 10px;
+            box-sizing: border-box;
+            white-space: pre-wrap;
+        }
+
+        .button-container {
+            width: 100%;
+            display: flex;
+            justify-content: flex-end;
+            margin-bottom: 10px;
+        }
+
+        button {
+            padding: 10px 20px;
+            font-size: 1rem;
+            margin-left: 10px;
+            cursor: pointer;
+            border: none;
+            transition: background-color 0.3s ease;
+        }
+
+        button:hover, button:focus {
+            outline: none; 
+        }
+
+        button.run {
+            background-color: teal;
+            color: #FFFFFF;
+        }
+    </style>
+</head>
+<body>
+
+    <div class="playground" id="playground">    
+        <div class="seesaw" id="seesaw"></div>
+        <div class="slide" id="slide"></div>
+    </div>
+
+    <div class="button-container">
+        <button onclick="clearEverything()">Clear</button>
+        <button onclick="downloadCodeAndEditor()">Download</button>
+        <button onclick="shareCode()">Share</button>
+        <button onclick="evaluateCode()" class="run">Run Code</button>
+    </div>
+    <textarea id="codeInput">mount(playground => {
+    const d = document.createElement('div');
+    const p = document.createElement('p');
+    const b = document.createElement('button');
+    const b2 = document.createElement('button');
+    
+    d.style = 'border: 1px solid black; padding: 2em';
+    p.textContent = 'Count: 0';
+    p.style = 'text-align: center; font-weight: bold';
+    b.textContent = 'Click Me';
+    b2.textContent = 'Reset';
+    b2.style = 'background-color: red; color: white';
+    d.append(p,b,b2);
+    
+    let count = 0;
+    b.onclick  = () => { count++;    p.innerHTML = 'Count: ' + count; }
+    b2.onclick = () => { count = 0;  p.innerHTML = 'Count: ' + count; }
+
+    playground.appendChild(d);
+});
+</textarea>
+    <div id="console"></div>
+
+    <script>
+        function evaluateCode() {
+            const code = document.getElementById('codeInput').value;
+            const consoleDiv = document.getElementById('console');
+            consoleDiv.innerHTML = '';
+
+            // Custom console.log function to output to the console div
+            const originalConsoleLog = console.log;
+            console.log = function(...args) {
+                args.forEach(arg => {
+                    const output = document.createElement('div');
+                    output.textContent = typeof arg === 'object' ? JSON.stringify(arg, null, 2) : arg;
+                    consoleDiv.appendChild(output);
+                });
+                originalConsoleLog.apply(console, args);
+            };
+
+            try {
+                eval(code);
+            } catch (error) {
+                const errorOutput = document.createElement('div');
+                errorOutput.textContent = error;
+                errorOutput.style.color = 'red';
+                consoleDiv.appendChild(errorOutput);
+            }
+
+            // Restore browser's console.log
+            console.log = originalConsoleLog;
+        }
+
+        function downloadCodeAndEditor() {
+            const codeInput = document.getElementById('codeInput').value;
+            const htmlContent = document.documentElement.outerHTML.replace(
+                /<textarea id="codeInput"[^>]*>.*<\/textarea>/,
+                `<textarea id="codeInput">${codeInput}</textarea>`
+            );
+
+            const blob = new Blob([htmlContent], { type: 'text/html' });
+            const url = URL.createObjectURL(blob);
+            const a = document.createElement('a');
+            a.href = url;
+            a.download = 'code_editor.html';
+            document.body.appendChild(a);
+            a.click();
+            document.body.removeChild(a);
+            URL.revokeObjectURL(url);
+        }
+
+        function shareCode() {
+            const code = document.getElementById('codeInput').value;
+            const encodedCode = btoa(encodeURIComponent(code));
+            window.location.hash = encodedCode;
+            window.prompt("Copy the URL to share.\nBe warned! Very long URLs don't share wicked well, sometimes.", window.location.href);
+        }
+
+        function clearEverything() {
+            if (!confirm('Are you sure you want to reset the playground?')) {
+                return;
+            } else {               
+                window.location.hash = '';
+                window.location.reload();
+            }
+        }
+
+        function loadCodeFromHash() {
+            const hash = window.location.hash.substring(1);
+            if (hash) {
+                try {
+                    const decodedCode = decodeURIComponent(atob(hash));
+                    document.getElementById('codeInput').value = decodedCode;
+                } catch (error) {
+                    console.error('Failed to decode the URL hash:', error);
+                }
+            }
+        }
+
+        function help() {
+            const helpText = `
+            Welcome to the JavaScript Playground! Here are some tips to get you started:
+
+            1. Enter your JavaScript code in the textarea.
+            2. Click the "Run Code" button to execute your code.
+            3. The console output will be displayed below the textarea.
+            4. Click the "Clear" button to reset the playground.
+            5. Click the "Download" button to save your code and editor as an HTML file.
+            6. Click the "Share" button to generate a URL to share your code with others.
+            7. You can also press "Cmd + Enter" to run your code.
+            8. There's an empty div above the buttons with the id "playground"
+            9. You can mount stuff to it using the "mount" function, for more info run "mountHelp()"
+            10. You can use the "clear()" function to clear the content's of the console.
+
+            Go nuts! Share scrappy fiddles!
+            `;
+            console.log(helpText);
+        }
+
+        function clear() {
+            document.getElementById('console').innerHTML = '';
+        }
+
+        function mountHelp() {
+            console.log(`
+            The mount function is used to mount stuff to the playground div.
+            It takes a function as an argument, which in turn receives the playground div as an argument.
+            Before mounting, it clears the playground div.
+            Here's an example of how to use the mount function:
+
+            mount(playground => {
+                const h1 = document.createElement('h1');
+                h1.textContent = 'Hell is empty and all the devils are here.';
+                playground.appendChild(h1);
+            });
+
+            This will add an h1 element to the playground div.
+            `);
+        }
+
+        function mount(mountFunction) {
+            const playground = document.getElementById('playground');
+            if (!playground) {
+                console.error("Couldn't find a div with the id 'playground'! You may need to reload the page.");
+                return;
+            }
+
+            if (playground.innerHTML.trim() !== "") {
+                playground.innerHTML = "";
+            }
+            mountFunction(playground);
+        }
+
+
+        document.getElementById('codeInput').addEventListener('keydown', function(event) {
+            if (event.metaKey && event.key === 'Enter') {
+                event.preventDefault();
+                evaluateCode();
+            }
+        });
+
+        window.onload = loadCodeFromHash;
+    </script>
+
+
+</body></html>
\ No newline at end of file
diff --git a/html/playground/index.html b/html/playground/index.html
index 680f022..a236d2f 100644
--- a/html/playground/index.html
+++ b/html/playground/index.html
@@ -6,238 +6,243 @@
     <title>JavaScript Playground</title>
     <meta name="description" content="A JavaScript jungle-gym for doing experiments and sharing scrappy fiddles.">
     <style>
-        body {
-            display: flex;
-            flex-direction: column;
-            align-items: center;
-            background-color: #ddd;
-            padding: 10px;
-            height: 100vh;
-            margin: 0;
-        }
-
-        textarea {
-            width: 100%;
-            height: 64%;
-            font-family: monospace;
-            background-color: #FFFEEC;
-            border: 2px solid #000;
-            scrollbar-width: none;            
-            font-size: 1rem;
-            margin-bottom: 10px;
-            padding: 10px;
-            box-sizing: border-box;
-            resize: none;
-            border-bottom: 12px solid teal;
-            -webkit-user-modify: read-write-plaintext-only;
-        }
-
-        textarea::-webkit-scrollbar {
-            display: none;
-        }
-
-        textarea::selection {
-            background-color: #EFECA7;
-        }
-
-        textarea:focus {
-            outline: none;
-        }
-
-        #console {
-            width: 100%;
-            height: 22%;
-            background-color: #000;
-            color: #0fc;
-            font-family: monospace;
-            font-size: 1rem;
-            overflow-y: auto;
-            padding: 10px;
-            box-sizing: border-box;
-            white-space: pre-wrap;
-        }
-
-        .button-container {
-            width: 100%;
-            display: flex;
-            justify-content: flex-end;
-            margin-bottom: 10px;
-        }
-
-        button {
-            padding: 10px 20px;
-            font-size: 1rem;
-            margin-left: 10px;
-            cursor: pointer;
-            border: none;
-            transition: background-color 0.3s ease;
-        }
-
-        button:hover, button:focus {
-            outline: none; 
-        }
-
-        button.run {
-            background-color: teal;
-            color: #FFFFFF;
-        }
+        html, body { height: 100%; margin: 0; padding: 0; }
+        body { display: flex; flex-direction: column; background-color: #ddd; }
+        #app { display: flex; flex-direction: column; padding: 10px; height: 100%; box-sizing: border-box; }
+        .button-container { width: 100%; display: flex; justify-content: flex-end; margin-bottom: 10px; flex-shrink: 0; }
+        button { padding: 10px 20px; font-size: 1rem; margin-left: 10px; cursor: pointer; border: none; transition: background-color 0.3s ease; }
+        button:hover, button:focus { outline: none; }
+        button:disabled { background-color: #999; cursor: not-allowed; }
+        button.run { background-color: teal; color: #FFFFFF; }
+        textarea { width: 100%; height: 64%; font-family: monospace; background-color: #FFFEEC; border: 2px solid #000; scrollbar-width: none; font-size: 1rem; margin-bottom: 10px; padding: 10px; box-sizing: border-box; resize: none; border-bottom: 12px solid teal; -webkit-user-modify: read-write-plaintext-only; flex-shrink: 0; }
+        textarea::-webkit-scrollbar { display: none; }
+        textarea::selection { background-color: #EFECA7; }
+        textarea:focus { outline: none; }
+        #console { width: 100%; height: 22%; background-color: #000; color: #0fc; font-family: monospace; font-size: 1rem; overflow-y: auto; padding: 10px; box-sizing: border-box; white-space: pre-wrap; flex-grow: 1; }
+        #console .log-item { margin-bottom: 5px; border-bottom: 1px solid #333; }
+        #console details { cursor: pointer; }
+        #console summary { outline: none; }
     </style>
 </head>
 <body>
+    <div id="app"></div>
 
-    <div class="playground" id="playground">    
-        <div class="seesaw" id="seesaw"></div>
-        <div class="slide" id="slide"></div>
-    </div>
-
-    <div class="button-container">
-        <button onclick="clearEverything()">Clear</button>
-        <button onclick="downloadCodeAndEditor()">Download</button>
-        <button onclick="shareCode()">Share</button>
-        <button onclick="evaluateCode()" class="run">Run Code</button>
-    </div>
-    <textarea id="codeInput" placeholder="Enter JavaScript..." spellcheck="false"></textarea>
-    <div id="console"></div>
+    <iframe id="sandbox" style="display: none;" title="JavaScript Sandbox"></iframe>
 
     <script>
-        function evaluateCode() {
-            const code = document.getElementById('codeInput').value;
-            const consoleDiv = document.getElementById('console');
-            consoleDiv.innerHTML = '';
-
-            // Custom console.log function to output to the console div
-            const originalConsoleLog = console.log;
-            console.log = function(...args) {
-                args.forEach(arg => {
-                    const output = document.createElement('div');
-                    output.textContent = typeof arg === 'object' ? JSON.stringify(arg, null, 2) : arg;
-                    consoleDiv.appendChild(output);
-                });
-                originalConsoleLog.apply(console, args);
-            };
-
-            try {
-                eval(code);
-            } catch (error) {
-                const errorOutput = document.createElement('div');
-                errorOutput.textContent = error;
-                errorOutput.style.color = 'red';
-                consoleDiv.appendChild(errorOutput);
+        /**
+         * ----------------------------------------------------------------
+         * Functional Utilities
+         * ----------------------------------------------------------------
+         */
+
+        const pipe = (...fns) => (initialValue) => fns.reduce((acc, fn) => fn(acc), initialValue);
+        const compose = (...fns) => (initialValue) => fns.reduceRight((acc, fn) => fn(acc), initialValue);
+
+        /**
+         * ----------------------------------------------------------------
+         * The Elm Architecture (Model, View, Update) Implementation
+         * ----------------------------------------------------------------
+         */
+
+        const init = {
+            code: `
+            const add = (a, b) => a + b;
+            const multiply = (a, b) => a * b;
+
+            const addAndMultiply = pipe(add, multiply);
+
+            console.log(addAndMultiply(2, 3));
+`,
+            consoleOutput: [],
+            sandboxReady: false,
+        };
+
+        const view = (model) => `
+            <div class="button-container">
+                <button onclick="dispatch({ type: 'CLEAR' })">Clear</button>
+                <button onclick="dispatch({ type: 'DOWNLOAD' })">Download</button>
+                <button onclick="dispatch({ type: 'SHARE' })">Share</button>
+                <button onclick="dispatch({ type: 'RUN_CODE' })" class="run" ${!model.sandboxReady ? 'disabled title="Sandbox is loading..."' : ''}>Run Code</button>
+            </div>
+            <textarea id="codeInput" oninput="dispatch({ type: 'CODE_CHANGED', payload: this.value })" onkeydown="handleKeyDown(event)">${model.code}</textarea>
+            <div id="console">
+                ${model.consoleOutput.map(log => {
+                    if (typeof log === 'object' && log !== null) {
+                        return `<div class="log-item"><details><summary>${Object.prototype.toString.call(log)}</summary><pre>${JSON.stringify(log, null, 2)}</pre></details></div>`;
+                    }
+                    return `<div class="log-item">${log}</div>`;
+                }).join('')}
+            </div>
+        `;
+
+        const update = (msg, model) => {
+            switch (msg.type) {
+                case 'CODE_CHANGED':
+                    return { ...model, code: msg.payload };
+                
+                case 'RUN_CODE':
+                    return model;
+
+                case 'CONSOLE_LOG':
+                    return { ...model, consoleOutput: [...model.consoleOutput, ...msg.payload] };
+
+                case 'CLEAR':
+                    if (confirm('Are you sure you want to reset the playground?')) {
+                        window.location.hash = '';
+                        window.location.reload();
+                    }
+                    return model;
+
+                case 'CLEAR_CONSOLE':
+                     return { ...model, consoleOutput: [] };
+                
+                case 'SHARE':
+                case 'DOWNLOAD':
+                    return model;
+
+                case 'SANDBOX_READY':
+                    return { ...model, sandboxReady: true };
+
+                default:
+                    return model;
             }
-
-            // Restore browser's console.log
-            console.log = originalConsoleLog;
-        }
-
-        function downloadCodeAndEditor() {
-            const codeInput = document.getElementById('codeInput').value;
-            const htmlContent = document.documentElement.outerHTML.replace(
-                /<textarea id="codeInput"[^>]*>.*<\/textarea>/,
-                `<textarea id="codeInput">${codeInput}</textarea>`
-            );
-
-            const blob = new Blob([htmlContent], { type: 'text/html' });
-            const url = URL.createObjectURL(blob);
-            const a = document.createElement('a');
-            a.href = url;
-            a.download = 'code_editor.html';
-            document.body.appendChild(a);
-            a.click();
-            document.body.removeChild(a);
-            URL.revokeObjectURL(url);
-        }
-
-        function shareCode() {
-            const code = document.getElementById('codeInput').value;
-            const encodedCode = btoa(encodeURIComponent(code));
-            window.location.hash = encodedCode;
-            window.prompt("Copy the URL to share.\nBe warned! Very long URLs don't share wicked well, sometimes.", window.location.href);
-        }
-
-        function clearEverything() {
-            if (!confirm('Are you sure you want to reset the playground?')) {
-                return;
-            } else {               
-                window.location.hash = '';
-                window.location.reload();
+        };
+
+        /**
+         * ----------------------------------------------------------------
+         * Application Core & Side-Effect Handling
+         * ----------------------------------------------------------------
+         */
+
+        let model = null;
+        const appContainer = document.getElementById('app');
+        const sandbox = document.getElementById('sandbox');
+
+        const dispatch = (msg) => {
+            const newModel = update(msg, model);
+            handleSideEffects(msg, newModel);
+            model = newModel;
+            render(model);
+        };
+
+        const handleSideEffects = (msg, model) => {
+             if (msg.type === 'RUN_CODE') {
+                if (!model.sandboxReady) return;
+                dispatch({ type: 'CLEAR_CONSOLE' });
+                sandbox.contentWindow.postMessage({ code: model.code }, '*');
+            } else if (msg.type === 'SHARE') {
+                const encodedCode = btoa(encodeURIComponent(model.code));
+                window.location.hash = encodedCode;
+                window.prompt("Copy the URL to share.", window.location.href);
+            } else if (msg.type === 'DOWNLOAD') {
+                const htmlContent = document.documentElement.outerHTML.replace(
+                    /<textarea id="codeInput"[^>]*>.*<\/textarea>/,
+                    `<textarea id="codeInput">${model.code}</textarea>`
+                );
+                const blob = new Blob([htmlContent], { type: 'text/html' });
+                const url = URL.createObjectURL(blob);
+                const a = document.createElement('a');
+                a.href = url;
+                a.download = 'playground.html';
+                a.click();
+                URL.revokeObjectURL(url);
             }
-        }
-
-        function loadCodeFromHash() {
-            const hash = window.location.hash.substring(1);
-            if (hash) {
-                try {
-                    const decodedCode = decodeURIComponent(atob(hash));
-                    document.getElementById('codeInput').value = decodedCode;
-                } catch (error) {
-                    console.error('Failed to decode the URL hash:', error);
+        };
+
+        const render = (model) => {
+            const focusedElementId = document.activeElement?.id;
+            const selectionStart = document.activeElement?.selectionStart;
+            const selectionEnd = document.activeElement?.selectionEnd;
+
+            appContainer.innerHTML = view(model);
+
+            if (focusedElementId === 'codeInput') {
+                const focusedElement = document.getElementById(focusedElementId);
+                if (focusedElement) {
+                    focusedElement.focus();
+                    if (typeof selectionStart === 'number') {
+                       focusedElement.selectionStart = selectionStart;
+                       focusedElement.selectionEnd = selectionEnd;
+                    }
                 }
             }
-        }
+        };
 
-        function help() {
-            const helpText = `
-            Welcome to the JavaScript Playground! Here are some tips to get you started:
-
-            1. Enter your JavaScript code in the textarea.
-            2. Click the "Run Code" button to execute your code.
-            3. The console output will be displayed below the textarea.
-            4. Click the "Clear" button to reset the playground.
-            5. Click the "Download" button to save your code and editor as an HTML file.
-            6. Click the "Share" button to generate a URL to share your code with others.
-            7. You can also press "Cmd + Enter" to run your code.
-            8. There's an empty div above the buttons with the id "playground"
-            9. You can mount stuff to it using the "mount" function, for more info run "mountHelp()"
-            10. You can use the "clear()" function to clear the content's of the console.
-
-            Go nuts! Share scrappy fiddles!
-            `;
-            console.log(helpText);
-        }
-
-        function clear() {
-            document.getElementById('console').innerHTML = '';
-        }
-
-        function mountHelp() {
-            console.log(`
-            The mount function is used to mount stuff to the playground div.
-            It takes a function as an argument, which in turn receives the playground div as an argument.
-            Before mounting, it clears the playground div.
-            Here's an example of how to use the mount function:
-
-            mount(playground => {
-                const h1 = document.createElement('h1');
-                h1.textContent = 'Hell is empty and all the devils are here.';
-                playground.appendChild(h1);
-            });
-
-            This will add an h1 element to the playground div.
-            `);
-        }
-
-        function mount(mountFunction) {
-            const playground = document.getElementById('playground');
-            if (!playground) {
-                console.error("Couldn't find a div with the id 'playground'! You may need to reload the page.");
-                return;
+        const handleKeyDown = (event) => {
+            if (event.key === 'Tab') {
+                event.preventDefault();
+                const start = event.target.selectionStart;
+                const end = event.target.selectionEnd;
+                event.target.value = event.target.value.substring(0, start) + "  " + event.target.value.substring(end);
+                dispatch({ type: 'CODE_CHANGED', payload: event.target.value });
+                event.target.selectionStart = event.target.selectionEnd = start + 2;
             }
+            if (event.metaKey && event.key === 'Enter') {
+                event.preventDefault();
+                dispatch({ type: 'RUN_CODE' });
+            }
+        };
+        
+        /**
+         * ----------------------------------------------------------------
+         * Sandbox Initialization
+         * ----------------------------------------------------------------
+         */
+         
+        const sandboxSrc = `
+            <script>
+                const pipe = ${pipe.toString()};
+                const compose = ${compose.toString()};
+            
+                const originalConsoleLog = console.log;
+                console.log = (...args) => {
+                    parent.postMessage({ type: 'CONSOLE_LOG', payload: args }, '*');
+                };
+
+                window.addEventListener('message', (event) => {
+                    try {
+                        eval(event.data.code);
+                    } catch (e) {
+                        console.log(e.toString());
+                    }
+                });
+            <\/script>
+        `;
 
-            if (playground.innerHTML.trim() !== "") {
-                playground.innerHTML = "";
+        window.addEventListener('message', (event) => {
+            if (event.source === sandbox.contentWindow && event.data.type === 'CONSOLE_LOG') {
+                dispatch(event.data);
             }
-            mountFunction(playground);
+        });
+        
+        /**
+         * ----------------------------------------------------------------
+         * Application Entry Point
+         * ----------------------------------------------------------------
+         */
+        
+        const hash = window.location.hash.substring(1);
+        if (hash) {
+            try {
+                const decodedCode = decodeURIComponent(atob(hash));
+                model = { ...init, code: decodedCode };
+            } catch (error) {
+                console.error('Failed to decode the URL hash:', error);
+                model = init;
+            }
+        } else {
+            model = init;
         }
 
+        render(model);
 
-        document.getElementById('codeInput').addEventListener('keydown', function(event) {
-            if (event.metaKey && event.key === 'Enter') {
-                event.preventDefault();
-                evaluateCode();
-            }
-        });
+        sandbox.onload = () => {
+            dispatch({ type: 'SANDBOX_READY' });
+        };
+
+        sandbox.srcdoc = sandboxSrc;
 
-        window.onload = loadCodeFromHash;
     </script>
 </body>
-</html>
+</html>
\ No newline at end of file
diff --git a/html/playground/little-regex.html b/html/playground/little-regex.html
new file mode 100644
index 0000000..c09139f
--- /dev/null
+++ b/html/playground/little-regex.html
@@ -0,0 +1,728 @@
+<html lang="en"><head>
+    <meta charset="UTF-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <title>JavaScript Playground</title>
+    <meta name="description" content="A JavaScript jungle-gym for doing experiments and sharing scrappy fiddles.">
+    <style>
+        body {
+            display: flex;
+            flex-direction: column;
+            align-items: center;
+            background-color: #ddd;
+            padding: 10px;
+            height: 100vh;
+            margin: 0;
+        }
+
+        textarea {
+            width: 100%;
+            height: 64%;
+            font-family: monospace;
+            background-color: #FFFEEC;
+            border: 2px solid #000;
+            scrollbar-width: none;            
+            font-size: 1rem;
+            margin-bottom: 10px;
+            padding: 10px;
+            box-sizing: border-box;
+            resize: none;
+            border-bottom: 12px solid teal;
+            -webkit-user-modify: read-write-plaintext-only;
+        }
+
+        textarea::-webkit-scrollbar {
+            display: none;
+        }
+
+        textarea::selection {
+            background-color: #EFECA7;
+        }
+
+        textarea:focus {
+            outline: none;
+        }
+
+        #console {
+            width: 100%;
+            height: 22%;
+            background-color: #000;
+            color: #0fc;
+            font-family: monospace;
+            font-size: 1rem;
+            overflow-y: auto;
+            padding: 10px;
+            box-sizing: border-box;
+            white-space: pre-wrap;
+        }
+
+        .button-container {
+            width: 100%;
+            display: flex;
+            justify-content: flex-end;
+            margin-bottom: 10px;
+        }
+
+        button {
+            padding: 10px 20px;
+            font-size: 1rem;
+            margin-left: 10px;
+            cursor: pointer;
+            border: none;
+            transition: background-color 0.3s ease;
+        }
+
+        button:hover, button:focus {
+            outline: none; 
+        }
+
+        button.run {
+            background-color: teal;
+            color: #FFFFFF;
+        }
+    </style>
+</head>
+<body>
+
+    <div class="playground" id="playground">    
+        <div class="seesaw" id="seesaw"></div>
+        <div class="slide" id="slide"></div>
+    </div>
+
+    <div class="button-container">
+        <button onclick="clearEverything()">Clear</button>
+        <button onclick="downloadCodeAndEditor()">Download</button>
+        <button onclick="shareCode()">Share</button>
+        <button onclick="evaluateCode()" class="run">Run Code</button>
+    </div>
+    <textarea id="codeInput">// Inspired by <https://www.cs.princeton.edu/courses/archive/spr09/cos333/beautiful.html>
+const matchHere = (pattern, text) => {
+    if (pattern.length === 0) return true;
+    
+    // If pattern ends with $, match end of string
+    if (pattern[0] === '
+    <div id="console"></div>
+
+    <script>
+        function evaluateCode() {
+            const code = document.getElementById('codeInput').value;
+            const consoleDiv = document.getElementById('console');
+            consoleDiv.innerHTML = '';
+
+            // Custom console.log function to output to the console div
+            const originalConsoleLog = console.log;
+            console.log = function(...args) {
+                args.forEach(arg => {
+                    const output = document.createElement('div');
+                    output.textContent = typeof arg === 'object' ? JSON.stringify(arg, null, 2) : arg;
+                    consoleDiv.appendChild(output);
+                });
+                originalConsoleLog.apply(console, args);
+            };
+
+            try {
+                eval(code);
+            } catch (error) {
+                const errorOutput = document.createElement('div');
+                errorOutput.textContent = error;
+                errorOutput.style.color = 'red';
+                consoleDiv.appendChild(errorOutput);
+            }
+
+            // Restore browser's console.log
+            console.log = originalConsoleLog;
+        }
+
+        function downloadCodeAndEditor() {
+            const codeInput = document.getElementById('codeInput').value;
+            const htmlContent = document.documentElement.outerHTML.replace(
+                /<textarea id="codeInput"[^>]*>.*<\/textarea>/,
+                `<textarea id="codeInput">${codeInput}</textarea>`
+            );
+
+            const blob = new Blob([htmlContent], { type: 'text/html' });
+            const url = URL.createObjectURL(blob);
+            const a = document.createElement('a');
+            a.href = url;
+            a.download = 'code_editor.html';
+            document.body.appendChild(a);
+            a.click();
+            document.body.removeChild(a);
+            URL.revokeObjectURL(url);
+        }
+
+        function shareCode() {
+            const code = document.getElementById('codeInput').value;
+            const encodedCode = btoa(encodeURIComponent(code));
+            window.location.hash = encodedCode;
+            window.prompt("Copy the URL to share.\nBe warned! Very long URLs don't share wicked well, sometimes.", window.location.href);
+        }
+
+        function clearEverything() {
+            if (!confirm('Are you sure you want to reset the playground?')) {
+                return;
+            } else {               
+                window.location.hash = '';
+                window.location.reload();
+            }
+        }
+
+        function loadCodeFromHash() {
+            const hash = window.location.hash.substring(1);
+            if (hash) {
+                try {
+                    const decodedCode = decodeURIComponent(atob(hash));
+                    document.getElementById('codeInput').value = decodedCode;
+                } catch (error) {
+                    console.error('Failed to decode the URL hash:', error);
+                }
+            }
+        }
+
+        function help() {
+            const helpText = `
+            Welcome to the JavaScript Playground! Here are some tips to get you started:
+
+            1. Enter your JavaScript code in the textarea.
+            2. Click the "Run Code" button to execute your code.
+            3. The console output will be displayed below the textarea.
+            4. Click the "Clear" button to reset the playground.
+            5. Click the "Download" button to save your code and editor as an HTML file.
+            6. Click the "Share" button to generate a URL to share your code with others.
+            7. You can also press "Cmd + Enter" to run your code.
+            8. There's an empty div above the buttons with the id "playground"
+            9. You can mount stuff to it using the "mount" function, for more info run "mountHelp()"
+            10. You can use the "clear()" function to clear the content's of the console.
+
+            Go nuts! Share scrappy fiddles!
+            `;
+            console.log(helpText);
+        }
+
+        function clear() {
+            document.getElementById('console').innerHTML = '';
+        }
+
+        function mountHelp() {
+            console.log(`
+            The mount function is used to mount stuff to the playground div.
+            It takes a function as an argument, which in turn receives the playground div as an argument.
+            Before mounting, it clears the playground div.
+            Here's an example of how to use the mount function:
+
+            mount(playground => {
+                const h1 = document.createElement('h1');
+                h1.textContent = 'Hell is empty and all the devils are here.';
+                playground.appendChild(h1);
+            });
+
+            This will add an h1 element to the playground div.
+            `);
+        }
+
+        function mount(mountFunction) {
+            const playground = document.getElementById('playground');
+            if (!playground) {
+                console.error("Couldn't find a div with the id 'playground'! You may need to reload the page.");
+                return;
+            }
+
+            if (playground.innerHTML.trim() !== "") {
+                playground.innerHTML = "";
+            }
+            mountFunction(playground);
+        }
+
+
+        document.getElementById('codeInput').addEventListener('keydown', function(event) {
+            if (event.metaKey && event.key === 'Enter') {
+                event.preventDefault();
+                evaluateCode();
+            }
+        });
+
+        window.onload = loadCodeFromHash;
+    </script>
+
+
+</body></html> && pattern.length === 1) return text.length === 0;
+
+    // If next char is '*', match zero or more occurrences of prev char
+    if (pattern[1] === '*') return matchStar(pattern[0], pattern.slice(2), text);
+
+    // Match . or literal character
+    if (text.length !== 0 && (pattern[0] === '.' || pattern[0] === text[0])) {
+        return matchHere(pattern.slice(1), text.slice(1));
+    }
+
+    return false;
+};
+
+const matchStar = (prevChar, pattern, text) => {
+    // Try matching zero occurrences first
+    if (matchHere(pattern, text)) return true;
+
+    // Then, match one or more occurrences of prevChar
+    while (text.length > 0 && (text[0] === prevChar || prevChar === '.')) {
+        text = text.slice(1);
+        if (matchHere(pattern, text)) return true;
+    }
+
+    return false;
+};
+
+const match = (pattern, text) => {
+    // Handle ^ anchor at the beginning
+    if (pattern[0] === '^') {
+        return matchHere(pattern.slice(1), text);
+    }
+
+    // Otherwise, check the entire string
+    for (let i = 0; i <= text.length; i++) {
+        if (matchHere(pattern, text.slice(i))) return true;
+    }
+
+    return false;
+};
+
+const assertEqual = (actual, expected, testName) => 
+    console.log(actual === expected ? `Passed: ${testName}` : `Failed: ${testName}. Expected ${expected} but got ${actual}`);
+
+assertEqual(match("ab*c", "ac"), true, "Star match 'ab*c' vs 'ac' (zero occurrences)");
+assertEqual(match("ab*c", "abbbc"), true, "Star match 'ab*c' vs 'abbbc' (multiple occurrences)");
+assertEqual(match("^ab.*c$", "abc"), true, "Complex match '^ab.*c
+    <div id="console"></div>
+
+    <script>
+        function evaluateCode() {
+            const code = document.getElementById('codeInput').value;
+            const consoleDiv = document.getElementById('console');
+            consoleDiv.innerHTML = '';
+
+            // Custom console.log function to output to the console div
+            const originalConsoleLog = console.log;
+            console.log = function(...args) {
+                args.forEach(arg => {
+                    const output = document.createElement('div');
+                    output.textContent = typeof arg === 'object' ? JSON.stringify(arg, null, 2) : arg;
+                    consoleDiv.appendChild(output);
+                });
+                originalConsoleLog.apply(console, args);
+            };
+
+            try {
+                eval(code);
+            } catch (error) {
+                const errorOutput = document.createElement('div');
+                errorOutput.textContent = error;
+                errorOutput.style.color = 'red';
+                consoleDiv.appendChild(errorOutput);
+            }
+
+            // Restore browser's console.log
+            console.log = originalConsoleLog;
+        }
+
+        function downloadCodeAndEditor() {
+            const codeInput = document.getElementById('codeInput').value;
+            const htmlContent = document.documentElement.outerHTML.replace(
+                /<textarea id="codeInput"[^>]*>.*<\/textarea>/,
+                `<textarea id="codeInput">${codeInput}</textarea>`
+            );
+
+            const blob = new Blob([htmlContent], { type: 'text/html' });
+            const url = URL.createObjectURL(blob);
+            const a = document.createElement('a');
+            a.href = url;
+            a.download = 'code_editor.html';
+            document.body.appendChild(a);
+            a.click();
+            document.body.removeChild(a);
+            URL.revokeObjectURL(url);
+        }
+
+        function shareCode() {
+            const code = document.getElementById('codeInput').value;
+            const encodedCode = btoa(encodeURIComponent(code));
+            window.location.hash = encodedCode;
+            window.prompt("Copy the URL to share.\nBe warned! Very long URLs don't share wicked well, sometimes.", window.location.href);
+        }
+
+        function clearEverything() {
+            if (!confirm('Are you sure you want to reset the playground?')) {
+                return;
+            } else {               
+                window.location.hash = '';
+                window.location.reload();
+            }
+        }
+
+        function loadCodeFromHash() {
+            const hash = window.location.hash.substring(1);
+            if (hash) {
+                try {
+                    const decodedCode = decodeURIComponent(atob(hash));
+                    document.getElementById('codeInput').value = decodedCode;
+                } catch (error) {
+                    console.error('Failed to decode the URL hash:', error);
+                }
+            }
+        }
+
+        function help() {
+            const helpText = `
+            Welcome to the JavaScript Playground! Here are some tips to get you started:
+
+            1. Enter your JavaScript code in the textarea.
+            2. Click the "Run Code" button to execute your code.
+            3. The console output will be displayed below the textarea.
+            4. Click the "Clear" button to reset the playground.
+            5. Click the "Download" button to save your code and editor as an HTML file.
+            6. Click the "Share" button to generate a URL to share your code with others.
+            7. You can also press "Cmd + Enter" to run your code.
+            8. There's an empty div above the buttons with the id "playground"
+            9. You can mount stuff to it using the "mount" function, for more info run "mountHelp()"
+            10. You can use the "clear()" function to clear the content's of the console.
+
+            Go nuts! Share scrappy fiddles!
+            `;
+            console.log(helpText);
+        }
+
+        function clear() {
+            document.getElementById('console').innerHTML = '';
+        }
+
+        function mountHelp() {
+            console.log(`
+            The mount function is used to mount stuff to the playground div.
+            It takes a function as an argument, which in turn receives the playground div as an argument.
+            Before mounting, it clears the playground div.
+            Here's an example of how to use the mount function:
+
+            mount(playground => {
+                const h1 = document.createElement('h1');
+                h1.textContent = 'Hell is empty and all the devils are here.';
+                playground.appendChild(h1);
+            });
+
+            This will add an h1 element to the playground div.
+            `);
+        }
+
+        function mount(mountFunction) {
+            const playground = document.getElementById('playground');
+            if (!playground) {
+                console.error("Couldn't find a div with the id 'playground'! You may need to reload the page.");
+                return;
+            }
+
+            if (playground.innerHTML.trim() !== "") {
+                playground.innerHTML = "";
+            }
+            mountFunction(playground);
+        }
+
+
+        document.getElementById('codeInput').addEventListener('keydown', function(event) {
+            if (event.metaKey && event.key === 'Enter') {
+                event.preventDefault();
+                evaluateCode();
+            }
+        });
+
+        window.onload = loadCodeFromHash;
+    </script>
+
+
+</body></html> vs 'abc'");
+assertEqual(match("^ab.*c$", "abcd"), false, "Complex mismatch '^ab.*c
+    <div id="console"></div>
+
+    <script>
+        function evaluateCode() {
+            const code = document.getElementById('codeInput').value;
+            const consoleDiv = document.getElementById('console');
+            consoleDiv.innerHTML = '';
+
+            // Custom console.log function to output to the console div
+            const originalConsoleLog = console.log;
+            console.log = function(...args) {
+                args.forEach(arg => {
+                    const output = document.createElement('div');
+                    output.textContent = typeof arg === 'object' ? JSON.stringify(arg, null, 2) : arg;
+                    consoleDiv.appendChild(output);
+                });
+                originalConsoleLog.apply(console, args);
+            };
+
+            try {
+                eval(code);
+            } catch (error) {
+                const errorOutput = document.createElement('div');
+                errorOutput.textContent = error;
+                errorOutput.style.color = 'red';
+                consoleDiv.appendChild(errorOutput);
+            }
+
+            // Restore browser's console.log
+            console.log = originalConsoleLog;
+        }
+
+        function downloadCodeAndEditor() {
+            const codeInput = document.getElementById('codeInput').value;
+            const htmlContent = document.documentElement.outerHTML.replace(
+                /<textarea id="codeInput"[^>]*>.*<\/textarea>/,
+                `<textarea id="codeInput">${codeInput}</textarea>`
+            );
+
+            const blob = new Blob([htmlContent], { type: 'text/html' });
+            const url = URL.createObjectURL(blob);
+            const a = document.createElement('a');
+            a.href = url;
+            a.download = 'code_editor.html';
+            document.body.appendChild(a);
+            a.click();
+            document.body.removeChild(a);
+            URL.revokeObjectURL(url);
+        }
+
+        function shareCode() {
+            const code = document.getElementById('codeInput').value;
+            const encodedCode = btoa(encodeURIComponent(code));
+            window.location.hash = encodedCode;
+            window.prompt("Copy the URL to share.\nBe warned! Very long URLs don't share wicked well, sometimes.", window.location.href);
+        }
+
+        function clearEverything() {
+            if (!confirm('Are you sure you want to reset the playground?')) {
+                return;
+            } else {               
+                window.location.hash = '';
+                window.location.reload();
+            }
+        }
+
+        function loadCodeFromHash() {
+            const hash = window.location.hash.substring(1);
+            if (hash) {
+                try {
+                    const decodedCode = decodeURIComponent(atob(hash));
+                    document.getElementById('codeInput').value = decodedCode;
+                } catch (error) {
+                    console.error('Failed to decode the URL hash:', error);
+                }
+            }
+        }
+
+        function help() {
+            const helpText = `
+            Welcome to the JavaScript Playground! Here are some tips to get you started:
+
+            1. Enter your JavaScript code in the textarea.
+            2. Click the "Run Code" button to execute your code.
+            3. The console output will be displayed below the textarea.
+            4. Click the "Clear" button to reset the playground.
+            5. Click the "Download" button to save your code and editor as an HTML file.
+            6. Click the "Share" button to generate a URL to share your code with others.
+            7. You can also press "Cmd + Enter" to run your code.
+            8. There's an empty div above the buttons with the id "playground"
+            9. You can mount stuff to it using the "mount" function, for more info run "mountHelp()"
+            10. You can use the "clear()" function to clear the content's of the console.
+
+            Go nuts! Share scrappy fiddles!
+            `;
+            console.log(helpText);
+        }
+
+        function clear() {
+            document.getElementById('console').innerHTML = '';
+        }
+
+        function mountHelp() {
+            console.log(`
+            The mount function is used to mount stuff to the playground div.
+            It takes a function as an argument, which in turn receives the playground div as an argument.
+            Before mounting, it clears the playground div.
+            Here's an example of how to use the mount function:
+
+            mount(playground => {
+                const h1 = document.createElement('h1');
+                h1.textContent = 'Hell is empty and all the devils are here.';
+                playground.appendChild(h1);
+            });
+
+            This will add an h1 element to the playground div.
+            `);
+        }
+
+        function mount(mountFunction) {
+            const playground = document.getElementById('playground');
+            if (!playground) {
+                console.error("Couldn't find a div with the id 'playground'! You may need to reload the page.");
+                return;
+            }
+
+            if (playground.innerHTML.trim() !== "") {
+                playground.innerHTML = "";
+            }
+            mountFunction(playground);
+        }
+
+
+        document.getElementById('codeInput').addEventListener('keydown', function(event) {
+            if (event.metaKey && event.key === 'Enter') {
+                event.preventDefault();
+                evaluateCode();
+            }
+        });
+
+        window.onload = loadCodeFromHash;
+    </script>
+
+
+</body></html> vs 'abcd'");</textarea>
+    <div id="console"></div>
+
+    <script>
+        function evaluateCode() {
+            const code = document.getElementById('codeInput').value;
+            const consoleDiv = document.getElementById('console');
+            consoleDiv.innerHTML = '';
+
+            // Custom console.log function to output to the console div
+            const originalConsoleLog = console.log;
+            console.log = function(...args) {
+                args.forEach(arg => {
+                    const output = document.createElement('div');
+                    output.textContent = typeof arg === 'object' ? JSON.stringify(arg, null, 2) : arg;
+                    consoleDiv.appendChild(output);
+                });
+                originalConsoleLog.apply(console, args);
+            };
+
+            try {
+                eval(code);
+            } catch (error) {
+                const errorOutput = document.createElement('div');
+                errorOutput.textContent = error;
+                errorOutput.style.color = 'red';
+                consoleDiv.appendChild(errorOutput);
+            }
+
+            // Restore browser's console.log
+            console.log = originalConsoleLog;
+        }
+
+        function downloadCodeAndEditor() {
+            const codeInput = document.getElementById('codeInput').value;
+            const htmlContent = document.documentElement.outerHTML.replace(
+                /<textarea id="codeInput"[^>]*>.*<\/textarea>/,
+                `<textarea id="codeInput">${codeInput}</textarea>`
+            );
+
+            const blob = new Blob([htmlContent], { type: 'text/html' });
+            const url = URL.createObjectURL(blob);
+            const a = document.createElement('a');
+            a.href = url;
+            a.download = 'code_editor.html';
+            document.body.appendChild(a);
+            a.click();
+            document.body.removeChild(a);
+            URL.revokeObjectURL(url);
+        }
+
+        function shareCode() {
+            const code = document.getElementById('codeInput').value;
+            const encodedCode = btoa(encodeURIComponent(code));
+            window.location.hash = encodedCode;
+            window.prompt("Copy the URL to share.\nBe warned! Very long URLs don't share wicked well, sometimes.", window.location.href);
+        }
+
+        function clearEverything() {
+            if (!confirm('Are you sure you want to reset the playground?')) {
+                return;
+            } else {               
+                window.location.hash = '';
+                window.location.reload();
+            }
+        }
+
+        function loadCodeFromHash() {
+            const hash = window.location.hash.substring(1);
+            if (hash) {
+                try {
+                    const decodedCode = decodeURIComponent(atob(hash));
+                    document.getElementById('codeInput').value = decodedCode;
+                } catch (error) {
+                    console.error('Failed to decode the URL hash:', error);
+                }
+            }
+        }
+
+        function help() {
+            const helpText = `
+            Welcome to the JavaScript Playground! Here are some tips to get you started:
+
+            1. Enter your JavaScript code in the textarea.
+            2. Click the "Run Code" button to execute your code.
+            3. The console output will be displayed below the textarea.
+            4. Click the "Clear" button to reset the playground.
+            5. Click the "Download" button to save your code and editor as an HTML file.
+            6. Click the "Share" button to generate a URL to share your code with others.
+            7. You can also press "Cmd + Enter" to run your code.
+            8. There's an empty div above the buttons with the id "playground"
+            9. You can mount stuff to it using the "mount" function, for more info run "mountHelp()"
+            10. You can use the "clear()" function to clear the content's of the console.
+
+            Go nuts! Share scrappy fiddles!
+            `;
+            console.log(helpText);
+        }
+
+        function clear() {
+            document.getElementById('console').innerHTML = '';
+        }
+
+        function mountHelp() {
+            console.log(`
+            The mount function is used to mount stuff to the playground div.
+            It takes a function as an argument, which in turn receives the playground div as an argument.
+            Before mounting, it clears the playground div.
+            Here's an example of how to use the mount function:
+
+            mount(playground => {
+                const h1 = document.createElement('h1');
+                h1.textContent = 'Hell is empty and all the devils are here.';
+                playground.appendChild(h1);
+            });
+
+            This will add an h1 element to the playground div.
+            `);
+        }
+
+        function mount(mountFunction) {
+            const playground = document.getElementById('playground');
+            if (!playground) {
+                console.error("Couldn't find a div with the id 'playground'! You may need to reload the page.");
+                return;
+            }
+
+            if (playground.innerHTML.trim() !== "") {
+                playground.innerHTML = "";
+            }
+            mountFunction(playground);
+        }
+
+
+        document.getElementById('codeInput').addEventListener('keydown', function(event) {
+            if (event.metaKey && event.key === 'Enter') {
+                event.preventDefault();
+                evaluateCode();
+            }
+        });
+
+        window.onload = loadCodeFromHash;
+    </script>
+
+
+</body></html>
\ No newline at end of file
diff --git a/html/playground/regex.html b/html/playground/regex.html
new file mode 100644
index 0000000..41f50e9
--- /dev/null
+++ b/html/playground/regex.html
@@ -0,0 +1,477 @@
+<html lang="en"><head>
+    <meta charset="UTF-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <title>JavaScript Playground</title>
+    <meta name="description" content="A JavaScript jungle-gym for doing experiments and sharing scrappy fiddles.">
+    <style>
+        body {
+            display: flex;
+            flex-direction: column;
+            align-items: center;
+            background-color: #ddd;
+            padding: 10px;
+            height: 100vh;
+            margin: 0;
+        }
+
+        textarea {
+            width: 100%;
+            height: 64%;
+            font-family: monospace;
+            background-color: #FFFEEC;
+            border: 2px solid #000;
+            scrollbar-width: none;            
+            font-size: 1rem;
+            margin-bottom: 10px;
+            padding: 10px;
+            box-sizing: border-box;
+            resize: none;
+            border-bottom: 12px solid teal;
+            -webkit-user-modify: read-write-plaintext-only;
+        }
+
+        textarea::-webkit-scrollbar {
+            display: none;
+        }
+
+        textarea::selection {
+            background-color: #EFECA7;
+        }
+
+        textarea:focus {
+            outline: none;
+        }
+
+        #console {
+            width: 100%;
+            height: 22%;
+            background-color: #000;
+            color: #0fc;
+            font-family: monospace;
+            font-size: 1rem;
+            overflow-y: auto;
+            padding: 10px;
+            box-sizing: border-box;
+            white-space: pre-wrap;
+        }
+
+        .button-container {
+            width: 100%;
+            display: flex;
+            justify-content: flex-end;
+            margin-bottom: 10px;
+        }
+
+        button {
+            padding: 10px 20px;
+            font-size: 1rem;
+            margin-left: 10px;
+            cursor: pointer;
+            border: none;
+            transition: background-color 0.3s ease;
+        }
+
+        button:hover, button:focus {
+            outline: none; 
+        }
+
+        button.run {
+            background-color: teal;
+            color: #FFFFFF;
+        }
+    </style>
+</head>
+<body>
+
+    <div class="playground" id="playground">    
+        <div class="seesaw" id="seesaw"></div>
+        <div class="slide" id="slide"></div>
+    </div>
+
+    <div class="button-container">
+        <button onclick="clearEverything()">Clear</button>
+        <button onclick="downloadCodeAndEditor()">Download</button>
+        <button onclick="shareCode()">Share</button>
+        <button onclick="evaluateCode()" class="run">Run Code</button>
+    </div>
+    <textarea id="codeInput">const tokenize = (pattern) => {
+    const tokens = [];
+    let i = 0;
+
+    while (i < pattern.length) {
+        const char = pattern[i];
+
+        if (char === '.' || char === '*' || char === '(' || char === ')' || char === '|') {
+            tokens.push({
+                type: char,
+                value: char
+            });
+        } else if (char === '\\') { // Handle escaped characters
+            i++;
+            tokens.push({
+                type: 'literal',
+                value: pattern[i]
+            });
+        } else if (char === '[') { // Handle character classes
+            let charClass = '';
+            i++;
+            while (pattern[i] !== ']' && i < pattern.length) {
+                charClass += pattern[i];
+                i++;
+            }
+            tokens.push({
+                type: 'charClass',
+                value: charClass
+            });
+        } else {
+            tokens.push({
+                type: 'literal',
+                value: char
+            });
+        }
+        i++;
+    }
+
+    return tokens;
+};
+
+
+
+
+const parse = (tokens) => {
+    let i = 0;
+
+    const parseSequenceExpression = () => {
+        const node = {
+            type: 'sequence',
+            elements: []
+        };
+
+        while (i < tokens.length) {
+            const token = tokens[i];
+
+            if (token.type === 'literal') {
+                node.elements.push({
+                    type: 'literal',
+                    value: token.value
+                });
+            } else if (token.type === '*') {
+                const lastElement = node.elements.pop();
+                node.elements.push({
+                    type: 'star',
+                    element: lastElement
+                });
+            } else if (token.type === '.') {
+                node.elements.push({
+                    type: 'dot'
+                });
+            } else if (token.type === 'charClass') {
+                node.elements.push({
+                    type: 'charClass',
+                    value: token.value
+                });
+            } else if (token.type === '|') {
+                i++;
+                const right = parseSequenceExpression();
+                return {
+                    type: 'alternation',
+                    left: node,
+                    right
+                };
+            } else if (token.type === '(') {
+                i++;
+                node.elements.push(parseSequenceExpression());
+            } else if (token.type === ')') {
+                break; // End of a grouping
+            }
+
+            i++;
+        }
+
+        return node;
+    };
+
+    return parseSequenceExpression();
+};
+
+
+
+const evaluateMatch = (node) => (input) => {
+    if (node.type === 'literal') {
+        return input[0] === node.value ? input.slice(1) : null;
+    }
+    if (node.type === 'dot') {
+        return input.length > 0 ? input.slice(1) : null;
+    }
+    if (node.type === 'star') {
+        let remainder = input;
+        while (remainder !== null) {
+            const next = evaluateMatch(node.element)(remainder);
+            if (next === null) {
+                break;
+            }
+            remainder = next;
+        }
+        return remainder;
+    }
+    if (node.type === 'charClass') {
+        return node.value.includes(input[0]) ? input.slice(1) : null;
+    }
+    if (node.type === 'alternation') {
+        const remainderLeft = evaluateMatch(node.left)(input);
+        const remainderRight = evaluateMatch(node.right)(input);
+        return remainderLeft !== null ? remainderLeft : remainderRight;
+    }
+    if (node.type === 'sequence') {
+        let remainder = input;
+        for (const element of node.elements) {
+            remainder = evaluateMatch(element)(remainder);
+            if (remainder === null) {
+                return null;
+            }
+        }
+        return remainder;
+    }
+};
+
+
+
+
+const assertEqual = (expected, actual, message) => {
+    if (expected !== actual) {
+        console.error(`FAIL: ${message}`);
+    } else {
+        console.log(`PASS: ${message}`);
+    }
+};
+
+
+
+const runTests = () => {
+    const tests = [{
+            pattern: "a.b*c",
+            input: "abbbc",
+            expected: true
+        },
+        {
+            pattern: "a.b*c",
+            input: "abc",
+            expected: true
+        },
+        {
+            pattern: "a.b*c",
+            input: "ac",
+            expected: true
+        },
+        {
+            pattern: "a.b*c",
+            input: "abbc",
+            expected: true
+        },
+        {
+            pattern: "a.b*c",
+            input: "axbc",
+            expected: false
+        },
+
+        // Character class tests
+        {
+            pattern: "[abc]x",
+            input: "bx",
+            expected: true
+        },
+        {
+            pattern: "[abc]x",
+            input: "dx",
+            expected: false
+        },
+
+        // Grouping and alternation tests
+        {
+            pattern: "(a|b)c",
+            input: "ac",
+            expected: true
+        },
+        {
+            pattern: "(a|b)c",
+            input: "bc",
+            expected: true
+        },
+        {
+            pattern: "(a|b)c",
+            input: "cc",
+            expected: false
+        },
+
+        // Escaped characters tests
+        {
+            pattern: "a\\.b",
+            input: "a.b",
+            expected: true
+        },
+        {
+            pattern: "a\\.b",
+            input: "a-b",
+            expected: false
+        },
+        {
+            pattern: "a\\*b",
+            input: "a*b",
+            expected: true
+        }
+    ];
+
+    tests.forEach(({ pattern, input, expected }, index) => {
+        const tokens = tokenize(pattern);
+        const ast = parse(tokens);
+        const result = evaluateMatch(ast)(input) !== null;
+        assertEqual(expected, result, `Test ${index + 1}`);
+    });
+};
+
+runTests();</textarea>
+    <div id="console"><div>PASS: Test 1</div><div>PASS: Test 2</div><div>PASS: Test 4</div><div>PASS: Test 6</div><div>PASS: Test 7</div><div>PASS: Test 8</div><div>PASS: Test 9</div><div>PASS: Test 10</div><div>PASS: Test 11</div><div>PASS: Test 12</div><div>PASS: Test 13</div></div>
+
+    <script>
+        function evaluateCode() {
+            const code = document.getElementById('codeInput').value;
+            const consoleDiv = document.getElementById('console');
+            consoleDiv.innerHTML = '';
+
+            // Custom console.log function to output to the console div
+            const originalConsoleLog = console.log;
+            console.log = function(...args) {
+                args.forEach(arg => {
+                    const output = document.createElement('div');
+                    output.textContent = typeof arg === 'object' ? JSON.stringify(arg, null, 2) : arg;
+                    consoleDiv.appendChild(output);
+                });
+                originalConsoleLog.apply(console, args);
+            };
+
+            try {
+                eval(code);
+            } catch (error) {
+                const errorOutput = document.createElement('div');
+                errorOutput.textContent = error;
+                errorOutput.style.color = 'red';
+                consoleDiv.appendChild(errorOutput);
+            }
+
+            // Restore browser's console.log
+            console.log = originalConsoleLog;
+        }
+
+        function downloadCodeAndEditor() {
+            const codeInput = document.getElementById('codeInput').value;
+            const htmlContent = document.documentElement.outerHTML.replace(
+                /<textarea id="codeInput"[^>]*>.*<\/textarea>/,
+                `<textarea id="codeInput">${codeInput}</textarea>`
+            );
+
+            const blob = new Blob([htmlContent], { type: 'text/html' });
+            const url = URL.createObjectURL(blob);
+            const a = document.createElement('a');
+            a.href = url;
+            a.download = 'code_editor.html';
+            document.body.appendChild(a);
+            a.click();
+            document.body.removeChild(a);
+            URL.revokeObjectURL(url);
+        }
+
+        function shareCode() {
+            const code = document.getElementById('codeInput').value;
+            const encodedCode = btoa(encodeURIComponent(code));
+            window.location.hash = encodedCode;
+            window.prompt("Copy the URL to share.\nBe warned! Very long URLs don't share wicked well, sometimes.", window.location.href);
+        }
+
+        function clearEverything() {
+            if (!confirm('Are you sure you want to reset the playground?')) {
+                return;
+            } else {               
+                window.location.hash = '';
+                window.location.reload();
+            }
+        }
+
+        function loadCodeFromHash() {
+            const hash = window.location.hash.substring(1);
+            if (hash) {
+                try {
+                    const decodedCode = decodeURIComponent(atob(hash));
+                    document.getElementById('codeInput').value = decodedCode;
+                } catch (error) {
+                    console.error('Failed to decode the URL hash:', error);
+                }
+            }
+        }
+
+        function help() {
+            const helpText = `
+            Welcome to the JavaScript Playground! Here are some tips to get you started:
+
+            1. Enter your JavaScript code in the textarea.
+            2. Click the "Run Code" button to execute your code.
+            3. The console output will be displayed below the textarea.
+            4. Click the "Clear" button to reset the playground.
+            5. Click the "Download" button to save your code and editor as an HTML file.
+            6. Click the "Share" button to generate a URL to share your code with others.
+            7. You can also press "Cmd + Enter" to run your code.
+            8. There's an empty div above the buttons with the id "playground"
+            9. You can mount stuff to it using the "mount" function, for more info run "mountHelp()"
+            10. You can use the "clear()" function to clear the content's of the console.
+
+            Go nuts! Share scrappy fiddles!
+            `;
+            console.log(helpText);
+        }
+
+        function clear() {
+            document.getElementById('console').innerHTML = '';
+        }
+
+        function mountHelp() {
+            console.log(`
+            The mount function is used to mount stuff to the playground div.
+            It takes a function as an argument, which in turn receives the playground div as an argument.
+            Before mounting, it clears the playground div.
+            Here's an example of how to use the mount function:
+
+            mount(playground => {
+                const h1 = document.createElement('h1');
+                h1.textContent = 'Hell is empty and all the devils are here.';
+                playground.appendChild(h1);
+            });
+
+            This will add an h1 element to the playground div.
+            `);
+        }
+
+        function mount(mountFunction) {
+            const playground = document.getElementById('playground');
+            if (!playground) {
+                console.error("Couldn't find a div with the id 'playground'! You may need to reload the page.");
+                return;
+            }
+
+            if (playground.innerHTML.trim() !== "") {
+                playground.innerHTML = "";
+            }
+            mountFunction(playground);
+        }
+
+
+        document.getElementById('codeInput').addEventListener('keydown', function(event) {
+            if (event.metaKey && event.key === 'Enter') {
+                event.preventDefault();
+                evaluateCode();
+            }
+        });
+
+        window.onload = loadCodeFromHash;
+    </script>
+
+
+</body></html>
\ No newline at end of file
diff --git a/html/playground/scheme.html b/html/playground/scheme.html
index dc6fb55..b8ecd6f 100644
--- a/html/playground/scheme.html
+++ b/html/playground/scheme.html
@@ -83,7 +83,10 @@
 </head>
 <body>
 
-    <div class="playground" id="playground"><div style="display: flex; flex-direction: column; width: 100%;"><textarea placeholder="Scheme here..." style="width: 100%; height: 100px; margin-bottom: 10px; font-family: monospace;"></textarea><button>Evaluate</button><pre style="width: 100%; height: 200px; overflow-y: auto; background-color: rgb(240, 240, 240); padding: 10px; font-family: monospace;"></pre></div></div>
+    <div class="playground" id="playground">    
+        <div class="seesaw" id="seesaw"></div>
+        <div class="slide" id="slide"></div>
+    </div>
 
     <div class="button-container">
         <button onclick="clearEverything()">Clear</button>
@@ -382,122 +385,8 @@ function mountRepl(playground) {
 }
 
 
-mount(mountRepl);
-
-
-
-// Testing 'define' and arithmetic operations
-console.log(evalScheme("(define x 10)")); // Should define 'x' as 10
-console.log(evalScheme("(+ x 5)")); // Should return 15
-console.log(evalScheme("(- x 3)")); // Should return 7
-console.log(evalScheme("(* x 2)")); // Should return 20
-console.log(evalScheme("(/ x 2)")); // Should return 5
-
-// Testing 'eq?' for equality
-console.log(evalScheme("(eq? 1 1)")); // Should return true
-console.log(evalScheme("(eq? 1 2)")); // Should return false
-
-// Testing 'car', 'cdr', 'cons', 'null?'
-console.log(evalScheme("(car (quote (1 2 3)))")); // Should return 1
-console.log(evalScheme("(cdr (quote (1 2 3)))")); // Should return (2 3)
-console.log(evalScheme("(cons 1 (quote (2 3)))")); // Should return (1 2 3)
-console.log(evalScheme("(null? (quote ()))")); // Should return true
-console.log(evalScheme("(null? (quote (1 2 3)))")); // Should return false
-
-// Testing 'zero?' for checking zero
-console.log(evalScheme("(zero? 0)")); // Should return true
-console.log(evalScheme("(zero? 1)")); // Should return false
-
-// Testing 'atom?' for checking if an element is an atom
-console.log(evalScheme("(atom? 1)")); // Should return true
-console.log(evalScheme("(atom? (quote (1 2 3)))")); // Should return false
-
-// Testing 'number?' for checking if an element is a number
-console.log(evalScheme("(number? 42)")); // Should return true
-console.log(evalScheme("(number? (quote hello))")); // Should return false
-
-// Testing 'add1' and 'sub1'
-console.log(evalScheme("(add1 5)")); // Should return 6
-console.log(evalScheme("(sub1 5)")); // Should return 4
-
-// Testing 'quote' for returning unevaluated expressions
-console.log(evalScheme("(quote (1 2 3))")); // Should return (1 2 3)
-
-// Testing 'and' and 'or'
-console.log(evalScheme("(and true true)")); // Should return true
-console.log(evalScheme("(and true false)")); // Should return false
-console.log(evalScheme("(or false false)")); // Should return false
-console.log(evalScheme("(or true false)")); // Should return true
-
-// Testing 'lambda' with a function definition
-console.log(evalScheme("(define add1 (lambda (x) (+ x 1)))")); // Should define add1 function
-console.log(evalScheme("(add1 10)")); // Should return 11
-
-// Testing 'if' for conditional expressions
-console.log(evalScheme("(if (eq? 1 1) (quote yes) (quote no))")); // Should return 'yes
-console.log(evalScheme("(if (eq? 1 2) (quote yes) (quote no))")); // Should return 'no
-
-// Testing 'cond' for multiple conditions
-console.log(evalScheme("(cond ((eq? 1 2) (quote no)) ((eq? 2 2) (quote yes)))")); // Should return 'yes
-console.log(evalScheme("(cond ((eq? 1 2) (quote no)) ((eq? 3 2) (quote nope)))")); // Should return null (no matching condition)
-
-// Testing 'letrec' for recursive bindings
-console.log(evalScheme("(letrec ((factorial (lambda (n) (if (zero? n) 1 (* n (factorial (sub1 n))))))) (factorial 5))"));
-// Should return 120 (5!)</textarea>
-    <div id="console"><div></div><div>15</div><div>7</div><div>20</div><div>5</div><div>true</div><div>false</div><div>{
-  "type": "NumberLiteral",
-  "value": 1
-}</div><div>{
-  "type": "List",
-  "value": [
-    {
-      "type": "NumberLiteral",
-      "value": 2
-    },
-    {
-      "type": "NumberLiteral",
-      "value": 3
-    }
-  ]
-}</div><div>{
-  "type": "List",
-  "value": [
-    1,
-    {
-      "type": "NumberLiteral",
-      "value": 2
-    },
-    {
-      "type": "NumberLiteral",
-      "value": 3
-    }
-  ]
-}</div><div>true</div><div>false</div><div>true</div><div>false</div><div>true</div><div>false</div><div>true</div><div>false</div><div>6</div><div>4</div><div>{
-  "type": "List",
-  "value": [
-    {
-      "type": "NumberLiteral",
-      "value": 1
-    },
-    {
-      "type": "NumberLiteral",
-      "value": 2
-    },
-    {
-      "type": "NumberLiteral",
-      "value": 3
-    }
-  ]
-}</div><div>true</div><div>false</div><div>false</div><div>true</div><div></div><div>11</div><div>{
-  "type": "Symbol",
-  "value": "yes"
-}</div><div>{
-  "type": "Symbol",
-  "value": "no"
-}</div><div>{
-  "type": "Symbol",
-  "value": "yes"
-}</div><div>null</div><div>120</div></div>
+mount(mountRepl);</textarea>
+    <div id="console"></div>
 
     <script>
         function evaluateCode() {