Shared publicly  - 
 
I'm sure +James Ferreira and +Romain Vialard will like this. +Bruce Mcpherson has created a way to publish google apps script source code using google apps script

#googleappsscript  
In a previous post I showed how Google Apps Script could return the contents of a script as Json so you could format that for including script samples on web sites. Today, here is how to use the html ...
4
1
Keisuke Oohashi (soundTricker さんとりー)'s profile photoJacob Jan Tuinstra's profile photoMartin Hawksey's profile photoBruce Mcpherson's profile photo
22 comments
 
Martin, I like the way you tie the Apps Script community together. Very nice.
 
Thanks Steve! Guess it's the educator in me trying to pull ideas and people together
 
He itterates through the objects by using GAS itself (+Martin Hawksey couldn't find the remark he made on your g+). I thought of using it to distinguish text/variables from code? 
 
beat the damned thing! here's a working version https://script.google.com/a/macros/mcpher.com/s/AKfycbzig_MZJ4dF-LGkWlThc7-_U-AP6Jaf0iYfKR9QxoiKRUCzIxex/exec?module=vEquivalents&template=pretty

and here's the code
https://script.google.com/d/1ZLyla9dIFWAmUOsPUArayu9ENTjV4yQ8VLwKc5YMQpo-tXW4aytXOOUX/edit

Turns out that there are 2 functions it didn't like (I ran through a bunch of code to see what failed). these..
var thingsThatScrewUp = [ 'toString', 'hasOwnProperty'];

so just change them to something else before prettifying

       for (var i = 0 ; i < thingsThatScrewUp.length ; i++ ) {
        c = c.replace(new RegExp("." + thingsThatScrewUp[i], 'g'),".sandw_" + i + "_ch");
       }

then change them back afterwards.. if you come across any more, let me know. I'll write this up on ramblings.mcpher.com at some point.
 
another day - another restriction. I cant embed the result of this in an iFrame on google sites because I hit this - "display forbidden by X-Frame-Options", so what I think i'll need to do is to surround the output by document.write(), escape all the html, and use the Content service to serve it up as a script that can be executed by the receiver. Haven't figured out the details yet.
 
Google Sites has an Apps Script editor if you move your code there you should be able to output the result in a widget
 
Yeah maybe have to but i was trying to avoid specific solutions.. Would still need to solve for blogger, jquery etc. If you take a look at prettified code from GitHub.. Gistid.js .. It uses a similar approach to what I suggested above...
 
wow I think my brain has just melted (partly because you are returning the code you use to do this in the example). Very clever stuff!!! 
Add a comment...