mtlite 0.3.1 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (6) hide show
  1. checksums.yaml +5 -5
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/lib/mtlite.rb +24 -10
  5. metadata +36 -31
  6. metadata.gz.sig +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 1876777b8c32548bb427a7a76204671f377aae17
4
- data.tar.gz: 70c0ff97f80fdcbe63870cd1b83b772fae9fd2b3
2
+ SHA256:
3
+ metadata.gz: 8ad72548b1d62cf4ae3af016f02824293b60dd03562902ffe36219df39197ffb
4
+ data.tar.gz: 5fb92f9b5a325a5638027ae704f3d33b1cf75ee05227268206c9b5f431bd9ad8
5
5
  SHA512:
6
- metadata.gz: 9888baf9f3cd0df54caccad91bc3766287b7a7a56bd1ca98f3e2905940c957913e23509667980c473785e12f88fac140f563875959963e22899840ddac8a12b5
7
- data.tar.gz: 4fc2f5fb36ed3dda3b7d3f125ba199ec6f86e26a3f93a31b4c5278c17c66f13da582e8de47bb93b608c4936c758deccd73b7bf5c2b64cde5c2d380aff734c8ad
6
+ metadata.gz: 4f364bdc994d39b8fb0202830ff74af6ebf5b10e72d66d447e132871158fd9fdb130a3f0441781818550f23f93604bb781aa361d96d26dda8138d6fc34201afb
7
+ data.tar.gz: b4ea6f85c444e48ef708320d67bd84bc896c45e187ffe9dbba0880c0cb05c306baeec0d7e2704f395b9a41b979d3818dbf393e701349951192b88176427ccd53
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
data/lib/mtlite.rb CHANGED
@@ -19,7 +19,7 @@ class MTLite
19
19
 
20
20
  end
21
21
 
22
- def to_html()
22
+ def to_html(para: false, ignore_domainlabel: false)
23
23
 
24
24
  raw_msg = @raw_msg.clone
25
25
  # if it looks like an MtLite list make it an MtLite list
@@ -37,11 +37,12 @@ class MTLite
37
37
  # convert square brackets to unicode check boxes
38
38
  # replaces a [] with a unicode checkbox,
39
39
  # and [x] with a unicode checked checkbox
40
- raw_msg = raw_msg.gsub(/\[\s*\]/,'☐').gsub(/\[x\]/,'☑')
40
+ raw_msg = raw_msg.gsub(/\[\s*\](?= )/,'☐').gsub(/\[x\]/,'☑')
41
41
 
42
42
  # convert fractions using their associated unicode character
43
43
  # i.e. 1/4, 1/2, 3/4
44
- raw_msg = raw_msg.gsub('1/4','¼').gsub('1/2','½').gsub('3/4','¾')
44
+ raw_msg = raw_msg.gsub('\b1/4\b','¼').gsub('\b1/2\b','½')\
45
+ .gsub('\b3/4\b','¾')
45
46
 
46
47
  # add strikethru to completed items
47
48
  # e.g. -milk cow- becomes <del>milk cow</del>
@@ -49,11 +50,15 @@ class MTLite
49
50
  x.sub(/-([&\w]+.*\w+)-/,'<del>\1</del>')
50
51
  end
51
52
 
