Search code examples
google-apps-scriptgoogle-docsgoogle-docs-api

Convert a Markdown text file into a Google Document using Appscript?


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


Solution

  • 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.