Highlights specific lines and/or line ranges.
Obviously, this only works on code blocks (<pre><code>
) and not for inline code.
You specify the lines to be highlighted through the data-line
attribute on the <pre>
element, in the following simple format:
Examples:
In case you want the line numbering to be offset by a certain number (for example, you want the 1st line to be number 41 instead of 1, which is an offset of 40), you can additionally use the data-line-offset
attribute.
You can also link to specific lines on any code snippet, by using the following as a url hash: #{element-id}.{lines}
where
{element-id}
is the id of the <pre>
element and {lines}
is one or more lines or line ranges that follow the format
outlined above. For example, if there is an element with id="play"
on the page, you can link to lines 5-6 by linking to #play.5-6