diff options
author | Stan Lo <[email protected]> | 2024-11-18 10:32:25 +0000 |
---|---|---|
committer | git <[email protected]> | 2024-11-18 10:32:31 +0000 |
commit | ee0915feeb1afdc448af610f2d470945a991a118 (patch) | |
tree | b06917631776ab3ae67eed5723105413af1d0e8b /lib/rdoc/generator | |
parent | 7b8db102be6b33db7f38c87ae6aca7be56c62b84 (diff) |
[ruby/rdoc] Extract excerpt from raw pages correctly
(https://github.com/ruby/rdoc/pull/1200)
Fixes https://bugs.ruby-lang.org/issues/20862
https://github.com/ruby/rdoc/commit/3c678249e2
Diffstat (limited to 'lib/rdoc/generator')
-rw-r--r-- | lib/rdoc/generator/darkfish.rb | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/rdoc/generator/darkfish.rb b/lib/rdoc/generator/darkfish.rb index 25ade1e9f1..08f2b85e3b 100644 --- a/lib/rdoc/generator/darkfish.rb +++ b/lib/rdoc/generator/darkfish.rb @@ -782,7 +782,19 @@ class RDoc::Generator::Darkfish # Returns an excerpt of the content for usage in meta description tags def excerpt(content) - text = content.is_a?(RDoc::Comment) ? content.text : content + text = case content + when RDoc::Comment + content.text + when RDoc::Markup::Document + # This case is for page files that are not markdown nor rdoc + # We convert them to markdown for now as it's easier to extract the text + formatter = RDoc::Markup::ToMarkdown.new + formatter.start_accepting + formatter.accept_document(content) + formatter.end_accepting + else + content + end # Match from a capital letter to the first period, discarding any links, so # that we don't end up matching badges in the README |