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

head and body html tags not showed #56

Open Splact opened 8 years ago

Splact commented 8 years ago

When I set the language as HTML, any "html", "head" and "body" tags are not showed when parsed. Any tips? This pen is just an example of the problem http://codepen.io/anon/pen/WroLBM

pc035860 commented 8 years ago

Hi, sorry for the late response.

You can't use pure hljs directive to highlight HTML code with special tags like html, head, body, since the content of hljs will be parsed by browser before AngularJS even get bootstrapped.

Use either hljs-source or hljs-include to ensure the code doesn't get parsed by browser.

<div hljs hljs-include="'html-source-code'"></div>

<script id="html-source-code" type="text/ng-template">
<head><title>fooo</title></head><h1 haha="noob">LOL</h1>
</script>