Action
Mochi Cloze Deletion
Posted by rwblickhan,
Last update
1 day ago
Convert a Markdown unordered list into Mochi’s cloze deletion format.
Steps
-
script
const lines = draft.content.split('\n'); let clozeCounter = 1; const convertedLines = []; for (const line of lines) { const numberedMatch = line.match(/^(\s*)(\d+).\s+(.+)$/); const bulletedMatch = line.match(/^(\s*)[-*]\s+(.+)$/); if (numberedMatch) { const indent = numberedMatch[1]; const number = numberedMatch[2]; const content = numberedMatch[3]; const convertedLine = `${indent}${number}. {{${clozeCounter}::${content}}}`; convertedLines.push(convertedLine); clozeCounter++; } else if (bulletedMatch) { const indent = bulletedMatch[1]; const content = bulletedMatch[2]; const convertedLine = `${indent}- {{${clozeCounter}::${content}}}`; convertedLines.push(convertedLine); clozeCounter++; } else { convertedLines.push(line); } } draft.content = convertedLines.join('\n'); draft.update();
-
clipboard
template [[draft]]
Options
-
After Success Default Notification Info Log Level Info
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.