Source Code Formatter is available as online tool to format the code on the go as well as a plugin to be put into your website.
Using the Source Code Formatter Plugin
Don't like embedded html within your code?? You can use our Source Code
Formatter Plugin to decorate your code without embedding any html within
your source code.
Note: You still need to escape HTML character (<,& and >) within your code. You
can use our online tool for this.
Step to use the Plugin:
1. Copy the code below just before the closing head tag(i.e </head>).
<script src="http://formatmycode.appspot.com/formatterPlugin.js"></script>
2. Now that plugin has been included, we need to prepare the code to ensure correct rendering. Basically, we need to escape some HTML characters like right angle brackets, e.g. all < must be replaced with <. To do so, you can use our formatter tool with formatting option set to 'Perform Only Escape Source'
3. Once you have the code with escaped characters, you can copy it on your website inside <pre> tags. You need to give the class name 'code' to your pre block as shown below.
1 <pre class="code">
2 ...
3 </pre></p>
4. You can also provide certain options to perform customized formatting. To do customized formatting, add a format attribute as shown below:
1 <pre class="code" format="lang:cpp;tab:2;theme:desert;">
2 ...
3 </pre>
Available formatting options are:
Option | Value |
---|---|
lang | Only 'java' and 'cpp' (C/C++) are supported now. |
tab | An integer value denoting the tab size. |
lineNumbering | true/false. |
removeBlankLine | true/false. |
limitMaxHeight | true/false. |
maxHeight | An integer denoting Maximum height of the code block. |
theme | Theme name. Valid theme values are:
|