PrismJS / PrismJS/prism

Autoloader: Add plugin support

Open
#2,748 0 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement plugins
Dominant language
JavaScript
Stars
13k
Forks
1.4k
Avg merge
15h 36m
Merged PRs (30d)
3

Description

Motivation
Autoloader can be used to load languages but not plugins. This is a problem because plugins, like languages, can have dependencies.

Right now, Autoloader is the only officially provided tool that supports CDNs.

Description
Add an API to Autoloader that allows users to load plugins as well. A data-* attribute API should also be supported.

As for the actual functions: I'd like to propose this API:

Prism.plugins.autoloader.loadPlugins(
  plugins: string | PluginInfo | (string | PluginInfo)[],
  successCallback: () => void,
  errorCallbackl: () => void
): void;

interface PluginInfo {
  id: string;
  /** A record of `data-*` attributes added to the `<script>` tag of the plugin. */
  data?: Record<string, string>;
}

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the Autoloader documentation linked in the issue and inspecting the existing language-loading API. Determine how plugin dependencies and script data-* attributes should fit the proposed loadPlugins API; the work is done when plugins can be loaded through the API and the data-* attribute interface is supported.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.