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

Make AutoLink ValidPreviousCharacters configurable #264

Merged
merged 1 commit into from
Oct 29, 2018

Conversation

MihaZupan
Copy link
Collaborator

public override bool Match(InlineProcessor processor, ref StringSlice slice)
{
// Previous char must be a whitespace or a punctuation
var previousChar = slice.PeekCharExtra(-1);
if (!IsValidPreviousCharacter(previousChar))
if (!previousChar.IsWhiteSpaceOrZero() && ValidPreviousCharacters.IndexOf(previousChar) == -1)
Copy link
Owner

Choose a reason for hiding this comment

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

Couldn't we use ValidPreviousCharacters.Contains here instead?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We could, but I think that IndexOf should be faster since string.Contains(char) is a Linq extension.
I haven't tested the difference tho.

Copy link
Owner

Choose a reason for hiding this comment

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

Han yes, sorry, actually you are right. IndexOf will be way faster then

@xoofx xoofx merged commit ce3078d into xoofx:master Oct 29, 2018
@xoofx
Copy link
Owner

xoofx commented Oct 29, 2018

Thanks for this!

@MihaZupan MihaZupan deleted the autolink-prev-chars branch March 11, 2019 17:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants