Add syntax highlighting to a static HTML documentation site without a build step or npm dependency.
Display code samples with automatic language detection on a blog or CMS that allows injecting a script tag.
Study the archived codebase as a reference for how tokenizer-based syntax highlighting was implemented in plain JavaScript.
This project is archived and no longer maintained, consider highlight.js or Prism.js for new projects.
Code Prettify is an archived JavaScript library originally created by Google that adds syntax highlighting to code snippets displayed on web pages. Syntax highlighting means coloring different parts of code (keywords, strings, comments, etc.) so they are easier to read visually. This library is no longer maintained, and the repository is marked as inactive. To use it, you include a single script tag in your HTML page and then mark any block of code with the class "prettyprint". The library automatically detects what programming language the code is written in and applies appropriate colors, so you do not have to specify the language yourself. You can optionally specify a language extension if you want to override that detection. Line numbers can be added with a separate class, and the visual styles can be changed through CSS. The library works with a wide range of languages out of the box, including C, C++, Java, Python, Bash, JavaScript, HTML, XML, CSS, SQL, and Rust. Additional language extensions are included in the repository for languages like Go, Haskell, Scala, Swift, Lua, Ruby, and YAML, among others. It handles code that contains embedded HTML links or other markup without breaking the display. The library was used in production on both Google Code and Stack Overflow, according to the README. It was tested with older browser versions including Internet Explorer 6 and early versions of Firefox and Safari. The README includes answers to several practical questions: how to prevent specific sections from being highlighted, how to control line numbering, how to handle code coming from Markdown renderers that do not allow adding CSS classes, and why it may behave unexpectedly on WordPress sites. Because this project is archived and no longer maintained, developers looking for an actively supported syntax highlighting library would need to look elsewhere.
← googlearchive on gitmyhub — every repo by this author, as a profile.
Verify against the repo before relying on details.