Skip to content

TypeError: Cannot read property 'tokenizePlaceholders' of undefined #1400

Description

@marc136

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions