diff --git a/assets/js/markdown.js b/assets/js/markdown.js index 49a8b24..42efc19 100644 --- a/assets/js/markdown.js +++ b/assets/js/markdown.js @@ -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('
' + code + '');
+ 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 = '' + code + '