diff --git a/.gitignore b/.gitignore index f0d18e4..40142e9 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ VERSION kramdown-parser-gfm.gemspec Gemfile Gemfile.lock +test/gemfiles/*.lock diff --git a/.travis.yml b/.travis.yml index 729d338..b5a1a95 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,10 +1,13 @@ language: ruby cache: bundler -rvm: - - 2.3 - - 2.4 - - 2.5 - - 2.6 +matrix: + include: + - rvm: 2.3 + - rvm: 2.4 + - rvm: 2.5 + - rvm: 2.6 + - gemfile: test/gemfiles/with_rinku.gemfile + rvm: 2.6 branches: only: diff --git a/README.md b/README.md index 38afbde..d4272e5 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,7 @@ Note: Until kramdown version 2.0.0 this parser was part of the kramdown distribu ```bash gem install kramdown-parser-gfm +gem install rinku # to get optional autolinking functionality (see below) ``` @@ -45,6 +46,11 @@ In this case the correct GFM result is:

This is a complex strike through *test ~~with nesting involved* here~~.

+### Autolinking of absolute URIs (bare links) + +GFM allows bare links with no markup to be converted into links (see https://github.github.com/gfm/#absolute-uri). +In order to enable this functionality you need to install the optional dependency (rinku)[https://github.com/vmg/rinku]. +If this is installed, then the bare links will be converted. ### Options @@ -87,6 +93,9 @@ provided rake tasks. Run `rake --tasks` to view a list of available tasks. +To test the rinku functionality locally: + + bundle exec --gemfile=test/gemfiles/with_rinku.gemfile rake ## License diff --git a/test/gemfiles/with_rinku.gemfile b/test/gemfiles/with_rinku.gemfile new file mode 100644 index 0000000..9bef320 --- /dev/null +++ b/test/gemfiles/with_rinku.gemfile @@ -0,0 +1,4 @@ +eval_gemfile '../../Gemfile' +# gemspec path: '../../' + +gem 'rinku' diff --git a/test/test_files.rb b/test/test_files.rb index 664f13d..a24e18f 100644 --- a/test/test_files.rb +++ b/test/test_files.rb @@ -15,10 +15,19 @@ Encoding.default_external = 'utf-8' +WITH_RINKU = begin + require 'rinku' + true + rescue LoadError + false + end + class TestFiles < Minitest::Test # Generate test methods for gfm-to-html conversion - Dir[__dir__ + '/testcases/**/*.text'].each do |text_file| + testcases_path = WITH_RINKU ? '/testcases_with_rinku/**/*.text' : '/testcases/**/*.text' + + Dir[__dir__ + testcases_path].each do |text_file| basename = text_file.sub(/\.text$/, '') html_file = basename + '.html' diff --git a/test/testcases_with_rinku/links.html b/test/testcases_with_rinku/links.html new file mode 100644 index 0000000..f81944b --- /dev/null +++ b/test/testcases_with_rinku/links.html @@ -0,0 +1,5 @@ +

Here is a markdown style link: https://github.com/kramdown/parser-gfm>

+ +

Here is a markdown style minimal link: https://github.com/kramdown/parser-gfm>

+ +

Here is a bare (gfm) link: https://github.com/kramdown/parser-gfm>

diff --git a/test/testcases_with_rinku/links.text b/test/testcases_with_rinku/links.text new file mode 100644 index 0000000..447d37a --- /dev/null +++ b/test/testcases_with_rinku/links.text @@ -0,0 +1,5 @@ +Here is a markdown style link: [https://github.com/kramdown/parser-gfm](https://github.com/kramdown/parser-gfm) + +Here is a markdown style minimal link: + +Here is a bare (gfm) link: https://github.com/kramdown/parser-gfm