Autoloader plugin feature: Support callback
See original GitHub issueInformation:
- 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.
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (5 by maintainers)
Top Results From Across the Web
How To Use Autoloading And A Plugin Container In ...
We will walk through the steps of creating a plugin and investigate the use of autoloading and a plugin container.
Read more >Using Namespaces and Autoloading in WordPress Plugins ...
So in this tutorial, we're going to put all of the pieces together. Specifically, we're going to revisit the source code of our...
Read more >Plugins - Avisynth wiki
1 LoadPlugin · 2 LoadCPlugin · 3 LoadVirtualDubPlugin · 4 LoadVFAPIPlugin · 5 Plugin Autoload and Name Precedence · 6 Plugin Autoload and...
Read more >Automatic class loading - MoodleDocs
This document describes how to use the functionality of the ... only should be used for existing code or APIs not supporting autoloading....
Read more >Loading class files via autoload method
Perhaps show the code you are using in your autoloader - doing this from a namespace in a plugin is both possible and...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
A hook for that seems like a viable path forward. Will take a look at that.
Autoloader loads language definitions and then highlights the element again, so I think that the current behavior of Prism, while not ideal, is correct.
It wouldn’t be too hard to implement as Autoloader-specific solution but we have other plugins that are also implemented by re-highlighting elements, so I’d personally prefer a unified solution. Thoughts? @mAAdhaTTah @Golmote
@nicojs Also, fetching some languages might fail. How should Prism behave in that case?