52
- # append a domain label after the URL
53
- raw_msg.gsub!(/(?:^\[|\s\[)[^\]]+\]\((https?:\/\/[^\s]+)/) do |x|
54
- s2 = x[/https?:\/\/([^\/]+)/,1].split(/\./)
55
- r = s2.length >= 3 ? s2[1..-1] : s2
56
- "%s [%s]" % [x, r.join('.')]
53
+ unless ignore_domainlabel then
54
+
55
+ # append a domain label after the URL
56
+ raw_msg.gsub!(/(?:^\[|\s\[)[^\]]+\]\((https?:\/\/[^\s]+)/) do |x|
57
+ s2 = x[/https?:\/\/([^\/]+)/,1].split(/\./)
58
+ r = s2.length >= 3 ? s2[1..-1] : s2
59
+ "%s [%s]" % [x, r.join('.')]
60
+ end
61
+
57
62
  end
58
63
 
59
64
  # generate html lists from mtlite 1-liner lists
@@ -73,11 +78,20 @@ class MTLite
73
78
 
74
79
  end
75
80
 
76
- msg = RDiscount.new(raw_msg).to_html.gsub(/<\/?p[^>]*>/,'')
81
+ msg = RDiscount.new(raw_msg).to_html
82
+ msg.gsub!(/<\/?p[^>]*>/,'') unless para
77
83
 
78
84
  regex = %r([\w\-/?=.#\(\)]+)
79
85
  # generate anchor tags for URLs which don't have anchor tags
80
86
  msg.gsub!(/(?:^(https?:#{regex})|\s(https?:#{regex}))/,' <a href="\2">\2</a>')
87
+
88
+ msg.gsub!(/(?<=\>)https?:#{regex}/) do |x|
89
+ url = x
90
+ url2 = url.sub(/^https?:\/\//,'').sub(/^www\./,'')
91
+ url3 = url2.length > 33 ? url2[0..33] + '...' : url2
92
+ #" <a href='#{url}'>#{url3}</a>"
93
+ end
94
+
81
95
  # add the target attribute to make all hyperlinks open in a new browser tab
82
96
  msg.gsub!(/<a /,'<a target="_blank" ')
83
97
 
@@ -128,4 +142,4 @@ class MTLite
128
142
 
129
143
  end
130
144
 
131
- end
145
+ end
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.3.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -10,28 +10,32 @@ bindir: bin
10
10
  cert_chain:
11
11
  - |
12
12
  -----BEGIN CERTIFICATE-----
13
- MIIDljCCAn6gAwIBAgIBATANBgkqhkiG9w0BAQUFADBIMRIwEAYDVQQDDAlnZW1t
14
- YXN0ZXIxHjAcBgoJkiaJk/IsZAEZFg5qYW1lc3JvYmVydHNvbjESMBAGCgmSJomT
15
- 8ixkARkWAmV1MB4XDTE0MDkyNzE4MTAwMloXDTE1MDkyNzE4MTAwMlowSDESMBAG
16
- A1UEAwwJZ2VtbWFzdGVyMR4wHAYKCZImiZPyLGQBGRYOamFtZXNyb2JlcnRzb24x
17
- EjAQBgoJkiaJk/IsZAEZFgJldTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
18
- ggEBAMo/fpvb8OTtAVX0VTHXWvMq+XAGcIMM6mOMgUhRmMrH+ij+R6LKUSNjk9YF
19
- 7UohOrcAQxbLO9dhXR3VQPmkH1WG8ruUcdmfTPJcWlmWMuefbkNugtik9tPWj2qc
20
- /2KKJZ9mOds78RDY7EAhfI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iSNANuPrW+VhvqGo3M8+f+5yYYyS67whR5w85z9TcUT+dPyTGYl6ClNUXFt0vR1i
33
+ HG+QtV9hBiE8GRODZL0uFwL4Cl2EjDBAIbjtqh2fUy1T6A/u7Y23eVL+cnelk/YT
34
+ f6uxrTojqd8rUrVvqz0lhaTd1eoT6kd/u2r7YbzLnvraDnBwiuFAPticmw7JuVpZ
35
+ RpkfFZne43vM6SRQRvmVREEMpk57Mub1ccA9v5eElBuZbfyEO5eMYSc88DkxHCkr
36
+ sfZbXuL/o5TgPyPL7UYvUyoJ
33
37
  -----END CERTIFICATE-----
34
- date: 2015-08-04 00:00:00.000000000 Z
38
+ date: 2021-02-23 00:00:00.000000000 Z
35
39
  dependencies:
36
40
  - !ruby/object:Gem::Dependency
37
41
  name: rdiscount
@@ -57,24 +61,24 @@ dependencies:
57
61
  name: embiggen
58
62
  requirement: !ruby/object:Gem::Requirement
59
63
  requirements:
60
- - - "~>"
61
- - !ruby/object:Gem::Version
62
- version: '0.1'
63
64
  - - ">="
64
65
  - !ruby/object:Gem::Version
65
66
  version: 0.1.0
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: '0.1'
66
70
  type: :runtime
67
71
  prerelease: false
68
72
  version_requirements: !ruby/object:Gem::Requirement
69
73
  requirements:
70
- - - "~>"
71
- - !ruby/object:Gem::Version
72
- version: '0.1'
73
74
  - - ">="
74
75
  - !ruby/object:Gem::Version
75
76
  version: 0.1.0
77
+ - - "~>"
78
+ - !ruby/object:Gem::Version
79
+ version: '0.1'
76
80
  description:
77
- email: james@r0bertson.co.uk
81
+ email: digital.robertson@gmail.com
78
82
  executables: []
79
83
  extensions: []
80
84
  extra_rdoc_files: []
@@ -100,8 +104,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
100
104
  version: '0'
101
105
  requirements: []
102
106
  rubyforge_project:
103
- rubygems_version: 2.4.8
107
+ rubygems_version: 2.7.10
104
108
  signing_key:
105
109
  specification_version: 4
106
- summary: mtlite
110
+ summary: Martile Lite generates HTML ideally from 1 line of a condensed kind of markdown
111
+ language.
107
112
  test_files: []
metadata.gz.sig CHANGED
Binary file