Code Block

From WU LibGuides Doc Site


The code block is similar to what is used throughout this wiki and is a custom block you can use to display code snippets.

Example Image

A screenshot of an example code block

Adding a code block

You can add a code block by first creating a div and assigning the class code-wu.

To write HTML code in the block you unfortunately can't just write it normally otherwise if you wrote <div>This is a test</div> it would disappear as it will render that as actual HTML when you click save, so you have to perform a little trick.

The trick is to write the '<' (less than) and '>' (greater than) symbols as 'Character Entities', this is done by first writing an & symbol followed by lt and a semicolon (;). It would look like this:

&lt;

and it would be closed with gt, which would look like this:

&gt;

The full code would look like:

&lt;div&gt;

which would give you: <div>

Most other code would be OK, except for JavaScript which may be rendered if you were to write <script> tags.

Example Code

<div class="code-wu">&lt;div class="container-wu"&gt;This is an example div&lt;/div&gt;</a>

What it looks like: