Autoloader plugin feature: Support callback
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 13k
- Forks
- 1.4k
- Avg merge
- 15h 36m
- Merged PRs (30d)
- 3
Description
Information:
- Prism version: 1.16.0
- Plugins: autoloader
- Environment: All environments
Description
Right now, the autoloader plugin has no way to signal it is done working. It downloads the language as expected and highlights the piece of the code, but it doesn't have a way to support a callback function for when it is done. As you can see in the source code:
https://github.com/PrismJS/prism/blob/be909b18faa0afa899bb71ac1ab1f06c499277ce/plugins/autoloader/prism-autoloader.js#L286
Example
import { highlightElement, plugins } from 'prismjs/components/prism-core';
import 'prismjs/plugins/autoloader/prism-autoloader';
plugins.autoloader.languages_path = `https://unpkg.com/prismjs@latest/components/`;
const code = this.root.querySelector('code');
highlightElement(code, false, () => {
alert('done highlighting');
});
In this example, the alert will show before actual highlighting is done, since the auto-loader plugin is still downloading the sources.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with plugins/autoloader/prism-autoloader.js around line 286 and trace how language downloads complete before highlighting. Define the callback timing so it runs only after the autoloader finishes and highlighting is complete, then verify the example no longer alerts early.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100