John Linquist example
http://angularjs.org/
HTML
<script src="https://raw.github.com/coreyti/showdown/master/compressed/showdown.js"></script>
<link rel="stylesheet" href="http://twitter.github.com/bootstrap/assets/css/bootstrap.css">
<script src="http://code.angularjs.org/1.0.1/angular-1.0.1.js"></script>
<div ng-controller="Main">
<markdown model="theContent"></markdown>
</div>
JavaScript
function Main($scope) {
$scope.theContent = '#asgakfgajgfas\n##akfaljfqpo\ndhvkajvlbndvm';
};
angular.module('myApp', [])
.directive("markdown", function ($compile) {
return {
restrict: 'E',
require: 'model',
scope: {
value: "=model"
},
template: '<div ng-bind-html-unsafe="value | markdown"></div>'
};
}).filter('markdown', function () {
var converter = new Showdown.converter();
return function (value) {
return converter.makeHtml(value || '');
};
});