Help:Script Samples: Difference between revisions

Content deleted Content added
No edit summary
Tag: 2017 source edit
 
(33 intermediate revisions by 2 users not shown)
Line 3:
== Four Main Tags ==
{| class="wikitable"
! Tag !! Code !! Result !! style="width:200px;" | When to use
! style="width:200px;" | When to use
|-
|
Line 110 ⟶ 109:
|}
 
== Scrollbars and Text wrapping ==
 
{| class="wikitable"
== <code>&lt;code&gt;</code> element ==
! class !! Code !! Result !! When to use
 
|-
Code tags are used for single lines of script only:<br><br>
|
<code>&lt;code&gt;</code><code>[root@node0-mraid14 /fse]# dd if=/dev/lun2 | od -c |less</code><code> &lt;/code&gt;</code>
default
<br><br>
|
 
<pre>
== <code>&lt;pre&gt;</code> element ==
&lt;pre&gt;
 
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Pre tags do not automatically shrink to fit their contents, use the class "inline" for auto fitting, this uses "display: inline-block" in the css:<br><br>
<code>&lt;/pre class="inline"&gt;</code>
<pre class="inline">
[root@node0-FS8600 /fse]# system-status
 
General System Status
-- Section ---- Section ---- Section ---- Section ---- Section ---- Section ---- Section ---- Section ---- Section ---- Section ----
expected status is ON
File system is up
 
Health Status
-- Section ---- Section ---- Section ---- Section ---- Section ---- Section ---- Section ---- Section ---- Section ---- Section ----
system health ok
 
[root@node0-FS8600 /fse]#
</pre>
|
<code>&lt;/pre&gt;</code>
<pre>
<br/><br/>
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
 
== <code>&lt;pre&gt;</code> element (with set-width) ==
 
In order to show the scroll bars on a pre element it is necessary to use the class "scroll" and it maybe necessary to statically set the '''width''':<br><br>
<code>&lt;pre class="scroll" style="width: 500px;"&gt;</code>
<pre class="scroll" style="width: 500px;">
<FluidFS> CLI > system authentication user-database set ldap -ldap_host ldap.furryyoghurt.com -ldap_base_dn "dc=exanet,dc=local"
<FluidFS> CLI >
</pre>
|
<code>&lt;/pre&gt;</code>
Default Behavior text is wrapped
<br><br>
|-
 
|
== <code>&lt;syntax-highlight lang="bash"&gt;</code> element ==
;scroll
 
<code>class="scroll"</code>
The syntaxhighlight tag requires the programming language to be specified in this case '''bash''':<br><br>
|
<code>&lt;syntaxhighlight lang="bash" class="inline"&gt;</code>
<pre>
<syntaxhighlight lang="bash" class="inline">
&lt;pre class="scroll" style="width:300px;"&gt;
#!/bin/bash
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
fileCount=800000
&lt;/pre&gt;</pre>
b=0
|
while [ $b -le $fileCount ]
<pre class="scroll" style="width:300px;">
do
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
echo B = $b
</pre>
dd if=/dev/urandom of=/mnt/nfs/file$b.txt bs=2k count=1
|
((b++))
Use for text based tables where it is easier to read if the text doesn't wrap
done
|-
|
;inline
<code>class="inline"</code>
|
<pre>
&lt;syntaxhighlight lang="lisp" class="inline"&gt;
(define-behavior (bounce
:start-when (or (bump?)
bounce-trigger? )
:abort-when (bump-edge?)
:onetime? t
)
)
&lt;/syntaxhighlight&gt;
</pre>
|
<syntaxhighlight lang="lisp" class="inline">
(define-behavior (bounce
:start-when (or (bump?)
bounce-trigger? )
:abort-when (bump-edge?)
:onetime? t
)
)
</syntaxhighlight>
| Use for smaller text blocks, if it is not desired that pre extend to the full width of the page
<code>&lt;/syntaxhighlight&gt;</code>
|-
<br/><br/>
|}
 
