14
votes

I am trying to migrate a load of documentation which was written in markdown into a Google Doc so it can be used by our marketing department.

Is there a mechanism using appscript/ Google Docs Api that I can import a file and convert it to a Google Doc using a predefined template? Eg H1s will map to Title, etc

4
Although I'm not sure whether this is the direction you want, as one of several workarounds, how about using Markdown API of GitHub? It can think of the following flow. 1. Upload the markdown file to Web Apps of Google side. 2. At Web Apps, the retrieved file is converted to HTML using Markdown API of GitHub and converted to Google Document. It might be required to modify the Document for the template. I'm not sure about your template, the number of files and the maximum file size. So if this was not the direction you want, I apologize. - Tanaike
Did you ever find a way to do bulk conversions from Markdown into Google Docs? I currently convert individual documents by pasting Markdown into a Markdown editor (e.g. dillinger.io) then copying the formatted text — but obviously that doesn't scale! - Sam Dutton

4 Answers

14
votes

One suggestion: use Pandoc to convert Markdown to docx, then import to Google Docs using the Google Drive API.

You can also accomplish this using the Google Drive web interface:

  1. Convert markdown to ODT (or some other intermediate) using pandoc: pandoc MyFile.md -f markdown -t odt -s -o MyFile.odt
  2. Move the ODT file into your Google Drive folder.
  3. Right-click the ODT file (in the web version of Drive) and press "Open With -> Google Docs".
  4. Google Drive will now create a new Google Doc, with contents matching the ODT file, and open it for you.
3
votes

I don't know of a tool or library that allows for a direct conversion from markdown to a google doc.

Maybe you can convert your markdown to an intermediary format compatible with Google Docs (viable formats include .docx, .docm .dot, .dotx, .dotm, .html, plain text (.txt), .rtf and .odt) and then go from there.

You just need to find a tool that can convert markdown to one of those formats and also process your files in bulk (maybe some command-line utility could help with that).

0
votes

There is the Google Docs Addon Markdown to Docs ... which converts Markdown to Google Docs.

It has its limitations due to the Gdoc format but works otherwise very well.

0
votes

One variation of the suggestion to use pandoc: try using the docx format instead of odt. Google Docs handles MS Office files natively so I found formatting was preserved somewhat better using this approach.

Revised steps:

  1. Convert markdown to DOCX using pandoc: pandoc MyFile.md -f markdown -t docx -s -o MyFile.docx
  2. Upload MyFile.docx into your Google Drive folder
  3. Double-click MyFile.docx in the web version of Drive
  4. Google Drive will open MyFile.docx in a new tab