Action

Markdown Emphasis (_)

Posted by agiletortoise, Last update over 4 years ago

Apply Markdown emphasis (_) to selection or insert _ if no selection.

Steps

  • script

    // Apply Markdown emphasis to selection, or insert _ if no selection
    const markup = "_";
    
    const sel = editor.getSelectedText();
    const [st, len] = editor.getSelectedRange();
    
    if (!sel || sel.length == 0) {
      editor.setSelectedText(markup);
      editor.setSelectedRange(st + markup.length,0);
    }
    else {
      editor.setSelectedText(markup + sel + markup);
      editor.setSelectedRange(st + len + (markup.length*2),0);
    }
    

Options

  • After Success Nothing
    Notification Error
    Log Level Error
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.