Google App : Code Format Service Example

This is a simple example that uses Google Apps to provide a code formatting service.

HTML

You can access the service via an HTML form at: http://xzfv.appspot.com/s/format.html

Service

You can access the service as a web service by making a POST to:

http://xzfv.appspot.com/doformat

The service takes the following parameters:

language : (REQUIRED) The language of the source code being formatted.

source : (REQUIRED) The source code to be formatted

output : The output format. Either XML or HTML (XML is default)

Language Codes

asActionScript
luaLua
perlPerl
pythonPython
rubyRuby
javaJava
csharpC#
bashBash
sqlSQL
cssCSS
htmlHTML
javascriptJavaScript
phpPHP
xmlXML
xsltXSLT

HTML Output Example

You can view an example of the HTML output here.

XML Output Example

<?xml version="1.0"?>
<response>
<code language="javascript">
<![CDATA[
<div class="highlight"><pre><span style="color: #008000; font-weight: bold">var</span> foo <span style="color: #666666">=</span> <span style="color: #BA2121">&quot;bar&quot;</span><span style="color: #666666">;</span>
</pre></div>

]]>
</code>
</response>
]]>

XML Error Example

<?xml version="1.0"?>
<response>
<error>source must be specified</error>
</response>

Source

You can download the source under an MIT license from here.

Comments / Bugs

Post any comments, bugs, questions or suggestions here.

Credits

Created by Mike Chambers

Uses the Python Pygments library