Skip to content

Commit

Permalink
upgrade deps, convert to TypeScript, and add "langs" option
Browse files Browse the repository at this point in the history
  • Loading branch information
hipstersmoothie committed Feb 14, 2021
1 parent 3ebaeab commit b27cf03
Show file tree
Hide file tree
Showing 7 changed files with 225 additions and 228 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ logs
npm-debug.log*
yarn-debug.log*
yarn-error.log*
dist

# Runtime data
pids
Expand Down
21 changes: 17 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ var shiki = require('rehype-shiki')
rehype()
.data('settings', {fragment: true})
.use(shiki)
.process(vfile.readSync('example.html'), function(err, file) {
.process(vfile.readSync('example.html'), function (err, file) {
console.error(report(err || file))
console.log(String(file))
})
Expand All @@ -46,10 +46,11 @@ Now, running `node example` yields:
example.html: no issues found
<h1>Hello World!</h1>

<pre style="background: #2e3440"><code class="language-js"><span style="color: #81A1C1">var</span><span style="color: #D8DEE9FF"> </span><span style="color: #D8DEE9">name</span><span style="color: #D8DEE9FF"> </span><span style="color: #81A1C1">=</span><span style="color: #D8DEE9FF"> </span><span style="color: #ECEFF4">"</span><span style="color: #A3BE8C">World</span><span style="color: #ECEFF4">"</span><span style="color: #81A1C1">;</span>
<pre
style="background: #2e3440"
><code class="language-js"><span style="color: #81A1C1">var</span><span style="color: #D8DEE9FF"> </span><span style="color: #D8DEE9">name</span><span style="color: #D8DEE9FF"> </span><span style="color: #81A1C1">=</span><span style="color: #D8DEE9FF"> </span><span style="color: #ECEFF4">"</span><span style="color: #A3BE8C">World</span><span style="color: #ECEFF4">"</span><span style="color: #81A1C1">;</span>
<span style="color: #8FBCBB">console</span><span style="color: #ECEFF4">.</span><span style="color: #88C0D0">warn</span><span style="color: #D8DEE9FF">(</span><span style="color: #ECEFF4">"</span><span style="color: #A3BE8C">Hello, </span><span style="color: #ECEFF4">"</span><span style="color: #D8DEE9FF"> </span><span style="color: #81A1C1">+</span><span style="color: #D8DEE9FF"> </span><span style="color: #D8DEE9">name</span><span style="color: #D8DEE9FF"> </span><span style="color: #81A1C1">+</span><span style="color: #D8DEE9FF"> </span><span style="color: #ECEFF4">"</span><span style="color: #A3BE8C">!</span><span style="color: #ECEFF4">"</span><span style="color: #D8DEE9FF">)</span>
</code></pre>

```

## API
Expand All @@ -58,7 +59,7 @@ example.html: no issues found

Apply syntax highlighting to `pre > code` using [**shiki**][shiki]; which tokenises the code block and new [**hast**][hast] nodes are subsequently created from (using this plugin).

Configure the language by using the `language-foo` class on the `code` element. For example;
Configure the language by using the `language-foo` class on the `code` element. For example;

```html
<pre><code class="language-js">console.log("Hello world!")</code></pre>
Expand All @@ -78,6 +79,18 @@ This is in respect to the [mdast-util-to-hast code handler](https://github.com/s

`boolean`, default: `true` - Whether to apply the background theme colour to the `pre` element.

##### `options.langs`

`ILanguageRegistration[]`, default: `[]` - Languages other than the default languages to load into shiki

```json
{
"id": "rockstar",
"scopeName": "source.rockstar",
"path": "./rockstar.tmLanguage.json" // or `plist`
}
```

## License

[MIT][license] © [@rsclarke][rsclarke]
Expand Down
120 changes: 0 additions & 120 deletions index.js

This file was deleted.

0 comments on commit b27cf03

Please sign in to comment.