question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Exclude certain languages from highlighting altogether

See original GitHub issue

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 available hooks don’t seem to be documented, for instance), I’m struggling to do so. Please help! 🙏 😃

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
RunDevelopmentcommented, Sep 26, 2019

[…] if Prism could be initialized with a CSS selector or array of elements (as a result from document.querySelectorAll())

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.

to configure a set of white-listed languages

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.

0reactions
asbjornucommented, Sep 26, 2019

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 document.querySelectorAll()) or (as in highlight.js) the ability to configure a set of white-listed languages Prism should highlight, alternatively black-list the languages it should not highlight.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Mode Reference — highlight.js 11.7.0 documentation
When the parser finds an illegal match it may immediately stop parsing the whole language altogether (see ignoreIllegals ). Smart use of illegal...
Read more >
Possible to disable spell checking in OneNote for a specific ...
Choose Review > Language > Set Proofing Language; Choose the language; Close the Proofing Language Sidebar. Process 2: select the text with the...
Read more >
Filtering Data - Tableau Help
Right-click (Control-click on Mac) the mark or header, and then click Keep Only or Exclude. Using filter cards. Filters are cards on the...
Read more >
VS Code: enable inline spell checker, but disable spell check ...
I use the code spell checker for VS Code. I would like to disable the spell checker warnings/errors in the "PROBLEMS" panel (standard...
Read more >
ReSharper - Configure code inspection settings - JetBrains
This option lets you enable or disable ReSharper syntax highlighting scheme. If it is selected, language identifiers are highlighted with colors as defined...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found