pc035860 / angular-highlightjs

AngularJS directive for syntax highlighting with highlight.js
http://pc035860.github.io/angular-highlightjs/example/
MIT License
294 stars 53 forks source link

Support custom initialization #51

Closed adaam2 closed 8 years ago

adaam2 commented 8 years ago

Apologies if this issue has been raised before, but I couldn't find it! The Highlight.js documentation (here) provides the below example for highlighting code that doesn't use <code> or <pre> tags:

$('div.code').each(function(i, block) {
  hljs.highlightBlock(block);
});

How can we do this in angular-highlightjs?

pc035860 commented 8 years ago

Hi @adaam2,

angular-highlightjs is just a set of directives, and the example you gave seems like you just need to call Highlight.js yourself. So I suggest that you can make your own directive with Highlight.js.

BTW, the Highlight.js is also available as an Angular service called hljsService. https://github.com/pc035860/angular-highlightjs/blob/master/src/angular-highlightjs.js#L20

And you can call hljsServiceProvider.setOptions in configuration phase to change some settings.

adaam2 commented 8 years ago

HI @pc035860 Thanks for the info, will look into that.