Skip to content

A remark plugin supporting syntax highlight, filename, line highlight for code block

License

Notifications You must be signed in to change notification settings

chenxsan/remark-code-block

Repository files navigation

Remark code block

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

  • support filename through meta field

        ```js filename=hello-world.js
        console.log(42);
        ```
      
  • 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

About

A remark plugin supporting syntax highlight, filename, line highlight for code block

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published