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

Allow passing in pre-existing highlighter #211

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

shivjm
Copy link

@shivjm shivjm commented May 23, 2021

I’m adapting an Eleventy codebase to use remark, so I set up remark-prism. Here is the build time without it:

Wrote 147 files in 7.43 seconds (50.5ms each, v0.12.1)

And then with the plugin:

Wrote 147 files in 39.14 seconds (266.3ms each, v0.12.1)

(Not all files need to run the plugin. It was 450–500ms per file where the plugin was called.)

I saw most of the time was spent in creating the highlighter. This PR makes it possible to pass one in so it doesn’t create a new one each time, like so:

import createHighlighter from "remark-prism/src/highlight";

// when configuring remark…
const highlighter = createHighlighter({});

// …
      {
        plugin: "remark-prism",
        options: {
          highlighter: highlight,
        },
      },
// …

With the change, my build times went back down to normal:

Wrote 147 files in 8.10 seconds (55.1ms each, v0.12.1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant