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

Too many blank lines after a foot note freezes Kramdown binary #256

Closed
aliok opened this Issue May 22, 2015 · 2 comments

Comments

Projects
None yet
2 participants
@aliok

aliok commented May 22, 2015

When I process following content with Kramdown, it freezes.

# Something
something[^note1].

# Footnotes
[^note1]:
    A note













































# Test

Here is my command:

kramdown the-file.markdown

Interestingly, it doesn't freeze when I reduce the number of blank lines.
Following input works just fine, although it takes more time than normal.

# Something
something[^note1].

# Footnotes
[^note1]:
    A note
























# Test

My environment:

ruby --version
> ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-darwin14]
kramdown --version
> 1.7.0
gem list

*** LOCAL GEMS ***
bigdecimal (1.2.6)
blankslate (2.1.2.4)
bundler (1.9.9)
celluloid (0.16.0)
classifier-reborn (2.0.3)
coffee-script (2.4.1)
coffee-script-source (1.9.1.1)
colorator (0.1)
execjs (2.5.2)
fast-stemmer (1.0.2)
ffi (1.9.8)
hitimes (1.2.2)
io-console (0.4.3)
jekyll (2.5.3)
jekyll-coffeescript (1.0.1)
jekyll-gist (1.2.1)
jekyll-paginate (1.1.0)
jekyll-sass-converter (1.3.0)
jekyll-watch (1.2.1)
json (1.8.1)
kramdown (1.7.0)
liquid (2.6.2)
listen (2.10.0)
mercenary (0.3.5)
minitest (5.4.3)
parslet (1.5.0)
posix-spawn (0.3.11)
power_assert (0.2.2)
psych (2.0.8)
pygments.rb (0.6.3)
rake (10.4.2)
rb-fsevent (0.9.5)
rb-inotify (0.9.5)
rdoc (4.2.0)
redcarpet (3.2.3)
safe_yaml (1.0.4)
sass (3.4.13)
test-unit (3.0.8)
timers (4.0.1)
toml (0.1.2)
yajl-ruby (1.2.1)

aliok added a commit to aliok/personalNotes that referenced this issue May 22, 2015

@gettalong gettalong self-assigned this May 25, 2015

@gettalong gettalong added the bug label May 25, 2015

@gettalong

This comment has been minimized.

Owner

gettalong commented May 25, 2015

Thanks for the bug report! I will look into it!

@gettalong

This comment has been minimized.

Owner

gettalong commented Jul 1, 2015

The problem comes from the regular expressions used in kramdown. Since Ruby uses a backtracking Regexp engine some regular expressions can take more time than expected.

I have changed a regular expression to use an atomic group to avoid needless backtracking and this has fixed the bug and the huge amount of time it took to process your test case. The fix also passes all of kramdown's test cases 😄.

In addition normal code block matching should also be faster in pathological cases.

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