Skip to content

Instantly share code, notes, and snippets.

@EpokK
Created August 12, 2013 06:15
Show Gist options
  • Save EpokK/6208597 to your computer and use it in GitHub Desktop.
Save EpokK/6208597 to your computer and use it in GitHub Desktop.
markdown directive with Showdown
myApp.directive('markdown', function () {
var converter = new Showdown.converter();
return {
restrict: 'AE',
link: function (scope, element, attrs) {
if (attrs.markdown) {
scope.$watch(attrs.markdown, function (newVal) {
var html = converter.makeHtml(newVal);
element.html(html);
});
} else {
var html = converter.makeHtml(element.text());
element.html(html);
}
}
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment