215

I love Google Docs. I write notes, essays, correspondences, invoices, journal entries, business ideas, planning documents- everything on there.

I also love the markdown format. I'm a programmer so sometimes I'm in my editor and just want to write things in markdown instead of going to Google Docs.

However, when I save my markdown files in Google Drive, I can't preview them there, which is extremely disruptive to my workflow. Being able to preview markdown files in Google Drive would be a huge improvement.

Is there any way to enjoy the benefits of both Google Docs and markdown? Or are these writing platforms largely incompatible? Any elegant solutions I'm not thinking of?

14 Answers 14

157

You can give StackEdit a try. It has a nice integration with Google Drive.

Once you import/export a Markdown document from/to Google Drive, you can open it later directly from Google Drive since StackEdit is integrated as a third party editor/viewer application.

You can find StackEdit as a Chrome application as well on the Web Store.

NOTE: I'm the developer of StackEdit.

19
  • 3
    Actually, did you try to open your .md files directly from Google Drive web site? When linked with your Google Drive account, StackEdit is the default application for opening text/x-markdown MIME type and .md extension. Works fine with me.
    – benweet
    May 14, 2013 at 22:28
  • 3
    I just modified the filter from the Google Drive Picker in StackEdit so that you can import text/x-markdown, text/plain, application/octet-stream MIME types. That should solve your problem.
    – benweet
    May 14, 2013 at 23:09
  • 3
    @benweet I am really pleased to see the StackEdit and I do like it as an MarkupEditor. Still, there is something that will prevent me from going this way: it is missing the most important features of google docs: the ability to collaborate on the same document, several people editing at the same document, inline-comments, ....that's gold for reviewing.
    – sorin
    Nov 10, 2013 at 12:33
  • 3
    It's clear some others don't understand what this does. Even though this question is about a markdown interface for Google Docs, this is actually a Docs alternative. Anything can be stored on Google Drive, it's separate from Docs. It looks nice but it's an alternative 'workflow'... Aug 18, 2015 at 1:12
  • 3
    alas this does not integrate with google docs in any way at all. this is not a solution. --
    – rektide
    Apr 23, 2018 at 2:03
23

A Google Docs document encodes everything in 'elements' within the Kix editor that it's all based on (it's closed source as basically this is the big trade secret, with which anyone else could run their own Docs service - which is a shame imo).

You can access these elements with Google Apps Script, a variant of Javascript - but writing Markdown from the elements isn't as straightforward as you'd think (you have to essentially implement a markdown parser in Apps Script).

When I came to do this earlier in the year there were dozens of forks of Renato Mangini's "gdocs2md" repo, but he seemed to have stopped fielding pull requests, and over the period of a few years forks had appeared that were far better than others. I went through many of these in the tree and put the best into a new package, which also generates HTML mixed with the markdown for elements Google Docs supports such as superscript and subscript elements (which markdown has no way of representing). Even incorporating the best of others' edits, the parsing needed work, and I'm confident that this is the best available for the job at present.

Script available on GitHub with installation instructions: lmmx/gdocs2md-html

I also worked on adding in the most important feature to such a script - user features - providing the markdown in a pop-up within Google Docs rather than saving to file (I think the original was batch saving for entire folders, which is not suitable for my document-drafting needs, or how I use Google Docs at all).

enter image description here enter image description here

I'd like to suggest it be a single more sophisticated project for interested developers to collaborate on (or at least suggest features for) rather than everyone forking off scripts of various quality, when we're likely working to the same aims.

As well as reducing duplication of effort, the Google Docs policy for creation of "add-ons" states that to be published (and therefore 'installable' rather than needing to be loaded for each document in a slightly awkward manner)

  • The add-on must be fully functional — it can't be a “work in progress.”

  • The script has been tested with multiple active users.

Obviously if you wanted a "pure" markdown then either switch off these features (the code is there to fork) or just don't use sub/superscripts, etc. It wouldn't be too difficult to add personalised settings to such a script if it matures as an add-on, if there's significant interest.

3
  • 2
    Would be nice to do it the other way around, i.e. md -> google docs
    – qed
    May 13, 2017 at 19:24
  • There is no trade secrets, just a sizable amount of work — see researchgate.net/publication/… . Open-source implementations of operational transform are available, e.g. prosemirror.net but deploying them, again, requires work.
    – DomQ
    Nov 15, 2020 at 13:52
  • The paper you link to is not written by Google, it's by some completely unrelated researchers in India. I never suggested it wasn't "a sizeable amount of work", but this doesn't change the fact it's a closed source web app hence yes, it is running on trade secrets. Please add your own answer if you have information you want to share not covered in mine. Nov 16, 2020 at 13:15
13

You can convert a Markdown document to HTML, and copy/paste the HTML page (not the source) into a Google Drive document. It will retain most of the formatting including headings, lists, links, bold/italic/underline.

