Code Formatting and Highlighting

As well as the formating styles for the texts in the posts, there is also help for formatting code in the posts. Using the <code > </code> tags enables code to be published within posts without having to worry about escaping characters such as < and > with &lt; and &gt; respectively.

 

The <code > tag also provide syntax highlighting for different programming languages by including the language parameter e.g. <code language=”ruby”></code>

 

Examples:

PHP - <code language=”php”>...</code>:

$hello = "Hello World";
echo $hello;

 

Java - <code language=”java”>...</code>:

String hello = "Hello World";
System.out.println(hello);

 

C++ - <code language=”C++”>...</code>:

string hellostr = "Hello World";
cout << hello;

 

Ruby - <code language=”ruby”>...</code>:

hello = "Hello World"
puts hello

 

ATARI BASIC - <code>...</code>:

5 DIM N$(16)
10 LET N$="Hello World"
20 PRINT N$

 

PHP can also be inserted without the need for a <code> block as long as the <?php ?> tags are included, like so:

<?php
$hello
= "Hello World";
echo
$hello;
?>