Ka-Note/ka-note/test-regex.mjs

13 lines
456 B
JavaScript

// Test the regex used in JournalView to detect task lines
const regex = /^\s*(?:\\?\[\\?\]|\[T:[^\]]+\]|\\?\[X\\?\])/;
const titles = [
'[] TASK1', // normalized: no backslash
'\\[\\] TASK1', // tiptap-serialized: single backslash
'[T:abc] test', // linked task
'[X] done', // completed (no backslash)
'\\[X\\] done', // completed (with backslash)
];
titles.forEach(t => console.log(JSON.stringify(t), '->', regex.test(t)));