Markdown to Plain Text [LaunchBar Action]

An Action for the LaunchBar application (macOS).

What it does

The Action takes Markdown-formatted text and converts it to plain text. This is especially useful for creating nice plain-text emails.

An example:

Input (Markdown):

This is an example text to demonstrate how Markdown^[This is an inline footnote] is converted to plain text:

An unordered list:
=================

- a list item
- another list item with a some more text to show how list items are hard-wrapped and indented (in this case with 4 spaces and to a max. length of 72 chars)
- and a last list item with a subitem:
    - subitem[^myFnote]

[^myFnote]: Also referenced footnotes can be used.

# An ordered list:

1. This is the __first__ point of an ordered list
1. Footnotes are useful to get longish links^[https://en.wikipedia.org/wiki/Hyperlink#Hyperlinks_in_various_technologies] out of the text body
1. …but the usual Markdown [link syntax](https://daringfireball.net/projects/markdown/syntax#link) will also be referenced at the end of the text.

A table in-between:

| Tables | Are | Cool |
|--|:--:|--:|
| col 1 is | left-aligned | $1600 |
| col 2 is | centered | $12 |
| col 3 is | right-aligned | $1 |

4. To continue a list numbering
4. just start with the desired number

End of text.

***

Output (plain text):

This is an example text to demonstrate how Markdown[1] is converted to	
plain text:



AN UNORDERED LIST:


-   a list item	
-   another list item with a some more text to show how list items are	
    hard-wrapped and indented (in this case with 4 spaces and to a max.	
    length of 72 chars)	
-   and a last list item with a subitem:	
    -   subitem[2]



AN ORDERED LIST:


1.  This is the FIRST point of an ordered list	
2.  Footnotes are useful to get longish links[3] out of the text body	
3.  …but the usual Markdown [link syntax][] will also be referenced at	
    the end of the text.

A table in-between:

  Tables           Are          Cool	
  ---------- --------------- -------	
  col 1 is    left-aligned     $1600	
  col 2 is      centered         $12	
  col 3 is    right-aligned       $1

4.  To continue a list numbering	
5.  just start with the desired number

End of text.

------------------------------------------------------------------------

[1] This is an inline footnote

[2] Also referenced footnotes can be used.

[3] https://en.wikipedia.org/wiki/Hyperlink#Hyperlinks_in_various_technologies

  [link syntax]: https://daringfireball.net/projects/markdown/syntax#link

How to use

  1. In your text editor, select the Markdown text that should be converted.
  2. Send it to LaunchBar with your Instant Send key
  3. Select the action by typing the appropriate abbreviation (for example mp or mtp).
  4. Press Return.
  5. Once the result appears in the LaunchBar window press ⌘C to copy it to the clipboard.
  6. Paste it wherever you want.

As you might know, LaunchBar allows you to directly insert string results by pressing Shift-Return. So, if you prefer to replace the current text selection with the result (instead of copying it to the clipboard), then just press Shift-Return in step 4.

If you want to send the result to another action, then press the Tab key as soon as the result appears in the LaunchBar window, and then invoke the other action.

How it works

  • The action uses a Perl script.
  • The conversion is done by Pandoc.
  • After the conversion the script appends a Tab character to the end of each line that is not followed by an empty line. This should prevent certain broken email clients (namely Outlook) from arbitrarily removing line breaks.1 You can deactivate this in the script (see the comments there), if you don’t use Outlook or if you don’t send plain text mails to Outlook users.

Requirements

  • LaunchBar, of course.
  • Pandoc; can conveniently be installed via Homebrew:
    brew install pandoc
    If you don’t want to install it, then download the standalone Action, which contains the Pandoc binary (~20MB; see Download section blow).
  • Perl (preinstalled with macOS).
  • I have included the required Perl modules Pandoc and JSON in the Action bundle.2

Customization

Pandoc is highly customizable and you can tweak the output text to your needs. To do so, just edit the Pandoc options in the script. (It is the line that begins with my $md2plain.)

You can for example adjust line length, indentation of lists, enable/disable “smart” replacement, footnotes location and more. For the complete documentation of the options see the Pandoc user manual. Explanations for the most important options you find also at the end of the script file (default.pl).

Use the excellent Action Editor to open and edit the script file.

Download

Normal version (recommended):

Download (1.0 / 2017-04-17)

Standalone version (with Pandoc, ~20MB):

Download (1.0 / 2017-04-17)

Bulk-Export Mails from Apple Mail, Part II

Apple’s mail client has an annoying limitation: If you want to export mail messages as .eml or .emlx you have to do it one by one, i.e. dragging one message at a time from the Mail App’s window to a Finder window. It won’t let you drag several messages at the same time.

applemail-icon

However with a small script this limitation can be circumvented easily. (This is Part II of the other Mail Export post.)

Continue reading Bulk-Export Mails from Apple Mail, Part II

‘Delete Immediately…’ in OS X El Capitan

With OS X El Capitan (10.11) the Finder has gained a handy new feature, called Delete Immediately… .

To immediately delete one or more files or folders select them in the Finder, then hold down the Option and Command key and press Backspace. (⌥⌘⌫)  Continue reading ‘Delete Immediately…’ in OS X El Capitan

Quick Comparison of some iOS Content Blockers

The new iOS 9 opened the door for third-party content blockers for Mobile Safari. A couple of days ago the first blockers appeared in the iTunes Store and the list is growing longer.

The “problem” is that almost all of them receive great customer ratings in the store. In no time I had downloaded a bunch of them (too many…) and still didn’t know with which one to go. In the absence of unbiased comparisons I made a little comparison myself.

Continue reading Quick Comparison of some iOS Content Blockers

Archive Assistant (Script)

Übersetzung verfügbar: Deutsch Deutsch

This AppleScript script is very handy for the creation of different type of archives and disk images.

It’s one of those scripts I use almost daily: It’s sitting in the Scripts menu in the menu bar and from there it allows me easy access to important and useful archive and disk image formats. Unlike other programs this script does not try to gather every available format. Just the ones that are right for a given purpose.

Updated 23 Apr 2017 @ 14 h: Compatible with Mac OS X 10.10, 10.11 and – now finally also – macOS 10.12 (Sierra).

The script can create these archive/dmg types:

Continue reading Archive Assistant (Script)

OS X: Understanding and Configuring Mail Drop

Übersetzung verfügbar: Deutsch Deutsch

Mail Drop is a new Yosemite features that drew relatively little attention.

Mail Drop is super useful. It allows to send huge (really huge) attachments just as if they were normal, small attachments. It does this by uploading the attached file to a third-party server (i.e. not the SMTP server). The receiving mail client then either downloads the file automatically or the user can download it with a click on the attachment icon/link. (This depends on whether a mail client or web mail is used on the receiving side, or on the settings of the mail client.)

This allows to avoid problems like these: Continue reading OS X: Understanding and Configuring Mail Drop

LaunchBar Action: Delete

Übersetzung verfügbar: Deutsch Deutsch

LaunchBar is my preferred application/file/script launcher on OS X. If you’re a LaunchBar user you know that it is very extensible through custom actions.

This little Action is called “Delete”. We all know that deleting files can quickly become boring. “Delete” brings back some variation and joy to the otherwise monotonous duty of file deletion. 😉 Continue reading LaunchBar Action: Delete

U.S.-TF: A Custom Keyboard Layout for OS X

A keyboard layout file sits between your physical keyboard and the operating system. It tells the computer what should happen when you hit a certain key on the keyboard, for example the key labeled “Z” or the combination of shift (), option () and 7.

Most common usage of keyboard layout files is to make language specific physical keyboards work as you would expect. If you bought, for example, your MacBook in France chances are high that the upper left letter keys are labelled “A” and “Z”, and not “Q” and “W” as on an US keyboard. And indeed, if you hit the upper left letter key on your French MacBook it’ll type the letter “A” into your text document.  Continue reading U.S.-TF: A Custom Keyboard Layout for OS X

Keep a History of your External IP Addresses

Today I had a look on my 404 log to check if there were any broken links or orphaned slugs on my site. The log was more than a couple of days old and … rather long. Since I made some “experiments” with my site recently, it was likely that the majority of the 404s have been triggered by myself, that is, from my Mac, behind a dynamic IP address.

So, how to filter out these not-so-interesting entries?  Continue reading Keep a History of your External IP Addresses