Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Replace marked with commonmark #575

Merged
merged 2 commits into from
Jan 17, 2017
Merged

Conversation

kyrias
Copy link
Contributor

@kyrias kyrias commented Nov 29, 2016

Marked has some annoying bugs, and the author is inactive, so replace it
with commonmark.js, which is the reference JavaScript implementation of
CommonMark. CommonMark is also preferable since it has a specification,
and a conformance test suite to make sure that parsers are correct.

Marked has some annoying bugs, and the author is inactive, so replace it
with commonmark.js, which is the reference JavaScript implementation of
CommonMark.  CommonMark is also preferable since it has a specification,
and a conformance test suite to make sure that parsers are correct.

Signed-off-by: Johannes Löthberg <johannes@kyriasis.com>
@matrixbot
Copy link
Member

Can one of the admins verify this patch?

par = par.parent
}
if (par.firstChild != par.lastChild) {
real_paragraph.bind(this)(node, entering);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you want real_paragraph.call(this, node, entering) here? (It's effectively the same, just doesn't make a bound function).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, don't do a lot of JS.

@dbkr
Copy link
Member

dbkr commented Nov 29, 2016

This generally seems like a pretty good idea, although it will break a couple of little bits of syntax we currently support from GFM. To be precise, I believe these are strikethrough and tables.

If we like, we can turn off the 'safe' option to allow HTML tags through, which will just let people type HTML into the box and it end up in the message, which is no worse than you could do by posting the same HTML using the API directly.

OTOH, typing mixed HR characters like -_- will no longer make HRs!

Anyone object?

@ara4n
Copy link
Member

ara4n commented Nov 29, 2016 via email

@kyrias
Copy link
Contributor Author

kyrias commented Nov 30, 2016

Yeah, I'm planning on looking into it for the rest too, but wanted to see if this would be accepted before doing the extra work.

Signed-off-by: Johannes Löthberg <johannes@kyriasis.com>
@kegsay
Copy link
Member

kegsay commented Nov 30, 2016

Personally, I'd rather keep using GFM - it's more feature-rich than Commonmark.

Marked has some annoying bugs

Which in particular are affecting you?

CommonMark is also preferable since it has a specification, and a conformance test suite to make sure that parsers are correct.

Whilst that is nice, I don't agree that we should crippleremove features on the basis that there's a simpler but more reliable library. I would certainly miss being able to strike-through to articulate my point :)

@richvdh
Copy link
Member

richvdh commented Nov 30, 2016

For me, the consistent spec and better-maintained library offset the loss of strikethrough.

@kyrias
Copy link
Contributor Author

kyrias commented Nov 30, 2016

Two things off the top of my head being three or more, with any combination of *, -, and _ causing a hr, and escaping underscores inside words being broken.

And with HTML enabled, which as mentioned won't allow anything malicious that wouldn't otherwise be possible, you can use <s>foo</s> (which even GitHub renders).

@kyrias
Copy link
Contributor Author

kyrias commented Dec 2, 2016

I fixed another markdown bug related to escaping markdown characters btw, but it either depends on this patch, or needs to be reimplemented for the current code, which I would rather not work on unless this is rejected.

@kegsay
Copy link
Member

kegsay commented Dec 5, 2016

Looks like I'm the only one holding out for GFM. Use of <s>stuff</s> is an acceptable replacement for ~~~ imo, and the consistent implementations would be nice. I'm not convinced that swapping to Commonmark will fix all compatibility issues, as parsers f.e language are in various states of development, but at least they're all aimed at the same target this way.

I'm happy for us to swap to Commonmark.

@richvdh
Copy link
Member

richvdh commented Dec 5, 2016

Matthew says:

we need input from Giom & Yannick
for instance, istr that Yannick is firing up an entire v8 VM in order to run marked on Android atm(!)
in order to get consistent syntax with the web
as the Android GFM libraries had lots of different edge cases
so he may either be very happy or very betrayed if we now go and switch to commonmark

@ylecollen, @giomfo: wdyt?

@giomfo
Copy link
Member

giomfo commented Dec 12, 2016

Manu and I agree to swap to Commonmark in Riot iOS (A new issue has been filed: element-hq/element-ios#862)

@ylecollen
Copy link

The mobile clients have a markdown parser and a markdown renderer.

This update will only update the parser side.

@manuroe
Copy link
Contributor

manuroe commented Dec 12, 2016

I would be happy to use the same library on all platforms as it was a pain to make iOS and Android MD work like the web client.

@richvdh
Copy link
Member

richvdh commented Dec 12, 2016

Ok, it sounds like we are all agreed in principle that the switch to CommonMark is a good idea \o/. Now all we have to do is make it happen.

I think consistency is important so I think we shouldn't merge this patch until we have support in the iOS and Android apps ready to go too.

@kyrias: did you have any interest in replicating this on the mobile apps?

@kyrias
Copy link
Contributor Author

kyrias commented Dec 12, 2016

I have never done any Android/iOS development, but I could certainly try if no one else gets to it before me.

@ylecollen
Copy link

Is there any unit tests set to ensure that the client parses properly ?

@kyrias
Copy link
Contributor Author

kyrias commented Dec 13, 2016

https://github.com/jgm/CommonMark is the commonmark test suite, but there's none for matrix-react-sdk.

@richvdh richvdh removed their assignment Dec 21, 2016
@kyrias
Copy link
Contributor Author

kyrias commented Jan 3, 2017

I haven't really had the time or energy to even start looking at the Android or iOS part of this, but it seems like there's a pure Java implementation that works on Android, and either a pure Swift implementation or the C reference implementation for iOS.

@kegsay
Copy link
Member

kegsay commented Jan 17, 2017

As per element-hq/element-web#2870 (comment) - We're pushing ahead with CommonMark. Merging.

@kegsay kegsay merged commit fcb1d7a into matrix-org:develop Jan 17, 2017
@kyrias kyrias deleted the commonmark branch January 17, 2017 20:04
@manuroe
Copy link
Contributor

manuroe commented Feb 27, 2017

FTR, it has been added to Matrix iOS kit thanks to matrix-org/matrix-ios-kit#248

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants