1

I am curious about saving space and real time editing code. Google docs don't take up any space, so I'm curious to see if it's possible, and with that there could be extentions that color code Google docs? And i want to stay off saying i know this is a funky way to do it but I'm curious to see if it's possible.

The way I imagine it working is like this: Google doc If you look at the document, you see that it is named "script.js" and the text inside is printing hello world. So then in the html page it could be something like

<script type=text/javascript src="https://docs.google.com/document/d/1-SCNoJSQlMGJh-hmBLIwlyh_4eM9IisJqspARMMNKg0?plaintext"></script>

(or plainhtml)

I have honestly no idea what the syntax could be of how to do it, but i hope i can get the point across.

And then for Google sheets, it could be something like

<script type=text/javascript src="https://docs.google.com/spreadsheets/d/1-cUUw0KJ8k87hTrPWhERRNyr8r-_hZn5tW5sbPsSiLc?plaintext&c=a&r=1"></script>

That would retrieve "hello world" from the Google sheet.

You could also go as far as doing this in the main html page:

<script type="text/javascript">
   var sheet = "https://docs.google.com/spreadsheets/d/1-cUUw0KJ8k87hTrPWhERRNyr8r-_hZn5tW5sbPsSiLc"
   // then getting the spot (c,4) where column is "c", and row is "r".
   Document.write(sheet+"?c=c&r=4");
</script>

Any ideas?

Wilson Vargas
  • 2,841
  • 1
  • 19
  • 28
Joe Theman
  • 11
  • 5

1 Answers1

0

Edit

It looks like the only way to get the raw text of the google doc would be to use the Drive API. But this is no good for your use case as it must be authenticated even when the file is publicly accessible. Leaving the possible awkward solution of downloading the file with JavaScript, and converting the text into functions.

Looks like this might be possible. However you will have to convert the doc from a editable state to a raw text state. You can take a look at this link for more info on that:

The URL for a document's raw text? (outdated)

But why not just use GitHub to host the code? (or other code oriented services) Github will even host your entire website (with restrictions).

If you looking for code collaboration Google docs is horrible for code formatting. I might point you towards this question for options other than Google Docs.

For Google sheets as a database That might be more feasible. I might take a look at this link. But now there are several free tier database as a service platforms with much richer features. (for databases)

In the end it might be a cool hack but ultimately painful for real use cases when compare to alternatives.

Niles Tanner
  • 3,911
  • 2
  • 17
  • 29
  • Thanks! The Google docs one looks exactly how'd I'd like it. Be nice if they could implement the same way into sheets. – Joe Theman Oct 04 '17 at 22:03
  • I looked into the first link, and saw that the link they provided was invalid. That was answered in '12. It doesn't work anymore. – Joe Theman Oct 07 '17 at 05:12
  • @JoeTheman I think your right. That link is seems to be out of date. I have updated my answer to be more complete. However it looks like what your trying to do if just not possible with simple `link` or `src` tags – Niles Tanner Oct 07 '17 at 16:50