Help:Adding a new programming example: Difference between revisions

m
Update syntax highlighting
m (Update syntax highlighting)
 
Line 19:
Optional text explaining stuff
 
<syntaxhighlight lang="c">
<lang c>
int main ( void ) {
// Some code here
}
</syntaxhighlight>
</lang></nowiki>
{{out}}
<pre>
Output, if desired or necessary
</langpre></nowiki>
 
You don't have to use the C programming language, and your code example will probably be different. You need to make sure you create a link to your language of choice, and to your compiler, interpreter, or what-have-you using the "works with" template. You should also note any special [[libraries]] you use with the "libheader" template.
 
The <nowiki><langsyntaxhighlight></nowiki> tags enclose the actual example, and allow [[Help:Syntax_highlighting|syntax highlighting]], which includes proper formatting for white space. Some languages don't have syntax highlighting support, but using the langsyntaxhighlight tags will not break anything. If your language is not supported, it will be as if you used pre tags. If support is added later, your example will automatically be highlighted, so add the lang tags no matter what. It is not necessary the the language parameter of the syntax highlighter match the actual language name. Even if your language is not specifically supported you may find a different language syntax highlighter is close enough.
 
The output section is only necessary if desired, or if the task requires to show output.
 
==Formatting==
10,327

edits