千家信息网

如何用Google Code Prettify页面语法高亮JS库

发表于:2024-10-01 作者:千家信息网编辑
千家信息网最后更新 2024年10月01日,本篇文章为大家展示了如何用Google Code Prettify页面语法高亮JS库,内容简明扼要并且容易理解,绝对能使你眼前一亮,通过这篇文章的详细介绍希望你能有所收获。Google Code Pr
千家信息网最后更新 2024年10月01日如何用Google Code Prettify页面语法高亮JS库

本篇文章为大家展示了如何用Google Code Prettify页面语法高亮JS库,内容简明扼要并且容易理解,绝对能使你眼前一亮,通过这篇文章的详细介绍希望你能有所收获。

Google Code Pretiffy 是 Google 的一个用来对代码进行语法着色的 JavaScript 库,支持 C/C++, Java, Python, Ruby, PHP, VisualBasic, AWK, Bash, SQL, HTML, XML, CSS, JavaScript, Makefiles和部分Perl。

package foo;   import java.util.Iterator;   /**   * the fibonacci series implemented as an Iterable.   */ public final class Fibonacci implements Iterable {    /** the next and previous members of the series. */   private int a = 1, b = 1;     @Override   public Iterator iterator() {      return new Iterator() {        /** the series is infinite. */       public boolean hasNext() { return true; }        public Integer next() {          int tmp = a;          a += b;          b = tmp;          return a;        }        public void remove() { throw new UnsupportedOperationException(); }      };    }     /**     * the nth element of the given series.     * @throws NoSuchElementException if there are less than n elements in the     *   given Iterable's {@link Iterable#iterator iterator}.     */   public static     T nth(int n, Iterable iterable) {      Iterator it = iterable.iterator();      while (--n > 0) {        it.next();      }      return it.next();    }     public static void main(String[] args) {      System.out.print(nth(10, new Fibonacci()));    }  }

上述内容就是如何用Google Code Prettify页面语法高亮JS库,你们学到知识或技能了吗?如果还想学到更多技能或者丰富自己的知识储备,欢迎关注行业资讯频道。

0