Google Code Prettify page syntax highlighting JS Library

Source: Internet
Author: User

Google Code prespony is a Google JavaScript library used to color the Code syntax. It supports C/C ++, Java, Python, Ruby, PHP, VisualBasic, AWK, Bash, SQL, HTML, XML, CSS, JavaScript, Makefiles, and some Perl.

 
  1. package foo;  
  2.  
  3. import java.util.Iterator;  
  4.  
  5. /**  
  6.  * the fibonacci series implemented as an Iterable.  
  7.  */ 
  8. public final class Fibonacci implements Iterable<Integer> {  
  9.   /** the next and previous members of the series. */ 
  10.   private int a = 1, b = 1;  
  11.  
  12.   @Override 
  13.   public Iterator<Integer> iterator() {  
  14.     return new Iterator<Integer>() {  
  15.       /** the series is infinite. */ 
  16.       public boolean hasNext() { return true; }  
  17.       public Integer next() {  
  18.         int tmp = a;  
  19.         a += b;  
  20.         b = tmp;  
  21.         return a;  
  22.       }  
  23.       public void remove() { throw new UnsupportedOperationException(); }  
  24.     };  
  25.   }  
  26.  
  27.   /**  
  28.    * the n<sup>th</sup> element of the given series.  
  29.    * @throws NoSuchElementException if there are less than n elements in the  
  30.    *   given Iterable's {@link Iterable#iterator iterator}.  
  31.    */ 
  32.   public static <T>  
  33.   T nth(int n, Iterable<T> iterable) {  
  34.     Iterator<? extends T> it = iterable.iterator();  
  35.     while (--n > 0) {  
  36.       it.next();  
  37.     }  
  38.     return it.next();  
  39.   }  
  40.  
  41.   public static void main(String[] args) {  
  42.     System.out.print(nth(10, new Fibonacci()));  
  43.   }  
  44. } 

More demos: http://google-code-prettify.googlecode.com/svn/trunk/tests/prettify_test.html

: Http://code.google.com/p/google-code-prettify/downloads/list

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.