Changeset 282
- Timestamp:
- 03/18/2008 10:14:04 (8 months ago)
- Location:
- trunk
- Files:
-
- 4 modified
-
README (modified) (6 diffs)
-
Rakefile (modified) (1 diff)
-
ext/redcloth_scan/redcloth_scan.rl (modified) (4 diffs)
-
lib/redcloth.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/README
r272 r282 1 = RedCloth - Textile and Markdown Hybridfor Ruby1 = RedCloth - Textile parser for Ruby 2 2 3 3 Homepage:: http://whytheluckystiff.net/ruby/redcloth/ 4 4 Author:: why the lucky stiff (http://whytheluckystiff.net/) 5 Copyright:: (cc) 2004 why the lucky stiff (and his puppet organizations.) 6 License:: BSD 5 Copyright:: (c) 2006 why the lucky stiff 7 6 8 (see http://hobix.com/textile/ for a Textile Reference.) 9 10 Based on (and also inspired by) both: 11 12 PyTextile: http://diveintomark.org/projects/textile/textile.py.txt 13 Textism for PHP: http://www.textism.com/tools/textile/ 7 (See http://hobix.com/textile/ for a Textile reference.) 14 8 15 9 = RedCloth 16 10 17 RedCloth is a Ruby library for converting Textile and/or Markdown 18 into HTML. You can use either format, intermingled or separately. 19 You can also extend RedCloth to honor your own custom text stylings. 20 21 RedCloth users are encouraged to use Textile if they are generating 22 HTML and to use Markdown if others will be viewing the plain text. 11 RedCloth is a Ruby library for converting Textile into HTML. 23 12 24 13 == What is Textile? … … 43 32 to the beginning of the paragraph. 44 33 45 h [n]. Header of size [n].34 h3. Header 3. 46 35 bq. Blockquote. 47 36 # Numeric list. … … 73 62 74 63 Optional: text in (parentheses) following the link text, 75 but before the closing quotation mark, will become a Title64 but before the closing quotation mark, will become a title 76 65 attribute for the link, visible as a tool tip when a cursor is above it. 77 66 78 67 Example: 79 68 80 "This is a link (This is a title) ":http://www.textism.com69 "This is a link (This is a title)":http://www.textism.com 81 70 82 71 Will become: … … 131 120 == Adding Tables 132 121 133 In Textile, simple tables can be added by sep erating each column by122 In Textile, simple tables can be added by separating each column by 134 123 a pipe. 135 124 … … 137 126 |And|Another|table|row| 138 127 139 Attributes are defined by style definitions in parentheses.128 Styles are applied with curly braces. 140 129 141 table (border:1px solid black).142 (background:#ddd;color:red). |{}| | ||130 table{border:1px solid black}. 131 {background:#ddd;color:red}. |a|red|row| 143 132 144 133 == Using RedCloth … … 156 145 puts doc.to_html 157 146 158 By default, RedCloth uses both Textile and Markdown formatting, with159 Textile formatting taking precedence. If you want to turn off Markdown160 formatting, to boost speed and limit the processor:161 162 class RedCloth::Textile.new( str ) -
trunk/Rakefile
r280 r282 70 70 rdoc.main = "README" 71 71 rdoc.title = "RedCloth Documentation" 72 rdoc.rdoc_files.add ['README', 'CHANGELOG', 'COPYING', 'lib/**/*.rb' ]72 rdoc.rdoc_files.add ['README', 'CHANGELOG', 'COPYING', 'lib/**/*.rb', 'ext/**/*.c'] 73 73 end 74 74 -
trunk/ext/redcloth_scan/redcloth_scan.rl
r274 r282 226 226 } 227 227 228 /* 229 * Generates HTML from the Textile contents. 230 * 231 * r = RedCloth.new( "And then? She *fell*!" ) 232 * r.to_html 233 * #=>"And then? She <strong>fell</strong>!" 234 */ 228 235 static VALUE 229 236 redcloth_to_html(self) … … 236 243 } 237 244 245 /* 246 * Generates LaTeX from the Textile contents. 247 * 248 * r = RedCloth.new( "And then? She *fell*!" ) 249 * r.to_latex 250 * #=>"And then? She \\textbf{fell}!\n\n" 251 */ 238 252 static VALUE 239 253 redcloth_to_latex(self) … … 258 272 void Init_redcloth_scan() 259 273 { 274 /* The RedCloth parser. See the README for Textile syntax. */ 260 275 super_RedCloth = rb_define_class("RedCloth", rb_cString); 261 276 rb_define_method(super_RedCloth, "to_html", redcloth_to_html, 0); … … 263 278 rb_define_method(super_RedCloth, "to", redcloth_to, 1); 264 279 super_ParseError = rb_define_class_under(super_RedCloth, "ParseError", rb_eException); 280 /* RedCloth HTML formatter. */ 265 281 super_HTML = rb_define_module_under(super_RedCloth, "HTML"); 282 /* RedCloth LaTeX formatter. */ 266 283 super_LATEX = rb_define_module_under(super_RedCloth, "LATEX"); 267 284 SYM_html_escape_entities = ID2SYM(rb_intern("html_escape_entities")); -
trunk/lib/redcloth.rb
r281 r282 9 9 VERSION = '4.0.0' 10 10 11 def initialize(input, opts=[]) 12 super(input) 11 # Returns a new RedCloth object, based on _string_. The 12 # _restrictions_ parameter is accepted for backwards 13 # compatibility but is not observed. 14 # 15 # r = RedCloth.new( "h1. A *bold* man" ) 16 # r.to_html 17 # #=>"<h1>A <b>bold</b> man</h1>" 18 # 19 def initialize( string, restrictions = [] ) 20 super( string ) 13 21 end 14 22