angular-highlightjs
angular-highlightjs copied to clipboard
dependency on highlight.js issue
as this module has dependency on highlight.js, if I install highlight.js via npm and give the path of the js file created under node_modules and install angular-highlightjs via npm/bower, it does not highlight any content. but if I use the cdn copy of highlight.js or build it locally myself, then it highlights content very well. What is the issue here?
@a-birla Can you provide error messages for the node_modules
setup?
Did it bundle highlight.js
package correctly?
in the highlight.js package, I have one highlight.js file inside lib folder. If I reference that in my script, it does not apply any highlighting. There are errors when I try to use
Uncaught Error: Unknown language: "bash" at Object.highlight (concat_vendor.js?t=1506575342991:494) at Object.j._highlight (concat_vendor.js?t=1506575342991:57380) at h (concat_vendor.js?t=1506575342991:57380)
Also I checked the highlight.js file on https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.3/highlight.min.js is very different from what is downloaded when I do npm install highlight.js

@a-birla CDN version might already have languages registered. Looks like npm
version has the languages registered in libs/index.js
.
Usually you'll require highlight.js
with
const hljs = require('highlight.js');
// This actually point to require('./path/to/node_modules/highlight.js/lib/index.js')
// which is defined in `package.json` key `main`
rather than require('./path/to/node_modules/highlight.js/lib/highlight.js');
So in the gulp task where we are concatenating all node modules js files, we give the path only for Index.js and not highlight.js?
On Sep 27, 2017, at 11:10 PM, Chih-Hsuan Fan [email protected] wrote:
@a-birla CDN version might already have languages registered. Looks like npm version has the languages registered in libs/index.js.
Usually you'll require highlight.js with
const hljs = require('highlight.js'); // This actually point to require('./path/to/node_modules/highlight.js/lib/index.js') // which is defined in
package.json
keymain
rather than require('./path/to/node_modules/highlight.js/lib/highlight.js');— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.
So you're using gulp to concatenate js files rather than bundlers like webpack, rollup etc?
Try node_modules/highlight.js/lib/index.js
then.
no that is not working either. If I only reference index.js, getting this error
Uncaught ReferenceError: require is not defined
It seems that the npm version still requires a build procress to work if you're not using a CommonJS compatible bundler.
I'd suggest just use the CDN version or integrate the highlight.js build process into your gulp task.
if you are using highlight.js
npm repository, try changing it to highlightjs
repository. Worked for me.
https://www.npmjs.com/package/highlightjs