Class: PinkShirt

Inherits:
Object
  • Object
show all
Defined in:
lib/pink_shirt.rb,
lib/pink_shirt/sax.rb,
lib/pink_shirt/output.rb,
lib/pink_shirt/version.rb,
lib/pink_shirt/entities.rb,
lib/pink_shirt/sax/base.rb,
lib/pink_shirt/sax/basic.rb,
lib/pink_shirt/sax/links.rb,
lib/pink_shirt/sax/lists.rb,
lib/pink_shirt/attributes.rb,
lib/pink_shirt/sax/images.rb,
lib/pink_shirt/sax/script.rb,
lib/pink_shirt/sax/tables.rb,
lib/pink_shirt/sax/acronym.rb,
lib/pink_shirt/sax/block_level.rb,
lib/pink_shirt/sax/boiler_plate.rb,
lib/pink_shirt/sax/preformatted.rb

Overview

An html2textile converter PinkShirt Undoes RedCloth

Usage

html = "stuff <b>goood</b> stuff" 
PinkShirt.new('stuff').to_textile

Internals

PinkShirt uses a sax parser built on nokogiri

Defined Under Namespace

Classes: Attributes, Entities, Flags, Output, SAX

Constant Summary collapse

VERSION =
"0.0.6"

Instance Method Summary collapse

Constructor Details

#initialize(html) ⇒ PinkShirt

Returns a new instance of PinkShirt.

Parameters:

  • html (String)


17
18
19
20
21
# File 'lib/pink_shirt.rb', line 17

def initialize(html)
  @html = html
  @sax_syntax = PinkShirt::SAX.new
  @parser     = Nokogiri::HTML::SAX::Parser.new(@sax_syntax)
end

Instance Method Details

#to_textileObject

renders to textile



24
25
26
27
28
29
# File 'lib/pink_shirt.rb', line 24

def to_textile
  @parser.parse(@html)do |config|
    config.replace_entities = false
  end
  @sax_syntax.to_textile
end