Node.js Prism.js Example to Highlight Source Code Syntax Using node-prismjs Library in Javascript Full Project For Beginners

 

 

npm i node-prismjs

 

 

 

index.js

 

 

const Prism = require('node-prismjs');
function highlight(lang, sourceCode) {
  const language = Prism.languages[lang] || Prism.languages.autoit;
  return Prism.highlight(sourceCode, language);
}

console.log(highlight("javascript","var i=0;"))

Leave a Reply