The font, margins, and font sizes will not match the Google Drive defaults, and will look "out of place" compared to standard Google Drive documents. Applying a custom CSS file to the HTML document will solve this, making the document look very similar.

I'm not sure about the other direction, converting Google Drive documents to Markdown. It may be possible to export to HTML and use an HTML to Markdown converter.

12

gdocs2md does a good job of converting Google documents to markdown, retaining headers, lists, tables, italics, bold, links and images. I use it to allow shared editing of documents, then export to markdown.

Some care does need to be taken to use formatting in the Google document that maps well to markdown, but this isn't particularly difficult. I've also extended the script to support exporting an entire folder of documents to a new "export" folder on Google Drive, and to slightly improve handling of italic and bold formatting, my fork is here.

1
  • 4
    Hi, I found and incorporated the edits in this fork amongst a bunch of others to a new repo with what I hope is some better user features (the handling of italic/bold etc was still really buggy, and not only batch saving to file but displaying markdown). Gonna leave my own answer, but please do take a look :-) Aug 18, 2015 at 2:15
8

You say you're a programmer, so this answer assumes you'd be comfortable with a little "roll your own" approach.

Google drive supports scripts: http://www.google.com/script/start/

So, you could create a little Showdown viewer that you point to your markdown files (as URLs).

2
  • Yes, I could do this. Thanks! I'm going to poke around some more to see if there's something that already exists. May 12, 2013 at 0:33
  • 2
    And that is what mangini/gdocs2md is - a script. See the answer by trepdatious.
    – nealmcb
    Oct 9, 2014 at 23:51
7

Download and install the Google Drive software. It's for Windows and Mac at the moment, a version for Linux is in the making. The software will create a folder on your computer that syncs with Google Drive. If you open a file in it, it will be opened in the appropriate installed program. Google Drive documents that you open will open in the browser.

This way, you can open/edit markdown files stored on Google Drive in an installed markdown editor.

0
4

I recommend Markdown Preview Is a simple Add-on that (just) makes previews of the markdown document you are creating.

As far I understand, the main request is to preview it, so I think this is what you are searching for.

0
4

Preview Markdown Add-on for Google Docs gets my work done, it shows markdown preview in realtime in the sidebar with syntax highlighting.

screen shot


I like to use Google Docs and I love the simplicity of markdown even more, that is why I put together showdown.js and highlight.js to create this small add-on.

3
  • If you are affiliated with the product in any way, please disclose that in your answer. Thanks!
    – jonsca
    May 10, 2017 at 20:52
  • 1
    This is cool, but note that the real-time preview is not scroll-synched, if you're used to that from VSCode or other previewers.
    – Kev
    May 26, 2017 at 13:12
  • That's a really good idea! I will try to implement it - if it's possible to get the scroll position via Google Docs API. Thanks :)
    – undefined
    May 29, 2017 at 13:02
3

One-way pandoc solution for Github-Flavored Markdown (GFM) .md with embedded MathJax-based LaTeX to Google Docs:

Offline, convert to .docx:

pandoc --from=markdown_github+tex_math_dollars --to docx test.md > test.docx

Then, merely upload to Google Drive. In Google Drive, right-click and choose Open with Google Docs.

0

Assuming that once you're done making a document in markdown you want to convert it into a true google document (as opposed to being able to preview the document in the google drive web interface and continue editing in markdown syntax) so that others unfamiliar with markdown can collaborate I've found the following fairly quick:

  1. Create your mark down wherever's convenient.
  2. When done export to the browser
  3. Copy the resulting text from the browser
  4. Paste into a new Google Doc

Google docs is ready to have HTML pasted in so it'll preserve all the headings, spacing, lists, and other formats. Of course this only makes sense if you just want to personally work in markdown, but collaborate with others in a regular google doc.

-1

Strangely enough, Tumblr interconverts rich text, HTML, and markdown. I have had success in all directions, including taking markdown generated in Typora, pasting into a Tumblr post in md format, and then converting to rich text. Rich text can be pasted into Google Docs.

-1

Trello is another option for authoring files in Markdown. The Description field in the card can be formatted with Markdown. While perhaps not as "robust" as desired, if you are already using Trello or in a pinch it can work quite well.

I store some of my writing in Trello because:

  • I'm in Trello quite frequently already.
  • Web and mobile apps so it's available just about everywhere I am.
  • Real-time synchronization.
-1

Easy solution using pandoc:

  • save your markdown file
  • convert it to html
pandoc -f markdown -t html5 mymarkdown.md > index.html
  • open html in browser, copy past to a google doc
0
-2

Hello INK for All has made our process around posting blog content to our static site so much faster with its integrated markdown export capability. The best part is It also exports Hugo compatible docs

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.