remark-code-block
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

Remark code block

  • [x] syntax highlighting with refractor which uses PrismJS under the hood.

  • [x] support filename through meta field

        ```js filename=hello-world.js
        console.log(42);
        ```
      
  • [x] support line highlighting through meta field

      ```js lines=[1,2-4]
      var name
      name = 'hello';
      console.log(name);
      console.log(42)
      ```
      

Use

import {remark} from 'remark';
import {remarkCodeBlock} from 'remark-code-block';
import js from 'refractor/lang/javascript.js';

// register any languages you want to apply syntax highlighting first
remarkCodeBlock.register(js);

remark().use(remarkCodeBlock);

Options

Option Type Default Description
enableLineNumbers boolean true Attach line numbers to span elements so you can show them through CSS

Package Sidebar

Install

npm i remark-code-block

Weekly Downloads

0

Version

0.1.1

License

MIT

Unpacked Size

13.1 kB

Total Files

15

Last publish

Collaborators

  • chenxsan