mtlite 0.4.0 → 0.4.1
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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/mtlite.rb +15 -4
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 287458fbd384815faecca342f0b7138ad8c8efcd32e2fbc593d15dc62c120693
|
4
|
+
data.tar.gz: 568dae5601d898528f8fb497c494d1a72171d4216e2552273e3c5c65d14660ba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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?:\/\/[
|
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([
|
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
|
-
|
98
|
+
|
99
|
+
# unescapeHTML will transform & 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.
|
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-
|
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
|