1
votes

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?

1

1 Answers

0
votes

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.