Share markdown angular filter via client.js

This commit is contained in:
Johannes Zellner
2020-07-10 15:20:53 +02:00
parent 48983879ab
commit 8b160cbbfd
8 changed files with 42 additions and 18 deletions

View File

@@ -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