Action

Paste as Markdown

Posted by agiletortoise, Last update over 1 year ago

If HTML content is available in clipboard, convert it to Markdown and paste it in the currrent draft. Falls back to plain text content if HTML is not available.

Steps

  • script

    let text
    // get HTML from clipboard
    let html = app.getClipboard("html")
    if (html) {
    	let h = new HTMLToMarkdown()
    	text = h.process(html)
    }
    // fall back to text content 
    if (!text || text.length == 0) {
    	text = app.getClipboard()
    	let h = new HTMLToMarkdown()
    	text = h.process(text)
    }
    
    // update text in editor
    let [st, len] = editor.getSelectedRange()
    editor.setSelectedText(text)
    editor.setSelectedRange(st, text.length)

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.