import { escape } from '../utils/string'; class TextParser { source: any; constructor(source: any) { this.source = source; } toHTML() { let html = escape(this.source); html = html .replace(/\n/g, '

') .replace(/

<\/p>/g, '


') .replace(/^\s/, ' ') .replace(/\s$/, ' ') .replace(/\s\s/g, '  '); if (html.indexOf('

') >= 0) { html = '

'.concat(html, '

'); } return html; } } export default TextParser;