googlearchive/code-prettify là dự án JavaScript với 5.8k sao. An embeddable script that makes source-code snippets in HTML prettier.
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
See Getting Started to configure that URL with
options you need.
Look at the skin gallery and pick styles that suit you.
Usage
Put code snippets in <pre class="prettyprint">...</pre> or
<code class="prettyprint">...</code> and it will automatically be
pretty-printed.
<pre class="prettyprint">class Voila {
public:
// Voila
static const string VOILA = "Voila";
// will not interfere with embedded <a href="#voila2">tags</a>.
}</pre>
FAQ
For which languages does it work?
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, Makefile, and Rust.
It works passably on Ruby, PHP, VB, and Awk and a decent subset of Perl and
Ruby, but because of commenting conventions, doesn't work on Smalltalk, OCaml,
etc. without a language extension.
If you'd like to add an extension for your favorite language, please look at
src/lang-lisp.js and submit a pull request.
How do I specify the language of my code?
You don't need to specify the language since PR.prettyPrint() will guess.
You can specify a language by specifying the language extension along with the
prettyprint class:
<pre class="prettyprint lang-html">
The lang-* class specifies the language file extensions.
File extensions supported by default include:
"bsh", "c", "cc", "cpp", "cs", "csh", "cyc", "cv", "htm", "html", "java",
"js", "m", "mxml", "perl", "pl", "pm", "py", "rb", "sh", "xhtml", "xml",
"xsl".
</pre>
You may also use the HTML 5 convention of embedding a <code> element
inside the <pre> and using language-java style classes:
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 tests to see if it works in your browser.
What's changed?
See the changelog.
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
WordPress's help center for info on how to stop smart quoting of code
snippets.
How do I put line numbers in my code?
You can use the linenums class to turn on line numbering. If your code
doesn't start at line number 1, you can add a colon and a line number to the
end of that class as in linenums:52. For example:
<pre class="prettyprint linenums:4"
>// This is line 4.
foo();
bar();
baz();
boo();
far();
faz();
</pre>
How do I prevent a portion of markup from being marked as code?
You can use the nocode class to identify a span of markup that is not code:
<pre class="prettyprint">
int x = foo(); /* This is a comment <span class="nocode">This is not code</span>
Continuation of comment */
int y = bar();
</pre>
For a more complete example see the issue #22 testcase.
I get an error message "a is not a function" or "opt_whenDone is not a function"
If you are calling prettyPrint via an event handler, wrap it in a function.
Instead of doing:
so that the browser does not pass an event object to PR.prettyPrint
which will confuse it.
How can I customize the colors and styles of my code?
Prettify adds <span> with classes describing the kind of code. You can
create CSS styles to matches these classes.
See the theme gallery for examples.
I can't add classes to my code (because it comes from Markdown, etc.)
Instead of <pre class="prettyprint ..."> you can use a comment or processing
instructions that survives processing instructions: <?prettify ...?> works
as explained in Getting Started.
How can I put line numbers on every line instead of just every fifth line?
Prettify puts lines into an HTML list element so that line numbers aren't
caught by copy/paste, and the line numbering is controlled by CSS in the
default stylesheet, prettify.css.
The following should turn line numbering back on for the other lines:
Trang TopGit này là một snapshot — tab "Readme" hiển thị nguyên văn README của repo (đã bỏ link, giữ ảnh). Repo GitHub ở github.com/googlearchive/code-prettify là nguồn chính thức.
googlearchive/code-prettify có bao nhiêu sao?
googlearchive/code-prettify có 5.8k sao GitHub — tải lại trang để xem số mới nhất, hoặc xem trực tiếp github.com/googlearchive/code-prettify. TopGit phản chiếu số sao của GitHub nhưng không cam kết đến từng phút.
googlearchive/code-prettify có phải mã nguồn mở không?
Có — googlearchive/code-prettify phát hành theo license Apache-2.0, nghĩa là mã nguồn mở để đọc, fork và (tùy license) tái sử dụng. Mã: github.com/googlearchive/code-prettify.
googlearchive/code-prettify còn đang phát triển không?
Commit gần nhất trên googlearchive/code-prettify là 6.6 năm trước (theo timestamp GitHub). Repo có 885 fork — một chỉ báo về mức độ quan tâm của cộng đồng.
googlearchive/code-prettify dùng license gì?
googlearchive/code-prettify phát hành theo license Apache-2.0. Nên mở file LICENSE trên GitHub để xác nhận — license metadata đôi khi lệch với thực tế dự án.
googlearchive/code-prettify là gì?
googlearchive/code-prettify (googlearchive/code-prettify) là dự án JavaScript trên GitHub. Theo mô tả gốc: An embeddable script that makes source-code snippets in HTML prettier.
googlearchive/code-prettify viết bằng ngôn ngữ gì?
googlearchive/code-prettify chủ yếu viết bằng JavaScript. Trường "language" của GitHub dựa trên phần lớn byte ở nhánh mặc định.
Đọc đầy đủ README ở tab phía trên.
Muốn nghe thêm một ý kiến về code-prettify?
Hỏi một AI đọc được trang này — một cú bấm là có ngay nhận định về code-prettify.