Drafts Action Directory

Text link > Markdown

Posted by @kerim, Last updated: 2018-07-04 02:56:24 UTC

Takes text followed by a URL and turns it into text.

Install

Steps

  • script

    // define regex to use...
    
    const findRegex = /^(.*?)\s(https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*))/g;
    
    // define replacement expression...
    
    const replaceWith = "[$1]($2)";
    
    // do the replacement...
    
    draft.content = draft.content.replace(findRegex, replaceWith);
    draft.update();

Comments

Actions available in the Action Directory are uploaded by community members. Use appropriate caution reviewing downloaded actions before use.