SmartBlocks
SmartBlocks copied to clipboard
Roam Bounty:: Codeblock Parser
✂️ Copy of your #42SmartBlock from Roam
- Code (copy this block ref)
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;
- #42SmartBlock Codeblock Parser - Roam Bounties
- <%SET:clipBoard,<%CLIPBOARDPASTETEXT%>%><%NOBLOCKOUTPUT%>
- <%JA:<%RESOLVEBLOCKREF:YOUR_BLOCK_REF_HERE%>%><%NOBLOCKOUTPUT%>
- <%CLIPBOARDCOPY:<%GET:codeBlocks%>%><%NOBLOCKOUTPUT%>
- <%NOTIFICATION:20,Codeblocks copied to clipboard!%><%NOBLOCKOUTPUT%>
📋 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!