Skip to content

Commit

Permalink
test harness and failing test for GFM autolinking
Browse files Browse the repository at this point in the history
  • Loading branch information
timdiggins committed Mar 14, 2021
1 parent f1012be commit dc74432
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ VERSION
kramdown-parser-gfm.gemspec
Gemfile
Gemfile.lock
test/gemfiles/*.lock
13 changes: 8 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
```


Expand Down Expand Up @@ -45,6 +46,11 @@ In this case the correct GFM result is:

<p>This <del>is a complex strike through *test ~~with nesting</del> involved* here~~.</p>

### 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

Expand Down Expand Up @@ -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

Expand Down
4 changes: 4 additions & 0 deletions test/gemfiles/with_rinku.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
eval_gemfile '../../Gemfile'
# gemspec path: '../../'

gem 'rinku'
11 changes: 10 additions & 1 deletion test/test_files.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
5 changes: 5 additions & 0 deletions test/testcases_with_rinku/links.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<p>Here is a markdown style link: <a href="https://github.com/kramdown/parser-gfm">https://github.com/kramdown/parser-gfm></a></p>

<p>Here is a markdown style minimal link: <a href="https://github.com/kramdown/parser-gfm">https://github.com/kramdown/parser-gfm></a></p>

<p>Here is a bare (gfm) link: <a href="https://github.com/kramdown/parser-gfm">https://github.com/kramdown/parser-gfm></a></p>
5 changes: 5 additions & 0 deletions test/testcases_with_rinku/links.text
Original file line number Diff line number Diff line change
@@ -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: <https://github.com/kramdown/parser-gfm>

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

0 comments on commit dc74432

Please sign in to comment.