Template:Code

From FedoraProject

(Difference between revisions)
Jump to: navigation, search
(show usage example)
(remove gray background, use faint border, show code block example)
Line 1: Line 1:
<code>{{{1}}}</code><noinclude>
+
<span style="background-color: #FFFFFF;
 +
  border: 1px dotted #e6e6e6;
 +
  font-family: monospace, 'Courier New';
 +
  font-size: 105%;
 +
  line-height: 1.26em;
 +
  overflow: auto;">{{{1}}}</span><noinclude>
  
 
==Usage==
 
==Usage==
  
{{Code|&#123;&#123;Code&#124;code line&#125;&#125;}}
+
{{Code|<nowiki>{{Code|code line}}</nowiki>}}
  
 +
{{Code|This is a long line of code that may have many words that continue for a long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long length.}}
  
 
Used to highlight code samples in an enlarged (through the site's main.css), monospace typeface that is easier to read than the default.
 
Used to highlight code samples in an enlarged (through the site's main.css), monospace typeface that is easier to read than the default.
  
 
The template form is shorter and easier to enter while editing.
 
The template form is shorter and easier to enter while editing.
 +
 +
==For code blocks==
 +
<pre> <nowiki><nowiki>
 +
Start with a space in the first column,
 +
(before the <nowiki>).
 +
 +
Then your block format will be
 +
    maintained.
 +
 +
This is good for copying in code blocks:
 +
 +
def function():
 +
    """documentation string"""
 +
 +
    if True:
 +
        print True
 +
    else:
 +
        print False</nowiki></nowiki>
 +
</pre>
 +
===Working Example (click edit to see wikicode)===
 +
<nowiki>
 +
def function():
 +
    """documentation string"""
 +
 +
    if True:
 +
        print True
 +
    else:
 +
        print False</nowiki>
 
</noinclude>
 
</noinclude>

Revision as of 06:58, 19 May 2012

{{{1}}}

Usage

{{Code|code line}}

This is a long line of code that may have many words that continue for a long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long length.

Used to highlight code samples in an enlarged (through the site's main.css), monospace typeface that is easier to read than the default.

The template form is shorter and easier to enter while editing.

For code blocks

 <nowiki>
Start with a space in the first column,
(before the <nowiki>).

Then your block format will be
    maintained.
 
This is good for copying in code blocks:

def function():
    """documentation string"""

    if True:
        print True
    else:
        print False</nowiki>

Working Example (click edit to see wikicode)

def function():
    """documentation string"""

    if True:
        print True
    else:
        print False