Action

Open Rich Text in Word

Posted by RoyRogers, Last update about 5 years ago

Convert Markdown draft to rich text and open it in MS Word using Shortcuts :)

Note: Install this shortcut before first run:
https://www.icloud.com/shortcuts/d6ef3a4ecc9146d48fbdbeb11c5a075d

Steps

  • script

    // Process Markdown to HTML
    var mmd = MultiMarkdown.create();
    var html = mmd.render(draft.content);
    
    // Wrap raw MMD output with HTML template with styles to set base fonts.
    
    var template = `<html>
    <body>
      ${html}
    </body>
    </html>
    `;
    
    // var html = template.replace("[[content]]", html);
    
    // Place in clipboard as rich-text
    if (!app.htmlToClipboard(template)) {
    	context.fail("Error rendering rich text from HTML.");
    }
  • url

    template
    shortcuts://run-shortcut?name=OpenInWord&input=[[safe_title]]
    useSafari
    false
    encodeTags
    true

Options

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