mtlite 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8ad72548b1d62cf4ae3af016f02824293b60dd03562902ffe36219df39197ffb
4
- data.tar.gz: 5fb92f9b5a325a5638027ae704f3d33b1cf75ee05227268206c9b5f431bd9ad8
3
+ metadata.gz: 287458fbd384815faecca342f0b7138ad8c8efcd32e2fbc593d15dc62c120693
4
+ data.tar.gz: 568dae5601d898528f8fb497c494d1a72171d4216e2552273e3c5c65d14660ba
5
5
  SHA512:
6
- metadata.gz: 4f364bdc994d39b8fb0202830ff74af6ebf5b10e72d66d447e132871158fd9fdb130a3f0441781818550f23f93604bb781aa361d96d26dda8138d6fc34201afb
7
- data.tar.gz: b4ea6f85c444e48ef708320d67bd84bc896c45e187ffe9dbba0880c0cb05c306baeec0d7e2704f395b9a41b979d3818dbf393e701349951192b88176427ccd53
6
+ metadata.gz: 992fae9a36ca694d417312360e01e34efeb0a639b3d5cd5475da38dc779a19a68206eb802b1e7dc0c742aaf15809178526af7764ce5ab189bfa98a7d5c576819
7
+ data.tar.gz: 38ce325e7523ac459a05f4a69a77bb7657c0af9fa1c41f50fce35e11f66426e64de846d38bc70340401b4c7cf33caee2c13f259c9ba99a0da1f434a1aa6ed9e5
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
data/lib/mtlite.rb CHANGED
@@ -7,16 +7,25 @@ require 'embiggen'
7
7
 
8
8
  class MTLite
9
9
 
10
- def initialize(raw_msg)
10
+ def initialize(raw_msg, debug: false)
11
11
 
12
+ @debug = debug
13
+
12
14
  # reveal the expanded URL from a shortened URL
13
- raw_msg.gsub!(/https?:\/\/[\w\-_\.\/?+&]+/) do |url|
15
+ raw_msg.gsub!(/https?:\/\/[^ ]+/) do |url|
16
+
17
+ puts 'url: ' + url.inspect if @debug
18
+
14
19
  Embiggen::URI(url).expand.to_s
15
20
  end
16
21
 
22
+ puts 'raw_msg: ' + raw_msg.inspect if @debug
23
+
17
24
  # make the smartlinks into Markdown links
18
25
  @raw_msg = smartlink(raw_msg)
19
26
 
27
+ puts '@raw_msg: ' + @raw_msg.inspect if @debug
28
+
20
29
  end
21
30
 
22
31
  def to_html(para: false, ignore_domainlabel: false)
@@ -81,12 +90,14 @@ class MTLite
81
90
  msg = RDiscount.new(raw_msg).to_html
82
91
  msg.gsub!(/<\/?p[^>]*>/,'') unless para
83
92
 
84
- regex = %r([\w\-/?=.#\(\)]+)
93
+ regex = %r([^ <]+)
85
94
  # generate anchor tags for URLs which don't have anchor tags
86
95
  msg.gsub!(/(?:^(https?:#{regex})|\s(https?:#{regex}))/,' <a href="\2">\2</a>')
87
96
 
88
97
  msg.gsub!(/(?<=\>)https?:#{regex}/) do |x|
89
- url = x
98
+
99
+ # unescapeHTML will transform &amp; to &
100
+ url = CGI.unescapeHTML x
90
101
  url2 = url.sub(/^https?:\/\//,'').sub(/^www\./,'')
91
102
  url3 = url2.length > 33 ? url2[0..33] + '...' : url2
92
103
  #" <a href='#{url}'>#{url3}</a>"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mtlite
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -35,7 +35,7 @@ cert_chain:
35
35
  RpkfFZne43vM6SRQRvmVREEMpk57Mub1ccA9v5eElBuZbfyEO5eMYSc88DkxHCkr
36
36
  sfZbXuL/o5TgPyPL7UYvUyoJ
37
37
  -----END CERTIFICATE-----
38
- date: 2021-02-23 00:00:00.000000000 Z
38
+ date: 2021-03-08 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: rdiscount
metadata.gz.sig CHANGED
Binary file