diff --git a/lib/rdoc/parser/changelog.rb b/lib/rdoc/parser/changelog.rb index 85ec46e0aa..802ac96f01 100644 --- a/lib/rdoc/parser/changelog.rb +++ b/lib/rdoc/parser/changelog.rb @@ -274,6 +274,27 @@ def create_entries(entries) def initialize(base, commit, author, email, date, contents) case contents when String + if base&.match(%r[\A([^:/]+:/+[^/]+/)[^/]+/[^/]+/]) + repo, host = $&, $1 + contents = contents.dup + # base: https://github.com/ruby/ruby/ + # Fix #15791 -> Fix [#15791](https://github.com/ruby/ruby/pull/15791) + # GH-15791 -> [GH-15791](https://github.com/ruby/ruby/pull/15791) + # (#15791) -> ([#15791](https://github.com/ruby/ruby/pull/15791)) + contents.gsub!(/\b(?:(?i:fix(?:e[sd])?) +)\K\#(\d+\b)|\bGH-(\d+)\b|\(\K\#(\d+)(?=\))/) do + "[#{$&}](#{repo}pull/#{$1 || $2 || $3})" + end + # repo#PR, repo@HASH + # ruby/ruby#15791 -> [ruby/ruby#15791](https://github.com/ruby/ruby/pull/15791) + # ruby/ruby@a8a989b6 -> [ruby/ruby@a8a989b6](https://github.com/ruby/ruby/commit/a8a989b6) + # ref in branckets is not extended + # [ruby/net-imap#543][ruby/ruby#15791] -> [ruby/net-imap#543][ruby/ruby#15791] + contents.gsub!(%r[(?