brendan-r / googdown

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Read / Write Doc via JSON / Apps Script

brendan-r opened this issue · comments

Currently, you're using the google drive API to download / upload documents in odt/docx format. An alternative is to use google apps script to upload/download a JSON representation of the document. Downloading is already possible via https://github.com/krilor/gdoc2json (tested). However, uploading would probably require writing software which:

  • Recursivley parse the JSON tree of the uploaded and original documents
  • diffs them, extracting the nature and location of changes
  • Converts the JSON diffs to function/method calls, which can be applied to the document structure to add/remove the differing elements

Which sounds like a lot of work for marginal benefit.

Advantages of Drive API relative to Apps Script:

  • No extra code to write in a weird subset of JavaScript to make upload/download possible
  • Most features supported
  • Pandoc reader / writer already written and mature
  • User does not have to trust a remote script (there is no way to verify that a remote script is what it says it is), or upload the scripts themselves (fiddly, error prone, tricky to automate, additional permissions / scopes)

Advantages of Apps Script relative to Drive API:

  • Could modify existing document, rather than adding and deleting everything, as currently happens (thus removing any existing comments)
  • The above would allow for much more frequent pushing / pulling
  • Could detect code blocks, and inline
  • Avoid styling via odt/docx format (awkward, indirect, lossy)
  • Easier to version control JSON