You can use plugins like line highlight or line numbers (all optional).This means that if multiple code snippets have the same language, you can just define it once, in one of their common ancestors. In addition, the language is defined through the way recommended in the HTML5 draft: through a language-xxxx class. On its own for inline code, or inside a for blocks of code. Prism forces you to use the correct element for marking up code. Other highlighters encourage or even force you to use elements that are semantically wrong, like (on its own) or. Each language definition adds roughly 300-500 bytes. You can choose one of the seven available themes. It’s used in thousands of websites, including some of those you visit daily.Īll styling is done through CSS, with sensible class names like. Prism is a lightweight, extensible syntax highlighter, built with modern web standards in mind. The required markup should look like : Some escaped code to highlight here To use highlight.js in your project, just include the css (1) and js (1) files and initialize with the initHighlightingOnLoad() method: If automatic detection doesn’t work for you, you can specify the language in the class attribute: It tries to detect the language automatically. Highlight is a super DOM code highlighter. Use the lor method to highlight the code : lor() 2. In your markup the data-language attribute is used to specify what language to use for highlighting: var testing = true It goes through code blocks, processes regex patterns, and wraps matching patterns in tags. It is completely themable via CSS. Rainbow on its own is very simple. It was designed to be lightweight (1.4kb), easy to use, and extendable. Rainbow is a code syntax highlighting library written in Javascript. Unfortunately SyntaxHighlighter doesn't support any standard, therefore your markup will be highlighted by this plugin and is not so maintainable. To initialize javascript code, you can use :
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |