Open bathrobe opened 3 years ago
const CB = roam42.smartBlocks.activeWorkflow.vars["clipBoard"]; const ticks = "`" + "`" + "`" const regString = "(" + ticks +")(.*?)("+ ticks + ")"; let re = new RegExp(regString, "gs"); const codeBlocks = [...CB.matchAll(re)].map(block=> "\n//"+block[2]+'\n').join('') roam42.smartBlocks.activeWorkflow.vars["codeBlocks"] = codeBlocks;
Copy a multi-block set of codeblocks and plain text and this SmartBlock will return ONLY your codeblocks, minus the backticks and separated by linebreaks. Loom here! https://www.loom.com/share/b331778d90af46bca25453b1d4468802
Make sure your browser's new enough to use the matchAll method for regular expressions (it probably is, I'd bet). Loom below!
matchAll
✂️ Copy of your #42SmartBlock from Roam
42SmartBlock Codeblock Parser - Roam Bounties
📋 Describe the SmartBlock
Copy a multi-block set of codeblocks and plain text and this SmartBlock will return ONLY your codeblocks, minus the backticks and separated by linebreaks. Loom here! https://www.loom.com/share/b331778d90af46bca25453b1d4468802
✅ Describe any prerequisites or dependencies that are required for this SmartBlock
Make sure your browser's new enough to use the
matchAll
method for regular expressions (it probably is, I'd bet). Loom below!📷 Screenshot of your #42SmartBlock workflow/template from Roam