# Highlight.js Highlight.js highlights syntax in code examples on blogs, forums and, in fact, on any web page. It's very easy to use because it works automatically: finds blocks of code, detects a language, highlights it. Autodetection can be fine tuned when it fails by itself (see "Heuristics"). ## Basic usage Link the library and a stylesheet from your page and hook highlighting to the page load event: ```html ``` This will highlight all code on the page marked up as `
..
`.
If you use different markup or need to apply highlighting dynamically, read
"Custom initialization" below.
- You can download your own customized version of "highlight.pack.js" or
use the hosted one as described on the download page:
`) pass `true` into the third parameter of `highlightBlock` to make highlight.js use `
` in the output: ```javascript $('div.code').each(function(i, e) {hljs.highlightBlock(e, null, true)}); ``` ## Heuristics Autodetection of a code's language is done using a simple heuristic: the program tries to highlight a fragment with all available languages and counts all syntactic structures that it finds along the way. The language with greatest count wins. This means that in short fragments the probability of an error is high (and it really happens sometimes). In this cases you can set the fragment's language explicitly by assigning a class to the `` element: ```html
``` You can use class names recommended in HTML5: "language-html", "language-php". Classes also can be assigned to the `...
` element. To disable highlighting of a fragment altogether use "no-highlight" class: ```html``` ## Export File export.html contains a little program that allows you to paste in a code snippet and then copy and paste the resulting HTML code generated by the highlighter. This is useful in situations when you can't use the script itself on a site. ## Meta - Version: 7.3 - URL: http://softwaremaniacs.org/soft/highlight/en/ - Author: Ivan Sagalaev (...
) For the license terms see LICENSE files. For the list of contributors see AUTHORS.en.txt file.