Overview
The ActiveLines extension highlights specified lines:
<div class="container">
<button class="button button--primary">
Click Me
</button>
</div>
It works with the LineNumbers extension:
export default function Layout( { children, hasFooter = true } ) {
return (
<div className={ styles.layout }>
<NavigationBar/>
<main id="main" className={ styles.layoutContent }>
{ children }
</main>
{ hasFooter && <Footer/> }
</div>
);
}
Usage
Register the ActiveLines extension:
import { RyuseiLight, ActiveLines } from '@ryusei/light';
RyuseiLight.compose( { ActiveLines } );
Or import the file:
<script src="path-to-the-file/active-lines.min.js"></script>
Lines to highlight can be specified by options as an array:
const ryuseilight = new RyuseiLight();
ryuseilight.apply( 'pre', { activeLines: [ 5, [ 8, 10 ] ] } );
Pass numbers for single lines to highlight, or arrays for ranges.
For example, [ 2, 5 ] highlights line 2 and 5, but [ [ 2, 5 ] ] highlights lines from 2 to 5.
Data Attribute
You can specify active lines by the data-rl-active-lines data attribute.
This value will overwrite options provided by the script.
<pre data-rl-active-lines="[5, [8, 10]]"> write code here </pre>