Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upgrade deps, convert to TypeScript, and add "langs" option #50

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
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
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.

Loading