Importing Markdown into Google Docs

markdown pandoc google docs

I’m a huge fan of plain text in writing. I love Markdown and I adore pandoc. Even this blog post is written in Markdown and transformed to its final form using pandoc.

But sometimes when one collaborates with other people, that has to happen through Google Docs. Alas, Google Docs rather infamously has no native Markdown support. So the best one can do is use pandoc to convert the Markdown source into an RTF or docx document in order to import it, living with the slightly odd non-native formatting and blue headings.

Or is it?

Turns out there’s a loophole to go from Markdown to the native Google Docs representation: rich text pasting of HTML. And as it turns out, it can represent quite a few formatting features.

Try saving the following as input.md:

# Hello *world*

## Math

$$x = 2 \cdot y^3$$

- foo
- **bar**
- ***baz***

```
main :: IO ()
main = putStrLn "Hello world"
```

1. Yes
2. No
3. Maybe

---

  Right     Left     Center     Default
-------     ------ ----------   -------
     12     12        12            12
    123     123       123          123
      1     1          1             1

Then run

pandoc -t html input.md | xclip -selection clipboard -t 'text/html'

And then just paste into a Google Doc.

I hope that makes drafting Google Docs quite a bit less unpleasant for you, as it did for me.