RedCloth 4.0.0-x86-mswin32-60

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of RedCloth might be problematic. Click here for more details.

Files changed (49) hide show
  1. data/CHANGELOG +17 -0
  2. data/COPYING +18 -0
  3. data/README +156 -0
  4. data/Rakefile +240 -0
  5. data/bin/redcloth +28 -0
  6. data/ext/redcloth_scan/extconf.rb +9 -0
  7. data/ext/redcloth_scan/redcloth.h +149 -0
  8. data/ext/redcloth_scan/redcloth_attributes.c +650 -0
  9. data/ext/redcloth_scan/redcloth_attributes.rl +78 -0
  10. data/ext/redcloth_scan/redcloth_common.rl +113 -0
  11. data/ext/redcloth_scan/redcloth_inline.c +5102 -0
  12. data/ext/redcloth_scan/redcloth_inline.rl +282 -0
  13. data/ext/redcloth_scan/redcloth_scan.c +9300 -0
  14. data/ext/redcloth_scan/redcloth_scan.rl +523 -0
  15. data/extras/mingw-rbconfig.rb +176 -0
  16. data/extras/ragel_profiler.rb +73 -0
  17. data/lib/redcloth.rb +24 -0
  18. data/lib/redcloth/formatters/base.rb +50 -0
  19. data/lib/redcloth/formatters/html.rb +342 -0
  20. data/lib/redcloth/formatters/latex.rb +227 -0
  21. data/lib/redcloth/formatters/latex_entities.yml +2414 -0
  22. data/lib/redcloth/textile_doc.rb +105 -0
  23. data/lib/redcloth/version.rb +18 -0
  24. data/lib/redcloth_scan.bundle +0 -0
  25. data/lib/redcloth_scan.so +0 -0
  26. data/test/basic.yml +794 -0
  27. data/test/code.yml +195 -0
  28. data/test/definitions.yml +71 -0
  29. data/test/extra_whitespace.yml +64 -0
  30. data/test/filter_html.yml +177 -0
  31. data/test/filter_pba.yml +12 -0
  32. data/test/helper.rb +108 -0
  33. data/test/html.yml +271 -0
  34. data/test/images.yml +202 -0
  35. data/test/instiki.yml +38 -0
  36. data/test/links.yml +214 -0
  37. data/test/lists.yml +283 -0
  38. data/test/poignant.yml +89 -0
  39. data/test/sanitize_html.yml +42 -0
  40. data/test/table.yml +267 -0
  41. data/test/test_custom_tags.rb +46 -0
  42. data/test/test_extensions.rb +31 -0
  43. data/test/test_formatters.rb +15 -0
  44. data/test/test_parser.rb +68 -0
  45. data/test/test_restrictions.rb +41 -0
  46. data/test/textism.yml +480 -0
  47. data/test/threshold.yml +772 -0
  48. data/test/validate_fixtures.rb +73 -0
  49. metadata +104 -0
