Template talk:CodeSample: Difference between revisions
imported>PhilmASTErpLus Created page with 'Comparison of various methods of formatting code: {|class="wikitable" style="background-color: white;" ! What it looks like !! What you type |- |<pre style="white-space: pre-wr…' |
imported>PhilmASTErpLus No edit summary |
||
Line 66: | Line 66: | ||
|} | |} | ||
So....like....why do we even NEED this template? | So....like....why do we even NEED this template? --[[User:PhilmASTErpLus|PhilmASTErpLus]] 03:40, 21 June 2010 (UTC) |
Revision as of 03:40, 21 June 2010
Comparison of various methods of formatting code:
What it looks like | What you type |
---|---|
You can insert in-line code using the <code><nowiki><code></nowiki></code> tag. To prevent invalid parsing of angle brackets, you can use the <code><nowiki></code> tag, or <code>&lt;</code> and <code>&gt;</code>. |
You can insert in-line code using the |
For syntax highlighting, use the <code><syntaxhighlight></code> tag: <syntaxhighlight> string [int] mymap; file_to_map( "somefile.txt" , mymap ); </syntaxhighlight> Be warned: <code><syntaxhighlight></code> does not wrap the code in pretty boxes. |
For syntax highlighting, use the string [int] mymap;
file_to_map( "somefile.txt" , mymap ); Be warned: |
You can use [[Template:CodeSample]] to wrap the code in a pretty box. {{CodeSample |code= item needed = $item[ ketchup hound ]; //Could someone think of a longer example, please? }} Be warned: [[Template:CodeSample]] does not format the text in monospace. |
You can use Template:CodeSample to wrap the code in a pretty box.
|
You can use the <code><pre></code> tag for pre-formatted text. Because the resulting box would result in unwrapped overflowing text, you may need to use <code><pre style="white-space: nowrap;"></code>. <pre style="white-space: nowrap;"> print( "Hello, world!" ); </pre> |
You can use the print( "Hello, world!" ); |
So....like....why do we even NEED this template? --PhilmASTErpLus 03:40, 21 June 2010 (UTC)