highlight.js on CDN

Published | Go Back

high­light.js is a pop­u­lar li­brary for syn­tax high­light­ing. I just fig­ured out how to use its CDN ver­sion.

According to the down­load in­struc­tions, there is a hosted ver­sion of high­light.js. It is a pre­built ver­sion with 23 com­monly used lan­guages. I was try­ing to high­light Vim script, which was not in­cluded. After search­ing on the Internet, I found it on cd­njs. Every sup­port­ing lan­guage was listed, so I down­loaded the one for Vim script (languages/vim.min.js) im­me­di­ately and started test­ing. It was not work­ing be­cause hljs” was not de­fined.

It took me a while to re­al­ize the struc­ture of those js files. The one I down­loaded for Vim script was merely an ad­don. In other words, I still needed the file high­light.min.js as a base. After ref­er­enc­ing both of them, Vim script high­light­ing fi­nally worked.