data/CHANGELOG ADDED
@@ -0,0 +1,17 @@
1
+ = RedCloth 4.0
2
+
3
+ * New SuperRedCloth (RedCloth 4.0) is a total rewrite using Ragel for the parsing.
4
+ * Markdown support has been removed.
5
+ * Single newlines become <br> tags, just as in traditional RedCloth and other Textile parsers.
6
+ * 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.
7
+ * The restrictions parameter is observed just like previous versions (except :hard_breaks is now the default).
8
+ * 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.
9
+ * Custom block tags can be implemented as in the previous version, though the means of implementing them differs.
10
+ * HTML embedded in the Textile input does not often need to be escaped from Textile parsing.
11
+ * The parser will not wrap lines that begin with a space in paragraph tags.
12
+ * Rudimentary support for LaTeX is built in.
13
+ * RedCloth::VERSION on a line by itself inserts the version number into the output.
14
+ * Output (less newlines and tabs) is identical to Textile 2 except a few cases where the RedCloth
15
+ way was preferable.
16
+ * Over 500 tests prevent regression
17
+ * It's 40 times faster than the previous version.
data/COPYING ADDED
@@ -0,0 +1,18 @@
1
+ Copyright (c) 2008 Jason Garber
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to
5
+ deal in the Software without restriction, including without limitation the
6
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7
+ sell copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
16
+ THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
17
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
18
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README ADDED
@@ -0,0 +1,156 @@
1
+ = RedCloth - Textile parser for Ruby
2
+
3
+ Homepage:: http://redcloth.org
4
+ Author:: Jason Garber
5
+ Copyright:: (c) 2008 Jason Garber
6
+ License:: MIT
7
+
8
+ (See http://redcloth.org/textile/ for a Textile reference.)
9
+
10
+ = RedCloth
11
+
12
+ RedCloth is a Ruby library for converting Textile into HTML.
13
+
14
+ == Installing
15
+
16
+ RedCloth can be installed via RubyGems:
17
+
18
+ sudo gem install RedCloth
19
+
20
+ Or can be compiled from its Ragel source with <tt>rake compile</tt>. Ragel 6.2
21
+ or greater is required to build RedCloth.
22
+
23
+ == What is Textile?
24
+
25
+ Textile is a simple formatting style for text
26
+ documents, loosely based on some HTML conventions.
27
+
28
+ == Sample Textile Text
29
+
30
+ h2. This is a title
31
+
32
+ h3. This is a subhead
33
+
34
+ This is a bit of paragraph.
35
+
36
+ bq. This is a blockquote.
37
+
38
+ = Writing Textile
39
+
40
+ A Textile document consists of paragraphs. Paragraphs
41
+ can be specially formatted by adding a small instruction
42
+ to the beginning of the paragraph.
43
+
44
+ h3. Header 3.
45
+ bq. Blockquote.
46
+ # Numeric list.
47
+ * Bulleted list.
48
+
49
+ == Quick Phrase Modifiers
50
+
51
+ Quick phrase modifiers are also included, to allow formatting
52
+ of small portions of text within a paragraph.
53
+
54
+ _emphasis_
55
+ __italicized__
56
+ *strong*
57
+ **bold**
58
+ ??citation??
59
+ -deleted text-
60
+ +inserted text+
61
+ ^superscript^
62
+ ~subscript~
63
+ @code@
64
+ %(classname)span%
65
+
66
+ ==notextile== (leave text alone)
67
+
68
+ == Links
69
+
70
+ To make a hypertext link, put the link text in "quotation
71
+ marks" followed immediately by a colon and the URL of the link.
72
+
73
+ Optional: text in (parentheses) following the link text,
74
+ but before the closing quotation mark, will become a title
75
+ attribute for the link, visible as a tool tip when a cursor is above it.
76
+
77
+ Example:
78
+
79
+ "This is a link (This is a title)":http://www.textism.com
80
+
81
+ Will become:
82
+
83
+ <a href="http://www.textism.com" title="This is a title">This is a link</a>
84
+
85
+ == Images
86
+
87
+ To insert an image, put the URL for the image inside exclamation marks.
88
+
89
+ Optional: text that immediately follows the URL in (parentheses) will
90
+ be used as the Alt text for the image. Images on the web should always
91
+ have descriptive Alt text for the benefit of readers using non-graphical
92
+ browsers.
93
+
94
+ Optional: place a colon followed by a URL immediately after the
95
+ closing ! to make the image into a link.
96
+
97
+ Example:
98
+
99
+ !http://www.textism.com/common/textist.gif(Textist)!
100
+
101
+ Will become:
102
+
103
+ <img src="http://www.textism.com/common/textist.gif" alt="Textist" />
104
+
105
+ With a link:
106
+
107
+ !/common/textist.gif(Textist)!:http://textism.com
108
+
109
+ Will become:
110
+
111
+ <a href="http://textism.com"><img src="/common/textist.gif" alt="Textist" /></a>
112
+
113
+ == Defining Acronyms
114
+
115
+ HTML allows authors to define acronyms via the tag. The definition appears as a
116
+ tool tip when a cursor hovers over the acronym. A crucial aid to clear writing,
117
+ this should be used at least once for each acronym in documents where they appear.
118
+
119
+ To quickly define an acronym in Textile, place the full text in (parentheses)
120
+ immediately following the acronym.
121
+
122
+ Example:
123
+
124
+ ACLU(American Civil Liberties Union)
125
+
126
+ Will become:
127
+
128
+ <acronym title="American Civil Liberties Union">ACLU</acronym>
129
+
130
+ == Adding Tables
131
+
132
+ In Textile, simple tables can be added by separating each column by
133
+ a pipe.
134
+
135
+ |a|simple|table|row|
136
+ |And|Another|table|row|
137
+
138
+ Styles are applied with curly braces.
139
+
140
+ table{border:1px solid black}.
141
+ {background:#ddd;color:red}. |a|red|row|
142
+
143
+ == Using RedCloth
144
+
145
+ RedCloth is simply an extension of the String class, which can handle
146
+ Textile formatting. Use it like a String and output HTML with its
147
+ RedCloth#to_html method.
148
+
149
+ doc = RedCloth.new "
150
+
151
+ h2. Test document
152
+
153
+ Just a simple test."
154
+
155
+ puts doc.to_html
156
+
data/Rakefile ADDED
@@ -0,0 +1,240 @@
1
+ require 'rake'
2
+ require 'rake/clean'
3
+ require 'rake/gempackagetask'
4
+ require 'rake/rdoctask'
5
+ require 'rake/testtask'
6
+ require 'fileutils'
7
+ include FileUtils
8
+ require 'lib/redcloth/version'
9
+
10
+ NAME = RedCloth::NAME
11
+ SUMMARY = RedCloth::DESCRIPTION
12
+ VERS = RedCloth::VERSION::STRING
13
+ CLEAN.include ['ext/redcloth_scan/*.{bundle,so,obj,pdb,lib,def,exp,c,o,xml}', 'ext/redcloth_scan/Makefile', '**/.*.sw?', '*.gem', '.config']
14
+ CLOBBER.include ['lib/*.{bundle,so,obj,pdb,lib,def,exp}']
15
+
16
+ desc "Does a full compile, test run"
17
+ task :default => [:compile, :test]
18
+
19
+ desc "Compiles all extensions"
20
+ task :compile => [:redcloth_scan] do
21
+ if Dir.glob(File.join("lib","redcloth_scan.*")).length == 0
22
+ STDERR.puts "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
23
+ STDERR.puts "Gem actually failed to build. Your system is"
24
+ STDERR.puts "NOT configured properly to build redcloth."
25
+ STDERR.puts "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
26
+ exit(1)
27
+ end
28
+ end
29
+
30
+ desc "Packages up RedCloth."
31
+ task :package => [:clean, :compile]
32
+
33
+ desc "Releases packages for all RedCloth packages and platforms."
34
+ task :release => [:package, :rubygems_win32]
35
+
36
+ desc "Run all the tests"
37
+ Rake::TestTask.new do |t|
38
+ t.libs << "test"
39
+ t.test_files = FileList['test/test_*.rb']
40
+ t.verbose = true
41
+ end
42
+
43
+ # Run specific tests or test files
44
+ #
45
+ # rake test:parser
46
+ # => Runs the full TestParser unit test
47
+ #
48
+ # rake test:parser:textism
49
+ # => Runs the tests matching /textism/ in the TestParser unit test
50
+ rule "" do |t|
51
+ # test:file:method
52
+ if /test:(.*)(:([^.]+))?$/.match(t.name)
53
+ arguments = t.name.split(":")[1..-1]
54
+ file_name = arguments.first
55
+ test_name = arguments[1..-1]
56
+
57
+ if File.exist?("test/test_#{file_name}.rb")
58
+ run_file_name = "test_#{file_name}.rb"
59
+ end
60
+
61
+ sh "ruby -Ilib:test test/#{run_file_name} -n /#{test_name}/"
62
+ end
63
+ end
64
+
65
+ Rake::RDocTask.new do |rdoc|
66
+ rdoc.rdoc_dir = 'doc/rdoc'
67
+ # rdoc.options += RDOC_OPTS
68
+ # rdoc.template = "extras/flipbook_rdoc.rb"
69
+ rdoc.main = "README"
70
+ rdoc.title = "RedCloth Documentation"
71
+ rdoc.rdoc_files.add ['README', 'CHANGELOG', 'COPYING', 'lib/**/*.rb', 'ext/**/*.c']
72
+ end
73
+
74
+ PKG_FILES = %w(CHANGELOG COPYING README Rakefile) +
75
+ Dir.glob("{bin,doc,test,lib,extras}/**/*") +
76
+ Dir.glob("ext/**/*.{h,c,rb,rl}") +
77
+ %w[attributes inline scan].map {|f| "ext/redcloth_scan/redcloth_#{f}.c"}
78
+
79
+ spec =
80
+ Gem::Specification.new do |s|
81
+ s.name = NAME
82
+ s.version = VERS
83
+ s.platform = Gem::Platform::RUBY
84
+ s.has_rdoc = true
85
+ s.extra_rdoc_files = ["README", "CHANGELOG", "COPYING"]
86
+ s.summary = SUMMARY
87
+ s.description = s.summary
88
+ s.author = "Jason Garber"
89
+ s.email = 'redcloth-upwards@rubyforge.org'
90
+ s.homepage = 'http://redcloth.org/'
91
+ s.rubyforge_project = 'redcloth'
92
+
93
+ s.files = PKG_FILES
94
+
95
+ s.require_path = "lib"
96
+ #s.autorequire = "redcloth" # no no no this is tHe 3v1l
97
+ s.extensions = FileList["ext/**/extconf.rb"].to_a
98
+ s.executables = ["redcloth"]
99
+ end
100
+
101
+ Rake::GemPackageTask.new(spec) do |p|
102
+ p.need_tar = true
103
+ p.gem_spec = spec
104
+ end
105
+
106
+ extension = "redcloth_scan"
107
+ ext = "ext/redcloth_scan"
108
+ ext_so = "#{ext}/#{extension}.#{Config::CONFIG['DLEXT']}"
109
+ ext_files = FileList[
110
+ "#{ext}/redcloth_scan.c",
111
+ "#{ext}/redcloth_inline.c",
112
+ "#{ext}/redcloth_attributes.c",
113
+ "#{ext}/extconf.rb",
114
+ "#{ext}/Makefile",
115
+ "lib"
116
+ ]
117
+
118
+ file ext_so => ext_files do
119
+ Dir.chdir(ext) do
120
+ sh(PLATFORM =~ /win32/ ? 'nmake' : 'make')
121
+ end
122
+ cp ext_so, "lib"
123
+ end
124
+
125
+ task "lib" do
126
+ directory "lib"
127
+ end
128
+
129
+ ["#{ext}/redcloth_scan.c","#{ext}/redcloth_inline.c","#{ext}/redcloth_attributes.c"].each do |name|
130
+ @code_style ||= "T0"
131
+ source = name.sub(/\.c$/, '.rl')
132
+ file name => [source, "#{ext}/redcloth_common.rl", "#{ext}/redcloth.h"] do
133
+ @ragel_v ||= `ragel -v`[/(version )(\S*)/,2].split('.').map{|s| s.to_i}
134
+ if @ragel_v[0] > 6 || (@ragel_v[0] == 6 && @ragel_v[1] >= 2)
135
+ sh %{ragel #{source} -#{@code_style} -o #{name}}
136
+ else
137
+ STDERR.puts "Ragel 6.2 or greater is required to generate #{name}."
138
+ exit(1)
139
+ end
140
+ end
141
+ end
142
+
143
+ desc "Builds just the #{extension} extension"
144
+ task extension.to_sym => ["#{ext}/Makefile", ext_so ]
145
+
146
+ file "#{ext}/Makefile" => ["#{ext}/extconf.rb", "#{ext}/redcloth_scan.c","#{ext}/redcloth_inline.c","#{ext}/redcloth_attributes.c"] do
147
+ Dir.chdir(ext) do ruby "extconf.rb" end
148
+ end
149
+
150
+ Win32Spec = Gem::Specification.new do |s|
151
+ s.name = NAME
152
+ s.version = VERS
153
+ s.platform = 'x86-mswin32-60'
154
+ s.has_rdoc = false
155
+ s.extra_rdoc_files = ["README", "CHANGELOG", "COPYING"]
156
+ s.summary = SUMMARY
157
+ s.description = s.summary
158
+ s.author = "Jason Garber"
159
+ s.email = 'redcloth-upwards@rubyforge.org'
160
+ s.homepage = 'http://redcloth.org/'
161
+ s.rubyforge_project = 'redcloth'
162
+
163
+ s.files = PKG_FILES + ["lib/redcloth_scan.so"]
164
+
165
+ s.require_path = "lib"
166
+ #s.autorequire = "redcloth" # no no no this is tHe 3v1l
167
+ s.extensions = []
168
+ s.bindir = "bin"
169
+ end
170
+
171
+ WIN32_PKG_DIR = "pkg/#{NAME}-#{VERS}-mswin32"
172
+
173
+ file WIN32_PKG_DIR => [:package] do
174
+ cp_r "pkg/#{NAME}-#{VERS}", "#{WIN32_PKG_DIR}"
175
+ end
176
+
177
+ desc "Cross-compile the redcloth_scan extension for win32"
178
+ file "redcloth_scan_win32" => [WIN32_PKG_DIR] do
179
+ cp "extras/mingw-rbconfig.rb", "#{WIN32_PKG_DIR}/ext/redcloth_scan/rbconfig.rb"
180
+ sh "cd #{WIN32_PKG_DIR}/ext/redcloth_scan/ && ruby -I. extconf.rb && make"
181
+ mv "#{WIN32_PKG_DIR}/ext/redcloth_scan/redcloth_scan.so", "#{WIN32_PKG_DIR}/lib"
182
+ end
183
+
184
+ desc "Build the binary RubyGems package for win32"
185
+ task :rubygems_win32 => ["redcloth_scan_win32"] do
186
+ Dir.chdir("#{WIN32_PKG_DIR}") do
187
+ Gem::Builder.new(Win32Spec).build
188
+ verbose(true) {
189
+ cp Dir["*.gem"].first, "../"
190
+ }
191
+ end
192
+ end
193
+
194
+ CLEAN.include WIN32_PKG_DIR
195
+
196
+ desc "Build and install the RedCloth gem on your system"
197
+ task :install => [:package] do
198
+ sh %{sudo gem install pkg/#{NAME}-#{VERS}}
199
+ end
200
+
201
+ desc "Uninstall the RedCloth gem from your system"
202
+ task :uninstall => [:clean] do
203
+ sh %{sudo gem uninstall #{NAME}}
204
+ end
205
+
206
+ RAGEL_CODE_GENERATION_STYLES = {
207
+ 'T0' => "Table driven FSM (default)",
208
+ 'T1' => "Faster table driven FSM",
209
+ 'F0' => "Flat table driven FSM",
210
+ 'F1' => "Faster flat table-driven FSM",
211
+ 'G0' => "Goto-driven FSM",
212
+ 'G1' => "Faster goto-driven FSM",
213
+ 'G2' => "Really fast goto-driven FSM"
214
+ }
215
+
216
+ desc "Find the fastest code generation style for Ragel"
217
+ task :optimize do
218
+ require 'extras/ragel_profiler'
219
+ results = []
220
+ RAGEL_CODE_GENERATION_STYLES.each do |style, name|
221
+ @code_style = style
222
+ profiler = RagelProfiler.new(style + " " + name)
223
+
224
+ # Hack to get everything to invoke again. Could use #execute, but then it
225
+ # doesn't execute prerequisites the second+ time
226
+ Rake::Task.tasks.each {|t| t.instance_eval "@already_invoked = false" }
227
+
228
+ Rake::Task['clobber'].invoke
229
+
230
+ profiler.measure(:compile) do
231
+ Rake::Task['compile'].invoke
232
+ end
233
+ profiler.measure(:test) do
234
+ Rake::Task['test'].invoke
235
+ end
236
+ profiler.ext_size(ext_so)
237
+
238
+ end
239
+ puts RagelProfiler.results
240
+ end
data/bin/redcloth ADDED
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/env ruby
2
+ $:.unshift(File.dirname(__FILE__) + '/../lib/')
3
+ require 'optparse'
4
+ require 'redcloth'
5
+
6
+ if %w(--version -v).include? ARGV.first
7
+ puts "#{RedCloth::NAME} #{RedCloth::VERSION::STRING}"
8
+ exit(0)
9
+ end
10
+
11
+ output_as = "html"
12
+ opts = OptionParser.new do |opts|
13
+ opts.banner = "Usage: redcloth [options] [redcloth_formatted.txt]"
14
+ opts.separator "If no file specified, STDIN will be used. If you are typing input, you can send an EOF by pressing ^D (^Z on Windows)"
15
+ opts.separator ""
16
+ opts.on("-o", "--output STYLE", "Output format (defaults to #{output_as})") do |o|
17
+ output_as = o
18
+ end
19
+ end
20
+ opts.parse! ARGV
21
+
22
+ red = RedCloth.new( ARGF.read )
23
+ out_meth = "to_#{ output_as }"
24
+ if red.respond_to? out_meth
25
+ puts red.method( out_meth ).call
26
+ else
27
+ abort "** No to_#{ output_as } method found for the `#{ output_as }' format"
28
+ end