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

[Markdown] reduce backtracking possibilities #877

Merged
merged 4 commits into from
Apr 5, 2017

Conversation

keith-hall
Copy link
Collaborator

this PR reduces the number of backtracking possibilities for regex engines like Oniguruma that use backtracking, and also explains the regex patterns better.

a simple Markdown snippet with a missing end backtick like

``he`lloworld`

will now fail in 73 steps rather than over 5000!

@FichteFoll
Copy link
Collaborator

FichteFoll commented Apr 4, 2017

I find the majority of these comments to be redundant.

I can see myself that [ ]{,3} matches "between 0 to 3 spaces" and do not need a comment to explain that. This is exactly like adding a comment to i += 1 # increase i by 1. Comments should be used to convey information that cannot immediately be seen, such as (?!`) # makes the {3,} possessive (although it appears that this pattern specifically is redundant because the preceding match already ensures that there can't be any following backticks (ref)).

@keith-hall
Copy link
Collaborator Author

I quite like the idea of being able to just read the comments to understand what a regex is doing, without having to look at the pattern itself at all, hence the "redundant" comments :) if you were to become the main maintainer of this package/syntax then I'm sure you could feel free to remove them ;)

I've updated the code fence regex you didn't like though :)

@FichteFoll
Copy link
Collaborator

Of course, I was just voicing my opinion and giving an analogy to code.

I just spotted the code fence regex while trying to look for a comment that does not literally describe the regex and something seemed off, so that was pure coincidence. 😆

trishume added a commit to trishume/Packages that referenced this pull request Apr 4, 2017
[Markdown] reduce backtracking possibilities
@wbond
Copy link
Member

wbond commented Apr 5, 2017

Everything passes with the latest unreleased version of Sublime Text

@wbond wbond merged commit 1dbcc07 into sublimehq:master Apr 5, 2017
@keith-hall keith-hall deleted the markdown_tweaks branch April 5, 2017 08:46
deathaxe pushed a commit to deathaxe/sublime-packages that referenced this pull request Jun 9, 2019
[Markdown] reduce backtracking possibilities
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.

None yet

3 participants