public
Description: RedCloth is a Ruby library for converting Textile into HTML.
Homepage: http://code.whytheluckystiff.net/redcloth/
Clone URL: git://github.com/jgarber/redcloth.git
Click here to lend your support to: redcloth and make a donation at www.pledgie.com !
Restructured classes because rdoc couldn't handle modules in classes.

I had modules inside classes and rdoc didn't like that (and it was bad 
form anyway), so converted the RedCloth class into a module.  Breaks 
complete backward compatibility with extensions if the extension was 
declared inside the class directly rather than included.
jgarber (author)
Thu Jul 17 10:01:04 -0700 2008
commit  8ba72f35731af053b0bfbef250b58d674c227f7d
tree    8c8addc35a27e463f24b5a056874ca142bc10d9e
parent  5c35ecd86b7efeb2c97d55a0ce74d28fa8374877
...
1
2
3
4
5
6
7
8
9
 
10
11
12
...
1
 
2
3
4
5
6
7
 
8
9
10
11
0
@@ -1,12 +1,11 @@
0
 = RedCloth 4.0
0
-=== 15th Feb, 2007
0
 
0
 * New SuperRedCloth (RedCloth 4.0) is a total rewrite using Ragel for the parsing.
0
 * Markdown support has been removed.
0
 * Single newlines become <br> tags, just as in traditional RedCloth and other Textile parsers.
0
 * HTML special characters are automatically escaped inside code signatures, like Textile 2. This means you can simply write @<br />@ and the symbols are escaped whereas in RedCloth 3 you had to write @&lt;br /&gt;@ to make the code fragment readable.
0
 * The restrictions parameter is observed just like previous versions (except :hard_breaks is now the default).
0
-* Arguments to RedCloth#to_html are called so extensions from the versions are compatible.
0
+* Arguments to RedCloth#to_html are called so extensions made for prior versions can work. Note: extensions need to be included rather than defined directly within the RedCloth class as was previously possible.
0
 * Custom block tags can be implemented as in the previous version, though the means of implementing them differs.
0
 * HTML embedded in the Textile input does not often need to be escaped from Textile parsing.
0
 * The parser will not wrap lines that begin with a space in paragraph tags.
0
...
5
6
7
8
 
9
10
11
...
5
6
7
 
8
9
10
11
0
@@ -5,7 +5,7 @@ Author:: Jason Garber
0
 Copyright:: (c) 2008 Jason Garber
0
 License:: MIT
0
 
