Skip to content

requarks/highlightjs-line-numbers-esm

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

highlightjs-line-numbers-esm

Fork of the Highlight.js Line Numbers plugin for Highlight.js line refactored for ESM.

Install

Copy the src/highlightjs-line-numbers.js file into your project.

Usage

Import both Highlight.js and the highlightjs-line-numbers.js file, then register the plugin:

// Import both libraries
import hljs from 'highlight.js'
import { registerHljsLineNumbers, injectHljsLineNumbersCss } from './src/highlightjs-line-numbers.js'

// Register the plugin
registerHljsLineNumbers(hljs)

// Optionally inject the default CSS for line numbers
injectHljsLineNumbersCss()
  • registerHljsLineNumbers(hljs) requires the hljs instance to be passed as its sole parameter.
  • injectHljsLineNumbersCss() will inject the base CSS for this plugin.

You can then call the hljs.lineNumbersBlock(), hljs.initLineNumbersOnLoad() and hljs.lineNumbersValue() methods as needed.

For more info, read the original plugin documentation.

About

ESM version of the line numbering plugin for Highlight.js

Resources

License

Stars

Watchers

Forks

Languages

  • JavaScript 100.0%