Paste as Markdown

Posted by agiletortoise, Last update about 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.


  • 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.setSelectedRange(st, text.length)


  • 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.