Personal tools

Difference between revisions of "Syntax highlighter"

From MohidWiki

Jump to: navigation, search
(Syntax)
Line 3: Line 3:
 
==Syntax==
 
==Syntax==
 
Simply add in the wiki article edit box this code:
 
Simply add in the wiki article edit box this code:
 +
 +
{|
 +
|a||b
 +
|}
  
 
{|
 
{|
<code> &lt;htm&gt;&lt;pre name="code" class="ruby"&gt;
+
|<code> &lt;htm&gt;&lt;pre name="code" class="ruby"&gt;
 
  File.open("sample.txt", "r") { |fs|   
 
  File.open("sample.txt", "r") { |fs|   
 
    
 
    
Line 17: Line 21:
 
  &lt;/pre&gt;&lt;/htm&gt;
 
  &lt;/pre&gt;&lt;/htm&gt;
 
</code>
 
</code>
|
+
||
 
<htm><pre name="code" class="ruby">
 
<htm><pre name="code" class="ruby">
 
  File.open("sample.txt", "r") { |fs|   
 
  File.open("sample.txt", "r") { |fs|   
Line 30: Line 34:
 
</pre></htm>
 
</pre></htm>
 
|}
 
|}
 +
 
==Installation procedure for mediawiki==
 
==Installation procedure for mediawiki==
  

Revision as of 23:15, 12 December 2008

This wiki allows to embed code with syntax highlighting.

Syntax

Simply add in the wiki article edit box this code:

a b
<htm><pre name="code" class="ruby">
File.open("sample.txt", "r") { |fs|  
  
   while line = fs.gets  
     if line.match(pattern)  
        puts "Line read was '#{line.chomp}'.\n"  
     end  
   end  
   fs.close  
}  
</pre></htm>

 File.open("sample.txt", "r") { |fs|  
   
    while line = fs.gets  
      if line.match(pattern)  
         puts "Line read was '#{line.chomp}'.\n"  
      end  
    end  
    fs.close  
 }  

Installation procedure for mediawiki

First, download and untar inside your wiki root folder the syntax highlighter code. Then, simply add the following code snippets in your monobook.php file.








        



























That's it! You can now test to see if it worked ...

External references