Refactored text panel to use markdown

This commit is contained in:
Rashid Khan
2013-03-05 15:31:46 -07:00
parent 8a521f2a7b
commit c586cbf3d6
4 changed files with 32 additions and 8 deletions
+26 -6
View File
@@ -12,6 +12,26 @@ angular.module('kibana.text', [])
$scope.init = function() {
}
}).directive('markdown', function() {
return {
restrict: 'E',
link: function(scope, element, attrs) {
scope.$on('render', function() {
render_panel();
})
function render_panel() {
var scripts = $LAB.script("panels/text/lib/showdown.js")
scripts.wait(function(){
var converter = new Showdown.converter();
var htmlText = converter.makeHtml(scope.panel.content);
element.html(htmlText);
});
}
render_panel();
}
}
})
.filter('newlines', function(){
return function (input) {
@@ -19,10 +39,10 @@ angular.module('kibana.text', [])
}
})
.filter('striphtml', function () {
return function(text) {
return text
.replace(/&/g, '&')
.replace(/>/g, '>')
.replace(/</g, '&lt;');
}
return function(text) {
return text
.replace(/&/g, '&amp;')
.replace(/>/g, '&gt;')
.replace(/</g, '&lt;');
}
});