Topic on Project:Support desk

Wriging C code in a wiki

2
85.187.128.21 (talkcontribs)

How do I ass C, Python or any other type of source code into my wiki pages? I tried code type="C" but that didn't quite work. Are there some examples out there?

Krinkle (talkcontribs)

By default <pre>...</pre> is available for wiki pages:

Like this

If you install Extension:SyntaxHighlight GeSHi (like Wikipedia.org and MediaWiki.org do), then you can use <syntaxhighlight>...</syntaxhighlight>, like this:

<syntaxhighlight lang="javascript">
function foo(a, b, c) {
    return a + b + c;
}
</syntaxhighlight>

Which renders with preserved whitespace in a monospace font, and with syntax highlighting:

function foo(a, b, c) {
    return a + b + c;
}
Reply to "Wriging C code in a wiki"