* For more details on usage, see the [http://www.mediawiki.org/wiki/Extension:SyntaxHighlight_GeSHi Mediawiki SyntaxHighlight Extension]
 
== Syntax Highlighting ==
<br><br>
----
<br><br>
 
Line 188 ⟶ 190:
17 8 8 Cluster FS8600 18 15 18 0 4 0 60757 (0) Fal (0) Fal (3) Both (1) Auto (1) Enab (0) Fal 0 0 0 42949672* Compellent FS8600 1.x FLUIDFS 60757
Walk: Display 4 of 4
</syntaxhighlight><br><br>
<code>&lt;/syntaxhighlight&gt;</code><br>
 
<br><br>
----
Demo of color coding using HTML markup and displaying line numbers:
<br><br>
<code>&lt;syntaxhighlight lang="html4strict" line class="inline"&gt;</code><syntaxhighlight lang="html4strict" line class="inline">
 
<table align=center style="background: ivory;color:maroon;font-style:italic;font-family:arial;font-weight:bold;font-size:10pt;">
This is the only example where it looks different in IE and the other browsers if the code is longer than the page and width is not set, IE will add scroll bars automatically no other browser will:<br><br>
<caption>This is the top caption</caption>
<code>&lt;syntaxhighlight lang="text" highlight="8-11" class="scroll"&gt;</code>
<tr><th> Heading 1 </th><th> Heading 2 </th></tr>
<syntaxhighlight lang="text" highlight="8-11" class="scroll">
<tr>
map profile show where ManagementApp FLUIDFS
<td style="padding:10px;"> This is cell 1 text </td>
<60756 (?)>
<td style="padding:10px;"> This is cell 2 text </td>
[60756] Mapping:MappingProfile 02/15/2013 12:53:34 AM
</tr>
 
</table>
Index Server Server Volume MZ MZ MultiPat LUN Persona Personali Boot Write VM Managemen Admin DebugOu Active Bad Path LUN OS OS ManagementApp Active
</syntaxhighlight><code>&lt;/syntaxhighlight&gt;</code><br>
Name Subsyst VolumeI Max Actual Preferr Actual Volume Protect Connect Status PathCo PathCo DownCo OnlyOne Product Version Controller
======= ======== =================================== ======= ======= ======= ======== ====== ======= ========= ======= ======= ========= ========= ======== ======= ====== ====== ====== ========= ============ ============ ============================== ==========
14 8 8 Cluster FS8600 15 15 15 0 1 0 60756 (0) Fal (0) Fal (3) Both (1) Auto (1) Enab (0) Fal 0 0 0 42949672* Compellent FS8600 1.x FLUIDFS 60756
15 8 8 Cluster FS8600 16 15 16 0 2 0 60757 (0) Fal (0) Fal (3) Both (1) Auto (1) Enab (0) Fal 0 0 0 42949672* Compellent FS8600 1.x FLUIDFS 60757
16 8 8 Cluster FS8600 17 15 17 0 3 0 60756 (0) Fal (0) Fal (3) Both (1) Auto (1) Enab (0) Fal 0 0 0 42949672* Compellent FS8600 1.x FLUIDFS 60756
17 8 8 Cluster FS8600 18 15 18 0 4 0 60757 (0) Fal (0) Fal (3) Both (1) Auto (1) Enab (0) Fal 0 0 0 42949672* Compellent FS8600 1.x FLUIDFS 60757
Walk: Display 4 of 4
</syntaxhighlight>
<code>&lt;/syntaxhighlight&gt;</code><br>
 
<br><br>
Line 231 ⟶ 225:
<code>&lt;/syntaxhighlight&gt;</code>
<br/><br/>
 
== Changing Colours ==
{| class="wikitable"
! class !! Code !! Result !! style="width:200px;" | When to use
|-
|
;blue-white
<code>class=blue-white</code>
|
<pre>
&lt;pre class="blue-white"&gt;
buffer = OPENSSL_malloc(1 + 2 + payload + padding);
bp = buffer;
/* Enter response type, length and copy payload */
*bp++ = TLS1_HB_RESPONSE;
s2n(payload, bp);
memcpy(bp, pl, payload);
bp += payload;
/* Random padding */
RAND_pseudo_bytes(bp, padding);
&lt;/pre&gt;</pre>
</pre>
|
<pre class="blue-white">
buffer = OPENSSL_malloc(1 + 2 + payload + padding);
bp = buffer;
/* Enter response type, length and copy payload */
*bp++ = TLS1_HB_RESPONSE;
s2n(payload, bp);
memcpy(bp, pl, payload);
bp += payload;
/* Random padding */
RAND_pseudo_bytes(bp, padding);
</pre>
|
White on a Blue background
|-
|
;black-white
<code>class=black-white</code>
|
<pre>
&lt;syntaxhighlight lang="javascript" highlight="13" class="black-white"&gt;
JSFX.FireSpark.prototype.changeColour = function()
{
var colour="";
 
r2= Math.random()*255;
g2= r2;
b2= 0;
 
if(!(r2 | g2 | b2))
{
r2=255;
g2=255;
b2=0;
}
 
colour = "#" + dec2hex(r2) + dec2hex(g2) + dec2hex(b2);
this.setBgColor(colour);
}
&lt;/syntaxhighlight&gt;
</pre>
|
<div style="width:400px;">
<syntaxhighlight lang="javascript" highlight="13" class="black-white">
JSFX.FireSpark.prototype.changeColour = function()
{
var colour="";
 
r2= Math.random()*255;
g2= r2;
b2= 0;
 
if(!(r2 | g2 | b2))
{
r2=255;
g2=255;
b2=0;
}
 
colour = "#" + dec2hex(r2) + dec2hex(g2) + dec2hex(b2);
this.setBgColor(colour);
}
</syntaxhighlight></div>
|
White on a black background
|-
|
;black-green
<code>class=black-green</code>
|
<pre>
&lt;syntaxhighlight lang="text" highlight="9" class="black-green scroll"&gt;
 
TEXT BASED TABLE OUTPUT HERE
 
&lt;/syntaxhighlight&gt;
</pre>
|
<div style="width:400px;">
<syntaxhighlight lang="text" highlight="9" class="black-green scroll">
map profile show where ManagementApp FLUIDFS
<60756 (?)>
[60756] Mapping:MappingProfile 02/15/2013 12:53:34 AM
 
Index Server Server Volume MZ MZ MultiPat LUN Persona Personali Boot Write VM Managemen Admin DebugOu Active Bad Path LUN OS OS ManagementApp Active
Name Subsyst VolumeI Max Actual Preferr Actual Volume Protect Connect Status PathCo PathCo DownCo OnlyOne Product Version Controller
======= ======== =================================== ======= ======= ======= ======== ====== ======= ========= ======= ======= ========= ========= ======== ======= ====== ====== ====== ========= ============ ============ ============================== ==========
14 8 8 Cluster FS8600 15 15 15 0 1 0 60756 (0) Fal (0) Fal (3) Both (1) Auto (1) Enab (0) Fal 0 0 0 42949672* Compellent FS8600 1.x FLUIDFS 60756
15 8 8 Cluster FS8600 16 15 16 0 2 0 60757 (0) Fal (0) Fal (3) Both (1) Auto (1) Enab (0) Fal 0 0 0 42949672* Compellent FS8600 1.x FLUIDFS 60757
16 8 8 Cluster FS8600 17 15 17 0 3 0 60756 (0) Fal (0) Fal (3) Both (1) Auto (1) Enab (0) Fal 0 0 0 42949672* Compellent FS8600 1.x FLUIDFS 60756
17 8 8 Cluster FS8600 18 15 18 0 4 0 60757 (0) Fal (0) Fal (3) Both (1) Auto (1) Enab (0) Fal 0 0 0 42949672* Compellent FS8600 1.x FLUIDFS 60757
Walk: Display 4 of 4
</syntaxhighlight></div>
| Green on a Black background
|-
|}
 
 
 
== Indenting <code>&lt;pre&gt;</code> tags ==
{{Caution|The only reliable way to get indents with <code>&lt;pre></code> tags is to use: <code>{{indent{{!}}&lt;pre> code here &lt;p/pre>}}</code>; <br /> For <code>&lt;code></code> and <code>&lt;syntaxhighlight></code> tags a <code>:</code> works fine}}
{{Note|There is something intermittent about this working which I haven't figured out yet. It doesn't render correctly below but it does on other pages}}
 
 
<pre>
{{Indent|{{Pre|class=blue-white|# for i in $(diskview -I s {{!}} awk '/Online/{print $2}'); do echo -e "\n::: ${i} :::"; dd if{{eq}}/dev/rpd${i}d bs{{eq}}512 count{{eq}}1 of{{eq}}/pss/cc/o-dsb-${i}.bin; done}}}}
</pre>
{{Indent|{{Pre|class=blue-white|# for i in $(diskview -I s {{!}} awk '/Online/{print $2}'); do echo -e "\n::: ${i} :::"; dd if{{eq}}/dev/rpd${i}d bs{{eq}}512 count{{eq}}1 of{{eq}}/pss/cc/o-dsb-${i}.bin; done}}}}
 
 
{{Note|There is something intermittent about the method below working which I haven't figured out yet. It doesn't render correctly below but it does on other pages
 
[[File:Pre in a numbered list.png]]
}}
 
 
Line 249 ⟶ 377:
|
# one
#:<pre class=scroll>
#::some stuff
#::some more stuff</pre>
</pre>
# two
|}
Line 294 ⟶ 423:
 
<pre>
;Same works for code tags:
{{Indent|{{Pre|class=blue-white|# for i in $(diskview -I s {{!}} awk '/Online/{print $2}'); do echo -e "\n::: ${i} :::"; dd if{{eq}}/dev/rpd${i}d bs{{eq}}512 count{{eq}}1 of{{eq}}/pss/cc/o-dsb-${i}.bin; done}}}}
:&lt;code>Indented code snippet&lt;/code>
</pre>
 
{{Indent|{{Pre|class=blue-white|# for i in $(diskview -I s {{!}} awk '/Online/{print $2}'); do echo -e "\n::: ${i} :::"; dd if{{eq}}/dev/rpd${i}d bs{{eq}}512 count{{eq}}1 of{{eq}}/pss/cc/o-dsb-${i}.bin; done}}}}
;Same works for code tags:
:<code>Indented code snippet</code>
 
== Annotate <code>&lt;pre&gt;</code> contents with Pointers / Boxes ==
Line 386 ⟶ 518:
 
 
<br>
 
=== Highlighting ===
 
{| class="wikitable"
Or use poem tags instead of pre:
! class !! Code !! Result !! style="width:200px;" | Colour
|-
|
NA
|
<pre>
&lt;syntaxhighlight lang=text highlight="2" inline"&gt;
&lt;poem&gt;
line one
In [[Wikipedia:Xanadu|Xanadu]] did Kubla Khan
line two
A stately pleasure-dome decree:
line three
Where Alph, the '''sacred river''', ran
line four
Through caverns measureless to man
&lt;/syntaxhighlight&gt;
Down to a sunless sea.
 
So twice five miles of fertile ground
With walls and towers were girdled round:
And there were gardens bright with sinuous rills,
Where blossomed many an incense-bearing tree;
And here were &lt;span style="color:green"&gt;forests&lt;/span&gt; ancient as the hills,
Enfolding sunny spots of greenery.
&lt;/poem&gt;
</pre>
|
 
<syntaxhighlight lang=text highlight="2" inline">
Results in:
line one
<poem>
line two
In [[Wikipedia:Xanadu|Xanadu]] did Kubla Khan
line three
A stately pleasure-dome decree:
line four
Where Alph, the '''sacred river''', ran
</syntaxhighlight>
Through caverns measureless to man
|
Down to a sunless sea.
Mediawiki Default Yellow Highlight
 
|-
So twice five miles of fertile ground
|
With walls and towers were girdled round:
;orange-highlight
And there were gardens bright with sinuous rills,
<code>class="orange-highlight"</code>
Where blossomed many an incense-bearing tree;
|
And here were <span style="color:green">forests</span> ancient as the hills,
<pre>
Enfolding sunny spots of greenery.
&lt;syntaxhighlight lang=text highlight="3" class="orange-highlight inline"&gt;
</poem>
line one
line two
line three
line four
&lt;/syntaxhighlight&gt;
</pre>
|
<syntaxhighlight lang=text highlight="3" class="orange-highlight inline">
line one
line two
line three
line four
</syntaxhighlight>
|
Fluorescent Orange
|-
|
;green-highlight
<code>class="green-highlight"</code>
|
<pre>
&lt;syntaxhighlight lang=text highlight="1" class="green-highlight inline"&gt;
line one
line two
line three
line four
&lt;/syntaxhighlight&gt;
</pre>
|
<syntaxhighlight lang=text highlight="1" class="green-highlight inline">
line one
line two
line three
line four
</syntaxhighlight>
| Fluorescent Green
|-
|
;pink-highlight
<code>class="pink-highlight"</code>
|
<pre>
&lt;syntaxhighlight lang=text highlight="4" class="pink-highlight inline"&gt;
line one
line two
line three
line four
&lt;/syntaxhighlight&gt;
</pre>
|
<syntaxhighlight lang=text highlight="4" class="pink-highlight inline">
line one
line two
line three
line four
</syntaxhighlight>
| Fluorescent Pink
|-
|
;blue-highlight
<code>class="blue-highlight"</code>
|
<pre>
&lt;syntaxhighlight lang=text highlight="3" class="blue-highlight inline"&gt;
line one
line two
line three
line four
&lt;/syntaxhighlight&gt;
</pre>
|
<syntaxhighlight lang=text highlight="3" class="blue-highlight inline">
line one
line two
line three
line four
</syntaxhighlight>
| Fluorescent Blue
|-
|}