JetBrains / markdown

Markdown parser written in kotlin
Apache License 2.0
682 stars 75 forks source link

Improve link autodetection #41

Closed Leonya closed 4 years ago

Leonya commented 4 years ago

Currently for a link to be detected as such it has to start with http(s):// or www., this is too simplistic. Please add TLDs to the link detection function.

Leonya commented 4 years ago

The full list of TLDs is here: https://data.iana.org/TLD/tlds-alpha-by-domain.txt

It contains lots of really obscure ones, so I'm not sure that including all of them is a good idea (it's 10K of text). I can provide a shorter one, if you want.

valich commented 4 years ago

@Leonya Can you provide examples of autolinks you'd like to parse? I think I tried to reverse-engineer the github markdown autolinks behaviour at the time.

Leonya commented 4 years ago

Sure:

t.co/foo (Twitter URL shortener)
jetbrains.team/abc
yandex.ru
Leonya commented 4 years ago

Basically anything that is a hostname.known-tld should be turned into a link.

valich commented 4 years ago

Doesn't it bother you that github does not linkininze such strings? I can surely do such change, but I suppose it's incorrect to call that GFM anymore

Leonya commented 4 years ago

No, I believe it's fine. It's not the kind of extension that goes against the spirit of GFM. I've read the corresponding part of the spec and it doesn't strike me as especially thought through.

valich commented 4 years ago

I've introduced SFM (space flavoured markdown) with proposed changes. A couple of coutry codes were still removed (e.g. .sh) because bash files occur in text quite frequently.

Will update MPP branch a little bit later.

Leonya commented 4 years ago

These two commits also need to be synced with the kotlin-js-clean branch: f4c743257f242efdca2bfc5559f8327cd73a02ec, 31647e1ae9cfb469dbb78f050643ee73a81f5530

valich commented 4 years ago

Force pushed kotlin-js-clean