Drafts Action Directory

Markdown Strong/Bold

Posted by toniwonkanobi, Last updated: 2018-07-04 03:20:45 UTC

Alternate version of Greg’s Action. This one creates Markdown strong around the selected text with asterisks (). If no text is selected, the Action inserts four asterisks () with the cursor in between them, ready for strong text entry.

Install

Steps

  • script

    // Apply Markdown bold to selection, or insert ** if no selection
    
    var sel = editor.getSelectedText();
    var selRange = editor.getSelectedRange();
    
    if (!sel || sel.length == 0) {
      editor.setSelectedText("****");
      editor.setSelectedRange(selRange[0]+2,0);
    }
    else {
      editor.setSelectedText("**"+sel+"**");
      editor.setSelectedRange(selRange[0]+selRange[1]+4,0);
    }
    

Comments

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