0
-(See http://hobix.com/textile/ for a Textile reference.)
0
+(See http://redcloth.org/textile/ for a Textile reference.)
0
 
0
 = RedCloth
0
 
...
5
6
7
8
 
9
10
11
...
5
6
7
 
8
9
10
11
0
@@ -5,7 +5,7 @@ require 'rake/rdoctask'
0
 require 'rake/testtask'
0
 require 'fileutils'
0
 include FileUtils
0
-require 'lib/version'
0
+require 'lib/redcloth/version'
0
 
0
 NAME = RedCloth::NAME
0
 SUMMARY = RedCloth::DESCRIPTION
...
3
4
5
6
 
7
8
9
...
3
4
5
 
6
7
8
9
0
@@ -3,7 +3,7 @@
0
 
0
 /* variable defs */
0
 #ifndef redcloth_scan_c
0
-extern VALUE super_ParseError, super_RedCloth;
0
+extern VALUE super_ParseError, mRedCloth, super_RedCloth;
0
 extern int SYM_escape_preformatted;
0
 #endif
0
 
...
8
9
10
11
 
12
13
14
...
509
510
511
512
513
 
 
 
 
514
515
516
...
8
9
10
 
11
12
13
14
...
509
510
511
 
 
512
513
514
515
516
517
518
0
@@ -8,7 +8,7 @@
0
 #include <ruby.h>
0
 #include "redcloth.h"
0
 
0
-VALUE super_ParseError, super_RedCloth, super_HTML, super_LATEX;
0
+VALUE mRedCloth, super_ParseError, super_RedCloth, super_HTML, super_LATEX;
0
 int SYM_escape_preformatted;
0
 
0
 %%{
0
@@ -509,8 +509,10 @@ redcloth_to(self, formatter)
0
 
0
 void Init_redcloth_scan()
0
 {
0
- /* The RedCloth parser. See the README for Textile syntax. */
0
- super_RedCloth = rb_define_class("RedCloth", rb_cString);
0
+ mRedCloth = rb_define_module("RedCloth");
0
+ /* A Textile document that can be converted to other formats. See
0
+ the README for Textile syntax. */
0
+ super_RedCloth = rb_define_class_under(mRedCloth, "TextileDoc", rb_cString);
0
   rb_define_method(super_RedCloth, "to", redcloth_to, 1);
0
   super_ParseError = rb_define_class_under(super_RedCloth, "ParseError", rb_eException);
0
   /* Escaping */
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
 
 
 
 
 
 
58
59
60
61
62
63
64
65
66
67
 
68
69
70
71
72
73
74
75
76
77
78
79
 
 
 
 
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
 
 
 
111
112
113
 
...
 
 
1
2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
4
5
6
7
8
9
 
 
 
 
 
 
 
 
 
10
11
 
 
 
 
 
 
 
 
 
 
 
12
13
14
15
16
17
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
19
20
21
22
23
24
0
@@ -1,113 +1,24 @@
0
-require 'redcloth_scan'
0
-
0
 $:.unshift(File.dirname(__FILE__))
0
 
0
-require 'formatters/base'
0
-require 'formatters/html'
0
-require 'formatters/latex'
0
-require 'version'
0
-
0
-class RedCloth
0
- #
0
- # Accessors for setting security restrictions.
0
- #
0
- # This is a nice thing if you're using RedCloth for
0
- # formatting in public places (e.g. Wikis) where you
0
- # don't want users to abuse HTML for bad things.
0
- #
0
- # If +:filter_html+ is set, HTML which wasn't
0
- # created by the Textile processor will be escaped.
0
- # Alternatively, if +:sanitize_html+ is set,
0
- # HTML can pass through the Textile processor but
0
- # unauthorized tags and attributes will be removed.
0
- #
0
- # If +:filter_styles+ is set, it will also disable
0
- # the style markup specifier. ('{color: red}')
0
- #
0
- # If +:filter_classes+ is set, it will also disable
0
- # class attributes. ('!(classname)image!')
0
- #
0
- # If +:filter_ids+ is set, it will also disable
0
- # id attributes. ('!(classname#id)image!')
0
- #
0
- attr_accessor :filter_html, :sanitize_html, :filter_styles, :filter_classes, :filter_ids
0
-
0
- #
0
- # Deprecated accessor for toggling hard breaks.
0
- #
0
- # Traditional RedCloth converted single newlines
0
- # to HTML break tags, but later versions required
0
- # +:hard_breaks+ be set to enable this behavior.
0
- # +:hard_breaks+ is once again the default. The
0
- # accessor is deprecated and will be removed in a
0
- # future version.
0
- #
0
- attr_accessor :hard_breaks
0
-
0
- # Accessor for toggling lite mode.
0
- #
0
- # In lite mode, block-level rules are ignored. This means
0
- # that tables, paragraphs, lists, and such aren't available.
0
- # Only the inline markup for bold, italics, entities and so on.
0
- #
0
- # r = RedCloth.new( "And then? She *fell*!", [:lite_mode] )
0
- # r.to_html
0
- # #=> "And then? She <strong>fell</strong>!"
0
- #
0
- attr_accessor :lite_mode
0
+require 'redcloth_scan'
0
+require 'redcloth/version'
0
+require 'redcloth/textile_doc'
0
+require 'redcloth/formatters/base'
0
+require 'redcloth/formatters/html'
0
+require 'redcloth/formatters/latex'
0
 
0
- #
0
- # Accessor for toggling span caps.
0
- #
0
- # Textile places `span' tags around capitalized
0
- # words by default, but this wreaks havoc on Wikis.
0
- # If +:no_span_caps+ is set, this will be
0
- # suppressed.
0
- #
0
- attr_accessor :no_span_caps
0
+module RedCloth
0
   
0
- # Returns a new RedCloth object, based on _string_, observing
0
- # any _restrictions_ specified.
0
- #
0
- # r = RedCloth.new( "h1. A *bold* man" )
0
- # #=> "h1. A *bold* man"
0
- # r.to_html
0
- # #=>"<h1>A <b>bold</b> man</h1>"
0
- #
0
- def initialize( string, restrictions = [] )
0
- restrictions.each { |r| method("#{r}=").call( true ) }
0
- super( string )
0
+ # A convenience method for creating a new TextileDoc. See
0
+ # RedCloth::TextileDoc.
0
+ def self.new( *args, &block )
0
+ RedCloth::TextileDoc.new( *args, &block )
0
   end
0
   
0
- #
0
- # Generates HTML from the Textile contents.
0
- #
0
- # RedCloth.new( "And then? She *fell*!" ).to_html
0
- # #=>"<p>And then? She <strong>fell</strong>!</p>"
0
- #
0
- def to_html( *rules )
0
- apply_rules(rules)
0
-
0
- to(RedCloth::Formatters::HTML)
0
- end
0
-
0
- #
0
- # Generates LaTeX from the Textile contents.
0
- #
0
- # RedCloth.new( "And then? She *fell*!" ).to_latex
0
- # #=> "And then? She \\textbf{fell}!\n\n"
0
- #
0
- def to_latex( *rules )
0
- apply_rules(rules)
0
-
0
- to(RedCloth::Formatters::LATEX)
0
- end
0
-
0
- private
0
- def apply_rules(rules)
0
- rules.each do |r|
0
- method(r).call(self) if self.respond_to?(r)
0
- end
0
+ # Include extension modules (if any) in TextileDoc.
0
+ def self.include(*args)
0
+ RedCloth::TextileDoc.send(:include, *args)
0
   end
0
   
0
 end
0
+

Comments

    No one has commented yet.