diff --git a/assets/js/markdown.js b/assets/js/markdown.js
index bc1fdf1..85b8b32 100644
--- a/assets/js/markdown.js
+++ b/assets/js/markdown.js
@@ -84,18 +84,24 @@ function parseMarkdown(markdown) {
return '' + text + '';
});
- // Task lists — must run before general list processing
- html = html.replace(/^\s*-\s+\[x\]\s+(.+)$/gim, '
☑ $1');
- html = html.replace(/^\s*-\s+\[ \]\s+(.+)$/gm, '☐ $1');
+ // Lists — tag each item type with a placeholder, then wrap consecutive runs
+ html = html.replace(/^\s*\d+\.\s+(.+)$/gm, '%%OLI%%$1');
+ html = html.replace(/^\s*[-*+]\s+\[x\]\s+(.+)$/gim, '%%TDI%%$1');
+ html = html.replace(/^\s*[-*+]\s+\[ \]\s+(.+)$/gm, '%%TTI%%$1');
+ html = html.replace(/^\s*[-*+]\s+(.+)$/gm, '%%ULI%%$1');
- // Unordered lists (- item or * item) — wrap consecutive in
- html = html.replace(/^\s*[-*]\s+(.+)$/gm, '- $1
');
- html = html.replace(/(- (?:(?!
- |<\/ul>)[\s\S])*<\/li>(?:\n
- (?:(?!
- |<\/ul>)[\s\S])*<\/li>)*)/g, '');
+ // Wrap consecutive ordered items in
+ html = html.replace(/(%%OLI%%.+(\n%%OLI%%.+)*)/g, function(block) {
+ return '' + block.replace(/%%OLI%%(.+)/g, '- $1
') + '
';
+ });
- // Ordered lists (1. item) — wrap in
- html = html.replace(/(?:^\s*\d+\.\s+.+$\n?)+/gm, function(block) {
- const items = block.trim().replace(/^\s*\d+\.\s+(.+)$/gm, '- $1
');
- return '' + items + '
';
+ // Wrap consecutive unordered/task items in
+ html = html.replace(/((?:%%(?:ULI|TDI|TTI)%%).+(?:\n(?:%%(?:ULI|TDI|TTI)%%).+)*)/g, function(block) {
+ return '' + block
+ .replace(/%%ULI%%(.+)/g, '- $1
')
+ .replace(/%%TDI%%(.+)/g, '- ☑ $1
')
+ .replace(/%%TTI%%(.+)/g, '- ☐ $1
')
+ + '
';
});
// Blockquotes (> text)