Ship CSRF-drift + markdown fixes to production #25

Merged
jared merged 5 commits from development into main 2026-07-15 16:54:01 -04:00
Showing only changes of commit 8f7c669b8f - Show all commits
+15 -3
View File
@@ -41,10 +41,22 @@ function parseMarkdown(markdown) {
.replace(/"/g, '"')
.replace(/'/g, ''');
// Code blocks (```code```) - preserve content and don't process further
// Code blocks (```lang\ncode\n```) - preserve content and don't process further
const codeBlocks = [];
html = html.replace(/```([\s\S]*?)```/g, function(match, code) {
codeBlocks.push('<pre class="code-block"><code>' + code + '</code></pre>');
html = html.replace(/```([a-zA-Z0-9_+-]*)\n?([\s\S]*?)```/g, function(match, lang, code) {
lang = lang ? lang.trim() : '';
const displayLang = lang || 'text';
// Build header with optional copy button if one exists in your UI, otherwise just lang
const header = '<div class="lt-code-header"><span class="lt-code-lang">' + displayLang + '</span></div>';
// Remove exactly one trailing newline from code block if it exists
if (code.endsWith('\n')) {
code = code.slice(0, -1);
}
// Wrap in the specific UI classes expected by base.css
codeBlocks.push('<div class="lt-code-block">' + header + '<pre><code>' + code + '</code></pre></div>');
return '%%CODEBLOCK' + (codeBlocks.length - 1) + '%%';
});