Overview
The Caption extension displays a code caption,
wrapping a code block with a figure
and appending a figcaption
for the semantic markup.
console.log( 'Hi!' );
You can show it on the bottom of the figure:
console.log( 'Hi!' );
Usage
Register the Caption extension:
import { RyuseiLight, Caption } from '@ryusei/light'; RyuseiLight.compose( { Caption } );
Or import the extension file:
<script src="path-to-the-file/caption.min.js"></script>
Then, set a caption by options:
ryuseilight.apply( 'pre', { caption: 'Code Caption' } );
If you'd like to show it on the bottom of the block,
pass an object with the position
property:
ryuseilight.apply( 'pre', { caption: { position: 'bottom', html : 'Code Caption', }, } );
Data Attribute
You can provide the caption by the data-rl-caption
data attribute:
This value will overwrite options provided by the script.
<pre data-rl-caption="Code Caption"> write code here </pre>