@web-atoms/core
Version:
33 lines (32 loc) • 1.65 kB
JavaScript
System.register(["tslib", "../../di/DISingleton"], function (_export, _context) {
"use strict";
var __decorate, DISingleton, MarkdownService_1, regExps, MarkdownService;
return {
setters: [function (_tslib) {
__decorate = _tslib.__decorate;
}, function (_diDISingleton) {
DISingleton = _diDISingleton.default;
}],
execute: function () {
regExps = [[/(\_{3})([^\_]+)(\_{3})/gmi, "<strong><em>$2</em></strong>"], [/(\_{2})([^\_]+)(\_{2})/gmi, "<strong>$2</strong>"], [/(\_{1})([^\_]+)(\_{1})/gmi, "<em>$2</em>"], [/(\*{3})([^\*]+)(\*{3})/gmi, "<strong><em>$2</em></strong>"], [/(\*{2})([^\*]+)(\*{2})/gmi, "<strong>$2</strong>"], [/(\*{1})([^\*]+)(\*{1})/gmi, "<em>$2</em>"], [/(\#{5})\s([^\n]+)/gmi, "<h5>$2</h5>"], [/(\#{4})\s([^\n]+)/gmi, "<h4>$2</h4>"], [/(\#{3})\s([^\n]+)/gmi, "<h3>$2</h3>"], [/(\#{2})\s([^\n]+)/gmi, "<h2>$2</h2>"], [/(\#{1})\s([^\n]+)/gmi, "<h1>$2</h1>"], [/\n+/gmi, t => `<br/>`]];
MarkdownService = MarkdownService_1 = class MarkdownService {
toHtml(text) {
for (const iterator of regExps) {
const reg = iterator[0];
if (iterator.length === 2) {
const re = iterator[1];
if (typeof re === "string" || typeof re === "function") {
text = text.replace(reg, re);
}
}
}
return text;
}
};
MarkdownService.instance = new MarkdownService_1();
MarkdownService = MarkdownService_1 = __decorate([DISingleton()], MarkdownService);
_export("default", MarkdownService);
}
};
});
//# sourceMappingURL=MarkdownService.js.map