red_cloth_formatters_plain 0.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ ._*
2
+ .DS_Store
3
+ *.orig
4
+ Thumbs.db
5
+ *.sqlite3.db
6
+ *.log
7
+ coverage/*
8
+ Gemfile.lock
9
+ .rvmrc
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source "http://rubygems.org"
2
+ gemspec
data/MIT-LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2009 Joseph HALTER
1
+ Copyright (c) 2012 Joseph HALTER
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person
4
4
  obtaining a copy of this software and associated documentation
@@ -19,4 +19,4 @@ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19
19
  HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20
20
  WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
21
  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
- OTHER DEALINGS IN THE SOFTWARE.
22
+ OTHER DEALINGS IN THE SOFTWARE.
data/README.textile CHANGED
@@ -1,10 +1,12 @@
1
+ **WARNING:** This project is untested with Ruby 1.9.
2
+
1
3
  h2. RedCloth::Formatters::Plain
2
4
 
3
5
  Similar to HTML and Latex formatters included in RedCloth, this one allows you to convert Textile to plain text discarding the Textile syntax.
4
6
 
5
7
  h3. Dependencies
6
8
 
7
- This plugin does of course require the RedCloth gem.
9
+ This plugin does only require the RedCloth gem.
8
10
 
9
11
  h3. Example
10
12
 
data/Rakefile CHANGED
@@ -1,38 +1,6 @@
1
- # load rspec as GEM or plugin
2
- rspec_gem_dir = nil
3
- Dir["#{File.dirname(__FILE__)}/../../gems/*"].each do |subdir|
4
- rspec_gem_dir = subdir if subdir.gsub("#{File.dirname(__FILE__)}/../../gems/","") =~ /^(\w+-)?rspec-(\d+)/ && File.exist?("#{subdir}/lib/spec/rake/spectask.rb")
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+ RSpec::Core::RakeTask.new("spec").tap do |config|
4
+ config.rspec_opts = "--color"
5
5
  end
6
- rspec_plugin_dir = File.expand_path(File.dirname(__FILE__) + '/../rspec')
7
- if rspec_gem_dir && (test ?d, rspec_plugin_dir)
8
- raise "\n#{'*'*50}\nYou have rspec installed in both vendor/gems and vendor/plugins\nPlease pick one and dispose of the other.\n#{'*'*50}\n\n"
9
- end
10
- if rspec_gem_dir
11
- $:.unshift("#{rspec_gem_dir}/lib")
12
- elsif File.exist?(rspec_plugin_dir)
13
- $:.unshift("#{rspec_plugin_dir}/lib")
14
- end
15
-
16
- # load rspec tasks
17
- require "rake"
18
- require "spec/rake/spectask"
19
-
20
- desc "Default: run specs."
21
6
  task :default => :spec
22
-
23
- desc "Run the specs"
24
- Spec::Rake::SpecTask.new(:spec) do |t|
25
- t.spec_opts = ["--colour --format progress --loadby mtime --reverse"]
26
- t.spec_files = FileList["spec/**/*_spec.rb"]
27
- end
28
-
29
- $LOAD_PATH.unshift File.expand_path("../lib/", __FILE__)
30
- require "red_cloth_formatters_plain"
31
-
32
- task :build do
33
- system "gem build redcloth-formatters-plain.gemspec"
34
- end
35
-
36
- task :release => :build do
37
- system "gem push red_cloth_formatters_plain-#{RedCloth::Formatters::Plain::VERSION}.gem"
38
- end
@@ -1,11 +1,9 @@
1
1
  # encoding: UTF-8
2
2
  require "cgi"
3
- require "RedCloth"
4
3
 
5
4
  module RedCloth
6
5
  module Formatters
7
6
  module Plain
8
- VERSION = "0.1"
9
7
 
10
8
  class Sanitizer
11
9
  def self.strip_tags(text)
@@ -69,7 +67,8 @@ module RedCloth
69
67
  end
70
68
  def li_open(opts)
71
69
  @li_need_closing = true
72
- "#{" " * (opts[:nest]-1)}- #{opts[:text]}"
70
+ num = opts[:nest] - 1
71
+ "#{" " * (num > 0 ? num : 0)}- #{opts[:text]}"
73
72
  end
74
73
  def li_close(opts=nil)
75
74
  # avoid multiple line breaks when closing multiple list items
@@ -0,0 +1,20 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = "red_cloth_formatters_plain"
6
+ s.version = "0.2.0"
7
+ s.authors = ["Joseph Halter", "Jeff Zellman"]
8
+ s.email = ["joseph@openhood.com", "jzellman@gmail.com"]
9
+ s.homepage = "https://github.com/JosephHalter/redcloth-formatters-plain"
10
+ s.summary = "Redcloth Plain Text Formatter"
11
+ s.description = "Allows Redcloth to output plain text"
12
+
13
+ s.files = `git ls-files`.split("\n")
14
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
15
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
16
+ s.require_paths = ["lib"]
17
+
18
+ s.add_development_dependency "rspec", "~>2.8.0"
19
+ s.add_dependency "RedCloth", ">= 4.2.3"
20
+ end
@@ -0,0 +1,482 @@
1
+ # encoding: UTF-8
2
+ require "spec_helper"
3
+
4
+ describe "RedCloth::Formatters::Plain" do
5
+
6
+ it "simple test" do
7
+ RedCloth.new("p. this is *simple* _test_").to_plain.should == "this is simple test"
8
+ end
9
+
10
+ describe "Writing Paragraph Text" do
11
+ describe "Simple paragraphs" do
12
+ it "implicit" do
13
+ input = "This is a paragraph.\n\nThis is another paragraph"
14
+ output = "This is a paragraph.\nThis is another paragraph"
15
+ RedCloth.new(input).to_plain.should == output
16
+ end
17
+ it "explicit" do
18
+ input = "p. This is one paragraph.\n\np. This is another."
19
+ output = "This is one paragraph.\nThis is another."
20
+ RedCloth.new(input).to_plain.should == output
21
+ end
22
+ end
23
+ describe "Line breaks" do
24
+ it "implicit" do
25
+ input = "Roses are red,\nViolets are blue,\nI'd like a sandwich;\nPerhaps even two."
26
+ RedCloth.new(input).to_plain.should == input
27
+ end
28
+ it "in tags" do
29
+ input = "<pre>\nMirror mirror\non the wall...\n</pre>"
30
+ output = "\nMirror mirror\non the wall...\n"
31
+ RedCloth.new(input).to_plain.should == output
32
+ end
33
+ end
34
+ describe "Curly quotes" do
35
+ it "quotations" do
36
+ input = "\"I said, 'hold the mayo' twice!\""
37
+ RedCloth.new(input).to_plain.should == input
38
+ end
39
+ it "apostrophes" do
40
+ input = "We went to Steven's mother's house for a party."
41
+ RedCloth.new(input).to_plain.should == input
42
+ end
43
+ end
44
+ describe "Dashes" do
45
+ it "single and double hyphens" do
46
+ input = "I could be happy--fantastically happy--on twenty-one thousand a year if I only had to work 9 am - 1 pm."
47
+ output = "I could be happy-fantastically happy-on twenty-one thousand a year if I only had to work 9 am - 1 pm."
48
+ RedCloth.new(input).to_plain.should == output
49
+ end
50
+ it "between words" do
51
+ input = "June - July 1967"
52
+ RedCloth.new(input).to_plain.should == input
53
+ end
54
+ it "em dashes" do
55
+ input = "Please use the em dash closed--or open if you must -- but I prefer it closed."
56
+ output = "Please use the em dash closed-or open if you must - but I prefer it closed."
57
+ RedCloth.new(input).to_plain.should == output
58
+ end
59
+ end
60
+ describe "Ellipses" do
61
+ it "tree periods" do
62
+ input = "He thought and thought ... and then thought some more."
63
+ RedCloth.new(input).to_plain.should == input
64
+ end
65
+ it "in conjunction with spaces and other punctuation" do
66
+ input = "Four score and seven years ago our fathers brought forth...a new nation...dedicated to the proposition that all men are created equal...."
67
+ RedCloth.new(input).to_plain.should == input
68
+ end
69
+ end
70
+ describe "Dimension sign" do
71
+ it "lowercase letter x" do
72
+ input = "4 x 4 = 16"
73
+ RedCloth.new(input).to_plain.should == input
74
+ end
75
+ it "to represent feet and inches" do
76
+ input = "My office measures 5' x 5'6\"."
77
+ RedCloth.new(input).to_plain.should == input
78
+ end
79
+ it "spaces are optional" do
80
+ input = "4x4=16"
81
+ RedCloth.new(input).to_plain.should == input
82
+ end
83
+ end
84
+ it "Registered, trademark, and copyright symbols" do
85
+ input = "RegisteredTrademark(r), Trademark(tm), and Copyright (c) 2008"
86
+ output = "RegisteredTrademark®, Trademark™, and Copyright © 2008"
87
+ RedCloth.new(input).to_plain.should == output
88
+ end
89
+ it "Acronyms" do
90
+ input = "The EPA(Environmental Protection Agency) is measuring GHG(greenhouse gas) emissions."
91
+ RedCloth.new(input).to_plain.should == input
92
+ end
93
+ it "Uppercase" do
94
+ input = "Many NASDAQ companies are ISO certified."
95
+ RedCloth.new(input).to_plain.should == input
96
+ end
97
+ end
98
+ describe "Page Layout" do
99
+ it "Headings" do
100
+ input = "h1. This is a Heading 1\n\nThis might be an introductory paragraph on the general topic.\n\nh2. Heading 2 gets more specific\n\nNow we're getting into the details."
101
+ output = "This is a Heading 1\nThis might be an introductory paragraph on the general topic.\nHeading 2 gets more specific\nNow we're getting into the details."
102
+ RedCloth.new(input).to_plain.should == output
103
+ end
104
+ describe "Block quotations" do
105
+ it "long quotations" do
106
+ input = "Even Mr. Sedaris, a noted luddite, has finally succumbed to doing his writing on a computer. The Internet, however, remains an idiotic trifle:\n\n"
107
+ input += "bq. I've never seen the Internet. I don't have email. I just enjoy lying on the couch and reading a magazine. When people say, \"You should visit my Web page,\" I'm always perplexed by it. Why? What do you do there?\n\n"
108
+ input += "Haven't we all pondered that at one time or another?"
109
+ output = "Even Mr. Sedaris, a noted luddite, has finally succumbed to doing his writing on a computer. The Internet, however, remains an idiotic trifle:\n"
110
+ output += "I've never seen the Internet. I don't have email. I just enjoy lying on the couch and reading a magazine. When people say, \"You should visit my Web page,\" I'm always perplexed by it. Why? What do you do there?\n"
111
+ output += "Haven't we all pondered that at one time or another?"
112
+ RedCloth.new(input).to_plain.should == output
113
+ end
114
+ it "citation URL immediately following the period" do
115
+ input = "A standard Lorem Ipsum passage has been used since the 1500s:\n\n"
116
+ input += "bq.:http://www.lipsum.com/ Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."
117
+ output = "A standard Lorem Ipsum passage has been used since the 1500s:\n"
118
+ output += "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."
119
+ RedCloth.new(input).to_plain.should == output
120
+ end
121
+ it "more than one paragraph" do
122
+ input = "bq.. This is one paragraph.\n\n"
123
+ input += "Another paragraph, also part of the quote.\n\n"
124
+ input += "p. A normal paragraph ends the quote."
125
+ output = "This is one paragraph.\n"
126
+ output += "Another paragraph, also part of the quote.\n"
127
+ output += "A normal paragraph ends the quote."
128
+ RedCloth.new(input).to_plain.should == output
129
+ end
130
+ end
131
+ it "Bullet lists" do
132
+ input = "Textile has several advantages over HTML:\n\n"
133
+ input += "* It's easier on the eyes\n"
134
+ input += "* You don't have to write all those HTML tags\n"
135
+ input += "** By not writing the tags yourself, you're less likely to make coding mistakes\n"
136
+ input += "** It requires fewer keystrokes\n"
137
+ input += "*** You don't wear out the keys on your keyboard as fast\n"
138
+ input += "*** You won't wear out your fingers as fast\n"
139
+ input += "* You can write it much quicker"
140
+ output = "Textile has several advantages over HTML:\n"
141
+ output += "- It's easier on the eyes\n"
142
+ output += "- You don't have to write all those HTML tags\n"
143
+ output += " - By not writing the tags yourself, you're less likely to make coding mistakes\n"
144
+ output += " - It requires fewer keystrokes\n"
145
+ output += " - You don't wear out the keys on your keyboard as fast\n"
146
+ output += " - You won't wear out your fingers as fast\n"
147
+ output += "- You can write it much quicker"
148
+ RedCloth.new(input).to_plain.should == output
149
+ end
150
+ it "Numbered lists" do
151
+ input = "How to make a PB&J:\n\n"
152
+ input += "# Gather bread, peanut butter, and jelly\n"
153
+ input += "# Slice the bread if necessary\n"
154
+ input += "# Assemble the sandwich\n"
155
+ input += "## Spread peanut butter on one slice of bread\n"
156
+ input += "## Put jelly on another slice\n"
157
+ input += "## Put the two slices together\n"
158
+ input += "# Enjoy"
159
+ output = "How to make a PB&J:\n"
160
+ output += "- Gather bread, peanut butter, and jelly\n"
161
+ output += "- Slice the bread if necessary\n"
162
+ output += "- Assemble the sandwich\n"
163
+ output += " - Spread peanut butter on one slice of bread\n"
164
+ output += " - Put jelly on another slice\n"
165
+ output += " - Put the two slices together\n"
166
+ output += "- Enjoy"
167
+ RedCloth.new(input).to_plain.should == output
168
+ end
169
+ it "Mixed nested lists" do
170
+ input = "Three reasons to walk to work:\n\n"
171
+ input += "# It saves fuel\n"
172
+ input += "# It's good for your health\n"
173
+ input += "** Walking burns calories\n"
174
+ input += "** Time outside means lower stress\n"
175
+ input += "# It's good for the environment"
176
+ output = "Three reasons to walk to work:\n"
177
+ output += "- It saves fuel\n"
178
+ output += "- It's good for your health\n"
179
+ output += " - Walking burns calories\n"
180
+ output += " - Time outside means lower stress\n"
181
+ output += "- It's good for the environment"
182
+ RedCloth.new(input).to_plain.should == output
183
+ end
184
+ it "Definition lists" do
185
+ input = "- coffee := Hot and black\n"
186
+ input += "- tea := Also hot, but a little less black\n"
187
+ input += "- milk :=\n"
188
+ input += "Nourishing beverage for baby cows.\n\n"
189
+ input += "Cold drink that goes great with cookies. =:"
190
+ output = "coffee:\n Hot and black\n"
191
+ output += "tea:\n Also hot, but a little less black\n"
192
+ output += "milk:\n Nourishing beverage for baby cows.\n"
193
+ output += "Cold drink that goes great with cookies."
194
+ RedCloth.new(input).to_plain.should == output
195
+ end
196
+ it "Footnotes" do
197
+ input = "42.7% of all statistics are made up on the spot.[1]\n\n"
198
+ input += "fn1. \"Dr. Katz\":http://en.wikiquote.org/wiki/Steven_Wright"
199
+ output = "42.7% of all statistics are made up on the spot."
200
+ RedCloth.new(input).to_plain.should == output
201
+ end
202
+ describe "Tables" do
203
+ it "simple" do
204
+ input = "|_. name|_. age|\n"
205
+ input += "|Walter|5|\n"
206
+ input += "|Florence|6|"
207
+ RedCloth.new(input).to_plain.should == ""
208
+ end
209
+ it "cellspan" do
210
+ input = "|{background:#ddd}. Cell with background|Normal|\n"
211
+ input += "|\2. Cell spanning 2 columns|\n"
212
+ input += "|/2. Cell spanning 2 rows|one|\n"
213
+ input += "|two|\n"
214
+ input += "|>. Right-aligned cell|<. Left-aligned cell|"
215
+ RedCloth.new(input).to_plain.should == ""
216
+ end
217
+ it "with attributes" do
218
+ input = "table(#prices).\n"
219
+ input += "|Adults|$5|\n"
220
+ input += "|Children|$2|"
221
+ RedCloth.new(input).to_plain.should == ""
222
+ end
223
+ end
224
+ it "Divisions" do
225
+ input = "div. A simple div."
226
+ output = "A simple div."
227
+ RedCloth.new(input).to_plain.should == output
228
+ end
229
+ end
230
+ describe "Phrase modifiers" do
231
+ it "Strong importance" do
232
+ input = "Don't *ever* pull this lever."
233
+ output = "Don't ever pull this lever."
234
+ RedCloth.new(input).to_plain.should == output
235
+ end
236
+ it "Stress emphasis" do
237
+ input = "You didn't actually _believe_ her, did you?"
238
+ output = "You didn't actually believe her, did you?"
239
+ RedCloth.new(input).to_plain.should == output
240
+ end
241
+ it "Stylistic offset" do
242
+ input = "Search results for **Textile**:\n\n"
243
+ input += "h4. [\"**Textile** (markup language) - Wikipedia\":http://en.wikipedia.org/wiki/Textile_(markup_language)]\n\n"
244
+ input += "**Textile** is a lightweight markup language originally developed by Dean Allen and billed as a \"humane Web text generator\". **Textile** converts its marked-up text ..."
245
+ output = "Search results for Textile:\n"
246
+ output += "Textile (markup language) - Wikipedia <http://en.wikipedia.org/wiki/Textile_(markup_language)>\n"
247
+ output += "Textile is a lightweight markup language originally developed by Dean Allen and billed as a \"humane Web text generator\". Textile converts its marked-up text ..."
248
+ RedCloth.new(input).to_plain.should == output
249
+ end
250
+ it "Alternate voice" do
251
+ input = "I just got the weirdest feeling of __déjà vu__."
252
+ output = "I just got the weirdest feeling of déjà vu."
253
+ RedCloth.new(input).to_plain.should == output
254
+ end
255
+ it "Citation" do
256
+ input = "My wife's favorite book is ??The Count of Monte Cristo?? by Dumas."
257
+ output = "My wife's favorite book is The Count of Monte Cristo by Dumas."
258
+ RedCloth.new(input).to_plain.should == output
259
+ end
260
+ describe "Insertions and deletions" do
261
+ it "using minuses and pluses" do
262
+ input = "The news networks declared -Al Gore- +George W. Bush+ the winner in Florida."
263
+ output = "The news networks declared George W. Bush the winner in Florida."
264
+ RedCloth.new(input).to_plain.should == output
265
+ end
266
+ it "surrounded with square brackets" do
267
+ input = "[-this was deleted-][+this was added+] to the paragraph"
268
+ output = "this was added to the paragraph"
269
+ RedCloth.new(input).to_plain.should == output
270
+ end
271
+ end
272
+ describe "Superscript and subscript" do
273
+ it "surrounded with caret and tilde characters" do
274
+ input = "f(x, n) = log ~4~ x ^n^"
275
+ output = "f(x, n) = log 4 x n"
276
+ RedCloth.new(input).to_plain.should == output
277
+ end
278
+ it "using square brackets" do
279
+ input = "f(x, n) = log[~4~]x[^n^]"
280
+ output = "f(x, n) = log4xn"
281
+ RedCloth.new(input).to_plain.should == output
282
+ end
283
+ end
284
+ describe "Links" do
285
+ it "followed by a colon" do
286
+ input = "Learn more \"about the company\":/about and our \"board of directors\":../about#board."
287
+ output = "Learn more about the company </about> and our board of directors <../about#board>."
288
+ RedCloth.new(input).to_plain.should == output
289
+ end
290
+ it "with title" do
291
+ input = "Visit our \"parent company (Example Corporation)\":http://example.com."
292
+ output = "Visit our parent company <http://example.com>."
293
+ RedCloth.new(input).to_plain.should == output
294
+ end
295
+ it "surrounded with square brackets" do
296
+ input = "This is a link to a [\"Wikipedia article about Textile\":http://en.wikipedia.org/wiki/Textile_(markup_language)]."
297
+ output = "This is a link to a Wikipedia article about Textile <http://en.wikipedia.org/wiki/Textile_(markup_language)>."
298
+ RedCloth.new(input).to_plain.should == output
299
+ end
300
+ it "with alias" do
301
+ input = "I'm really excited about \"RedCloth\":redcloth. I love it so much, I think I'll name my first child \"RedCloth\":redcloth.\n\n"
302
+ input += "[redcloth]http://redcloth.org"
303
+ output = "I'm really excited about RedCloth <http://redcloth.org>. I love it so much, I think I'll name my first child RedCloth <http://redcloth.org>."
304
+ RedCloth.new(input).to_plain.should == output
305
+ end
306
+ end
307
+ describe "Images" do
308
+ it "with exclamation marks" do
309
+ input = "!http://www.w3.org/Icons/valid-html401(This page is valid HTML)!"
310
+ output = "This page is valid HTML"
311
+ RedCloth.new(input).to_plain.should == output
312
+ end
313
+ it "linked" do
314
+ input = "!http://www.w3.org/Icons/valid-html401!:http://validator.w3.org/check?uri=referer"
315
+ output = ""
316
+ RedCloth.new(input).to_plain.should == output
317
+ end
318
+ end
319
+ end
320
+ describe "Attributes" do
321
+ describe "CSS classes and IDs" do
322
+ it "class or id" do
323
+ input = "p(my-class). This is a paragraph that has a class and this *(#special-phrase)emphasized phrase* has an id."
324
+ output = "This is a paragraph that has a class and this emphasized phrase has an id."
325
+ RedCloth.new(input).to_plain.should == output
326
+ end
327
+ it "id on paragraph" do
328
+ input = "p(#my-paragraph). This is a paragraph that has an id."
329
+ output = "This is a paragraph that has an id."
330
+ RedCloth.new(input).to_plain.should == output
331
+ end
332
+ it "both class and id" do
333
+ input = "div(myclass#myid). This div has both a CSS class and ID."
334
+ output = "This div has both a CSS class and ID."
335
+ RedCloth.new(input).to_plain.should == output
336
+ end
337
+ end
338
+ it "CSS styles" do
339
+ input = "p{color:blue;letter-spacing:.5em}. Spacey blue"
340
+ output = "Spacey blue"
341
+ RedCloth.new(input).to_plain.should == output
342
+ end
343
+ it "Language" do
344
+ input = "p[fr]. Parlez-vous français ?"
345
+ output = "Parlez-vous français ?"
346
+ RedCloth.new(input).to_plain.should == output
347
+ end
348
+ it "Alignment" do
349
+ input = "p<. align left\n\n"
350
+ input += "p>. align right\n\n"
351
+ input += "p=. centered\n\n"
352
+ input += "p<>. justified justified justified justified justified justified justified justified justified"
353
+ output = "align left\n"
354
+ output += "align right\n"
355
+ output += "centered\n"
356
+ output += "justified justified justified justified justified justified justified justified justified"
357
+ RedCloth.new(input).to_plain.should == output
358
+ end
359
+ it "Indentation" do
360
+ input = "p(. Left pad 1em.\n\n"
361
+ input += "p)). Right pad 2em.\n\n"
362
+ input += "p(). Pad both left and right sides 1em."
363
+ output = "Left pad 1em.\n"
364
+ output += "Right pad 2em.\n"
365
+ output += "Pad both left and right sides 1em."
366
+ RedCloth.new(input).to_plain.should == output
367
+ end
368
+ end
369
+ describe "HTML Integration and Escapement" do
370
+ it "HTML spans" do
371
+ input = "I can put in a %(myclass)span with a class% like this."
372
+ output = "I can put in a span with a class like this."
373
+ RedCloth.new(input).to_plain.should == output
374
+ end
375
+ it "Inline code" do
376
+ input = "On the command line, you can just type @redcloth@."
377
+ output = "On the command line, you can just type redcloth."
378
+ RedCloth.new(input).to_plain.should == output
379
+ end
380
+ describe "Block code" do
381
+ it "block of code" do
382
+ input = "bc. # Output \"I love Ruby\"\n"
383
+ input += "say = \"I love Ruby\"\n"
384
+ input += "puts say"
385
+ output = "# Output \"I love Ruby\"\n"
386
+ output += "say = \"I love Ruby\"\n"
387
+ output += "puts say"
388
+ RedCloth.new(input).to_plain.should == output
389
+ end
390
+ it "including blank lines" do
391
+ input = "bc.. # Output \"I love Ruby\"\n"
392
+ input += "say = \"I love Ruby\"\n"
393
+ input += "puts say\n\n"
394
+ input += "# Output \"I *LOVE* RUBY\"\n"
395
+ input += "say['love'] = \"*love*\"\n"
396
+ input += "puts say.upcase\n\n"
397
+ input += "p. And that is how you do it."
398
+ output = "# Output \"I love Ruby\"\n"
399
+ output += "say = \"I love Ruby\"\n"
400
+ output += "puts say\n\n"
401
+ output += "# Output \"I *LOVE* RUBY\"\n"
402
+ output += "say['love'] = \"*love*\"\n"
403
+ output += "puts say.upcase\n"
404
+ output += "And that is how you do it."
405
+ RedCloth.new(input).to_plain.should == output
406
+ end
407
+ end
408
+ it "Inline HTML" do
409
+ input = "I can use HTML directly in my <span class=\"youbetcha\">Textile</span>."
410
+ output = "I can use HTML directly in my Textile."
411
+ RedCloth.new(input).to_plain.should == output
412
+ end
413
+ it "Block HTML" do
414
+ input = "<div id=\"shopping-cart\">\n"
415
+ input += "<form action=\"form_action\" method=\"get\">\n"
416
+ input += "h3. Your cart\n\n"
417
+ input += "* Item one\n"
418
+ input += "* Item two\n\n"
419
+ input += "<p><input type=\"submit\" value=\"Check Out\" /></p>\n\n"
420
+ input += "</form>\n"
421
+ input += "</div>"
422
+ output = "\n\n"
423
+ output += "Your cart\n"
424
+ output += "- Item one\n"
425
+ output += "- Item two"
426
+ output += "\n\n"
427
+ RedCloth.new(input).to_plain.should == output
428
+ end
429
+ describe "No Textile" do
430
+ it "notextile tag or double-equals" do
431
+ input = "<notextile>\n"
432
+ input += "Don't touch this!\n"
433
+ input += "</notextile>\n\n"
434
+ input += "Use ==*asterisks*== to say something *strongly*."
435
+ output = "Don't touch this!\n"
436
+ output += "Use *asterisks* to say something strongly."
437
+ RedCloth.new(input).to_plain.should == output
438
+ end
439
+ it "as normal or extended block" do
440
+ input = "notextile. This has *no* textile formatting, see?\n\n"
441
+ input += "notextile.. And this notextile block\n\n"
442
+ input += "Just keeps going and going.\n\n"
443
+ input += "p. Until you end it with another block."
444
+ output = "This has *no* textile formatting, see?\n\n"
445
+ output += "And this notextile block\n\n"
446
+ output += "Just keeps going and going."
447
+ output += "Until you end it with another block."
448
+ RedCloth.new(input).to_plain.should == output
449
+ end
450
+ end
451
+ describe "Preformatted text" do
452
+ it "pre block" do
453
+ output = " Text in a pre block\n"
454
+ output += "is displayed in a fixed-width\n"
455
+ output += " font. It preserves\n"
456
+ output += " s p a c e s, line breaks\n"
457
+ output += " and ascii bunnies.\n"
458
+ output += " _ _ \n"
459
+ output += " \`\ /`/ \n"
460
+ output += " \ V / \n"
461
+ output += " /. .\ \n"
462
+ output += " =\ T /= \n"
463
+ output += " / ^ \ \n"
464
+ output += " {}/\\ //\ \n"
465
+ output += " __\ " " /__ \n"
466
+ output += " (____/^\____)"
467
+ input = "pre. #{output}"
468
+ RedCloth.new(input).to_plain.should == output
469
+ end
470
+ it "extended" do
471
+ input = "pre.. All monospaced\n\n"
472
+ input += "Even the blank lines\n\n"
473
+ input += "p. But now a paragraph"
474
+ output = "All monospaced\n"
475
+ output += "Even the blank lines\n"
476
+ output += "But now a paragraph"
477
+ RedCloth.new(input).to_plain.should == output
478
+ end
479
+ end
480
+ end
481
+
482
+ end
@@ -0,0 +1,2 @@
1
+ require "redcloth"
2
+ require "red_cloth_formatters_plain"
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: red_cloth_formatters_plain
3
3
  version: !ruby/object:Gem::Version
4
- hash: 9
5
- prerelease: false
4
+ hash: 23
5
+ prerelease:
6
6
  segments:
7
7
  - 0
8
- - 1
9
- version: "0.1"
8
+ - 2
9
+ - 0
10
+ version: 0.2.0
10
11
  platform: ruby
11
12
  authors:
12
13
  - Joseph Halter
@@ -15,8 +16,7 @@ autorequire:
15
16
  bindir: bin
16
17
  cert_chain: []
17
18
 
18
- date: 2010-10-07 00:00:00 -05:00
19
- default_executable:
19
+ date: 2012-02-28 00:00:00 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  name: rspec
@@ -24,12 +24,14 @@ dependencies:
24
24
  requirement: &id001 !ruby/object:Gem::Requirement
25
25
  none: false
26
26
  requirements:
27
- - - ">="
27
+ - - ~>
28
28
  - !ruby/object:Gem::Version
29
- hash: 3
29
+ hash: 47
30
30
  segments:
31
+ - 2
32
+ - 8
31
33
  - 0
32
- version: "0"
34
+ version: 2.8.0
33
35
  type: :development
34
36
  version_requirements: *id001
35
37
  - !ruby/object:Gem::Dependency
@@ -40,14 +42,17 @@ dependencies:
40
42
  requirements:
41
43
  - - ">="
42
44
  - !ruby/object:Gem::Version
43
- hash: 3
45
+ hash: 49
44
46
  segments:
45
- - 0
46
- version: "0"
47
+ - 4
48
+ - 2
49
+ - 3
50
+ version: 4.2.3
47
51
  type: :runtime
48
52
  version_requirements: *id002
49
53
  description: Allows Redcloth to output plain text
50
54
  email:
55
+ - joseph@openhood.com
51
56
  - jzellman@gmail.com
52
57
  executables: []
53
58
 
@@ -56,13 +61,16 @@ extensions: []
56
61
  extra_rdoc_files: []
57
62
 
58
63
  files:
59
- - lib/red_cloth_formatters_plain.rb
64
+ - .gitignore
65
+ - Gemfile
60
66
  - MIT-LICENSE
61
67
  - README.textile
62
68
  - Rakefile
63
- - init.rb
64
- has_rdoc: true
65
- homepage:
69
+ - lib/red_cloth_formatters_plain.rb
70
+ - red_cloth_formatters_plain.gemspec
71
+ - spec/red_cloth_formatters_plain_spec.rb
72
+ - spec/spec_helper.rb
73
+ homepage: https://github.com/JosephHalter/redcloth-formatters-plain
66
74
  licenses: []
67
75
 
68
76
  post_install_message:
@@ -84,18 +92,17 @@ required_rubygems_version: !ruby/object:Gem::Requirement
84
92
  requirements:
85
93
  - - ">="
86
94
  - !ruby/object:Gem::Version
87
- hash: 23
95
+ hash: 3
88
96
  segments:
89
- - 1
90
- - 3
91
- - 6
92
- version: 1.3.6
97
+ - 0
98
+ version: "0"
93
99
  requirements: []
94
100
 
95
101
  rubyforge_project:
96
- rubygems_version: 1.3.7
102
+ rubygems_version: 1.8.10
97
103
  signing_key:
98
104
  specification_version: 3
99
105
  summary: Redcloth Plain Text Formatter
100
- test_files: []
101
-
106
+ test_files:
107
+ - spec/red_cloth_formatters_plain_spec.rb
108
+ - spec/spec_helper.rb
data/init.rb DELETED
@@ -1 +0,0 @@
1
- require "red_cloth_formatters_plain"