parity-RedCloth 4.2.11 → 4.2.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 77ab2e0c8f4f9771b803c5ad141f47f3119c0739
4
- data.tar.gz: 528b437fbc9d3df7a02453e2f2e0abb276946c0d
3
+ metadata.gz: 532ead9fc1ffda2848c8a3b81c6219d32b3a9855
4
+ data.tar.gz: f4e46b78782c336753b1fab6aa0ff80ae1d995da
5
5
  SHA512:
6
- metadata.gz: 8b195fcb0500154c7f9b1dd8d3061e2f1f2ad917686a7bfa4ef38ef64de38925c5b1b36e82159b739602661e4e18faca835c7402a882ff91842569d137ded1bf
7
- data.tar.gz: 6688609fafabe71165e1fc5562ca0cd4154c15a3551da5f584829d83286da76267cba1afbaa483284a76552348642869fdefc2c5b8262e59f1fac6f5a80dab5a
6
+ metadata.gz: 4c4690a6d1f94b8338936a433378d15a085f881c8d1463b83f1b9862abb54bff6657e03ad59c7953423878cd260e57c228d51df45e7417993da38ae36311cd48
7
+ data.tar.gz: f703240d32eb998eca86d9465acc2b553d76672d952f060b91c6755467943266fca085bffa36645ee4f63f01f0f6cb698beb0811a16c0cb200bd8538b0089a5d
@@ -114,12 +114,18 @@ module RedCloth::Formatters::HTML
114
114
  "<a href=\"#{escape_attribute opts[:href]}\"#{pba(opts)}>#{opts[:name]}</a>"
115
115
  end
116
116
 
117
+ def truncate(text, length = 30, truncate_string = "...")
118
+ if text.nil? then return end
119
+ l = length - truncate_string.chars.to_a.size
120
+ (text.chars.to_a.size > length ? text.chars.to_a[0...l].join + truncate_string : text).to_s
121
+ end
122
+
117
123
  def auto_link(opts)
118
124
  return opts[:href] unless auto_link_urls
119
125
  href_with_proto = opts[:href]
120
126
  href_with_proto = 'http://' + href_with_proto unless href_with_proto.index('http') == 0
121
127
  text = opts[:href]
122
- text = text[0, [text.length - 6, 47].max] + text[-5,3].replace("...") + text[-2..-1]
128
+ text = truncate(text[0, text.length - 6] + text[-5,3].replace("...") + text[-2..-1], 50)
123
129
  "<a href=\"#{escape_attribute href_with_proto}\">#{escape_attribute text}</a>"
124
130
  end
125
131
 
@@ -2,7 +2,7 @@ module RedCloth
2
2
  module VERSION
3
3
  MAJOR = 4
4
4
  MINOR = 2
5
- TINY = 11
5
+ TINY = 12
6
6
  RELEASE_CANDIDATE = nil
7
7
 
8
8
  STRING = [MAJOR, MINOR, TINY, RELEASE_CANDIDATE].compact.join('.')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: parity-RedCloth
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.2.11
4
+ version: 4.2.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Garber
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2015-03-30 00:00:00.000000000 Z
14
+ date: 2015-04-07 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: bundler
@@ -203,7 +203,7 @@ rubyforge_project: redcloth
203
203
  rubygems_version: 2.2.1
204
204
  signing_key:
205
205
  specification_version: 4
206
- summary: RedCloth-4.2.11
206
+ summary: RedCloth-4.2.12
207
207
  test_files:
208
208
  - spec/benchmark_spec.rb
209
209
  - spec/custom_tags_spec.rb