orschiro
orschiro

Reputation: 21833

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?

Upvotes: 22

Views: 7430

Answers (4)

Farhan Hai Khan
Farhan Hai Khan

Reputation: 828

Google Docs -> docx to Markdown -> md

I myself looked far and wide but I believe the best way to do this is by using Pandoc.

Works for all platforms (check their incredible website ) , what you are looking for is the following command on your cmd or PowerShell (Windows) :

pandoc input_filename.docx -s -o output.md

Pro Tip: Pandoc comes with a little trick to store up even all of the images in your document to your custom folder and then adding the image tags in the markdown by using relative referencing to those images at the correct places. The amazing line of code is:

pandoc --extract-media ./your_custom_folder input_filename.docx -o output_filename.md

Upvotes: 0

Sergio Majluf
Sergio Majluf

Reputation: 1355

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!

Upvotes: 32

theblackout
theblackout

Reputation: 1

Another option would be to change how files are delimited in Excel on your computer. This guide can help you do that (http://www.howtogeek.com/howto/21456/export-or-save-excel-files-with-pipe-or-other-delimiters-instead-of-commas/)

Then every time you copy and paste from excel to a markdown file/jekyll you automatically have the pipes. All you will need to do is add some dashes to separate your topline..

Upvotes: 0

janos
janos

Reputation: 124804

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.

Upvotes: 1

Related Questions