Class: Mdoc::Writer

Inherits:
Object
  • Object
show all
Defined in:
lib/mdoc/writer.rb

Direct Known Subclasses

PandocWriter

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#tiltObject

Returns the value of attribute tilt.



5
6
7
# File 'lib/mdoc/writer.rb', line 5

def tilt
  @tilt
end

Instance Method Details

#default_processorsObject



18
19
20
21
22
23
24
25
# File 'lib/mdoc/writer.rb', line 18

def default_processors
  %w[
    add_toc
    add_title
    smart_code_block
    expand_link
  ]
end

#out(doc) ⇒ Object



7
8
9
# File 'lib/mdoc/writer.rb', line 7

def out(doc)
  Mdoc.opts.no_output ? $stdout : File.new(doc.out_file, 'wb')
end

#process!(doc) ⇒ Object



11
12
13
14
15
16
# File 'lib/mdoc/writer.rb', line 11

def process!(doc)
  @tilt = Tilt::ERBTemplate.new(doc.tpl_file)
  oh = out(doc)
  oh.write @tilt.render(doc)
  oh.close unless oh == $stdout
end