From 511fcce55345adb2a6b05cf058fd4d238abcc521 Mon Sep 17 00:00:00 2001 From: hmhealey Date: Wed, 23 Sep 2015 17:42:57 -0400 Subject: Restricted markdown output to only appear on one line when in singleline mode --- web/react/utils/markdown.jsx | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'web/react') diff --git a/web/react/utils/markdown.jsx b/web/react/utils/markdown.jsx index 347024e1a..8b511cd07 100644 --- a/web/react/utils/markdown.jsx +++ b/web/react/utils/markdown.jsx @@ -15,6 +15,14 @@ export class MattermostMarkdownRenderer extends marked.Renderer { this.formattingOptions = formattingOptions; } + br() { + if (this.formattingOptions.singleline) { + return ' '; + } + + return super.br(); + } + heading(text, level, raw) { const id = `${this.options.headerPrefix}${raw.toLowerCase().replace(/[^\w]+/g, '-')}`; return `${text}`; @@ -36,6 +44,14 @@ export class MattermostMarkdownRenderer extends marked.Renderer { return output; } + paragraph(text) { + if (this.formattingOptions.singleline) { + return `

${text}

`; + } + + return super.paragraph(text); + } + table(header, body) { return `${header}${body}
`; } -- cgit v1.2.3-1-g7c22