| 
 | 1 | +<!DOCTYPE html>  | 
 | 2 | +<html lang="en">  | 
 | 3 | + | 
 | 4 | +<head>  | 
 | 5 | +    <meta charset="UTF-8">  | 
 | 6 | +    <meta name="viewport" content="width=device-width, initial-scale=1.0">  | 
 | 7 | +    <title>blog.mtib.dev</title>  | 
 | 8 | +    <link rel="preconnect" href="https://fonts.googleapis.com">  | 
 | 9 | +    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>  | 
 | 10 | +    <link href="https://fonts.googleapis.com/css2?family=Noto+Sans:wght@500&display=swap" rel="preload" as="style"  | 
 | 11 | +        onload="this.onload=null;this.rel='stylesheet'">  | 
 | 12 | +    <noscript>  | 
 | 13 | +        <link href="https://fonts.googleapis.com/css2?family=Noto+Sans:wght@500&display=swap" rel="stylesheet">  | 
 | 14 | +    </noscript>  | 
 | 15 | +    <link rel="stylesheet" href="/main.css">  | 
 | 16 | +    <link rel="icon" href="/assets/m.png">  | 
 | 17 | +    <meta name="application-name" content="blog.mtib.dev">  | 
 | 18 | +    <meta name="theme-color" content="#2a0a2a">  | 
 | 19 | +    <link rel="manifest" href="/assets/manifest.json" />  | 
 | 20 | +    <meta name="description"  | 
 | 21 | +        content="A personal blog of Markus Horst Becker aka mtib, linking to academic resources and open-source apps.">  | 
 | 22 | +    <meta name="robots" content="index,follow">  | 
 | 23 | +    <meta name="subject" content="software development">  | 
 | 24 | +    <meta name="rating" content="General">  | 
 | 25 | +    <meta name="referrer" content="no-referrer">  | 
 | 26 | +    <meta name="ICBM" content="55.681389, 12.455">  | 
 | 27 | +    <meta name="geo.position" content="55.681389;12.455">  | 
 | 28 | +    <meta name="geo.region" content="DK">  | 
 | 29 | +    <meta name="geo.placename" content="Copenhagen">  | 
 | 30 | +</head>  | 
 | 31 | + | 
 | 32 | +<body>  | 
 | 33 | + | 
 | 34 | +    <div class="noto-sans-default">  | 
 | 35 | +        <div style="  | 
 | 36 | +        display: flex;  | 
 | 37 | +        flex-direction: column;  | 
 | 38 | +        gap: 50px;  | 
 | 39 | +        align-items: center;  | 
 | 40 | +        padding: 10px 0 50px 0;">  | 
 | 41 | +            <div class="item">  | 
 | 42 | +                  | 
 | 43 | +<h1>blog.mtib.dev</h1>  | 
 | 44 | +<a href="/index.html">back</a>  | 
 | 45 | + | 
 | 46 | +            </div>  | 
 | 47 | +              | 
 | 48 | +<div class="item">  | 
 | 49 | +    <h2>Text Manipulation</h2>  | 
 | 50 | +    <textarea name="input" id="input"></textarea>  | 
 | 51 | + | 
 | 52 | +<select name="algo" id="algo">  | 
 | 53 | +    <option value="codeQuote">Code quote</option>  | 
 | 54 | +</select>  | 
 | 55 | + | 
 | 56 | +<code id="outputWrap">  | 
 | 57 | +<pre id="output">  | 
 | 58 | +</pre>  | 
 | 59 | +</code>  | 
 | 60 | + | 
 | 61 | +<input type="button" value="Copy" id="copyBtn">  | 
 | 62 | + | 
 | 63 | +<script>  | 
 | 64 | +    const input = document.getElementById('input');  | 
 | 65 | +    const output = document.getElementById('output');  | 
 | 66 | + | 
 | 67 | +    function codeQuote(data) {  | 
 | 68 | +        return data.replace(/(?<!`)(_?[a-zA-Z0-9()/\\]+(_|\([a-zA-Z0-9()/\\]*\)|\->)[a-zA-Z0-9()/\\]*)(?!`)/g, '`$1`');  | 
 | 69 | +    }  | 
 | 70 | + | 
 | 71 | +    const algos = {  | 
 | 72 | +        codeQuote: codeQuote,  | 
 | 73 | +    };  | 
 | 74 | + | 
 | 75 | +    function getAlgo() {  | 
 | 76 | +        const algoName = document.getElementById('algo').value;  | 
 | 77 | +        const algo = algos[algoName]  | 
 | 78 | + | 
 | 79 | +        if (algo) {  | 
 | 80 | +            return algo;  | 
 | 81 | +        }  | 
 | 82 | + | 
 | 83 | +        return (data) => `Unknown algorithm: ${algoName}`;  | 
 | 84 | +    }  | 
 | 85 | + | 
 | 86 | +    input.addEventListener('input', () => {  | 
 | 87 | +        output.textContent = getAlgo()(input.value);  | 
 | 88 | +    });  | 
 | 89 | + | 
 | 90 | +    document.getElementById('copyBtn').addEventListener('click', () => {  | 
 | 91 | +        navigator.clipboard.writeText(output.textContent);  | 
 | 92 | +    });  | 
 | 93 | +</script>  | 
 | 94 | + | 
 | 95 | +<style>  | 
 | 96 | +    textarea#input {  | 
 | 97 | +        width: 100%;  | 
 | 98 | +        min-height: 6em;  | 
 | 99 | +        background-color: #202;  | 
 | 100 | +        border: #fdf 1px solid;  | 
 | 101 | +        border-radius: 1em;  | 
 | 102 | +        padding: 1em 1em;  | 
 | 103 | +        color: #fdf;  | 
 | 104 | +        margin-bottom: 0.5em;  | 
 | 105 | +    }  | 
 | 106 | +    #outputWrap {  | 
 | 107 | +        display: block;  | 
 | 108 | +        width: 100%;  | 
 | 109 | +        overflow: auto;  | 
 | 110 | +        border: #fdf 1px solid;  | 
 | 111 | +        border-radius: 1em;  | 
 | 112 | +        padding: 1em 1em;  | 
 | 113 | +        margin-top: 1em;  | 
 | 114 | +    }  | 
 | 115 | +    #copyBtn {  | 
 | 116 | +        display: block;  | 
 | 117 | +        margin-top: 1em;  | 
 | 118 | +    }  | 
 | 119 | +</style>  | 
 | 120 | +</div>  | 
 | 121 | + | 
 | 122 | +        </div>  | 
 | 123 | +    </div>  | 
 | 124 | + | 
 | 125 | +    <style>  | 
 | 126 | +        .item {  | 
 | 127 | +            width: min(calc(100vw - 20px), 800px);  | 
 | 128 | +        }  | 
 | 129 | + | 
 | 130 | +        .item h2 {  | 
 | 131 | +            margin-bottom: 8px;  | 
 | 132 | +        }  | 
 | 133 | + | 
 | 134 | +        .app {  | 
 | 135 | +            padding-top: 20px;  | 
 | 136 | +        }  | 
 | 137 | + | 
 | 138 | +        div.item>div.app:nth-of-type(1) {  | 
 | 139 | +            padding-top: 0px;  | 
 | 140 | +        }  | 
 | 141 | +    </style>  | 
 | 142 | + | 
 | 143 | +</body>  | 
 | 144 | + | 
 | 145 | + | 
 | 146 | +</html>  | 
0 commit comments