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

Uncaught TypeError: Cannot read property 'tokenizePlaceholders' of undefined #1423

Closed
jwillmer opened this issue May 15, 2018 · 8 comments
Closed
Assignees

Comments

@jwillmer
Copy link

I updated prism to 1.14.0 because I needed to support another language and since then I get the following error on my page:

prism.js:formatted:1119 Uncaught TypeError: Cannot read property 'tokenizePlaceholders' of undefined
    at prism.js:formatted:1119
    at Object.run (prism.js:formatted:249)
    at Object.highlight (prism.js:formatted:154)
    at Object.highlightElement (prism.js:formatted:139)
    at Object.highlightAllUnder (prism.js:formatted:97)
    at HTMLDocument.highlightAll (prism.js:formatted:88)

If I follow prism.jsformatted:1119 I get to the following code:

e.hooks.add("after-tokenize", function(n) {
   e.languages["markup-templating"].tokenizePlaceholders(n, "php")
})
@Golmote
Copy link
Contributor

Golmote commented May 16, 2018

You need to include the markup-templating component in your code. See related #1395 and #1400.

@Golmote Golmote closed this as completed May 16, 2018
@jwillmer
Copy link
Author

What is markup-templating? The website says I only need to add the js and css to my website in order to work. Is the website wrong or is the current version broken?

@Golmote
Copy link
Contributor

Golmote commented May 16, 2018

How did you download Prism? And what language are you highlighting?

markup-templating is a component just like c-like or any other language definition. It is required for several languages to be highlighted properly.

@jwillmer
Copy link
Author

jwillmer commented May 16, 2018

I use the following link to get the css and js:
http://prismjs.com/download.html?#themes=prism&languages=markup+css+clike+javascript+c+csharp+bash+batch+cpp+aspnet+arduino+coffeescript+ruby+git+java+json+less+objectivec+php+powershell+python+scss&plugins=line-highlight+line-numbers

I implement it in a static web site by referencing the css and js file. I highlight Arduino code.

Interestingly adding the markup-templating to my selection fixes the problem. But that looks more like a workaround then a solution.

@Golmote
Copy link
Contributor

Golmote commented May 16, 2018

Hm, it seems the Download page fails to handle cases with multiple dependencies, when specified from the redownload URL. I'll take a look, thanks for reporting.

@Golmote Golmote self-assigned this May 16, 2018
@Golmote
Copy link
Contributor

Golmote commented May 16, 2018

It should be fixed with c2ff248. Can you please try to redownload Prism using the same link you posted above? You should see that the checkbox "Markup templating" is automatically checked now.

@jwillmer
Copy link
Author

Now it works, thank you!

@Volmarg
Copy link

Volmarg commented Aug 30, 2020

In my case I had this
import Prism from 'prismjs';

should've been:

import * as Prism from 'prismjs';

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

3 participants