Action

Elixir Radar (RTF) Email Import

Posted by Robert Rainthorpe, Last update about 4 years ago

Converts the Articles section of Elixir Radar digests into a Draft, ready to process.

Copy the Articles section into the clipboard and run this action.

Elixir Radar digests look like this

Code is really just for learning how to convert RTF-formatted clipboard data into something usable in Drafts. It uses pbpaste to retrieve the RTF part of the clipboard data. This is then converted into simple HTML using textutil. Finally the HTML is converted to Markdown via pandoc.

The code could easily be adapted for any RTF clipboard data. Change the title constant and you’re done!

Requires pandoc. Use brew install pandoc or similar.

With thanks to agiletortoise, martinpacker and sylumer on the community site for their help glueing this together.

Output looks like this:

# Elixir Radar Reading List

[A Brief Guide to OTP in Elixir](https://sendy.elixir-radar.com/l/2nPONT9TSV5oJoXU1azM763A/Zs763892RZY7QK8wmEOn31ECRg/T9jm1gfoSoU3TDqgUqnB2A)  
[serokell.io](http://serokell.io/)  
Gints Dreimanis gives an overview of what OTP is, as well as a clear explanation of processes, GenServer, and Supervisor.  
[Elixir 1.11 and Erlang Docs](https://sendy.elixir-radar.com/l/2nPONT9TSV5oJoXU1azM763A/M8Ja8bVKvK7QZrLoBfFb5A/T9jm1gfoSoU3TDqgUqnB2A)  
[thinkingelixir.com](http://thinkingelixir.com/)  
Elixir 1.11 gives you the ability to show the docs for Erlang functions. This is a short guide to help you get it working if you encountered any problems.  

See Elixir Radar (Markdown) to OmniFocus for an action that imports the list of articles into OmniFocus

Steps

  • script (macOS only)

    const title = "# Elixir Radar Reading List";
    
    let script = `#!/bin/bash
    pbpaste -Prefer public.rtf | \
     textutil -stdin -convert html  -stdout -excludedelements "(head,table,div,ul,p,font,span,u)" | \ 
     /usr/local/bin/pandoc --from=html --to=markdown_mmd --wrap=preserve
    `;
    
    let runner = ShellScript.create(script);
    
    if (runner.execute()) {
        let d = new Draft();
        d.content = title;
        d.languageGrammar = "Markdown";
        d.append(runner.standardOutput, "\n\n");
        d.update();
    }
    else {
        alert("STDERR: " + runner.standardError);
    }
    
    

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.