Skip to content
This repository was archived by the owner on Apr 16, 2024. It is now read-only.
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: mapbox/rehype-prism
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.7.0
Choose a base ref
...
head repository: mapbox/rehype-prism
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v0.8.0
Choose a head ref
  • 7 commits
  • 9 files changed
  • 3 contributors

Commits on Aug 12, 2021

  1. Bump path-parse from 1.0.6 to 1.0.7 (#26)

    Bumps [path-parse](https://github.com/jbgutierrez/path-parse) from 1.0.6 to 1.0.7.
    - [Release notes](https://github.com/jbgutierrez/path-parse/releases)
    - [Commits](https://github.com/jbgutierrez/path-parse/commits/v1.0.7)
    
    ---
    updated-dependencies:
    - dependency-name: path-parse
      dependency-type: indirect
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    dependabot[bot] authored Aug 12, 2021

    Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    radovanradic Radovan Radic
    Copy the full SHA
    f089ab1 View commit details

Commits on Sep 21, 2021

  1. Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    radovanradic Radovan Radic
    Copy the full SHA
    0046890 View commit details
  2. Bump semver-regex from 3.1.2 to 3.1.3 (#30)

    Bumps [semver-regex](https://github.com/sindresorhus/semver-regex) from 3.1.2 to 3.1.3.
    - [Release notes](https://github.com/sindresorhus/semver-regex/releases)
    - [Commits](https://github.com/sindresorhus/semver-regex/commits)
    
    ---
    updated-dependencies:
    - dependency-name: semver-regex
      dependency-type: indirect
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    dependabot[bot] authored Sep 21, 2021

    Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    radovanradic Radovan Radic
    Copy the full SHA
    fb41376 View commit details
  3. Bump tmpl from 1.0.4 to 1.0.5 (#31)

    Bumps [tmpl](https://github.com/daaku/nodejs-tmpl) from 1.0.4 to 1.0.5.
    - [Release notes](https://github.com/daaku/nodejs-tmpl/releases)
    - [Commits](https://github.com/daaku/nodejs-tmpl/commits/v1.0.5)
    
    ---
    updated-dependencies:
    - dependency-name: tmpl
      dependency-type: indirect
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    dependabot[bot] authored Sep 21, 2021

    Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    radovanradic Radovan Radic
    Copy the full SHA
    0d5860a View commit details
  4. Update devDependencies

    Katy DeCorah committed Sep 21, 2021

    Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    radovanradic Radovan Radic
    Copy the full SHA
    ddbd86f View commit details
  5. Prepare 0.8.0

    Katy DeCorah committed Sep 21, 2021

    Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    radovanradic Radovan Radic
    Copy the full SHA
    ce9e1b1 View commit details
  6. 0.8.0

    Katy DeCorah committed Sep 21, 2021

    Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    radovanradic Radovan Radic
    Copy the full SHA
    fb4174f View commit details
Showing with 2,464 additions and 830 deletions.
  1. +1 −0 .husky/.gitignore
  2. +4 −0 .husky/pre-commit
  3. +4 −0 CHANGELOG.md
  4. +9 −0 README.md
  5. +9 −0 __snapshots__/test.js.snap
  6. +4 −0 index.js
  7. +2,406 −818 package-lock.json
  8. +13 −12 package.json
  9. +14 −0 test.js
1 change: 1 addition & 0 deletions .husky/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx lint-staged
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 0.8.0

- Add `alias` option to support aliases in refractor.

## 0.7.0

- Update dependencies: refractor@3.4.0, eslint, jest, and prettier.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.alias

Type: `Record<string, string | string[]>`.
Default: `undefined`.

Provide [aliases] to refractor to register as alternative names for a language.

## Usage

Use this package [as a rehype plugin](https://github.com/rehypejs/rehype/blob/master/doc/plugins.md#using-plugins).
@@ -104,3 +111,5 @@ unified()
[refractor]: https://github.com/wooorm/refractor

[language supported by refractor]: https://github.com/wooorm/refractor#syntaxes

[aliases]: https://github.com/wooorm/refractor#refractoraliasname-alias
9 changes: 9 additions & 0 deletions __snapshots__/test.js.snap
Original file line number Diff line number Diff line change
@@ -18,4 +18,13 @@ exports[`handles uppercase languages correctly 1`] = `
</div>"
`;
exports[`with options.alias it can highlight language aliases 1`] = `
"<pre class=\\"language-vue\\"> <code class=\\"language-vue\\">
<span class=\\"token tag\\"><span class=\\"token tag\\"><span class=\\"token punctuation\\">&#x3C;</span>script</span> <span class=\\"token attr-name\\">setup</span><span class=\\"token punctuation\\">></span></span><span class=\\"token script\\"><span class=\\"token language-javascript\\">
<span class=\\"token keyword\\">const</span> id <span class=\\"token operator\\">=</span> <span class=\\"token number\\">7</span>
</span></span><span class=\\"token tag\\"><span class=\\"token tag\\"><span class=\\"token punctuation\\">&#x3C;/</span>script</span><span class=\\"token punctuation\\">></span></span>
</code>
</pre>"
`;
exports[`with options.ignoreMissing, does nothing to code block with fake language- class 1`] = `"<pre class=\\"language-thisisnotalanguage\\"><code class=\\"language-thisisnotalanguage\\">p { color: red }</code></pre>"`;
4 changes: 4 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -7,6 +7,10 @@ const refractor = require('refractor');
module.exports = (options) => {
options = options || {};

if (options.alias) {
refractor.alias(options.alias);
}

return (tree) => {
visit(tree, 'element', visitor);
};
Loading