Help:Preformatted text: Difference between revisions
(Copying http://wiki.flightgear.org/index.php?title=Help:Formatting&oldid=89657#Pre-formatted_text here) |
(+ Wiki help navbar template) |
||
(2 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
{{Wiki help navbar}} | |||
Monospaced '''preformatted text''' can be added in many different ways on the FlightGear wiki. | Monospaced '''preformatted text''' can be added in many different ways on the FlightGear wiki. | ||
Line 49: | Line 51: | ||
|} | |} | ||
=== 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 <nowiki><syntaxhighlight></nowiki> 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. | Note that you can use syntax highlighting for command lines as well. | ||
<'''syntaxhighlight''' lang="" ''line start=""'' ''highlight=""'' '' | <'''syntaxhighlight''' lang="" ''line start=""'' ''highlight=""'' ''inline''></syntaxhighlight> | ||
All attributes but '''lang''' | All attributes but '''lang''' are optional. '''start''' have to be used together with '''line'''. Values must be put inside quotation marks ('''"'''). | ||
; lang: The language to be highlighted, for example '''bash''', '''cpp | ; lang: The language to be highlighted, for example '''bash''', '''cpp''' or '''xml'''. | ||
; line: Use line numbering. | ; line: Use line numbering. | ||
Line 89: | Line 69: | ||
; start: 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. | ; start: 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. | ||
; highlight: Used for highlighting a line. Do note that lines are counted from the first line in a snippet disregarding '''start'''. For example will '''3''' highlight | ; highlight: 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. | ||
; | ; inline | ||
: | : Used when syntax highlighting is needed in running text. | ||
{| class="wikitable" width="100%" | {| class="wikitable" width="100%" | ||
Line 99: | Line 78: | ||
! width="30%" | What you type | ! width="30%" | What you type | ||
! width="30%" | What you get | ! width="30%" | What you get | ||
|- | |- | ||
| XML highlighting, here with line numbering, but without specifying the line number of the first line. | | XML highlighting, here with line numbering, but without specifying the line number of the first line. | ||
| | | | ||
< | <nowiki><syntaxhighlight lang="xml" line> | ||
<animation> | <animation> | ||
<object-name>Object</object-name> | <object-name>Object</object-name> | ||
Line 123: | Line 87: | ||
</animation> | </animation> | ||
</syntaxhighlight> | </syntaxhighlight> | ||
</ | </nowiki> | ||
| <syntaxhighlight lang="xml" line enclose="div"> | | <syntaxhighlight lang="xml" line enclose="div"> | ||
<animation> | <animation> | ||
Line 131: | Line 95: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
|- | |- | ||
| C++ highlighting, arbitrarily starting from line 46, and highlighting the 4th line in the snippet. | | C++ highlighting, arbitrarily starting from line 46, and highlighting the 1st, 3rd and 4th line in the snippet. | ||
| | | | ||
< | <nowiki><syntaxhighlight lang="cpp" line start="46" highlight="1,3-4"> | ||
globals->get_commands()->execute("profiler-start"); | globals->get_commands()->execute("profiler-start"); | ||
// or with filename | // or with filename | ||
Line 139: | Line 103: | ||
args.setStringValue("filename", "output.profile"); | args.setStringValue("filename", "output.profile"); | ||
globals->get_commands()->execute("profiler-start", &args); | globals->get_commands()->execute("profiler-start", &args); | ||
</syntaxhighlight></ | </syntaxhighlight></nowiki> | ||
|<syntaxhighlight lang="cpp" line start="46" highlight="4 | | <syntaxhighlight lang="cpp" line start="46" highlight="1,3-4"> | ||
globals->get_commands()->execute("profiler-start"); | globals->get_commands()->execute("profiler-start"); | ||
// or with filename | // or with filename | ||
Line 146: | Line 110: | ||
args.setStringValue("filename", "output.profile"); | args.setStringValue("filename", "output.profile"); | ||
globals->get_commands()->execute("profiler-start", &args); | globals->get_commands()->execute("profiler-start", &args); | ||
</syntaxhighlight> | </syntaxhighlight> | ||
|- | |- | ||
| | | Syntax highlighting in running text | ||
| | | | ||
<nowiki>A typical C++ comment <syntaxhighlight lang="cpp" inline>// looks like this</syntaxhighlight>.</nowiki> | |||
<syntaxhighlight lang=" | | A typical C++ comment <syntaxhighlight lang="cpp" inline>// looks like this</syntaxhighlight>. | ||
</ | |||
</ | |||
<syntaxhighlight lang=" | |||
</syntaxhighlight> | |||
|} | |} | ||
== External links == | == External links == | ||
* [[mediawikiwiki:Extension:SyntaxHighlight]] | * [[mediawikiwiki:Extension:SyntaxHighlight]] | ||
* [http://pygments.org/docs/lexers/ Available Pygments lexers] | |||
[[Category:Help]] | [[Category:Help]] |
Latest revision as of 11:52, 3 June 2018
Wiki help |
---|
Reading |
Editing |
Advanced editing |
Writing about specific topics |
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 (").
- lang
- The language to be highlighted, for example bash, cpp or xml.
- line
- Use line numbering.
- start
- 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.
- highlight
- 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.
- inline
- 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> <animation> <object-name>Object</object-name> <enable-hot type="bool">false</enable-hot> </animation> </syntaxhighlight> |
<animation>
<object-name>Object</object-name>
<enable-hot type="bool">false</enable-hot>
</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"> globals->get_commands()->execute("profiler-start"); // or with filename SGPropertyNode args; args.setStringValue("filename", "output.profile"); globals->get_commands()->execute("profiler-start", &args); </syntaxhighlight> |
globals->get_commands()->execute("profiler-start");
// or with filename
SGPropertyNode args;
args.setStringValue("filename", "output.profile");
globals->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 .
|