Action

MD to Rich Text (with implicit line breaks and user styling) (copy)

Posted by @sylumer, Last update over 1 year ago - Unlisted

Transform Markdown to Rich Text, with implicit line breaks & user styling and place result on the clipboard

Steps

  • defineTemplateTag

    name
    font-family
    template
    Avenir Next
  • defineTemplateTag

    name
    font-size
    template
    14
  • script

    let mmd = MultiMarkdown.create();
    let strFontFamily = draft.processTemplate("[[font-family]]");
    var strFontSize = draft.processTemplate("[[font-size]]");
    
    let strHTML = mmd.render(draft.content.replaceAll(/(\n)/gm, "  $1"));
    let strTemplate = `<html><body style="font-size: ${strFontSize}px; font-family: ${strFontFamily};">
    [[content]]
    </body></html>`;
    if (!app.htmlToClipboard(strTemplate.replace("[[content]]", strHTML))) context.fail("Error could not generate HTML.");

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.