Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert Google Docs to Jekyll Markdown

How can I convert a Google Docs, which contains images and tables, into a Markdown file which can be published as a post using Jekyll?

Is it possible to first export the Google Docs into a PDF and then convert the PDF to Markdown? What will happen to the images and tables in that case?

like image 399
orschiro Avatar asked Nov 04 '13 14:11

orschiro


People also ask

Can Google Docs convert Markdown?

Docs to Markdown (GD2md-html) converts Google Docs to simple, readable Markdown or HTML. Now open-source! This add-on allows you to create documents using the excellent editing and collaborative features of Google Docs, then convert to Markdown or HTML that you can store as text files using a version-control system.

How do I download Google Docs as Markdown?

You have to manually turn it on in the settings first. That's why I'm writing this post. If you want to enable Markdown support, open a document in Google Docs, head over to the top of the screen, go to “Tools” then “Preferences” and enable “Automatically detect Markdown.” After that, you're good to go.

Can you upload a Google Doc to github?

There is no direct way to quickly convert a Google Doc into Github or your own website. However, you can convert your Google doc to markdown or HTML and then use the result in your Github or own website.


2 Answers

May 2018 Update

The script originally suggested in this answer appears to no longer work and has not been updated for 5 years.

An alternative solution (which is based on the old script) can be found at https://github.com/evbacher/gd2md-html

I tried it out, it works pretty well.

Previous Answer

You can use a Google Script to do the conversion for you!

This one will let you convert to .md and it will email you the converted file. I've tested it and works fine. It works with basic tables, and if you have images in the doc, it will attach them to the email.

Instructions for installing are on the same link, in the GitHub description, but I pasted it here for ease of access:

Add the script:

  • Open your Google Drive document (http://drive.google.com)
  • Tools -> Script Manager > New
  • Select "Blank Project", then paste this code in and save.
  • Clear the myFunction() default empty function and paste the contents of converttomarkdown.gapps into the code editor
  • File -> Save

Run the script:

  • Tools > Script Manager
  • Select "ConvertToMarkdown" function.
  • Click Run button (First run will require you to authorize it. Authorize and run again)
  • Converted doc with images attached will be emailed to you. Subject will be "[MARKDOWN_MAKER]...".

Good luck!

like image 105
Sergio Majluf Avatar answered Sep 22 '22 05:09

Sergio Majluf


You can export as HTML. Jekyll can serve static HTML files.

Btw, "standard" markdown doesn't have tables. There are implementation that have it, but I'm afraid you'll have to convert them by hand to the right format, which will be implementation dependent. I don't know about Jekyll, maybe it's easiest to just use HTML tables within the markdown text.

You could create a new theme based on the HTML export. The export should contain the stylesheet embedded in a <style> tag within the HTML document. It's not really easy to create new themes, but doable. Or, if you just want the content and don't mind using whatever Jekyll theme you already have, then you can cut out the stylesheet part and keep the html only.

like image 26
janos Avatar answered Sep 21 '22 05:09

janos