Skip to content

Instantly share code, notes, and snippets.

@subudeepak
Last active May 16, 2017 09:56
Show Gist options
  • Save subudeepak/9645949 to your computer and use it in GitHub Desktop.
Save subudeepak/9645949 to your computer and use it in GitHub Desktop.
Angular Prettyprint with linenums
function replaceText(str)
{
var str1 = String(str);
return str1.replace(/\n/g,"<br/>");
}
app.directive('prettyprint', function() {
return {
restrict: 'C',
link: function postLink(scope, element, attrs) {
element.html(prettyPrintOne(replaceText(element.html()),'',true));
}
};
});
@capgunmedia
Copy link

Nice! Do you have an example of how this will look?

@subudeepak
Copy link
Author

Something like

<pre prettyprint>
blah blah
</pre>

should work

Ofcourse, you still need to use Google Prettify.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment