RedCloth 3.0.2 → 3.0.3
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.
- data/bin/redcloth +1 -1
- data/lib/redcloth.rb +28 -17
- data/tests/markdown.yml +11 -7
- metadata +5 -4
data/bin/redcloth
CHANGED
data/lib/redcloth.rb
CHANGED
@@ -166,7 +166,7 @@
|
|
166
166
|
|
167
167
|
class RedCloth < String
|
168
168
|
|
169
|
-
VERSION = '3.0.
|
169
|
+
VERSION = '3.0.3'
|
170
170
|
DEFAULT_RULES = [:textile, :markdown]
|
171
171
|
|
172
172
|
#
|
@@ -193,6 +193,16 @@ class RedCloth < String
|
|
193
193
|
#
|
194
194
|
attr_accessor :hard_breaks
|
195
195
|
|
196
|
+
#
|
197
|
+
# Accessor for toggling span caps.
|
198
|
+
#
|
199
|
+
# Textile places `span' tags around capitalized
|
200
|
+
# words by default, but this wreaks havoc on Wikis.
|
201
|
+
# If +:no_span_caps+ is set, this will be
|
202
|
+
# suppressed.
|
203
|
+
#
|
204
|
+
attr_accessor :no_span_caps
|
205
|
+
|
196
206
|
#
|
197
207
|
# Establishes the markup predence. Available rules include:
|
198
208
|
#
|
@@ -344,7 +354,7 @@ class RedCloth < String
|
|
344
354
|
[ /"/, '“' ], # double opening
|
345
355
|
[ /\b( )?\.{3}/, '\1…' ], # ellipsis
|
346
356
|
[ /\b([A-Z][A-Z0-9]{2,})\b(?:[(]([^)]*)[)])/, '<acronym title="\2">\1</acronym>' ], # 3+ uppercase acronym
|
347
|
-
[ /(^|[^"][>\s])([A-Z][A-Z0-9 ]{2,})([^<a-z0-9]|$)/, '\1<span class="caps">\2</span>\3' ], # 3+ uppercase caps
|
357
|
+
[ /(^|[^"][>\s])([A-Z][A-Z0-9 ]{2,})([^<a-z0-9]|$)/, '\1<span class="caps">\2</span>\3', :no_span_caps ], # 3+ uppercase caps
|
348
358
|
[ /(\.\s)?\s?--\s?/, '\1—' ], # em dash
|
349
359
|
[ /\s->\s/, ' → ' ], # right arrow
|
350
360
|
[ /\s-\s/, ' – ' ], # en dash
|
@@ -370,7 +380,7 @@ class RedCloth < String
|
|
370
380
|
QTAGS = [
|
371
381
|
['**', 'b'],
|
372
382
|
['*', 'strong'],
|
373
|
-
['??', 'cite'],
|
383
|
+
['??', 'cite', :limit],
|
374
384
|
['-', 'del', :limit],
|
375
385
|
['__', 'i'],
|
376
386
|
['_', 'em', :limit],
|
@@ -414,7 +424,8 @@ class RedCloth < String
|
|
414
424
|
|
415
425
|
# Search and replace for Textile glyphs (quotes, dashes, other symbols)
|
416
426
|
def pgl( text )
|
417
|
-
GLYPHS.each do |re, resub|
|
427
|
+
GLYPHS.each do |re, resub, tog|
|
428
|
+
next if tog and method( tog ).call
|
418
429
|
text.gsub! re, resub
|
419
430
|
end
|
420
431
|
end
|
@@ -546,14 +557,12 @@ class RedCloth < String
|
|
546
557
|
end
|
547
558
|
end
|
548
559
|
|
549
|
-
CODE_RE = /
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
(?=[\s\]}\)<#{PUNCT}]|$) # 4 closing bracket?
|
556
|
-
/x
|
560
|
+
CODE_RE = /(\W)
|
561
|
+
@
|
562
|
+
(?:\|(\w+?)\|)?
|
563
|
+
(.+?)
|
564
|
+
@
|
565
|
+
(?=\W)/x
|
557
566
|
|
558
567
|
def inline_textile_code( text )
|
559
568
|
text.gsub!( CODE_RE ) do |m|
|
@@ -934,11 +943,13 @@ class RedCloth < String
|
|
934
943
|
|
935
944
|
def flush_left( text )
|
936
945
|
indt = 0
|
937
|
-
|
938
|
-
|
939
|
-
|
940
|
-
|
941
|
-
|
946
|
+
if text =~ /^ /
|
947
|
+
while text !~ /^ {#{indt}}\S/
|
948
|
+
indt += 1
|
949
|
+
end unless text.empty?
|
950
|
+
if indt.nonzero?
|
951
|
+
text.gsub!( /^ {#{indt}}/, '' )
|
952
|
+
end
|
942
953
|
end
|
943
954
|
end
|
944
955
|
|
data/tests/markdown.yml
CHANGED
@@ -19,14 +19,19 @@ out: |-
|
|
19
19
|
</table>
|
20
20
|
<p>This is another regular paragraph.</p>
|
21
21
|
---
|
22
|
+
in: '"Larry Bird":http://images.google.com/images?num=30&q=larry+bird'
|
23
|
+
out: '<p>"Larry Bird":http://images.google.com/images?num=30&q=larry+bird</p>'
|
24
|
+
---
|
22
25
|
in: '©'
|
23
26
|
out: <p>©</p>
|
24
27
|
---
|
25
28
|
in: AT&T
|
26
29
|
out: <p>AT&T</p>
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
+
|
31
|
+
# We don't do this.
|
32
|
+
# ---
|
33
|
+
# in: 4 < 5
|
34
|
+
# out: 4 < 5
|
30
35
|
---
|
31
36
|
in: |
|
32
37
|
This is an H1
|
@@ -74,7 +79,7 @@ in: |
|
|
74
79
|
> This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet,
|
75
80
|
consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus.
|
76
81
|
Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.
|
77
|
-
|
82
|
+
>
|
78
83
|
> Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse
|
79
84
|
id sem consectetuer libero luctus adipiscing.
|
80
85
|
out: |-
|
@@ -126,9 +131,8 @@ out: |-
|
|
126
131
|
<p>1. This is the first list item.
|
127
132
|
2. This is the second list item.</p>
|
128
133
|
|
129
|
-
<p>Here's some example code
|
130
|
-
<code>return shell_exec(
|
131
|
-
</p>
|
134
|
+
<p>Here's some example code:</p>
|
135
|
+
<pre><code>return shell_exec("echo $input | $markdown_script");</code></pre>
|
132
136
|
|
133
137
|
</blockquote>
|
134
138
|
---
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.8.
|
2
|
+
rubygems_version: 0.8.4
|
3
3
|
specification_version: 1
|
4
4
|
name: RedCloth
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 3.0.
|
7
|
-
date: 2005-02-
|
6
|
+
version: 3.0.3
|
7
|
+
date: 2005-02-06
|
8
8
|
summary: RedCloth is a module for using Textile and Markdown in Ruby. Textile and Markdown are text formats. A very simple text format. Another stab at making readable text that can be converted to HTML.
|
9
9
|
require_paths:
|
10
10
|
- lib
|
11
|
-
author: Why the Lucky Stiff
|
12
11
|
email: why@ruby-lang.org
|
13
12
|
homepage: http://www.whytheluckystiff.net/ruby/redcloth/
|
14
13
|
rubyforge_project: redcloth
|
@@ -37,6 +36,8 @@ required_ruby_version: !ruby/object:Gem::Version::Requirement
|
|
37
36
|
version: 0.0.0
|
38
37
|
version:
|
39
38
|
platform: ruby
|
39
|
+
authors:
|
40
|
+
- Why the Lucky Stiff
|
40
41
|
files:
|
41
42
|
- bin/redcloth
|
42
43
|
- tests/code.yml
|