remark-react-lowlight
Syntax highlighting for remark-react through lowlight
Last updated 3 years ago by bebraw .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install remark-react-lowlight 
SYNC missed versions from official npm registry.

build status bitHound Score Dependency Status

remark-react-lowlight

Syntax highlighting for remark-react through lowlight

Usage:

...

import remark from 'remark';
import reactRenderer from 'remark-react';
import RemarkLowlight from 'remark-react-lowlight';

import js from 'highlight.js/lib/languages/javascript';

import githubSchema from 'hast-util-sanitize/lib/github.json';

const schema = Object.assign({}, githubSchema, {
  attributes: Object.assign({}, githubSchema.attributes, {
    code: [
      ...(githubSchema.attributes.code || []),
      'className'
    ]
  })
});

...
{remark().use(reactRenderer, {
  sanitize: schema,
  remarkReactComponents: {
    code: RemarkLowlight({
      js
    })
  }
}).processSync(readme).contents}
...

Notes

  • The default santization schema (GitHub's) excludes className, but we want those hljs-* classes for our highlighting! Hence the custom object passed to santization.
  • You'll need stylings for the classes that Highlight.js adds. You can choose from a bunch bunch of pre-made stylesheets.

Contributors

License

MIT.

Current Tags

  • 0.7.0                                ...           latest (3 years ago)

7 Versions

  • 0.7.0                                ...           3 years ago
  • 0.6.0                                ...           3 years ago
  • 0.4.1                                ...           4 years ago
  • 0.4.0                                ...           4 years ago
  • 0.3.0                                ...           4 years ago
  • 0.2.0                                ...           4 years ago
  • 0.1.0                                ...           5 years ago
Downloads
Today 0
This Week 1
This Month 3
Last Day 1
Last Week 2
Last Month 2
Dependencies (1)
Dev Dependencies (23)

Copyright 2014 - 2017 © taobao.org |