Class: ClothRed
- Inherits:
-
String
- Object
- String
- ClothRed
- Defined in:
- lib/clothred.rb
Constant Summary collapse
- TEXT_FORMATTING =
–
[ ["<b>", "**"], ["</b>","**"], ["<em>","_"], ["</em>", "_"], ["<b>", "*"], ["</b>", "*"], ["<cite>", "??"], ["</cite>", "??"], ["<code>", "@"], ["</code>", "@"], ["<del>", "-"], ["</del>", "-"], ["<ins>", "+"], ["</ins>", "+"], ["<sup>","^"], ["</sup>","^"], ["<sub>","~"], ["</sub>","~"], ["<strong>", "*"], ["</strong>", "*"], ["<i>","__"], ["</i>", "__"] ]
- HEADINGS =
[ ["<h1>","h1. "], ["</h1>", "\n\n"], ["<h2>","h2. "], ["</h2>", "\n\n"], ["<h3>","h3. "], ["</h3>", "\n\n"], ["<h4>","h4. "], ["</h4>", "\n\n"], ["<h5>","h5. "], ["</h5>", "\n\n"], ["<h6>","h6. "], ["</h6>", "\n\n"], ["<h7>","h7. "], ["</h7>", "\n\n"] ]
- STRUCTURES =
[ ["<p>", "p. "],["</p>","\n\n"], ["<blockquote>", "bq. "], ["</blockquote>",""], ["<br />", "\n"], ["<br>", "\n"] ]
- ENTITIES =
[ ["“", '"'], ["”", '"'], ["—", "--"], ["—", "--"], ["–","-"], ["…", "..."], ["×", " x "], ["™","(TM)"], ["®","(R)"], ["©","(C)"], ["’", "'"] ]
- TABLES =
[ ["<table>",""], ["</table>",""], ["<tr>",""], ["</tr>","|\n"], ["<td>","|"], ["</td>",""], ["<th>", "|_."], ["</th>", ""] ]
Instance Method Summary collapse
-
#initialize(html) ⇒ ClothRed
constructor
A new instance of ClothRed.
-
#to_textile ⇒ Object
Call all necessary methods to convert a string of HTML into Textile markup.
Constructor Details
#initialize(html) ⇒ ClothRed
Returns a new instance of ClothRed.
50 51 52 53 |
# File 'lib/clothred.rb', line 50 def initialize (html) super(html) @workingcopy = html end |
Instance Method Details
#to_textile ⇒ Object
Call all necessary methods to convert a string of HTML into Textile markup.
57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/clothred.rb', line 57 def to_textile headings(@workingcopy) structure(@workingcopy) text_formatting(@workingcopy) entities(@workingcopy) tables(@workingcopy) @workingcopy = CGI::unescapeHTML(@workingcopy) @workingcopy end |