angular-highlightjs icon indicating copy to clipboard operation
angular-highlightjs copied to clipboard

head and body html tags not showed

Open Splact opened this issue 9 years ago • 1 comments

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

Splact avatar Dec 30 '15 21:12 Splact

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>

pc035860 avatar Jan 28 '16 04:01 pc035860