Action

load-css (copy)

Last update 6 days ago

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

Steps

  • script

    // read stylesheet from file in iCloud
    var fm = FileManager.create(false);
    var css = fm.read("drafts-styles-fig30-1.css");
    
    // place in template tag
    draft.setTemplateTag("css", css);
    
    
    // Advanced Print
    // RV 2020-03-26 at 21:01
    
    'use strict';
    
    function main() {
      var fm = FileManager.create(false);
      var cssFile = fm.read("drafts-styles-fig30-1.css");
    
      let css = cssFile;
      let doc = '';
      doc = draft.content;
      makeHTML(doc, css);
    }
    
    function makeHTML(doc, css) {
      let mmd = MultiMarkdown.create();
      mmd.format = "html";
      let body = mmd.render(doc);
      // css = '';
      let html = `<!DOCTYPE html>
      <html dir="auto">
      <head>
      <title></title>
      <meta name="viewport" content="width=device-width, initial-scale=1">
      <style>
      ${css}
      </style>
      <link rel="stylesheet"
          href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.15.6/styles/default.min.css">
    <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.15.6/highlight.min.js"></script>
    <script>hljs.initHighlightingOnLoad();</script><script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
      </head>
      <body>
      ${body}
      </div>
      </body>
      </html>
      `
      draft.setTemplateTag("html", html);
      console.log(html);
    }
    
    main();
    
    
  • htmlpreview

    [[html]]
  • runShortcut

    shortcutName
    html2pdf-mod
    waitForResponse
    false
  • print

    template
    [[html]]
    format
    html

Options

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