Skip to content

Commit

Permalink
Merge pull request #44685 from SkipKayhil/dym-for-guide-links
Browse files Browse the repository at this point in the history
use DidYouMean for broken link fixes in guides
  • Loading branch information
eileencodes committed Mar 15, 2022
2 parents 4d7a956 + 8b71dc1 commit 3fc9d12
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 48 deletions.
5 changes: 1 addition & 4 deletions guides/rails_guides/generator.rb
Expand Up @@ -10,7 +10,6 @@

require "rails_guides/markdown"
require "rails_guides/helpers"
require "rails_guides/levenshtein"

module RailsGuides
class Generator
Expand Down Expand Up @@ -206,9 +205,7 @@ def check_fragment_identifiers(html, anchors)
html.scan(/<a\s+href="#([^"]+)/).flatten.each do |fragment_identifier|
next if fragment_identifier == "mainCol" # in layout, jumps to some DIV
unless anchors.member?(CGI.unescape(fragment_identifier))
guess = anchors.min { |a, b|
Levenshtein.distance(fragment_identifier, a) <=> Levenshtein.distance(fragment_identifier, b)
}
guess = DidYouMean::SpellChecker.new(dictionary: anchors).correct(fragment_identifier).first
puts "*** BROKEN LINK: ##{fragment_identifier}, perhaps you meant ##{guess}."
end
end
Expand Down
44 changes: 0 additions & 44 deletions guides/rails_guides/levenshtein.rb

This file was deleted.

0 comments on commit 3fc9d12

Please sign in to comment.