Skip to content

Commit

Permalink
linkify the changelog when rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
flavorjones committed Nov 19, 2023
1 parent 95913b4 commit 4fa918d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ group :development do
gem 'rcodetools'
gem 'yard'
gem 'nokogiri'
gem 'hoe-markdown', ">= 1.6.0"
end

group :test do
Expand Down
11 changes: 11 additions & 0 deletions tasks/nokogiri_tasks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

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

0 comments on commit 4fa918d

Please sign in to comment.