{"id":17247538,"url":"https://github.com/pvorb/google-code-prettify","last_synced_at":"2025-03-26T05:41:10.124Z","repository":{"id":66029508,"uuid":"2522834","full_name":"pvorb/google-code-prettify","owner":"pvorb","description":"Inofficial mirror for Google's code prettify","archived":false,"fork":false,"pushed_at":"2011-10-05T22:58:58.000Z","size":8727,"stargazers_count":3,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-31T07:16:34.318Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://code.google.com/p/google-code-prettify/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pvorb.png","metadata":{"files":{"readme":"README-zh-Hans.html","changelog":"CHANGES.html","contributing":null,"funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2011-10-05T22:55:56.000Z","updated_at":"2022-04-15T12:11:14.000Z","dependencies_parsed_at":"2023-02-19T21:30:51.824Z","dependency_job_id":null,"html_url":"https://github.com/pvorb/google-code-prettify","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pvorb%2Fgoogle-code-prettify","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pvorb%2Fgoogle-code-prettify/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pvorb%2Fgoogle-code-prettify/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pvorb%2Fgoogle-code-prettify/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pvorb","download_url":"https://codeload.github.com/pvorb/google-code-prettify/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245598294,"owners_count":20641882,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-15T06:38:11.566Z","updated_at":"2025-03-26T05:41:10.105Z","avatar_url":"https://github.com/pvorb.png","language":"JavaScript","readme":"\u003c!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"\n \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"\u003e\n\n\u003chtml\u003e\n  \u003chead\u003e\n    \u003cmeta http-equiv=\"content-type\" value=\"text/html; charset=UTF-8\" /\u003e\n    \u003ctitle\u003eJavascript code prettifier\u003c/title\u003e\n\n    \u003clink href=\"src/prettify.css\" type=\"text/css\" rel=\"stylesheet\" /\u003e\n\n    \u003cscript src=\"src/prettify.js\" type=\"text/javascript\"\u003e\u003c/script\u003e\n\n    \u003cstyle type=\"text/css\"\u003e\n      body { margin-left: .5in }\n      h1, h2, h3, h4, .footer { margin-left: -.4in; }\n    \u003c/style\u003e\n  \u003c/head\u003e\n\n  \u003cbody onload=\"prettyPrint()\" bgcolor=\"white\"\u003e\n    \u003ch1\u003eJavascript code prettifier\u003c/h1\u003e\n\t\u003ch1\u003eJavascript 代码美容师\u003c/h1\u003e\n    \u003ch2\u003e安装使用\u003c/h2\u003e\n    \u003col\u003e\n      \u003cli\u003e\u003ca href=\"http://google-code-prettify.googlecode.com/files/prettify-small-5-Jul-2008.zip\"\u003e下载\u003c/a\u003e 文件\n      \u003cli\u003e在你的文件中包含这儿的脚本和样式表(你要保证这儿的 css 和 js 文件按在你的服务器上, 并且调整在 \u003ctt\u003escript\u003c/tt\u003e 和 \u003ctt\u003elink\u003c/tt\u003e标签中的路径)\n        \u003cpre class=\"prettyprint\"\u003e\n\u0026lt;link href=\"prettify.css\" type=\"text/css\" rel=\"stylesheet\" /\u003e\n\u0026lt;script type=\"text/javascript\" src=\"prettify.js\"\u003e\u0026lt;/script\u003e\u003c/pre\u003e\n      \u003cli\u003e添加\u003ccode class=\"prettyprint\"\u003eonload=\"prettyPrint()\"\u003c/code\u003e 到你的文件的 body 标签中.\n      \u003cli\u003e修改样式表,使用你自己喜欢的颜色.\u003c/li\u003e\n    \u003c/ol\u003e\n\n    \u003ch2\u003e使用方法\u003cbr\u003e\u003c/h2\u003e\n    \u003cp\u003e在\n    \u003ctt\u003e\u0026lt;pre class=\"prettyprint\"\u0026gt;...\u0026lt;/pre\u0026gt;\u003c/tt\u003e 或 \u003ctt\u003e\u0026lt;code class=\"prettyprint\"\u0026gt;...\u0026lt;/code\u0026gt;\u003c/tt\u003e\n    中间放上代码片段,它就会自动被美化了.\n\n    \u003ctable summary=\"code examples\"\u003e\n      \u003ctr\u003e\n        \u003cth\u003eThe original\n        \u003cth\u003ePrettier\n      \u003ctr\u003e\n        \u003ctd\u003e\u003cpre style=\"border: 1px solid #888;padding: 2px\"\n             \u003e\u003ca name=\"voila1\"\u003e\u003c/a\u003eclass Voila {\npublic:\n  // Voila\n  static const string VOILA = \"Voila\";\n\n  // will not interfere with embedded \u003ca href=\"#voila1\"\u003etags\u003c/a\u003e.\n}\u003c/pre\u003e\n\n        \u003ctd\u003e\u003cpre class=\"prettyprint\"\u003e\u003ca name=\"voila2\"\u003e\u003c/a\u003eclass Voila {\npublic:\n  // Voila\n  static const string VOILA = \"Voila\";\n\n  // will not interfere with embedded \u003ca href=\"#voila2\"\u003etags\u003c/a\u003e.\n}\u003c/pre\u003e\n    \u003c/table\u003e\n\n    \r\n    \u003ch2\u003e常见问题\u003c/h2\u003e\n    \u003ch3 id=\"langs\"\u003e它是为什么语言工作的?\u003c/h3\u003e\n    \u003cp\u003e\u003ctt\u003eprettify.js中的注释是权威的,但是它的语法分析程序可以在很多语言中使用\u003c/tt\u003e,包括 C ,\n    Java, Python, Bash, SQL, HTML, XML, CSS, Javascript, 和 Makefiles.\n    它在 Ruby, PHP, VB, 和 Awk 中还算可以,而且也可以在 Perl 和 Ruby的合适子集中起作用,但是, 因为注释的约定,它对\n    Smalltalk, 或 CAML类似的语言起作用.\u003cbr\u003e\u003c/p\u003e\n\n    \n    \u003cp\u003eLISP系列的语言可以使用一个拓展\u003ca href=\"http://code.google.com/p/google-code-prettify/source/browse/trunk/src/lang-lisp.js\"\u003e\u003ccode\u003elang-lisp.js\u003c/code\u003e\u003c/a\u003e.\u003c/p\u003e\u003cp\u003e对于 \u003ca href=\"http://code.google.com/p/google-code-prettify/source/browse/trunk/src/lang-css\"\u003e\u003ccode\u003eCSS\u003c/code\u003e\u003c/a\u003e,\n    \u003ca href=\"http://code.google.com/p/google-code-prettify/source/browse/trunk/src/lang-hs\"\u003e\u003ccode\u003eHaskell\u003c/code\u003e\u003c/a\u003e,\n    \u003ca href=\"http://code.google.com/p/google-code-prettify/source/browse/trunk/src/lang-lua.js\"\u003e\u003ccode\u003eLua\u003c/code\u003e\u003c/a\u003e,\n    \u003ca href=\"http://code.google.com/p/google-code-prettify/source/browse/trunk/src/lang-ml.js\"\u003e\u003ccode\u003eOCAML, SML, F#\u003c/code\u003e\u003c/a\u003e,\n    \u003ca href=\"http://code.google.com/p/google-code-prettify/source/browse/trunk/src/lang-vb.js\"\u003e\u003ccode\u003eVisual Basic\u003c/code\u003e\u003c/a\u003e,\n    \u003ca href=\"http://code.google.com/p/google-code-prettify/source/browse/trunk/src/lang-sql.js\"\u003e\u003ccode\u003eSQL\u003c/code\u003e\u003c/a\u003e,\n    \u003ca href=\"http://code.google.com/p/google-code-prettify/source/browse/trunk/src/lang-proto.js\"\u003e\u003ccode\u003eProtocol Buffers\u003c/code\u003e\u003c/a\u003e, 和\n    \u003ca href=\"http://code.google.com/p/google-code-prettify/source/browse/trunk/src/lang-wiki.js\"\u003e\u003ccode\u003eWikiText\u003c/code\u003e\u003c/a\u003e..也是类似的\u003c/p\u003e\u003cp\u003e如果你想给你喜欢的语言写个拓展版本, 请参阅\u003ctt\u003esrc/lang-lisp.js\u003c/tt\u003e ,并写一个包括你的语言的拓展的 \u003ca href=\"http://code.google.com/p/google-code-prettify/issues/list\"\n     \u003e发布\u003c/a\u003e 和一个测试用例.\u003c/p\u003e\n\n    \u003ch3\u003e如何指定我的代码在哪种语言里?\u003c/h3\u003e\n    \u003cp\u003e你不需要指定语言环境,因为 \u003ccode\u003eprettyprint()\u003c/code\u003e\n    会对此进行猜测.  你可以使用\u003ccode\u003e prettyprint \u003c/code\u003e这个类通过指定语言的拓展名来指定语言,就像这样:\u003c/p\u003e\n    \u003cpre class=\"prettyprint lang-html\"\n\u003e\u0026lt;pre class=\u0026quot;prettyprint \u003cb\u003elang-html\u003c/b\u003e\u0026quot;\u0026gt;\n  The lang-* class specifies the language file extensions.\n  File extensions supported by default include\n    \"bsh\", \"c\", \"cc\", \"cpp\", \"cs\", \"csh\", \"cyc\", \"cv\", \"htm\", \"html\",\n    \"java\", \"js\", \"m\", \"mxml\", \"perl\", \"pl\", \"pm\", \"py\", \"rb\", \"sh\",\n    \"xhtml\", \"xml\", \"xsl\".\n\u0026lt;/pre\u0026gt;\u003c/pre\u003e\n\n    \u003ch3\u003e它在混淆代码例子上不起作用吗?\u003c/h3\u003e\n    \u003cp\u003e是的.  美化混淆代码就像给小猪涂口红,也就是不在这个工具的范围内. \u003cbr\u003e\u003c/p\u003e\n\n    \u003ch3\u003e它可以在那些浏览器上工作?\u003c/h3\u003e\n    \u003cp\u003e这个工具已经在 IE 6, Firefox 1.5 \u0026amp; 2, 和 Safari 2.0.4 上测试通过. 打开 \u003ca href=\"tests/prettify_test.html\"\u003e测试页面\u003c/a\u003e ,看看它能不能在你的浏览器上起作用.\u003c/p\u003e\n\n    \u003ch3\u003e有什么改变?\u003c/h3\u003e\n    \u003cp\u003e查看 \u003ca href=\"CHANGES.html\"\u003e变化日志\u003c/a\u003e\u003c/p\u003e\n\n    \u003ch3\u003e\u0026nbsp;为什么Prettyprinting 对WordPress中的字符串没用?\u003c/h3\u003e\n    \u003cp\u003e很显然,wordpress 在 \u0026quot;smart quoting\u0026quot; 时会改变关闭符号.\n    这使得关闭符号跟开始符号不配套.\n    \u003cp\u003e这和复制粘贴代码一样,破坏了美化作用. 去\n    \u003ca href=\"http://wordpress.org/support/topic/125038\"\n    \u003eWordPress's help center\u003c/a\u003e 查看更多关于如何关闭插入代码段时的\u0026quot;smart quoting\u0026quot;的信息.\u003c/p\u003e\n\n    \u003ch3\u003e如何在我的代码中加入行号?  (Out of date -- see \u003ca href=\"README.html\"\u003eEnglish version\u003c/a\u003e)\u003c/h3\u003e\n    \u003cp\u003e你可以使用 \u003ccode\u003enocode\u003c/code\u003e 类来标记 span 标记不是代码.\n\u003cpre\u003e\u0026lt;pre class=prettyprint\u0026gt;\n\u0026lt;span class=\"\u003cb\u003enocode\u003c/b\u003e\"\u0026gt;1:\u0026lt;/span\u0026gt; /* This is line 1 of my code\n\u0026lt;span class=\"\u003cb\u003enocode\u003c/b\u003e\"\u0026gt;2:\u0026lt;/span\u0026gt;  * and here's line 2 */\n\u0026lt;span class=\"\u003cb\u003enocode\u003c/b\u003e\"\u0026gt;3:\u0026lt;/span\u0026gt; print(\"I'm line number 3\");\n\u0026lt;/pre\u0026gt;\u003c/pre\u003e得到\n\u003cpre class=prettyprint\u003e\n\u003cspan class=\"nocode\"\u003e1:\u003c/span\u003e /* This is line 1 of my code\n\u003cspan class=\"nocode\"\u003e2:\u003c/span\u003e  * and here's line 2 */\n\u003cspan class=\"nocode\"\u003e3:\u003c/span\u003e print(\"I'm line number 3\");\n\u003c/pre\u003e\n\n    \u003cp\u003e查看一个更完整的例子： issue22\n    \u003ca href=\"tests/prettify_test.html#issue22\"\u003etestcase\u003c/a\u003e.\u003c/p\u003e\n\n    \u003ch3\u003e我得到了这样一条错误信息 \u0026quot;a is not a function\u0026quot; 或 \u0026quot;opt_whenDone is not a function\u0026quot;\u003c/h3\u003e\n    \u003cp\u003e如果你通过事件句柄条用 \u003ccode\u003eprettyPrint\u003c/code\u003e , 把它隐藏到一个函数中. \u003cbr\u003e\u003c/p\u003e\u003cp\u003e不要这么写\n    \u003c/p\u003e\u003cblockquote\u003e\n      \u003ccode class=\"prettyprint lang-js\"\n       \u003eaddEventListener('load', prettyPrint, false);\u003c/code\u003e\n    \u003c/blockquote\u003e而要这么写\n    \u003cblockquote\u003e\n      \u003ccode class=\"prettyprint lang-js\"\n       \u003eaddEventListener('load', function (event) { prettyPrint() }, false);\u003c/code\u003e\n    \u003c/blockquote\u003e这样的话,浏览器就不会把时间对象传递给 \u003ccode\u003eprettyPrint\u003c/code\u003e ,事件对象会让它困惑的.\n\n    \u003cbr\u003e\u003cbr\u003e\u003cbr\u003e\n\n    \u003cdiv class=\"footer\"\u003e\n\u003c!-- Created: Tue Oct  3 17:51:56 PDT 2006 --\u003e\n\u003c!-- hhmts start --\u003e\nLast modified: Wed Jan  7 13:25:42 PST 2009\u003cbr\u003e\u003c!-- hhmts end --\u003e\n    \u003c/div\u003e\n  \u003c/body\u003e\n\u003c/html\u003e\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpvorb%2Fgoogle-code-prettify","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpvorb%2Fgoogle-code-prettify","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpvorb%2Fgoogle-code-prettify/lists"}