martile 0.2.2 → 0.3.0

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.
Files changed (6) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +3 -1
  4. data/lib/martile.rb +57 -18
  5. metadata +36 -12
  6. metadata.gz.sig +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dc3aa70713cdb6ddbcaced04f0aae2cceb9d03dc
4
- data.tar.gz: 3a2500985fe8fbfdb29ff9ed85044fb9c0e2286c
3
+ metadata.gz: 1eb1343e216876841f720a759c80c515d3d31caf
4
+ data.tar.gz: 3089b41e29ff067736133a8e0ef12a550a040e1d
5
5
  SHA512:
6
- metadata.gz: 633b92c9f66bba8c7dea9c4cb041985a4fc80c357b7f75ad53bf241d51c2260d6d1600dfadc2c6aa50a5197bfd7030aa1916b0e7b3ff08584e4e02ffcb9f6fe0
7
- data.tar.gz: 5fab9e33fe8c9142d6cb40bb7927980b49295115c013431af547ad9da2069896d1a75e46cce78a2c6ae071d4eacedadb921b9ff350043d705dd3e9429b89ebeb
6
+ metadata.gz: c6a3f65b3ca6ab982ed94ded7c44e04229a878811501494346fe80ba6d1c174d365be2e4dd4b805ad1f158a175e58c03f1c34d5f3053c8cbb217f758575dd3a4
7
+ data.tar.gz: 0db9a920deced5a775593883f09ac4174aaacc6f5e9960d9fada11fd3fcab4e3090465ca936ba831d899086e868833e7ec8363ecd255c33d26268cb7f9926803
Binary file
data.tar.gz.sig CHANGED
@@ -1 +1,3 @@
1
- N���p�f�^j������g���dDF��D|!��b��\��B:5�9 Q�‰&�� ���"z�[��y�'��#�HN;�9!��uމ�4�]��U ��[Wao7 ��+���(9��yV7��,��y2��crH4Nq�(�ӄ+�/�\�x��D_�L�r4JGڐ���Ǵ�X�7q
1
+ m��x�U�2�%��<<)Ik����>
2
+ ���(#69�Ua|�u[r� ��N� ��,����C�5�� #ǪC�-��6�O�漙'��F3�{�$�N�^��׶�p�\�<��ݖ��x�D�3L�����>��R�0�X��e;C�T�l�ݟ�B���?ɂ���i��X�rDwM�%~r �pq��
3
+ ��f�w⸜s~kmt{�?� oj�4�������F�&\��x\K�_ X�L��M�
@@ -8,6 +8,8 @@ require 'dynarex'
8
8
  require 'rdiscount'
9
9
 
10
10
 
11
+ # feature: 24-Sep-2014: A kind of markdown list can now be created inside
12
+ # of <ol> or <ul> tags
11
13
  # bug fix: 16-Apr-2014: Words containing an underscore should no longer be
12
14
  # transformed to an underline tag
13
15
  # bug fix: 03-Apr-2014: XML or HTML elements should now be filtered out
@@ -39,8 +41,7 @@ class Martile
39
41
 
40
42
  def initialize(s)
41
43
 
42
- raw_s2 = apply_filter(s) {|x| code_block_to_html x }
43
- #puts 'raw_s2: ' + raw_s2.inspect
44
+ raw_s2 = apply_filter(s.strip) {|x| code_block_to_html x }
44
45
 
45
46
  # ensure all angle brackets within <pre><code> is escaped
46
47
  s2 = raw_s2.split(/(?=<pre><code>)/m).map { |y|
@@ -61,23 +62,23 @@ class Martile
61
62
  end
62
63
 
63
64
  #puts 's2 : ' + s2.inspect
64
-
65
- s3 = apply_filter(s2) {|x| ordered_list_to_html x }
66
- #puts 's3 : ' + s3.inspect
67
-
68
- s4 = apply_filter(s3) {|x| unordered_list_to_html x }
65
+ s3 = apply_filter(s2, %w(ol ul)) {|x| explicit_list_to_html x }
66
+ s4 = apply_filter(s3) {|x| ordered_list_to_html x }
69
67
  #puts 's4 : ' + s4.inspect
70
68
 
71
- s5 = apply_filter(s4) {|x| dynarex_to_table x }
72
- #puts 's5 :' + s5.inspect
69
+ s5 = apply_filter(s4) {|x| unordered_list_to_html x }
70
+ #puts 's5 : ' + s5.inspect
73
71
 
74
- s6 = apply_filter(s5) {|x| table_to_html x }
75
- #puts 's6 : ' + s6.inspect
72
+ s6 = apply_filter(s5) {|x| dynarex_to_table x }
73
+ #puts 's6 :' + s6.inspect
76
74
 
77
- s7 = apply_filter(s6) {|x| underline x }
75
+ s7 = apply_filter(s6) {|x| table_to_html x }
78
76
  #puts 's7 : ' + s7.inspect
79
77
 
80
- @to_html = s7
78
+ s8 = apply_filter(s7) {|x| underline x }
79
+ #puts 's8 : ' + s8.inspect
80
+
81
+ @to_html = s8
81
82
  end
82
83
 
83
84
  private
@@ -148,11 +149,49 @@ class Martile
148
149
 
149
150
  end
150
151
 
151
- def apply_filter(s, &block)
152
+ def apply_filter(s, names=[], &block)
152
153
 
153
- Rexle.new("<root>#{s}</root>").root\
154
- .map {|x| x.is_a?(String) ? block.call(x) : x}.join
155
- end
154
+ Rexle.new("<root>#{s}</root>").root.map do |x|
155
+
156
+ if x.is_a?(String) then
157
+ block.call(x)
158
+ else
159
+
160
+ if names.grep x.name then
161
+ block.call(x.xml)
162
+ else
163
+ x
164
+ end
165
+
166
+ end
167
+ end.join
168
+ end
169
+
170
+ def explicit_list_to_html(s)
171
+
172
+ match = s.match(/<([ou]l)>([\*#])/m)
173
+
174
+ if match then
175
+
176
+ type, symbol = match.captures
177
+ symbol = ('\\' + symbol) if symbol == '*'
178
+
179
+ a3 = s.split(/(?=<#{type}>)/).map do |x|
180
+ # puts 'x' + x.inspect
181
+ if x =~ /<ol>/ then
182
+ "<%s>%s</%s>" % \
183
+ [type, x[/<#{type}>[#{symbol}]\s*(.*)<\/#{type}>/m,1]\
184
+ .split(/\n#{symbol}\s*/).map {|y| "<li>%s</li>" % y}.join, type]
185
+ else
186
+ x
187
+ end
188
+ end
189
+
190
+ else
191
+ s
192
+ end
193
+
194
+ end
156
195
 
157
196
  def ordered_list_to_html(s)
158
197
  list_to_html s, '#'
@@ -193,4 +232,4 @@ class Martile
193
232
 
194
233
  end
195
234
 
196
- end
235
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: martile
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -31,64 +31,88 @@ cert_chain:
31
31
  YF3JmVOebtMx3b9sXkLX1YyX0fsg59FXvg9CVfAoaG6qjG2Y/okBwMSqqMLQiiao
32
32
  aRfEuwOkM9Z+zA==
33
33
  -----END CERTIFICATE-----
34
- date: 2014-04-16 00:00:00.000000000 Z
34
+ date: 2014-09-24 00:00:00.000000000 Z
35
35
  dependencies:
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rexle-builder
38
38
  requirement: !ruby/object:Gem::Requirement
39
39
  requirements:
40
+ - - "~>"
41
+ - !ruby/object:Gem::Version
42
+ version: '0.1'
40
43
  - - ">="
41
44
  - !ruby/object:Gem::Version
42
- version: '0'
45
+ version: 0.1.9
43
46
  type: :runtime
44
47
  prerelease: false
45
48
  version_requirements: !ruby/object:Gem::Requirement
46
49
  requirements:
50
+ - - "~>"
51
+ - !ruby/object:Gem::Version
52
+ version: '0.1'
47
53
  - - ">="
48
54
  - !ruby/object:Gem::Version
49
- version: '0'
55
+ version: 0.1.9
50
56
  - !ruby/object:Gem::Dependency
51
57
  name: rexle
52
58
  requirement: !ruby/object:Gem::Requirement
53
59
  requirements:
60
+ - - "~>"
61
+ - !ruby/object:Gem::Version
62
+ version: '1.0'
54
63
  - - ">="
55
64
  - !ruby/object:Gem::Version
56
- version: '0'
65
+ version: 1.0.11
57
66
  type: :runtime
58
67
  prerelease: false
59
68
  version_requirements: !ruby/object:Gem::Requirement
60
69
  requirements:
70
+ - - "~>"
71
+ - !ruby/object:Gem::Version
72
+ version: '1.0'
61
73
  - - ">="
62
74
  - !ruby/object:Gem::Version
63
- version: '0'
75
+ version: 1.0.11
64
76
  - !ruby/object:Gem::Dependency
65
77
  name: rdiscount
66
78
  requirement: !ruby/object:Gem::Requirement
67
79
  requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '2.1'
68
83
  - - ">="
69
84
  - !ruby/object:Gem::Version
70
- version: '0'
85
+ version: 2.1.7.1
71
86
  type: :runtime
72
87
  prerelease: false
73
88
  version_requirements: !ruby/object:Gem::Requirement
74
89
  requirements:
90
+ - - "~>"
91
+ - !ruby/object:Gem::Version
92
+ version: '2.1'
75
93
  - - ">="
76
94
  - !ruby/object:Gem::Version
77
- version: '0'
95
+ version: 2.1.7.1
78
96
  - !ruby/object:Gem::Dependency
79
97
  name: dynarex
80
98
  requirement: !ruby/object:Gem::Requirement
81
99
  requirements:
100
+ - - "~>"
101
+ - !ruby/object:Gem::Version
102
+ version: '1.2'
82
103
  - - ">="
83
104
  - !ruby/object:Gem::Version
84
- version: '0'
105
+ version: 1.2.90
85
106
  type: :runtime
86
107
  prerelease: false
87
108
  version_requirements: !ruby/object:Gem::Requirement
88
109
  requirements:
110
+ - - "~>"
111
+ - !ruby/object:Gem::Version
112
+ version: '1.2'
89
113
  - - ">="
90
114
  - !ruby/object:Gem::Version
91
- version: '0'
115
+ version: 1.2.90
92
116
  description:
93
117
  email: james@r0bertson.co.uk
94
118
  executables: []
@@ -108,7 +132,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
108
132
  requirements:
109
133
  - - ">="
110
134
  - !ruby/object:Gem::Version
111
- version: '0'
135
+ version: 2.1.0
112
136
  required_rubygems_version: !ruby/object:Gem::Requirement
113
137
  requirements:
114
138
  - - ">="
@@ -116,7 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
116
140
  version: '0'
117
141
  requirements: []
118
142
  rubyforge_project:
119
- rubygems_version: 2.1.11
143
+ rubygems_version: 2.2.2
120
144
  signing_key:
121
145
  specification_version: 4
122
146
  summary: Converts a martile string to html
metadata.gz.sig CHANGED
Binary file