Class: Ace::Support::Items::Atoms::TitleExtractor
- Inherits:
-
Object
- Object
- Ace::Support::Items::Atoms::TitleExtractor
- Defined in:
- lib/ace/support/items/atoms/title_extractor.rb
Overview
Extracts the first H1 heading from markdown body content.
Class Method Summary collapse
-
.extract(body) ⇒ String?
Extract title from the first ‘# H1` heading in body content.
Class Method Details
.extract(body) ⇒ String?
Extract title from the first ‘# H1` heading in body content
12 13 14 15 16 17 |
# File 'lib/ace/support/items/atoms/title_extractor.rb', line 12 def self.extract(body) return nil if body.nil? || body.empty? match = body.match(/^#\s+(.+)$/) match ? match[1].strip : nil end |