Solvedprism TypeError: Cannot read property 'tokenizePlaceholders' of undefined

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:

const Prism = require('prismjs')
require('prismjs/components/prism-php')
require('prismjs/components/prism-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])}"`)

When I use prismjs@1.14.0 I receive this output:

Available languages:
["extend","insertBefore","DFS","markup","xml","html","mathml","svg","css","clike","javascript","js","php","python"]
D:\test\node_modules\prismjs\components\prism-php.js:121
                Prism.languages['markup-templating'].tokenizePlaceholders(env, 'php');
                                                     ^

TypeError: Cannot read property 'tokenizePlaceholders' of undefined
    at D:\test\node_modules\prismjs\components\prism-php.js:121:40
    at Object.run (D:\test\node_modules\prismjs\prism.js:456:5)
    at Object.highlight (D:\test\node_modules\prismjs\prism.js:287:11)
    at Object.<anonymous> (D:\test\problem.js:13:32)
    at Module._compile (module.js:660:30)
    at Object.Module._extensions..js (module.js:671:10)
    at Module.load (module.js:573:32)
    at tryModuleLoad (module.js:513:12)
    at Function.Module._load (module.js:505:3)
    at Function.Module.runMain (module.js:701:10)

If I remove the line require('prismjs/components/prism-php'), I get the desired output:

Available languages:
["extend","insertBefore","DFS","markup","xml","html","mathml","svg","css","clike","javascript","js","python"]
python: "just a string"

I also get the same output if I use prismjs@1.13.0 instead

Maybe it was introduced with #1367 ?

Regards,
marc

16 Answers

✔️Accepted Answer

For anyone who comes here and is not using node or Webpack, you have to include prismjs/components/prism-markup-templating.js before prismjs/components/prism-php.js to fix the error in this issue.

Other Answers:

For anyone who comes here and is not using node or Webpack, you have to include prismjs/components/prism-markup-templating.js before prismjs/components/prism-php.js to fix the error in this issue.
it works! thx a lot!

Related Issues:

88
prism TypeError: Cannot read property 'tokenizePlaceholders' of undefined
For anyone who comes here and is not using node or Webpack Hello When I use version 1.14.0 in node.j...
23
prism Using non-default Prism languages with Webpack
I figured it out by using this: Prism is pretty stupid on resolving dynamic dependencies First prism...