<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    code prettifier

    Posted on 2008-09-02 02:30 H2O 閱讀(508) 評論(0)  編輯  收藏 所屬分類: javascript

    Javascript code prettifier

    Setup

    1. Download a distribution
    2. Include the script and stylesheets in your document (you will need to make sure the css and js file are on your server, and adjust the paths in the script and link tag)
      <link href="prettify.css" type="text/css" rel="stylesheet" />
      <script type="text/javascript" src="prettify.js"></script>
    3. Add onload="prettyPrint()" to your document's body tag.
    4. Modify the stylesheet to get the coloring you prefer

    Usage

    Put code snippets in <pre class="prettyprint">...</pre> or <code class="prettyprint">...</code> and it will automatically be pretty printed.
    The original Prettier
    class Voila {
                    public:
                    // Voila
                    static const string VOILA = "Voila";
                    // will not interfere with embedded tags.
                    }
    class Voila {
    public:
     
    // Voila
     
    static const string VOILA = "Voila";

     
    // will not interfere with embedded tags.
    }

    FAQ

    Which languages does it work for?

    The comments in prettify.js are authoritative but the lexer should work on a number of languages including C and friends, Java, Python, Bash, SQL, HTML, XML, CSS, Javascript, and Makefiles. It works passably on Ruby, PHP and Awk and a decent subset of Perl, but, because of commenting conventions, doesn't work on Smalltalk, or CAML-like languages.

    LISPy languages are supported via an extension: lang-lisp.js.

    And similarly for LUA, OCAML, SML, F#, SQL, and Protocol Buffers.

    If you'd like to add an extension for your favorite language, please look at lang-lisp.js and file an issue including your language extension, and a testcase.

    How do I specify which language my code is in?

    You don't need to specify the language since prettyprint() will guess. You can specify a language by specifying the language extension along with the prettyprint class like so:

    <pre class="prettyprint lang-html">
      The lang-* class specifies the language file extensions.
      Supported file extensions include
        "c", "cc", "cpp", "cs", "cyc", "java", "bsh", "csh", "sh",
        "cv", "py", "perl", "pl", "pm", "rb", "js",
        "html", "html", "xhtml", "xml", "xsl".
    </pre>

    It doesn't work on <obfuscated code sample>?

    Yes. Prettifying obfuscated code is like putting lipstick on a pig — i.e. outside the scope of this tool.

    Which browsers does it work with?

    It's been tested with IE 6, Firefox 1.5 & 2, and Safari 2.0.4. Look at the test page to see if it works in your browser.

    What's changed?

    See the change log

    Why doesn't Prettyprinting of strings work on WordPress?

    Apparently wordpress does "smart quoting" which changes close quotes. This causes end quotes to not match up with open quotes.

    This breaks prettifying as well as copying and pasting of code samples. See for info on how to stop smart quoting of code snippets.

    How do I put line numbers in my code?

    You can use the nocode class to identify a span of markup that is not code.

    <pre class=prettyprint>
        <span class="nocode">1:</span> /* This is line 1 of my code
        <span class="nocode">2:</span>  * and here's line 2 */
        <span class="nocode">3:</span> print("I'm line number 3");
        </pre>
    produces
    1: /* This is line 1 of my code
    2:  * and here's line 2 */
    3: print("I'm line number 3");

    For a more complete example see the issue22 testcase.




    posts - 0, comments - 21, trackbacks - 0, articles - 101

    Copyright © H2O

    主站蜘蛛池模板: 国产特级淫片免费看| 四虎免费大片aⅴ入口| 久久久亚洲精品蜜桃臀| 亚洲av最新在线观看网址| 国内免费高清在线观看| 亚洲中文字幕无码av在线| 成年人免费的视频| 亚洲一区二区三区在线| 一个人免费高清在线观看| 亚洲成人激情小说| 国产一精品一aⅴ一免费| 美女啪啪网站又黄又免费| 亚洲成A人片在线观看中文| 日本激情猛烈在线看免费观看| 亚洲国产成人a精品不卡在线| 全部一级一级毛片免费看| 91麻豆国产自产在线观看亚洲 | 亚洲中文字幕久久精品无码VA| 在线观看无码AV网站永久免费 | 综合亚洲伊人午夜网 | 亚洲av日韩综合一区久热| 国产乱子伦精品免费女| 久青草国产免费观看| 亚洲精品无码午夜福利中文字幕 | 亚洲国产精品久久久久秋霞小| 免费大学生国产在线观看p| 一级一黄在线观看视频免费| 亚洲精品自产拍在线观看| 2021在线永久免费视频| 亚洲乱码中文字幕在线| 亚洲色欲一区二区三区在线观看| 男人j进入女人j内部免费网站| 亚洲导航深夜福利| 国产一级做a爱免费视频| 成人久久免费网站| 精品国产日韩久久亚洲| 亚洲中文字幕伊人久久无码| 午夜精品免费在线观看| 成人婷婷网色偷偷亚洲男人的天堂| 久久久久亚洲精品无码网址 | 97在线视频免费|