Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

It would be nice if autolink could be matched on more leading punctuations #261

Closed
jijiechen opened this issue Oct 27, 2018 · 4 comments
Closed

Comments

@jijiechen
Copy link

jijiechen commented Oct 27, 2018

In current implementation of Markdig as of 0.15.2, links are not automatically created if there are more kinds of leading punctuations than the ones recognized by Markdig at here:

https://github.com/lunet-io/markdig/blob/master/src/Markdig/Extensions/AutoLinks/AutoLinkParser.cs#L34

(Only whitespace, *, *, _, ~ ( are accepted for now).

So if links could be matched and created on more kinds of leading punctuations, that'll be nice. Either list more allowed punctuations or make the IsValidPreviousCharacter method an instance method and overridable is helpful.

I know and fully understand that it's a normal manner to put whitespaces before links in English (because links are just new words in sentences.) But in other languages, like Chinese, it's also normal there are other punctuations before links.

For instance:

请访问网址查看更多:https://share.weiyun.com/5D8g7nO

Punctuations need to be matched are:

new []{ ':', '。', ',', '、', '—', ';', '!', '?', '(' };
@jijiechen jijiechen changed the title It would be nice if autolink could be matched on more leading punctuation It would be nice if autolink could be matched on more leading punctuations Oct 27, 2018
@xoofx
Copy link
Owner

xoofx commented Oct 29, 2018

Yes, markdig should follow what GitHub is actually expecting for autolinks.

You can make a PR by changing the test:

c.IsWhiteSpaceOrZero() || c == '*' || c == '_' || c == '~' || c == '(';

and using a string instead:

public string ValidPreciousCharacters {get; set; }

ValidPreciousCharacters = "*_~( \t";

ValidPreciousCharacters.Contains(c)  (check other whitespace characters)

PR welcome!

@MihaZupan
Copy link
Collaborator

Would something like #264 be okay?

(Most of it is just exposing the public field)

@jijiechen
Copy link
Author

jijiechen commented Oct 29, 2018

This is a just-pushed commit!
I think so, it should match the requirement. Many thanks!

@MihaZupan
Copy link
Collaborator

Closing as resolved

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

No branches or pull requests

3 participants