I have a pastebin-like app. I want to be able to paste in code, and output the code to a user, with some highlightings and other fanciness. The code can be of ANY language. I use google's prettify.js for this.
The code is saved in a db as a string. Heres how i get the data:
$http.get('/paste/' + $scope.paste).success(getCallback);
var getCallback = function(data) {
setTimeout(function() {
$scope.paste = data[0].code;
$scope.$apply();
}, 0);
};
So far so good. When i want to apply some highlighting to the pasted code i have done this.
app.filter('pretty', function() {
return function(text) {
// a method in the prettify.js
return prettyPrintOne(text, '', true);
};
});
And i apply it like this:
<pre ng-bind-html="paste|pretty"></pre>
The result is a nice-looking paste. However the angular sanitizer fails when theres tags like <?php
of similar that it does not understand, or tags that are pure html elements <div>
So how could i bind the expression with the html formatting to the paste.
If i only do ng-bind
i actually get the correct data showing, including tags like <?php
(in html comments?) but the formatting goes out of the window.