mtlite 0.1.1 → 0.1.2

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: 36e64acbf7572b9914cf88c9c5b9c88babe8824b
4
- data.tar.gz: acf6d5fd67286142d6abb392458bd28cef0ead9d
3
+ metadata.gz: 82871eb2f41da3e1f961e5767252770326d5313e
4
+ data.tar.gz: 0fcd2d10894b4e1f7da8f77247a834237ab9b577
5
5
  SHA512:
6
- metadata.gz: d826eba9b723e695c5f24f7faf182d1ef9f669307cff9b6cce34d74380abd7a1bc8a3884a7c25dfbf0d2a07dc34a42943b916f050152b6dea25dbbd219bd17d4
7
- data.tar.gz: 7ce1186f224202a812d39b1ba8df1b6d623d53daf4807e6fb082f2b7b47733a6c33379d22b4e4cf9e6c8b9d70b5fdf59aa8bd9a17b9699e7245b29a035b173f8
6
+ metadata.gz: 7f8b2b673496d50d2d5fddb33474274f6252b86dc83466e491cc45337c889ee94b87d2b1b24555ea79c57c144959a1e97b7b658917108e621fb0f9aeeae2ad06
7
+ data.tar.gz: 75126f472d9ea55b29d1424fe9b0bcc337e9edc5e6ea50814e104ff7b213c2183b65524f9c36a68d90c8ed2a46d14d5a9c7d46132d72d3344be4ead3c64a07c1
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/mtlite.rb CHANGED
@@ -8,20 +8,41 @@ class MTLite
8
8
 
9
9
  def initialize(raw_msg)
10
10
 
11
+ # if it looks like an MtLite list make it an MtLite list
12
+ # e.g. "a todo list:\n* line 1\n* line 2" =>
13
+ # a todo list: [* line 1 * line 2]
14
+ raw_msg.sub!(/^(?:[\*\[#][^\n]+\n?)+/,'[\0]')
15
+ raw_msg.gsub!(/\n/,' ')
16
+
17
+
18
+ # add br tags to checklist items
19
+ # todo list: [[x] line 1 [] line 2] =>
20
+ # todo list: <br/>[x] line 1 <br/>[] line 2
11
21
  raw_msg.sub!(/\[\[.*\]/){|x| x[0..-2].gsub(/[^\n](\[[x\s]?\])/,'<br/>\1') }
22
+
23
+ # convert square brackets to unicode check boxes
24
+ # replaces a [] with a unicode checkbox,
25
+ # and [x] with a unicode checked checkbox
12
26
  raw_msg = raw_msg.gsub(/\[\s*\]/,'&#9744;').gsub(/\[x\]/,'&#9745;')
27
+
28
+ # convert fractions using their associated unicode character
29
+ # i.e. 1/4, 1/2, 3/4
13
30
  raw_msg = raw_msg.gsub('1/4','&#188;').gsub('1/2','&#189;').gsub('3/4','&#190;')
14
31
 
32
+ # add strikethru to completed items
33
+ # e.g. -milk cow- becomes <del>milk cow</del>
15
34
  raw_msg.gsub!(/\s-[^-]+-?[^-]+-[\s\]]/) do |x|
16
35
  x.sub(/-([&\w]+.*\w+)-/,'<del>\1</del>')
17
36
  end
18
37
 
38
+ # append a domain label after the URL
19
39
  raw_msg.gsub!(/(?:^\[|\s\[)[^\]]+\]\((https?:\/\/[^\s]+)/) do |x|
20
40
  s2 = x[/https?:\/\/([^\/]+)/,1].split(/\./)
21
41
  r = s2.length >= 3 ? s2[1..-1] : s2
22
42
  "%s [%s]" % [x, r.join('.')]
23
43
  end
24
44
 
45
+ # generate html lists from mtlite 1-liner lists
25
46
  raw_msg.gsub!(/\[[\*#][^\]]+\]/) do |list|
26
47
 
27
48
  if not list[/\n/] then
@@ -39,7 +60,9 @@ class MTLite
39
60
  end
40
61
 
41
62
  msg = RDiscount.new(raw_msg).to_html.gsub(/<\/?p[^>]*>/,'')
63
+ # generate anchor tags for URLs which don't have anchor tags
42
64
  msg.gsub!(/(?:^(https?:[^\s]+)|\s(https?:[^\s]+))/,' <a href="\2">\2</a>')
65
+ # add the target attribute to make all hyperlinks open in a new browser tab
43
66
  msg.gsub!(/<a /,'<a target="_blank" ')
44
67
 
45
68
  @msg = msg
@@ -58,4 +81,4 @@ class MTLite
58
81
  @msg.gsub('<br/>',"\n").gsub(/<\/?.[^>]*>/,'')
59
82
  end
60
83
 
61
- end
84
+ end
data.tar.gz.sig CHANGED
@@ -1,2 +1,3 @@
1
- hණ��[Xv�� ��<���J>j���O|�K�<�;��è
2
- -���{� �^���;��ϒ`��CZ%~(�6~�.p%g���j��W���=Y�*�I�ք�-F���Ѷ-,̀i�:暨q<Ai��uD����K°�1��?���AX
1
+ ����ee��zA��R(Y��I1Mh����m5b13d<O�@E�� զ;6�}\R��Or�����jl q��-T�=׾��u��x�6���,G�����x��B�΢뱯��`�Uw�i�(ݬa��\�m�!o�"W�BF~U�,��J��0�pL>k���㥣�
2
+ ���k�q 2J��݁�� ���~�d��,�>��ύ�� 2��1 ��N[��;ٜ�Q
3
+ 5�1<N�� �+��j�#��
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.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -31,20 +31,20 @@ cert_chain:
31
31
  5/TxC35nCZmPNpOqets9YZ3k51P68rX0BUcUlqXZn7VmkT1Un30VYxuWwUsOhOYA
32
32
  dZmrX4ybr1RPCQ==
33
33
  -----END CERTIFICATE-----
34
- date: 2013-09-09 00:00:00.000000000 Z
34
+ date: 2014-01-29 00:00:00.000000000 Z
35
35
  dependencies:
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rdiscount
38
38
  requirement: !ruby/object:Gem::Requirement
39
39
  requirements:
40
- - - '>='
40
+ - - ">="
41
41
  - !ruby/object:Gem::Version
42
42
  version: '0'
43
43
  type: :runtime
44
44
  prerelease: false
45
45
  version_requirements: !ruby/object:Gem::Requirement
46
46
  requirements:
47
- - - '>='
47
+ - - ">="
48
48
  - !ruby/object:Gem::Version
49
49
  version: '0'
50
50
  description:
@@ -64,17 +64,17 @@ require_paths:
64
64
  - lib
65
65
  required_ruby_version: !ruby/object:Gem::Requirement
66
66
  requirements:
67
- - - '>='
67
+ - - ">="
68
68
  - !ruby/object:Gem::Version
69
69
  version: '0'
70
70
  required_rubygems_version: !ruby/object:Gem::Requirement
71
71
  requirements:
72
- - - '>='
72
+ - - ">="
73
73
  - !ruby/object:Gem::Version
74
74
  version: '0'
75
75
  requirements: []
76
76
  rubyforge_project:
77
- rubygems_version: 2.0.0.rc.2
77
+ rubygems_version: 2.1.11
78
78
  signing_key:
79
79
  specification_version: 4
80
80
  summary: mtlite
metadata.gz.sig CHANGED
Binary file