Mae's website :3 maemoon.me
personal website svelte sveltekit
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix

+3 -9
+3 -9
src/routes/experiments/markdown/+page.svelte
··· 1 1 <script> 2 - // #, ##, ###, ####, #####, ###### 3 2 const headingRegex = /^(#{1,6})\s(.*)$/; 4 - // $variable=value 5 3 const expressionRegex = /^\$(.*)$/; 6 - // *italic* or _italic_ 7 4 const italicRegex = /(\*|_)(.*?)\1/g; 8 - // **bold** or __bold__ 9 5 const boldRegex = /(\*\*|__)(.*?)\1/g; 10 - // <input ${variable} /> 11 - const inputRegex = /<input\s\$\{(.+?)\}\s\/>/g; 12 6 let rawContent = $state( 13 7 '# Heading\n## Heading 2\n### Heading 3\nSome body text!\n\n**Bold text**\n*Italic text*\n\n$variable=*nyaa~*\nvar: {variable}\n\n$variable2=**:3**\nvar 2: {variable2}\n\n$variable3={variable} {variable2}\nvar 3: {variable3}' 14 8 ); ··· 16 10 let content = $derived.by(() => { 17 11 let lines = rawContent.split('\n'); 18 12 let parsedLines = []; 19 - let initialDocumentVariables = {}; 13 + let documentVariables = {}; 20 14 21 15 const applyInlineStyles = (text, visited = new Set()) => { 22 16 let textToReturn = text; ··· 45 39 46 40 const handleExpression = (expression) => { 47 41 const [variable, value] = expression.split('='); 48 - initialDocumentVariables[variable] = value; 42 + documentVariables[variable] = value; 49 43 }; 50 44 51 45 for (let line of lines) { ··· 105 99 white-space: pre-wrap; 106 100 padding: 0.5em; 107 101 } 108 - </style> 102 + </style>