5 Things You Can Do With DocumentAlchemy

the DocumentAlchemy blog

Last Updated:
5 Things You Can Do With DocumentAlchemy

2. Render Markdown as HTML, PDF or Microsoft Word

Technically that's three things, but we'll group them as one.

Markdown, as you probably know, is John Gruber's clever codification of largely pre-existing conventions for styling text in plain-text, like _underscores_ for emphasis and **stars** for bold.

Markdown was introduced a little more than a decade ago, and since that time has become a quite popular way to express rich-text styling in a plain-text format.

Markdown was originally designed as way to represent HTML as “readable” text, and HTML remains the primary target for most Markdown transformations.

But since HTML formatting (e.g., headings, paragraphs, lists, links, bold, italic, etc.) is pretty good model for most common document formats and structures, it's not unusual for Markdown to be used as the “source” version of other formatted documents, especially PDFs.

DocumentAlchemy can render Markdown as HTML, PDF and Microsoft Word files (and we expect other target document types to come online relatively soon).

To render a Markdown document as PDF

, for example, you can use the following curl command:

The same syntax works equally well to convert Markdown to HTML or Markdown to Microsoft Word. Just change the pdf at the end of the URL in line 3 to html or docx to render the Markdown file as HTML or MS Word, respectively. (While not strictly necessary, you'll probably want to change the extension on the generated file found in line 4 as well.)

Here's a more general-purpose shell-script for that task:

Save the script as md2x.sh, make sure it is executable (chmod a+x md2x.sh) and run it like this:

./md2x.sh foo.md docx

to convert the Markdown file foo.md to a Word document (saved as foo.docx).

Change the docx to pdf:

./md2x.sh foo.md pdf

to convert the Markdown file a PDF document (saved as foo.pdf).

Change the docx to html:

./md2x.sh foo.md html

to convert the Markdown file an HTML document (saved as foo.html).

EDIT: See “Render Markdown as HTML, PDF or Microsoft Word.” in “Five Things You Can Do With the DocumentAlchemy API - Command-Line Interface Edition” for an even easier interface to this functionality.

About DocumentAlchemy

DocumentAlchemy is a RESTful web service that developers can use to add document generation, conversion and processing features to their app.

Visit our live demonstrations or interactive API reference to explore Document Alchemy's rapidly growing API for working with MS Office documents, PDFs, images, web pages and more.

Copyright © 2017 DocumentAlchemy.