About
Formatting Syntax Highlighter is an HTML format for displaying code in a more attractive way based on PrismJS.
This formatting will perform a series of processes on the code text, adding copy functionality, highlighting certain parts such as tags,
attributes, variables, and more - (Demo).
Specification
Configuration
Description
line-number
Activate line numbers - (View).
break
formatting
By default, the system will process all PRE and CODE elements that placed in supported spesification (see data Spesification).
By setting this configuration to no,
the element will not be processed with formatting (it will use the browser's default style).
Usage
-
HTML FORMAT
<code class='language-***'>Parsed Code...</code><pre> <code class='language-***'>Parsed Code...</code> </pre>
Explanationlanguage-***
This class defines the language of the code to be highlighted. Replace *** with one of the supported languages: html, css, javascript, xml, clike, markup, svg, mathml, ssml, atom, rss, plain.
Example:<code class='language-html'>Parsed Code...</code>
Parsed Code
Place the parsed code here. For complete information about parsing, Google: How to parse HTML.
Example:<pre> <code class='language-html'> <div>lorem ipsum</div> </code> </pre><div>lorem ipsum</div>
Inline and Block
The Inline format is used to highlight code without creating a new line. Use this format for highlighting short code snippets within a paragraph.
The Block format is used to highlight code by displaying it in a special box. Use this format for highlighting longer code snippets.
Compare the results for the two examples below:
Inline Example:Lorem ipsum dolor sit amet. <code class='language-html'> <div>lorem ipsum</div> </code> Lorem ipsum dolor sit amet.Lorem ipsum dolor sit amet.<div>lorem ipsum</div>Lorem ipsum dolor sit amet.
Block Example:Lorem ipsum dolor sit amet. <pre> <code class='language-html'> <div>lorem ipsum</div> <div>lorem ipsum</div> </code> </pre> Lorem ipsum dolor sit amet.Lorem ipsum dolor sit amet.
Lorem ipsum dolor sit amet.<div>lorem ipsum</div> <div>lorem ipsum</div>
-
Adding Configuration
Add the desired configuration by adding the attribute
data-configuration-name='Value' to the PRE element.
Example:<pre data-box='shadow'> <code class='language-html'> <div>lorem ipsum</div> </code> </pre><div>lorem ipsum</div>