Fr/Aide:Preformatted text

From FlightGear wiki
Jump to navigation Jump to search

Version traduite le 14 novembre 2022 Pending Pending 0}% completed

Cet article est en cours de traduction.

Monospaced preformatted text can be added in many different ways on the FlightGear wiki.

Pre-formatted running text

Description What you type What you get
Using <code> HTML tags.
Here is a <code>'''Class()'''</code>.
Here is a Class().
Using <tt> HTML tags.
Here is a <tt>''variable''</tt>.
Here is a variable.

Pre-formatted blocks

Apart from using <tt> and <code> on entire blocks of text one one can use the below methods.

Description What you type What you get
The simplest way is with a leading blank space on each line.
 You '''''can''''' use '''wiki markup'''
 using this method.
You can use wiki markup
using this method.
Using <nowiki> tags with a leading blank space.
 <nowiki>Here is some text.
And some more.</nowiki>
Here is some text.
And some more.
Using <pre> tags.
<pre>Some text.
Some more text.</pre>
Some text.
Some more text.

Syntax highlighting

Syntax highlighting will make source code more readable. This wiki has support for syntax highlighting of many programming languages, XML and C++ (see link at the bottom for a more complete list). The source code snippet to be highlighted is put between <syntaxhighlight> tags. The tag can be given some attributes to control how the source code appears.

Unfortunately the lexer for Nasal was obsoleted in February 2016 as the newer version of the MediaWiki software the wiki is running had dropped the GeSHi highlighter in favor for the Pygmets highlighter.

Note that you can use syntax highlighting for command lines as well.

<syntaxhighlight lang="" line start="" highlight="" inline></syntaxhighlight>

All attributes but lang are optional. start have to be used together with line. Values must be put inside quotation marks (").

The language to be highlighted, for example bash, cpp or xml.
Use line numbering.
Used together with line if you want the line numbering to start somewhere else than one. For example will 42 start the line numbering from 42 instead of 1.
Used for highlighting a line. Do note that lines are counted from the first line in a snippet disregarding start. For example will 3,5-7 highlight line 3 and 5-7 in a snippet.
Used when syntax highlighting is needed in running text.
Description What you type What you get
XML highlighting, here with line numbering, but without specifying the line number of the first line.
<syntaxhighlight lang="xml" line>
  <enable-hot type="bool">false</enable-hot>

1 <animation>
2  <object-name>Object</object-name>
3  <enable-hot type="bool">false</enable-hot>
4 </animation>
C++ highlighting, arbitrarily starting from line 46, and highlighting the 1st, 3rd and 4th line in the snippet.
<syntaxhighlight lang="cpp" line start="46" highlight="1,3-4">
// or with filename
SGPropertyNode args;
args.setStringValue("filename", "output.profile");
globals->get_commands()->execute("profiler-start", &args);
47// or with filename
48SGPropertyNode args;
49args.setStringValue("filename", "output.profile");
50globals->get_commands()->execute("profiler-start", &args);
Syntax highlighting in running text
A typical C++ comment <syntaxhighlight lang="cpp" inline>// looks like this</syntaxhighlight>.
A typical C++ comment // looks like this.

External links