Shared publicly  - 
 
Google+ and code indenting, first accettable test

http://www.claudiodangelis.it/projects/googlepluscodeindenter

JS snippet without indentation:

function showTooltip() {
// If it is an HTTP link, and if it is from the same host
// as this script is, we can use XMLHttpRequest
// to get more information about it.
if (link.protocol == "http:" && link.host == location.host) {
// Make an XMLHttpRequest for the headers of the link
HTTP.getHeaders(link.href, function(headers) {
// Use the headers to build a string of text
var tip = "URL: " + link.href + "<br>" +
"Type: " + headers["Content-Type"] + "<br>" +
"Size: " + headers["Content-Length"] + "<br>" +
"Date: " + headers["Last-Modified"];
// And display it as a tooltip
tooltip.show(tip, x, y);
});

}
else {
// Otherwise, if it is an offsite link, the
// tooltip is just the URL of the link
tooltip.show("URL: " + link.href, x, y);
}
}

JS snippet with indentation:

function showTooltip() {
        // If it is an HTTP link, and if it is from the same host
        // as this script is, we can use XMLHttpRequest
        // to get more information about it.
  if (link.protocol == "http:" && link.host == location.host) {
            // Make an XMLHttpRequest for the headers of the link
            HTTP.getHeaders(link.href, function(headers) {
                // Use the headers to build a string of text
                var tip = "URL: " + link.href + "<br>" +
                    "Type: " + headers["Content-Type"] + "<br>" +
                    "Size: " + headers["Content-Length"] + "<br>" +
                    "Date: " + headers["Last-Modified"];
                // And display it as a tooltip
                tooltip.show(tip, x, y);
            });
         }
        else {
            // Otherwise, if it is an offsite link, the
            // tooltip is just the URL of the link
            tooltip.show("URL: " + link.href, x, y);
        }
      }


Python snippet without indentation:

class ASTNode:
def __init__(self, nodeType, *args):
self.nodeType = nodeType
self.children = []
for item in args:
self.children.append(item)
def show(self, level):
self.showLevel(level)
print 'Node -- Type %s' % NodeTypeDict[self.nodeType]
level += 1
for child in self.children:
if isinstance(child, ASTNode):
child.show(level)
elif type(child) == types.ListType:
for item in child:
item.show(level)
else:
self.showLevel(level)
print 'Child:', child
def showLevel(self, level):
for idx in range(level):
print ' ',

Python snippet with indentation

class ASTNode:
    def __init__(self, nodeType, *args):
        self.nodeType = nodeType
        self.children = []
        for item in args:
            self.children.append(item)
    def show(self, level):
        self.showLevel(level)
        print 'Node -- Type %s' % NodeTypeDict[self.nodeType]
        level += 1
        for child in self.children:
            if isinstance(child, ASTNode):
                child.show(level)
            elif type(child) == types.ListType:
                for item in child:
                    item.show(level)
            else:
                self.showLevel(level)
                print 'Child:', child
    def showLevel(self, level):
        for idx in range(level):
            print ' ',

Google+ Code Indenter
http://www.claudiodangelis.it/projects/googlepluscodeindenter

Stay tuned! #googleplus #codeindenting #coders
2
Matt Reid's profile photoClaudio d'Angelis's profile photo
3 comments
 
nice work. I'm going to use this....
 
+Matt Reid, it seems that G+ now featured code indenting in posts.
<parent>
    <parent>
        <child/>
    </parent>
</parent>
 
...and yes , I like to think it's because of this tool's popularity, ahah :)
Add a comment...