Skip to content

Commit

Permalink
Merge pull request rails#53124 from codergeek121/fix-guide-meta-descr…
Browse files Browse the repository at this point in the history
…iptions-whitespace

Fix prefixed headings in guide pages meta descriptions
  • Loading branch information
p8 authored Nov 23, 2024
2 parents 31d3cae + ee4f5a9 commit ce8a6f1
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions guides/rails_guides/markdown.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ def render(body)
@raw_body = body
extract_raw_header_and_body
generate_header
generate_description
generate_title
generate_description
generate_body
generate_structure
generate_index
Expand Down Expand Up @@ -95,7 +95,7 @@ def generate_header

def generate_description
sanitizer = Rails::Html::FullSanitizer.new
@description = sanitizer.sanitize(@header).squish
@description = sanitizer.sanitize(@header).squish.delete_prefix(@heading)
end

def generate_structure
Expand Down Expand Up @@ -174,8 +174,8 @@ def generate_index
end

def generate_title
if heading = html_fragment(@header).at(:h1)
@title = "#{heading.text} — Ruby on Rails Guides"
if @heading = html_fragment(@header).at(:h1)
@title = "#{@heading.text} — Ruby on Rails Guides"
else
@title = "Ruby on Rails Guides"
end
Expand Down

0 comments on commit ce8a6f1

Please sign in to comment.