Widget:Prettyprint

From Guild Wars 2 Wiki
Jump to navigationJump to search

Description

This widget enables syntax highlighting for code blocks using google-code-prettify. Code blocks that should be pretty-printed require a prettyprint class. The widget only needs to be used once on a page.

It’s also possible to add a language hint to the block by adding specific class names. For example lang-html for HTML code, lang-js for JavaScript.

Example

<pre class="prettyprint">
function example () {
    console.log('This is a JavaScript example.');
}
if (true) {
    example();
}
</pre>
{{#Widget:prettyprint}}

This results in the following output:

function example () {
    console.log('This is a JavaScript example.');
}
if (true) {
    example();
}