Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

digitalmoksha/markdown-it-inject-linenumbers

Open more actions menu

Repository files navigation

markdown-it-inject-linenumbers

Insert line numbers to support sync scrolling for the markdown-it markdown parser.

Inject the source line numbers into the final HTML. This gives you the anchor points to implement synchronized scrolling.

lorem => <p class="line" data-source-line="0">lorem</p>

Inline elements are not supported. Only the following block level elements are currently supported:

  • headings
  • paragraphs
  • list items
  • tables

This plugin was built using the markdown-it demo sync scrolling as a starting point.

Install

node.js, browser:

npm install markdown-it-inject-linenumbers --save
bower install markdown-it-inject-linenumbers --save

Use

var md = require('markdown-it')()
            .use(require('markdown-it-inject-linenumbers'));

md.render('lorem') // => '<p class="source-line" data-source-line="0">lorem</p>'

Differences in browser. If you load script directly into the page, without package system, module will add itself globally as window.markdownitInjectLinenumbers.

License

MIT

About

Insert line numbers to support sync scrolling for the markdown-it parser.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published
Morty Proxy This is a proxified and sanitized view of the page, visit original site.