Skip to content
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

document highlight not working #2562

Closed
troy351 opened this issue Sep 18, 2020 · 5 comments
Closed

document highlight not working #2562

troy351 opened this issue Sep 18, 2020 · 5 comments

Comments

@troy351
Copy link

troy351 commented Sep 18, 2020

Information:

  • Prism version: 1.21.0
  • Plugins: 'none'
  • Environment: Chrome 85

Description
According to #1541 , @param in jsdoc should be highlighted, but it's not.

Example
image

https://codepen.io/troy351/pen/rNeZErz

@troy351
Copy link
Author

troy351 commented Sep 18, 2020

fixed by adding two languages <code class="language-js language-jsdoc">, is this the right way to do it?

@RunDevelopment
Copy link
Member

Since you're using Autoloader, you have to use the data-dependencies attribute: <pre class="language-js" data-dependencies="jsdoc"><code>...</code></pre>

Specifying multiple language-xxxx classes causes undefined behavior AFAIK. No idea why it worked in your example but it's not intentional.

@troy351
Copy link
Author

troy351 commented Sep 18, 2020

Thanks for the explanation. Does this feature in the docs?
I have another question, if I use prism.highlight, how to add jsdoc support?

@RunDevelopment
Copy link
Member

if I use prism.highlight, how to add jsdoc support?

JSDoc will add itself to JavaScript as soon as it is loaded. This means you just have to ensure that both JS and JSDoc are loaded. (This is all data-dependencies does actually. It ensures that these languages are loaded before highlighting the code block.)

Please keep in mind that load order is important, so please don't load languages by their files directly. Always use either Autoloader, loadLanguages, or our babel plugin.

Does this feature in the docs?

I'm not sure what you mean by that.

@troy351
Copy link
Author

troy351 commented Sep 18, 2020

Thanks again, I'll try that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants