elee / gdoc-markdown-converter

Convert a Google Drive Document to the Markdown format suitable for publishing.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

gdoc-markdown-converter

A Google Docs add-on to convert a properly formatted Google Drive Document to the markdown (.md) format. Then either download it or add it to your Google Drive. It also attached images which are available inside the doc.

Usage

  • How to install ?
    • Open any google document from your drive that can be converted into an MD file
    • Click on Tools -> Script Editor
    • Click on "Blank Project"
    • Delete all the contents in the file code.gs and paste all the contents from converttomarkdown.js file
    • Save the project and the file
    • There will be a drop down saying "Select Function"
    • Select the function "ConvertToMarkDown" from the drop down.
  • How to Use ?
    • After creating the project as said above, open the document where you have created the scripts.
    • Click on the Add-ons menu, you will see an add-on by the name of the project that you have created while installing.
    • Click on "Add To Drive" menu.
    • The file will be converted into an MD file with the name, same as that of the source document.
    • The converted file will be placed in a folder created with the name same as that of source document, under the folder "Google Docs to Markdown"
    • If the above said folders are not there, the script will automatically create it.
    • If any inline image are there, it will also be placed within the folder where the converted MD file is placed already.
    • Please note that the converted images cannot be viewed directly from google drive. You have to download to view it because of this issue [http://code.google.com/p/google-apps-script-issues/issues/detail?id=1239]
    • To convert multiple documents, it is better to create this as a google docs plugin and publish it within your own domain after getting approval from google.
    • To change the otuput folder, click on the "Change Output Folder" menu. It will show you the default output folder and a text box to change it.
    • Type in the new output folder name and press 'OK'. All the converted MD files in future will be placed under this new common folder. If the folder doesn't exist, it will create when the next time you convert any MD file.
    • Please note that if you change the output folder name in plugin, it will be reflected across all documents.
    • Cheers, Happy Converting.

Interpreted formats

  • Text:
    • paragraphs are separated by two newlines
    • text styled as heading 1, 2, 3, etc is converted to Markdown heading: #, ##, ###, etc
    • text formatted with Courier New is backquoted: text
    • links are converted to MD format: [anchortext](url)
  • Lists:
    • Numbered lists are converted correctly, including nested lists
    • bullet lists are converted to "*" Markdown format appropriately, including nested lists
  • Images:
    • images are correctly extracted and sent as attachments
  • Blocks:
    • Table of contents is replaced by [[TOC]]
    • blocks of text delimited by "--- class whateverclassnameyouwant" and "---" are converted to <div class="whateverclassnameyouwant"></div>
    • Source code:
      • UPDATED: blocks of text delimited by "--- source code" or "--- src" and "---" are converted to <pre></pre>
      • NEW: blocks of text delimited by "--- source pretty" or "--- srcp" and "---" are converted to <pre class="prettyprint"></pre>
    • Tables:
      • NEW: Simple <table> processing
  • "--- jsperf <testID>" is replaced by an iframe that shows an interactive chart of a JSPerf test. The <testID> is the last part of the URL of the Browserscope anchor in your JSPerf test. Something like "agt1YS1wcm9maWxlcnINCxIEVGVzdBjlm_EQDA" in the URL http://www.browserscope.org/user/tests/table/agt1YS1wcm9maWxlcnINCxIEVGVzdBjlm_EQDA

CONTRIBUTORS

  • Supreet Pal Singh - supreetpal.in
  • Siva Subramaniam - Github

CREDITS

As this project was forked from their original script available at: https://github.com/mangini/gdocs2md

LICENSE

Use this script at your will, on any document you want and for any purpose, commercial or not. The MarkDown files generated by this script are not considered derivative work and don't require any attribution to the owners of this script.

If you want to modify and redistribute the script (not the converted documents - those are yours), just keep a reference to this repo or to the license info below:

Copyright 2013 Google Inc. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

About

Convert a Google Drive Document to the Markdown format suitable for publishing.

License:Apache License 2.0


Languages

Language:JavaScript 100.0%