Skip to content

Instantly share code, notes, and snippets.

@fannheyward
Forked from EpokK/markdown.js
Created August 16, 2013 01:43
Show Gist options
  • Save fannheyward/6246547 to your computer and use it in GitHub Desktop.
Save fannheyward/6246547 to your computer and use it in GitHub Desktop.
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