Difference between revisions of "Template talk:SyntaxHighlight"
From Amahi Wiki
(2 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
---- | ---- | ||
+ | |||
== Syntax Highlight for Code == | == Syntax Highlight for Code == | ||
If you like syntax highlighting, we have the syntax highlight extension and you can do this: | If you like syntax highlighting, we have the syntax highlight extension and you can do this: | ||
− | + | <!-- | |
<pre> | <pre> | ||
<syntaxhighlight lang="php"> | <syntaxhighlight lang="php"> | ||
Line 36: | Line 37: | ||
=> ["Amahi is cool!", "Linux is cool!"] | => ["Amahi is cool!", "Linux is cool!"] | ||
</syntaxhighlight> | </syntaxhighlight> | ||
+ | --> | ||
+ | {|border="1" Cellspacing="0" style="width: 99%; border-width: 1px; border-style: solid; border-color: #aaa" | ||
+ | ! Language | ||
+ | ! width=15% | | ||
+ | ! width=70% | | ||
+ | |- | ||
+ | !rowspan="2"|lang="php" | ||
+ | |you type | ||
+ | | | ||
+ | <pre> | ||
+ | <syntaxhighlight lang="php"> | ||
+ | <?php | ||
+ | $v = "string"; // sample initialization | ||
+ | ?> | ||
+ | </syntaxhighlight> | ||
+ | </pre> | ||
+ | |- | ||
+ | |you get | ||
+ | | | ||
+ | <syntaxhighlight lang="php"> | ||
+ | <?php | ||
+ | $v = "string"; // sample initialization | ||
+ | ?> | ||
+ | </syntaxhighlight> | ||
+ | |- | ||
+ | !rowspan="2"|lang="ruby" | ||
+ | |you type | ||
+ | | | ||
+ | <pre> | ||
+ | <syntaxhighlight lang="ruby"> | ||
+ | > ["Amahi", "Linux"].map{|i| "#{i} is cool!"} | ||
+ | => ["Amahi is cool!", "Linux is cool!"] | ||
+ | </syntaxhighlight> | ||
+ | </pre> | ||
+ | |- | ||
+ | |you get | ||
+ | |<syntaxhighlight lang="ruby"> | ||
+ | > ["Amahi", "Linux"].map{|i| "#{i} is cool!"} | ||
+ | => ["Amahi is cool!", "Linux is cool!"] | ||
+ | </syntaxhighlight> | ||
+ | |} | ||
We have set the [http://www.mediawiki.org/wiki/Extension:SyntaxHighlight_GeSHi syntax highliting] extension with bash as the default language, since it's probably the most common in this wiki. You can override it as above. | We have set the [http://www.mediawiki.org/wiki/Extension:SyntaxHighlight_GeSHi syntax highliting] extension with bash as the default language, since it's probably the most common in this wiki. You can override it as above. | ||
[[Category:Help]] | [[Category:Help]] |
Latest revision as of 21:03, 2 January 2011
Syntax Highlight for Code
If you like syntax highlighting, we have the syntax highlight extension and you can do this:
Language | ||
---|---|---|
lang="php" | you type |
<syntaxhighlight lang="php"> <?php $v = "string"; // sample initialization ?> </syntaxhighlight> |
you get |
<?php
$v = "string"; // sample initialization
?>
| |
lang="ruby" | you type |
<syntaxhighlight lang="ruby"> > ["Amahi", "Linux"].map{|i| "#{i} is cool!"} => ["Amahi is cool!", "Linux is cool!"] </syntaxhighlight> |
you get | > ["Amahi", "Linux"].map{|i| "#{i} is cool!"}
=> ["Amahi is cool!", "Linux is cool!"]
|
We have set the syntax highliting extension with bash as the default language, since it's probably the most common in this wiki. You can override it as above.