-
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
TypeError: Cannot read property 'tokenizePlaceholders' of undefined #1400
Comments
Thank you @mAAdhaTTah, that solves my problem. Updated example: const Prism = require('prismjs'),
loadLanguages = require('prismjs/components/index')
loadLanguages(['php', 'python'])
console.log('Available languages:')
console.log(JSON.stringify(Object.keys(Prism.languages)))
let code = 'just a string'
let lang = 'php'
lang = 'python'
console.log(`${lang}: "${Prism.highlight(code, Prism.languages[lang])}"`) |
For anyone who comes here and is not using node or Webpack, you have to include |
|
Thank you! |
It works! You saved my day! |
It would be really helpful if this was somehow visible in the docs. I just wasted fifteen minutes chasing down this error until stumbling upon the comment from @simpixelated ... |
@Radiergummi We don't have documentation for "manually importing language definitions" generally. I'd be interested in knowing more about your use case for this so we could address it that way. |
Isn't "manually importing language definitions" kind of a bad idea because you have to handle dependencies yourself? Isn't that one of the reasons we have the Autoloader? Also, You could then use the Autoloader like this:<script src="path/to/components/prism-core.min.js"></script>
<script src="path/to/plugins/autoloader/prism-autoloader.min.js"></script>
<script>
Prism.plugins.autoloader.enabled = false;
Prism.plugins.autoloader.loadLanguages(["php", "sql"], (languages) => {
console.log("Finished loading languages");
console.log('Available languages:');
console.log(JSON.stringify(Object.keys(Prism.languages)));
// use Prism as usual.
}, (erroredLanguage) => {
console.log("Failed to load: " + erroredLanguage);
});
</script> |
Yes–this is why I'm interested in the use case that caused them to head in that direction and see why our current solutions didn't work. |
@mAAdhaTTah I have lots of cases for internal dashboards, an exception handler, quick one-off things in general, where I'll just include files using script tags from cdnjs, without ever using a build pipeline. I wasn't aware of the autoloader though, so this is entirely my fault... I wasn't reading the documentation carefully enough. I'd like to apologize for the comment. |
@Radiergummi No worries! The intention is to have users build their own Prism via the download page, which handles all of that for you. We did also update the Autoloader to work with CDNs, so that should also help with your use case. |
Oh mann!! Saved my life. |
It works for me! Thank you so much. |
you are the hero we need |
修正 prism API 变更导致编译失败的问题 (PrismJS/prism#1400)
Automatically detect and download Prism language dependencies (some languages will not load correctly without them, e.g. [`php` requires `markup-templating`](PrismJS/prism#1400)). **Before ——** ![image](https://user-images.githubusercontent.com/44172267/229880541-9436a9fd-520b-43f8-b284-08db9971ea1d.png) ![image](https://user-images.githubusercontent.com/44172267/229880582-6ab702ea-80c6-4ebc-ac4f-6637e7be5153.png) **After ——** ![image](https://user-images.githubusercontent.com/44172267/229880475-aa604e16-1bef-4c78-9742-6c3fdf48536f.png)
Automatically detect and download Prism language dependencies (some languages will not load correctly without them, e.g. [`php` requires `markup-templating`](PrismJS/prism#1400)). **Before ——** ![image](https://user-images.githubusercontent.com/44172267/229880541-9436a9fd-520b-43f8-b284-08db9971ea1d.png) ![image](https://user-images.githubusercontent.com/44172267/229880582-6ab702ea-80c6-4ebc-ac4f-6637e7be5153.png) **After ——** ![image](https://user-images.githubusercontent.com/44172267/229880475-aa604e16-1bef-4c78-9742-6c3fdf48536f.png)
Hello,
When I use version 1.14.0 in node.js, I get an undefined error (which is not present when I use 1.13.0)
I would guess it is a problem with the php component. Can someone reproduce it?
example:
When I use [email protected] I receive this output:
If I remove the line
require('prismjs/components/prism-php')
, I get the desired output:I also get the same output if I use [email protected] instead
Maybe it was introduced with #1367 ?
Regards,
marc
The text was updated successfully, but these errors were encountered: