zfben_extend 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -5,7 +5,7 @@ class ZfbenExtend::String < String
5
5
  link: true,
6
6
  link_regexp: /[a-zA-Z]{3,}:\/\/\S+/,
7
7
  tag: true,
8
- tag_regexp: /#[a-zA-Z0-9]+/,
8
+ tag_regexp: /&?#[a-zA-Z0-9]+/,
9
9
  tag_url: '/tags/',
10
10
  mail: true,
11
11
  mail_regexp: /[a-zA-Z0-9.-]+@[a-zA-Z0-9]+\.[a-zA-Z0-9.]+/,
@@ -27,8 +27,12 @@ class ZfbenExtend::String < String
27
27
  if options[:tag]
28
28
  data[:tag] = []
29
29
  text = text.gsub(options[:tag_regexp]){ |tag|
30
- data[:tag].push('<a href="' + options[:tag_url] + tag.gsub('#', '') + '">' + tag + '</a>')
31
- 'ZFBENTAG' + (data[:tag].length - 1).to_s + 'ZFBENTAG'
30
+ if tag[0] != '&'
31
+ data[:tag].push('<a href="' + options[:tag_url] + tag.gsub('#', '') + '">' + tag + '</a>')
32
+ 'ZFBENTAG' + (data[:tag].length - 1).to_s + 'ZFBENTAG'
33
+ else
34
+ tag
35
+ end
32
36
  }
33
37
  end
34
38
 
data/test/string_test.rb CHANGED
@@ -28,10 +28,12 @@ class TestToHtml < Test::Unit::TestCase
28
28
  assert_equal ZfbenExtend::String.to_html('#a', tag: false), '#a'
29
29
  assert_equal ZfbenExtend::String.to_html('#a'), '<a href="/tags/a">#a</a>'
30
30
  assert_equal ZfbenExtend::String.to_html('text #a #b'), 'text <a href="/tags/a">#a</a> <a href="/tags/b">#b</a>'
31
+ assert_equal ZfbenExtend::String.to_html('&#39;s'), '&#39;s'
31
32
 
32
33
  assert_equal ZfbenExtend::String.new('#a').to_html(tag: false), '#a'
33
34
  assert_equal ZfbenExtend::String.new('#a').to_html, '<a href="/tags/a">#a</a>'
34
35
  assert_equal ZfbenExtend::String.new('text #a #b').to_html, 'text <a href="/tags/a">#a</a> <a href="/tags/b">#b</a>'
36
+ assert_equal ZfbenExtend::String.new('&#39;s').to_html, '&#39;s'
35
37
  end
36
38
 
37
39
  def test_mail
data/zfben_extend.gemspec CHANGED
@@ -3,7 +3,7 @@ $:.push File.expand_path('../lib', __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = 'zfben_extend'
6
- s.version = '0.0.2'
6
+ s.version = '0.0.3'
7
7
  s.authors = ['Ben']
8
8
  s.email = ['ben@zfben.com']
9
9
  s.homepage = 'https://github.com/benz303/zfben_extend'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zfben_extend
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-01-27 00:00:00.000000000 Z
12
+ date: 2012-02-01 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: ''
15
15
  email: