Skip to content

Instantly share code, notes, and snippets.

@aih
Created October 12, 2020 18:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aih/9987d84335da6c2601222b4ccd8c0409 to your computer and use it in GitHub Desktop.
Save aih/9987d84335da6c2601222b4ccd8c0409 to your computer and use it in GitHub Desktop.
# Notes on converting GDoc to Asciidoctor
## GDoc to AsciiDoctor using Java + Google APIs
This method is described here as experimental. I did not try it: https://github.com/maxandersen/gdoc2adoc
## GDoc to AsciiDoctor script
This method uses a Google Apps script, which adds a menu to your Google Docs. The script and instructions are here:
https://github.com/maxandersen/gdoc2adoc
I followed the directions here (`Tools -> Script Editor`) to create a script that adds an `AsciiDoc` menu item in my Google Docs which converts to Asciidoctor.
The script to copy is here: https://github.com/maxandersen/gdoc2adoc/blob/master/converttoasciidoc.gapps
Notes:
* Running the script on a given Google Doc requires accepting a number of Google permissions for the script which I added.
* Your Google Doc must be inside a directory in Google Docs (if it is not already, create a parent directory for it). That is where the AsciiDoc files will go.
* I got an error because of an unsupported element in the document. I had to comment out this error: https://github.com/maxandersen/gdoc2adoc/blob/master/converttoasciidoc.gapps#L767
## GDoc to MS Word download, then use pandoc conversion
Download your Google Doc as MS Word (`File -> Download -> MSWord`). Then convert using Pandoc:
https://asciidoctor.org/docs/migrating-from-msword/
$ pandoc --from=docx --to=asciidoc --wrap=none --atx-headers \
--extract-media=extracted-media input.docx > output.adoc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment