diff --git a/Gemfile b/Gemfile index f1f7aab8..0a40d6d4 100644 --- a/Gemfile +++ b/Gemfile @@ -6,6 +6,7 @@ group :development do gem 'rcodetools' gem 'yard' gem 'nokogiri' + gem 'hoe-markdown', ">= 1.6.0" end group :test do diff --git a/tasks/nokogiri_tasks.rb b/tasks/nokogiri_tasks.rb index e53e8edd..0a29a65f 100644 --- a/tasks/nokogiri_tasks.rb +++ b/tasks/nokogiri_tasks.rb @@ -19,6 +19,8 @@ def create_nokogiri_tasks(source_dir, dest_dir) "index.md" => "README.md", } + linkify_files = ["CHANGELOG.md"] + Dir.chdir(nokogiri_dir) do Dir.glob(File.join("adr", "*.md")).each do |adr| file_pairs[adr] = adr @@ -41,6 +43,7 @@ def create_nokogiri_tasks(source_dir, dest_dir) FileUtils.mkdir_p(target_dir, verbose: true) unless File.directory?(target_dir) FileUtils.cp(source_path, dest_path, verbose: true) modify_readme_links(dest_path) + github_linkify(dest_path) if linkify_files.include?(dest_file) end end @@ -60,6 +63,14 @@ def create_nokogiri_tasks(source_dir, dest_dir) dest_paths end +def github_linkify(path) + require "hoe/markdown" + md = File.read(path) + md = Hoe::Markdown::Util.linkify_github_usernames(md) + md = Hoe::Markdown::Util.linkify_github_issues(md, "https://github.com/sparklemotion/nokogiri/issues") + File.write(path, md) +end + require "nokogiri" def nokogiri_dir