Skip to content
This repository was archived by the owner on Apr 16, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"workbench.colorCustomizations": {
"terminal.foreground": "#fff",
"terminal.background": "#000"
}
}
19 changes: 14 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# @mapbox/rehype-prism
# rehype-prism-2

[![Build Status](https://travis-ci.com/mapbox/rehype-prism.svg?branch=main)](https://travis-ci.com/mapbox/rehype-prism)

Expand All @@ -12,7 +12,7 @@ If you would like to perform syntax highlighting *in the browser*, you should lo
## Installation

```
npm install @mapbox/rehype-prism
npm install rehype-prism-2
```

## API
Expand All @@ -38,6 +38,13 @@ By default, if `{name}` does not correspond to a [language supported by refracto

If you would like to silently skip `<code>` elements with invalid languages, set this option to `true`.

#### options.syntax

Type: `refractor.RefractorSyntax`.
Default: `undefined`.

Provide a syntax that's to be [registered] by refactor.

#### options.alias

Type: `Record<string, string | string[]>`.
Expand All @@ -53,7 +60,7 @@ Some examples of how you might do that:

```js
const rehype = require('rehype');
const rehypePrism = require('@mapbox/rehype-prism');
const rehypePrism = require('rehype-prism-2');

rehype()
.use(rehypePrism)
Expand All @@ -63,7 +70,7 @@ rehype()
```js
const unified = require('unified');
const rehypeParse = require('rehype-parse');
const rehypePrism = require('@mapbox/rehype-prism');
const rehypePrism = require('rehype-prism-2');

unified()
.use(rehypeParse)
Expand All @@ -77,7 +84,7 @@ If you'd like to get syntax highlighting in Markdown, parse the Markdown (with r
const unified = require('unified');
const remarkParse = require('remark-parse');
const remarkRehype = require('remark-rehype');
const rehypePrism = require('@mapbox/rehype-prism');
const rehypePrism = require('rehype-prism-2');

unified()
.use(remarkParse)
Expand Down Expand Up @@ -113,3 +120,5 @@ unified()
[language supported by refractor]: https://github.com/wooorm/refractor#syntaxes

[aliases]: https://github.com/wooorm/refractor#refractoraliasname-alias

[registered]: https://github.com/wooorm/refractor#refractorregistersyntax
4 changes: 4 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ const refractor = require('refractor');
module.exports = (options) => {
options = options || {};

if (options.syntax) {
Comment thread
mertyildiran marked this conversation as resolved.
refractor.register(options.syntax);
}

if (options.alias) {
refractor.alias(options.alias);
}
Expand Down
Loading