Class: Ronn::RoffFilter

Inherits:
Object
  • Object
show all
Includes:
Utils
Defined in:
lib/ronn/roff.rb

Overview

Filter for converting HTML to ROFF

Constant Summary

Constants included from Utils

Utils::HTML, Utils::HTML_BLOCK, Utils::HTML_EMPTY, Utils::HTML_INLINE

Instance Method Summary collapse

Methods included from Utils

#block_element?, #child_of?, #empty_element?, #html_element?, #inline_element?

Constructor Details

#initialize(html_fragment, name, section, tagline, manual = nil, version = nil, date = nil) ⇒ RoffFilter

Convert Ronn HTML to roff. The html input is an HTML fragment, not a complete document



11
12
13
14
15
16
17
18
19
20
# File 'lib/ronn/roff.rb', line 11

def initialize(html_fragment, name, section, tagline, manual = nil,
               version = nil, date = nil)
  @buf = []
  title_heading name, section, tagline, manual, version, date
  doc = Nokogiri::HTML.fragment(html_fragment)
  remove_extraneous_elements! doc
  normalize_whitespace! doc
  block_filter doc
  write "\n"
end

Instance Method Details

#to_sObject



22
23
24
# File 'lib/ronn/roff.rb', line 22

def to_s
  @buf.join.gsub(/[ \t]+$/, '')
end