Skip to content

Instantly share code, notes, and snippets.

@cggaurav
Created June 7, 2013 17:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cggaurav/5731024 to your computer and use it in GitHub Desktop.
Save cggaurav/5731024 to your computer and use it in GitHub Desktop.
toString errors
.filter('highlight', function() {
return function(text) {
if (text.toString().length > 0 && !_.isUndefined(text) && !_.isNull(text)) {
return text.toString().
replace(/&/g, '&').
replace(/</g, '&lt;').
replace(/>/g, '&gt;').
replace(/\r?\n/g, '<br/>').
replace(/@start-highlight@/g, '<code class="highlight">').
replace(/@end-highlight@/g, '</code>')
}
return '';
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment