Drafts Action Directory

Markdown Preview with iCloud CSS

Posted by agiletortoise, Last update 3 months ago

Read CSS file named “markdown-style.css” in the iCloud “Drafts5” folder, and use it as the style for a Markdown preview.

Install

Steps

  • script

    // read stylesheet from file in iCloud
    var fm = FileManager.create(false);
    var css = fm.read("markdown-style.css");
    
    // place in template tag
    draft.setTemplateTag("css", css);
    
  • htmlpreview

    <!DOCTYPE html>
    <html dir="auto">
    <head>
    <title>Preview</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <style>
    [[css]]
    </style>
    </head>
    <body>
      %%[[draft]]%%
    </body>
    </html>
    

Options

  • After Success Nothing
    Notification Info
    Log Level Error

Comments

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