Share markdown angular filter via client.js
This commit is contained in:
@@ -87,6 +87,24 @@ angular.module('Application').filter('prettyDiskSize', function () {
|
||||
return function (size, fallback) { return prettyByteSize(size, fallback) || 'Not available yet'; }
|
||||
});
|
||||
|
||||
angular.module('Application').filter('markdown2html', function () {
|
||||
var converter = new showdown.Converter({
|
||||
extensions: [ 'targetblank' ],
|
||||
simplifiedAutoLink: true,
|
||||
strikethrough: true,
|
||||
tables: true
|
||||
});
|
||||
|
||||
// without this cache, the code runs into some infinite loop (https://github.com/angular/angular.js/issues/3980)
|
||||
var cache = {};
|
||||
|
||||
return function (text) {
|
||||
if (cache[text]) return cache[text];
|
||||
cache[text] = converter.makeHtml(text);
|
||||
return cache[text];
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
// ----------------------------------------------
|
||||
// Cloudron REST API wrapper
|
||||
|
||||
Reference in New Issue
Block a user