dtext_rb 1.0.0 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/ext/dtext/extconf.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  require "mkmf"
2
2
 
3
+ $CFLAGS << " -std=c99"
4
+
3
5
  pkg_config "glib-2.0"
4
6
 
5
7
  have_library "glib-2.0"
data/lib/dtext.rb CHANGED
@@ -1 +1,11 @@
1
1
  require "dtext/dtext"
2
+
3
+ module DTextRagel
4
+ def self.parse_inline(str)
5
+ parse(str, :inline => true)
6
+ end
7
+
8
+ def self.parse_strip(str)
9
+ parse(str, :strip => true)
10
+ end
11
+ end
data/test/dtext_test.rb CHANGED
@@ -99,7 +99,7 @@ class DTextTest < Minitest::Test
99
99
  end
100
100
 
101
101
  def test_urls
102
- assert_parse('<p>a <a href="http://test.com">http://test.com</a> b</p>', p('a http://test.com b'))
102
+ assert_parse('<p>a <a href="http://test.com">http://test.com</a> b</p>', 'a http://test.com b')
103
103
  end
104
104
 
105
105
  def test_urls_with_newline
@@ -107,41 +107,41 @@ class DTextTest < Minitest::Test
107
107
  end
108
108
 
109
109
  def test_urls_with_paths
110
- assert_parse('<p>a <a href="http://test.com/~bob/image.jpg">http://test.com/~bob/image.jpg</a> b</p>', p('a http://test.com/~bob/image.jpg b'))
110
+ assert_parse('<p>a <a href="http://test.com/~bob/image.jpg">http://test.com/~bob/image.jpg</a> b</p>', 'a http://test.com/~bob/image.jpg b')
111
111
  end
112
112
 
113
113
  def test_urls_with_fragment
114
- assert_parse('<p>a <a href="http://test.com/home.html#toc">http://test.com/home.html#toc</a> b</p>', p('a http://test.com/home.html#toc b'))
114
+ assert_parse('<p>a <a href="http://test.com/home.html#toc">http://test.com/home.html#toc</a> b</p>', 'a http://test.com/home.html#toc b')
115
115
  end
116
116
 
117
117
  def test_auto_urls
118
- assert_parse('<p>a <a href="http://test.com">http://test.com</a>. b</p>', p('a http://test.com. b'))
118
+ assert_parse('<p>a <a href="http://test.com">http://test.com</a>. b</p>', 'a http://test.com. b')
119
119
  end
120
120
 
121
121
  def test_auto_urls_in_parentheses
122
- assert_parse('<p>a (<a href="http://test.com">http://test.com</a>) b</p>', p('a (http://test.com) b'))
122
+ assert_parse('<p>a (<a href="http://test.com">http://test.com</a>) b</p>', 'a (http://test.com) b')
123
123
  end
124
124
 
125
125
  def test_old_style_links
126
- assert_parse('<p><a href="http://test.com">test</a></p>', p('"test":http://test.com'))
126
+ assert_parse('<p><a href="http://test.com">test</a></p>', '"test":http://test.com')
127
127
  end
128
128
 
129
129
  def test_old_style_links_with_special_entities
130
- assert_parse('<p>"1" <a href="http://three.com">2 &amp; 3</a></p>', p('"1" "2 & 3":http://three.com'))
130
+ assert_parse('<p>"1" <a href="http://three.com">2 &amp; 3</a></p>', '"1" "2 & 3":http://three.com')
131
131
  end
132
132
 
133
133
  def test_new_style_links
134
- assert_parse('<p><a href="http://test.com">test</a></p>', p('"test":[http://test.com]'))
134
+ assert_parse('<p><a href="http://test.com">test</a></p>', '"test":[http://test.com]')
135
135
  end
136
136
 
137
137
  def test_new_style_links_with_parentheses
138
- assert_parse('<p><a href="http://test.com/(parentheses)">test</a></p>', p('"test":[http://test.com/(parentheses)]'))
139
- assert_parse('<p>(<a href="http://test.com/(parentheses)">test</a>)</p>', p('("test":[http://test.com/(parentheses)])'))
140
- assert_parse('<p>[<a href="http://test.com/(parentheses)">test</a>]</p>', p('["test":[http://test.com/(parentheses)]]'))
138
+ assert_parse('<p><a href="http://test.com/(parentheses)">test</a></p>', '"test":[http://test.com/(parentheses)]')
139
+ assert_parse('<p>(<a href="http://test.com/(parentheses)">test</a>)</p>', '("test":[http://test.com/(parentheses)])')
140
+ assert_parse('<p>[<a href="http://test.com/(parentheses)">test</a>]</p>', '["test":[http://test.com/(parentheses)]]')
141
141
  end
142
142
 
143
143
  def test_lists_1
144
- assert_parse('<ul><li>a</li></ul>', p('* a'))
144
+ assert_parse('<ul><li>a</li></ul>', '* a')
145
145
  end
146
146
 
147
147
  def test_lists_2
@@ -206,6 +206,10 @@ class DTextTest < Minitest::Test
206
206
  end
207
207
 
208
208
  def test_inline_mode
209
- assert_equal("hello", DTextRagel.parse("hello", :inline => true).strip)
209
+ assert_equal("hello", DTextRagel.parse_inline("hello").strip)
210
+ end
211
+
212
+ def test_strip
213
+ assert_equal("hellozworld", DTextRagel.parse_strip("h[b]e[/b]llo[quote]z[/quote]wo[expand]rld[/expand]"))
210
214
  end
211
215
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dtext_rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - r888888888