Action
 Fix Empty Links
Fix Empty Links
                  
        Posted by RosemaryOrchard,
    Last update
    almost 6 years ago
    This finds empty Markdown links in your text (e.g. [Drafts]()), and gives you a prompt to allow you to fill each one in.
Steps
- 
    scriptlet content = draft.content; let pattern = /\[[^\]]+]\(\)/g let matches = content.match(pattern); let p = Prompt.create(); p.title = "Missing Links"; matches.forEach(function (match, index){ p.addTextField(index, match.replace('[', '').replace(']()', ''), ""); }); p.addButton("OK"); let didSelect = p.show(); if (didSelect) { if (p.buttonPressed == "OK") { Object.keys(p.fieldValues).forEach(function (index) { content = content.replace(matches[index], matches[index].replace('()', '('+p.fieldValues[index]+')')) }); } } draft.content = content; draft.update();
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.