Nancywiki1.0.1 Update-Automatic Code coloring

Source: Internet
Author: User
Nancywiki is developed based on Google App Engine and uses python. The Wiki markup language uses markdown because it is simple and easy to use. Nancywiki is designed to build a personal wiki system that users really want. Use nancywiki to read more books, learn more, and take more notes!

I am very pleased to see some friends download and use nancywiki! So I updated nancywiki this weekend. I hope that my friends who use nancywiki can continue to give me comments and make nancywiki more and more useful!

Nancywiki1.0.1 is updated as follows:

1. Add the "Index" menu link.

2.CodeAutomatic coloring. (No need to specifyProgramming Language)

3. Repair"_" In the Code is converted to"95 ;".

Automatic Code coloring

Most code coloring tools, such as syntaxhighlighter, must specify the language in which the code is used. For standard markdown, It is unfriendly to color a piece of code by changing the standard method, and it will be troublesome for users to use it. Because you need to write something like class = "Brush: Python. So what I think is that different codes can be colored without specifying the language used by the code without changing the markdown standard.

There are two methods to paste the standard markdown code:

1. Put the code in '', for example:

` Printf ( " Hello World " );'

2. ''is applicable to single lines or multiple lines of code without blank lines. If you need to paste multiple lines of code with blank lines in the middle, you can use four spaces or tabs. For example:

Int A =   1 ;

A = A +   1 ;

The above two marking methods will be automatically converted to the following format:

< Pre > < Code > Xxx Code> Pre>Or<Code>Xxx Code>

After knowing the conversion principle, let's break through the coloring difficulty, that is, coloring the code without specifying the code language. Fortunately, prettasksIt is exactly what I want. It only needs to be colored in any code in the following format:

< Pre Class = " Prettyprint " > Xxx Pre>

Or

< COD E Class = " Prettyprint " > Xxx Code>

Well, the Code converted from markdown is only one step away, that is, class = "prettyprint". I need to add this class automatically. At this time, jquery will be used. I need to automatically add the class attribute to each code node:

< Script Type = "Text/JavaScript" >
$ ( ' Code ' ). Addclass ( ' Prettyprint ' );
</ Script >

 

So the effect came out. You still paste the code as usual, and nancywiki will automatically color according to your code language. The following figure shows the effect:

 

Original code before coloring (four spaces before each line in the code line ):

C # sample code:

[Testmethod]
Public   Void Test_executecommands ()
{
Plateau =   New Plateau ( 5 , 5 );
VaR roverfactory =   New Nasaroverfactory ();
Rover rover1 = Roverfactory. Create ();
Rover1.deploy ( 1 , 2 , " N " , Plateau );

Rover1.executecommands ("Lmlmlmlmm");

Assert. areequal ("1 3 N", Rover1.reportstate ());

Rover rover2=Roverfactory. Create ();
Rover2.deploy (3,3,"E", Plateau );

Rover2.executecommands ("Mmrmmrmrrm");

Assert. areequal ("5 1 E", Rover2.reportstate ());
}

 

Code after coloring:

What are you waiting for? Download nancywiki1.0.1 and try it:

Download: http://nancywiki.googlecode.com/files/nancywiki1.0.1.zip

Home: http://nancywiki.googlecode.com

Demo: http://wiki.coderzh.com

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.