Help:Adding a new programming example: Difference between revisions
Help:Adding a new programming example (view source)
Revision as of 22:39, 28 September 2022
, 1 year agoUpdate syntax highlighting
(→Navigation: edit is a tab, not a button) |
Thundergnat (talk | contribs) m (Update syntax highlighting) |
||
(9 intermediate revisions by 6 users not shown) | |||
Line 1:
{{#set:is contribution page=true}}So you want to contribute code, eh?
==Every page is editable (almost)==
Almost every page in the wiki is editable.
To edit a wiki, you need only click that "edit" tab, make changes in the text field on the resulting page, and click Submit. Really, though we'd rather you clicked Preview first, and then clicked submit once you were satisfied with how it looks.
==Navigation==
To add your own programming example, you must [[:Category:Solutions by Programming Task|navigate]] to the programming task to which you wish to add a solution to. Once you find your task, go ahead and click the Edit tab at the top of the page, find the place in the list of languages already applied where your language would fall alphabetically, and make your changes.▼
▲To add your own programming example, you must [[:Category:Solutions by Programming Task|navigate]] to the programming task to which you wish to add a solution
In order to maintain the readability, searchability and browsability of Rosetta Code, we need you to follow certain formatting rules. Please ensure that your contributed code conforms to one of these [[Help:Programming Example Prototypes|programming example prototypes]]. A simple example should look something like this:▼
▲In order to maintain the readability, searchability and
<nowiki>▼
=={{header|C}}==▼
int main ( void ) {▼
// Some code here▼
▲ <nowiki>=={{header|C}}==
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. To create a link, surround the text with double square brackets. For example, [[GCC]] would be represented as <nowiki>[[GCC]]</nowiki>.▼
{{works with|gcc|4.0.1}}
{{libheader|SDL}}
Optional text explaining stuff
<syntaxhighlight lang="c">
}
</syntaxhighlight>
{{out}}
<pre>
Output, if desired or necessary
▲You don't have to use the C programming language, and your code example will probably be different.
The <nowiki><syntaxhighlight></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 syntaxhighlight 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==
Formatting a wiki is easy once you've done it, but you have to get used to it, especially if you're used to working with HTML.
==Before you go==
Now, why don't you wander over to the [[Help:Sandbox|Sandbox]] and apply what you've learned?
|