Class: Mdoc::Processor::AddTitle

Inherits:
Mdoc::Processor show all
Defined in:
lib/mdoc/processor/add_title.rb

Instance Method Summary collapse

Methods inherited from Mdoc::Processor

#post_processors, #pre_processors, #repeatable?

Instance Method Details

#process!(doc) ⇒ Object



4
5
6
7
8
9
10
11
12
13
# File 'lib/mdoc/processor/add_title.rb', line 4

def process!(doc)
  title = doc.title
  if title
    unless doc.body =~ /^\s*\#*\s*#{title}/
      title = '# ' << title << "\n"
      title << "{: .title .no_toc}\n\n"
      doc.body = title + doc.body
    end
  end
end