Markdown Macos



I have recently been delving into the world of Markdown, an easy lightweight markup syntax, mostly geared for writing for the Web. One popular Markdown app for iOS is Markdown Mail. I wondered how I could hack together a way to compose an email in Markdown and have it turned into HTML to send.

Markdown macos update

I started to make an OS X text service with Automator. The idea is that you select some text, then go to the services menu under the application’s menu or on the context (right-click) menu of the text. You select your service, it runs and usually is set to replace the selected text with its output.

Mou, Markdown editor for developers, on Mac OS X.

Make by native macOS technology, the pursuit of the perfect. The External Mode uses a directory tree to edit and manage your markdown documentation. Start writing Markdown text, save the file with the.md extension and then you can toggle the visualization of the editor between the code and the.

Markdown Macos

The problem I encountered was that you can’t replace the text selection object — formatting and all — with the result of such a service. The plain text of the selection is sent to the service workflow, and plaintext is extracted from the result and that replaces the text characters of the selection, but not their format. I needed to be able to replace the selection with an HTML clipping rather than the HTML text that the Markdown converter generates. This is fine if you are in a text editor and are going to compose an HTML post or file by writing in Markdown, then selecting all and converting it to HTML text. You can see how to make this service in this nice post by Matt Gibson.

There might be some other way, but for now what I had to do was to save the HTML generated from the Markdown conversion to a temporary file, then open that in Safari, have Safari select all and copy to the clipboard (copying an HTML object), then having Mail paste it – replacing the selected Markdown text. So, the service workflow takes the selected text, but does not itself replace the selection directly.

To make this Automator service:

  1. Open Automator

  2. Choose to create a Service

  3. Set the initial options:

    • Service receives selected text in Mail
    • Uncheck “Replaces selected text” (we will be pasting in rich text ourselves)
  4. From the Actions library on the left, select “Automator” to see its actions.

  5. Select the “Run Shell Script” action and drag it to the workflow area or just double-click it.

  6. Replace the sample code with:

    [Update]: I originally used MultiMarkdown in this example and opened the resulting HTML in Safari, but I've had Safari give problems opening a file: URL. The solution I've come to is to use pandoc to convert the Markdown to RTF and open that in TextEdit. You could still use Safari if it works for you, just replace 'TextEdit' with 'Safari' in the Applescript below and use this code in the shell script:

    You can add other options for pandoc or use your favorite Markdown converter to produce an HTML output file.

  7. From the Automator actions list on the left, add a “Run Applescript” step to the workflow.

  8. In the script box, place this Applescript code:

    onrun {input, parameters}

    tellapplication 'TextEdit'

    activate

    tellapplication 'System Events'

    keystroke 'a' using {command down}

    keystroke 'c' using {command down}

    keystroke 'w' using {command down}

    endtell

    endtell

    tellapplication 'Mail'

    activate

    tellapplication 'System Events' tokeystroke 'v' using {command down}

    endtell

    return input

    endrun

  9. Save the workflow as, for example, “Markdown to HTML Mail”. You could also save this as a regular workflow to the Mail application scripts folder (~/Library/Scripts/Applications/Mail) if you have the menubar scripts menu, then it would appear there when Mail is active.

Now, compose a new message in Mail, typing in Markdown. Then select all and either right-click on the text and go to the Services sub-menu or go to the Mail application menu and the Services sub-menu from there. You should find “Markdown to HTML Mail” there, and after selecting it, and a flash of action, your Markdown text has been replaced with rendered HTML. You can always use undo if it didn’t come out well, so you might want to use a variation of this service to have a Markdown preview to check on things until you are finished. That’s in the next post.

Bear features at a glance

Macos Markdown Editor Github

Macos

Macos Markdown Quicklook

  • Advanced Markup Editor that supports and highlights over 150 programming languages
  • Encrypt individual notes and lock Bear with Face/Touch ID to protect sensitive information
  • Rich previews while writing so you see prose, not code
  • In-line support for images and photos
  • Use Cross-Note Links to build a body of work, quickly reference other notes, and more
  • Quickly add todos to individual notes to keep yourself on task
  • Multiple themes to offer a style for everyone
  • Multiple export options including HTML, PDF, DOCX, MD, JPG, and more
Markdown
  • Smart Data Recognition of elements like links, emails, addresses, colors, and more to come
  • Hashtags to quickly find and organize notes however you like
  • One-tap formatting on iPhone and iPad with a custom shortcut bar and rich keyboard shortcuts
  • Focus Mode hides notes and other options when it matters
  • All your notes are stored in plain text for the ultimate in portability
  • Effortless, secure, and private multi-device sync via iCloud
  • Regular updates to keep you and your writing current