-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Exclude certain languages from highlighting altogether #2068
Comments
There is a |
@mAAdhaTTah, thanks. I was able to get it to work by doing the following: <script src="prism.js" data-manual></script> var elements = document.querySelectorAll('.highlighter-rouge:not(.language-mermaid) pre.highlight');
for (var element of elements) {
Prism.highlightElement(element, false);
} The problem is that it performs several times worse than Prism does out of the box without |
Can you elaborate on the performance degradation you're seeing? There isn't anything you're doing here that looks terribly different from what Prism does itself. |
Perhaps it's just me, but I find that my home-grown solution causes a very notable flash of un-highlighted code before Prism performs the highlight, while removing |
@asbjornu Chrome as a bit of an issue with large changes to the DOM (100 LOC add about 2000 new nodes). There is a workaround for this: Detach the
Sounds like asynchronous highlighting. Try passing
Nope. It's as dumb as it gets. |
Your assumptions are correct, @RunDevelopment. Even though that helps, It would be nice if Prism could be initialized with a CSS selector or array of elements (as a result from |
I against this because the resulting function will look something like this: function highlightElements(selectorOrElements: string | Iterable<Element>): void {
if (typeof selectorOrElements === 'string') {
selectorOrElements = document.querySelectorAll(selectorOrElements);
}
for (const element of selectorOrElements) {
Prism.highlightElement(element);
}
} I think that this is a function simple enough that we don't need to include it in our library.
I don't know the details of what you intend here but I guess that it's similar to #1761. I'll make a small plugin for this and ping you when it's done. |
Motivation
Prism's current behavior makes it impossible to use Prism and Mermaid on the same page.
Description
I'd like to have what the title in #558 says ("Ignore some html tags") and not what the provided solution does ("Preserve markup even after Prism has applied syntax highlighting"). The issue I'm facing is having both Mermaid and Prism on the same page and Prism just destroys Mermaid code blocks so Mermaid can't do anything sensible with it. Instead of preserving markup (which I suppose will also "fix" the problem), I'd like Prism to just not touch
.language-mermaid
elements. Is this not possible?Alternatives
I've searched around and found gaearon/gitbook-plugin-prism#28 which proves that there's a need for this feature and I can't think of a way to work around this. Had there only been a
Prism.highlightElements()
method that took a list of elements I could select and filter beforehand manually, I could have solved this myself. But since this method doesn't exist, I'm unable to fix this without learning how to develop a Prism plugin of some sort. And I find the Prism API documentation to be very sparse (the availablehooks
don't seem to be documented, for instance), I'm struggling to do so. Please help! 🙏 😃The text was updated successfully, but these errors were encountered: