marker 0.2.2 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/lib/marker/common.rb CHANGED
@@ -11,7 +11,7 @@ module Treetop #:nodoc:
11
11
  class SyntaxNode #:nodoc:
12
12
  # returns whether the ParseNode matched any text
13
13
  def present?
14
- text_value.any?
14
+ not text_value.empty?
15
15
  end
16
16
  end
17
17
  end
@@ -614,7 +614,7 @@ module Marker
614
614
  # * %XX is allowed as a character, these are escaped characters
615
615
  # * '#' is added for HTML anchors
616
616
  rule url_safe_char
617
- !"]" [A-Za-z0-9$-_.+!*'(),@:/#]
617
+ !"]" [A-Za-z0-9$-_.+!?*'(),@:/#]
618
618
  /
619
619
  "%" xdigit xdigit
620
620
  end
data/lib/marker/links.rb CHANGED
@@ -137,23 +137,17 @@ module Marker #:nodoc:
137
137
 
138
138
  class URL < ParseNode
139
139
  def to_html( options = {} )
140
- f = options[:footnotes]
141
- if f
142
- n = f.add( bare_url )
143
- "<a href='#{bare_url}'>[#{n}]</a>"
140
+ url = bare_url
141
+ if url =~ /[.,!?:]$/
142
+ "<a href='#{url[0...-1]}'>#{url[0...-1]}</a>#{url[-1]}"
144
143
  else
145
- "<a href='#{bare_url}'>#{bare_url}</a>"
144
+ "<a href='#{url}'>#{url}</a>"
146
145
  end
147
146
  end
148
147
 
149
148
  def to_s( options = {} )
150
- f = options[:footnotes]
151
- if f
152
- n = f.add( bare_url )
153
- "[#{n}]"
154
- else
155
- bare_url
156
- end
149
+ # no need to worry about trailing punctuation since it's all text.
150
+ bare_url
157
151
  end
158
152
 
159
153
  # returns just the URL that was matched
data/test/links_test.rb CHANGED
@@ -101,25 +101,35 @@ class LinkTest < Test::Unit::TestCase
101
101
  text = "http://www.example.com following text"
102
102
  markup = Marker.parse text
103
103
 
104
- assert_match("<p><a href='http://www.example.com'>[1]</a> following text</p>\n<ol><li><a href='http://www.example.com'>http://www.example.com</a></li></ol>", markup.to_html)
104
+ assert_match("<p><a href='http://www.example.com'>http://www.example.com</a> following text</p>", markup.to_html)
105
105
  end
106
106
 
107
107
  def test_bare_url_with_encodings
108
108
  text = "http://www.example.com/page?input=%28%29 following text"
109
109
  markup = Marker.parse text
110
110
 
111
- assert_match("<p><a href='http://www.example.com/page?input=%28%29'>[1]</a> following text</p>\n<ol><li><a href='http://www.example.com/page?input=%28%29'>http://www.example.com/page?input=%28%29</a></li></ol>", markup.to_html)
111
+ assert_match("<p><a href='http://www.example.com/page?input=%28%29'>http://www.example.com/page?input=%28%29</a> following text</p>", markup.to_html)
112
112
  end
113
113
 
114
114
  def test_bare_url_with_anchor
115
115
  text = "http://www.example.com/page#anchor following text"
116
116
  markup = Marker.parse text
117
117
 
118
- assert_match("<p><a href='http://www.example.com/page#anchor'>[1]</a> following text</p>\n<ol><li><a href='http://www.example.com/page#anchor'>http://www.example.com/page#anchor</a></li></ol>", markup.to_html)
118
+ assert_match("<p><a href='http://www.example.com/page#anchor'>http://www.example.com/page#anchor</a> following text</p>", markup.to_html)
119
+ end
120
+
121
+ def test_bare_url_with_punctuation
122
+ text = "http://www.example.com. following text"
123
+ markup = Marker.parse text
124
+ assert_match("<p><a href='http://www.example.com'>http://www.example.com</a>. following text</p>", markup.to_html)
125
+
126
+ text = "http://www.example.com, following text"
127
+ markup = Marker.parse text
128
+ assert_match("<p><a href='http://www.example.com'>http://www.example.com</a>, following text</p>", markup.to_html)
119
129
  end
120
130
 
121
131
  def test_multiple_footnotes
122
- text = "http://www.example.com [http://www.example.com]"
132
+ text = "[http://www.example.com] [http://www.example.com]"
123
133
  markup = Marker.parse text
124
134
 
125
135
  # TODO: should this collect identical links into one footnote?
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: marker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 3
8
+ - 0
9
+ version: 0.3.0
5
10
  platform: ruby
6
11
  authors:
7
12
  - Ryan Blue
@@ -9,19 +14,23 @@ autorequire:
9
14
  bindir: bin
10
15
  cert_chain: []
11
16
 
12
- date: 2010-02-01 00:00:00 +01:00
17
+ date: 2010-04-06 00:00:00 +02:00
13
18
  default_executable:
14
19
  dependencies:
15
20
  - !ruby/object:Gem::Dependency
16
21
  name: treetop
17
- type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
20
24
  requirements:
21
25
  - - ">="
22
26
  - !ruby/object:Gem::Version
27
+ segments:
28
+ - 1
29
+ - 4
30
+ - 2
23
31
  version: 1.4.2
24
- version:
32
+ type: :runtime
33
+ version_requirements: *id001
25
34
  description:
26
35
  email: rdblue@gmail.com
27
36
  executables:
@@ -33,15 +42,15 @@ extra_rdoc_files:
33
42
  - LICENSE
34
43
  files:
35
44
  - bin/marker
36
- - lib/marker.rb
37
- - lib/marker/verbatim.rb
38
- - lib/marker/templates.rb
39
- - lib/marker/markup.rb
40
45
  - lib/marker/common.rb
41
- - lib/marker/text.rb
42
- - lib/marker/links.rb
43
46
  - lib/marker/lists.rb
44
47
  - lib/marker/headings.rb
48
+ - lib/marker/text.rb
49
+ - lib/marker/markup.rb
50
+ - lib/marker/verbatim.rb
51
+ - lib/marker/links.rb
52
+ - lib/marker/templates.rb
53
+ - lib/marker.rb
45
54
  - lib/marker/language.treetop
46
55
  - README
47
56
  - LICENSE
@@ -58,26 +67,28 @@ required_ruby_version: !ruby/object:Gem::Requirement
58
67
  requirements:
59
68
  - - ">="
60
69
  - !ruby/object:Gem::Version
70
+ segments:
71
+ - 0
61
72
  version: "0"
62
- version:
63
73
  required_rubygems_version: !ruby/object:Gem::Requirement
64
74
  requirements:
65
75
  - - ">="
66
76
  - !ruby/object:Gem::Version
77
+ segments:
78
+ - 0
67
79
  version: "0"
68
- version:
69
80
  requirements: []
70
81
 
71
82
  rubyforge_project:
72
- rubygems_version: 1.3.5
83
+ rubygems_version: 1.3.6
73
84
  signing_key:
74
85
  specification_version: 3
75
86
  summary: A markup parser that outputs html and text. Syntax is similar to MediaWiki.
76
87
  test_files:
77
- - test/templates_test.rb
78
88
  - test/verbatim_test.rb
79
89
  - test/headings_test.rb
80
- - test/formatting_test.rb
81
- - test/test_helper.rb
82
90
  - test/links_test.rb
91
+ - test/test_helper.rb
92
+ - test/formatting_test.rb
83
93
  - test/lists_test.rb
94
+ - test/templates_test.rb