I'm trying to get syntax highlighting for all code elements inside a dynamically added html which will be added to the current page with ng-bind-html.
<div ng-repeat="activity in activities">
<h3>{{activity.title}}</h3>
<div ng-bind-html="activity.text">
</div>
</div>
The activity.text variable contains something like this:
<p>This is a paragraph with some code following.</p>
<pre><code class="lang-python">
s = "Python syntax highlighting"
print s
</code></pre>
<p>some other HTML elements </p>
This works so far but without syntax highlighting. So I've added highlightjs and angular-highlightjs. I've changed <div ng-bind-html="activity.text"> to <div hljs ng-bind-html="activity.text">
The problem now is that combining the ng-bind-html and the hljs directives is not working as expected.
It does not add syntax highlighting to the code tag (pre code) but to the whole html content.
Is there a better way to get syntax highlighting for dynamically added content?