From fc90ed1c3ac557492aef95d3d87ebe8e486a1293 Mon Sep 17 00:00:00 2001 From: David Baker Date: Thu, 2 Feb 2017 11:27:07 +0000 Subject: [PATCH] Update the comments in Markdown.js so they don't claim it;s a wrapper around marked when it's now commonmark, and comment why we render markdown to plaintext which is somewhat unintuitive. --- src/Markdown.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/Markdown.js b/src/Markdown.js index 2f278183a3..c342e7cceb 100644 --- a/src/Markdown.js +++ b/src/Markdown.js @@ -17,7 +17,7 @@ limitations under the License. import commonmark from 'commonmark'; /** - * Class that wraps marked, adding the ability to see whether + * Class that wraps commonmark, adding the ability to see whether * a given message actually uses any markdown syntax or whether * it's plain text. */ @@ -33,11 +33,7 @@ export default class Markdown { // running the parser on the tokens with a dummy // rendered and seeing if any of the renderer's // functions are called other than those noted below. - // In case you were wondering, no we can't just examine - // the tokens because the tokens we have are only the - // output of the *first* tokenizer: any line-based - // markdown is processed by marked within Parser by - // the 'inline lexer'... + // TODO: can't we just examine the output of the parser? let is_plain = true; function setNotPlain() { @@ -85,6 +81,12 @@ export default class Markdown { return rendered; } + /* + * Render the mrkdown message to plain text. That is, essentially + * just remove any backslashes escaping what would otherwise be + * markdown syntax + * (to fix https://github.com/vector-im/riot-web/issues/2870) + */ toPlaintext() { const real_paragraph = this.renderer.paragraph;