Note

The Funtoo Linux project has transitioned to "Hobby Mode" and this wiki is now read-only.

Difference between revisions of "Help:Funtoo Editing Guidelines/Source Code"

From Funtoo
Jump to navigation Jump to search
(Created page with "=== Displaying Source Code === To display source code, use can use the file template, specifying a <tt>lang=</tt> parameter: <pre> {{file|name=foobar|lang=python|desc=foobar...")
 
Line 3: Line 3:
To display source code, use can use the file template, specifying a <tt>lang=</tt> parameter:
To display source code, use can use the file template, specifying a <tt>lang=</tt> parameter:


<pre>
{{file|name=source code example|body=<nowiki>
{{file|name=foobar|lang=python|desc=foobarosity|body=
{{file|name=foobar|lang=python|desc=foobarosity|body=
import system
import system
}}
}}
</pre>
</nowiki>}}


This will produce:
This will produce:

Revision as of 03:17, February 24, 2019

Displaying Source Code

To display source code, use can use the file template, specifying a lang= parameter:

   source code example

{{file|name=foobar|lang=python|desc=foobarosity|body=
import system
}}

This will produce:

   foobar (python source code) - foobarosity
import system

The parameters name (filename), lang (language for syntax highlighting) and desc (Description, appearing as a caption) are optional. For a list of supported languages, see this list.

   Important

If you need to display the pipe ("|") character within the body of a file template, replace each "|" with {{!}} -- otherwise your file contents will not display properly. This is necessary because {{file}} is a template and the "|" character is used as a delimiter for arguments to the template.