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.
pull/21833/head
David Baker 2017-02-02 11:27:07 +00:00
parent f8d7902d2e
commit fc90ed1c3a
1 changed files with 8 additions and 6 deletions

View File

@ -17,7 +17,7 @@ limitations under the License.
import commonmark from 'commonmark'; 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 * a given message actually uses any markdown syntax or whether
* it's plain text. * it's plain text.
*/ */
@ -33,11 +33,7 @@ export default class Markdown {
// running the parser on the tokens with a dummy // running the parser on the tokens with a dummy
// rendered and seeing if any of the renderer's // rendered and seeing if any of the renderer's
// functions are called other than those noted below. // functions are called other than those noted below.
// In case you were wondering, no we can't just examine // TODO: can't we just examine the output of the parser?
// 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'...
let is_plain = true; let is_plain = true;
function setNotPlain() { function setNotPlain() {
@ -85,6 +81,12 @@ export default class Markdown {
return rendered; 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() { toPlaintext() {
const real_paragraph = this.renderer.paragraph; const real_paragraph = this.renderer.paragraph;