Rocket.Chat
Rocket.Chat copied to clipboard
[WIP] [NEW] [UPGRADE] Use showdown module to parse markdown
Ref RocketChat/feature-requests#642 RocketChat/Rocket.Chat#13885 RocketChat/Rocket.Chat#13883
This is work in progress. This is a very crude PR in which no coding standards have been followed.
The current markdown parser is not good enough for all the needs. I suggest to use Showdown module to parse markdown to HTML.
I will add the documentation PR soon if, the community agrees to use showdown module.
Intro
Showdown is a Javascript Markdown to HTML converter, based on the original works by John Gruber.
Showdown was created by John Fraser as a direct port of the original parser written by markdown's creator, John Gruber. Although Showdown has evolved since its inception, in "vanilla mode", it tries to follow the original markdown spec (henceforth refereed as vanilla) as much as possible. There are, however, a few important differences, mainly due to inconsistencies in the original spec, which we addressed following the author's advice as stated in the markdown's "official" newsletter.
For more information: https://github.com/showdownjs/showdown
Features
- github - GFM (GitHub Flavored Markdown) is available
- Markdown Support for various elements can be chosen by choice, i.e. some markdown elements can be disabled on choice.
- Can be used on both client and server side. In fact it can be used as CLI also.
- Direct install and import via npm/ bower for easy development setup.
- Showdown allows additional functionality to be loaded via extensions. (sample extensions https://github.com/showdownjs/showdown/wiki/extensions)
- Can directly attach
id
attribute to the html element.
Markdown Support
- Paragraphs
- Headings (including atx style)
- Block quotes
- Bold/ italic/ strikethrough
- Code formatting
- Inline
- Multiline
- Lists
- Unordered lists
- Ordered lists
- TaskLists (GFM Style)
- List syntax
- Nested blocks
- Nested lists
- Nested code blocks
- Links
- Simple
- Inline
- Reference Style
- Images
- Inline
- Reference Style
- Image dimensions
- Base64 encoded images
- Tables
- HTML tags inside markdown
- Escaping Entities
What have I been able to set-up?
Additional yet essential information
-
As you know, ShowdownJS is a free library and it will remain free forever.
-
ShowdownJS v 2.0 is release under the MIT version. Previous versions are release under BSD. (as quoted from https://github.com/showdownjs/showdown/blob/master/README.md)
-
Showdown has been tested successfully with:
Firefox 1.5 and 2.0 Chrome 12.0 Internet Explorer 6 and 7 Safari 2.0.4 Opera 8.54 and 9.10 Netscape 8.1.2 Konqueror 3.5.4 In theory, Showdown will work in any browser that supports ECMA 262 3rd Edition (JavaScript 1.5). The converter itself might even work in things that aren't web browsers, like Acrobat. No promises.
Concerns regarding XSS
A document on Markdown and XSS (https://michelf.ca/blog/2010/markdown-and-xss/ and https://github.com/showdownjs/showdown/wiki/Markdown's-XSS-Vulnerability-(and-how-to-mitigate-it))
@engelgabriel What are you views? In ref to RocketChat/feature-requests#642
Also, a document on Markdown and XSS (https://michelf.ca/blog/2010/markdown-and-xss/ and https://github.com/showdownjs/showdown/wiki/Markdown's-XSS-Vulnerability-(and-how-to-mitigate-it))
Should I move forward with it?
@fliptrail @engelgabriel Rockat.Chat supports Marked markdown now. So, maybe this PR is obsolete.