martile 0.1.14 → 0.1.15

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: f1ded764190af8c226d4536daad4a7435efa158c
4
- data.tar.gz: 878222fd429d1504f9f4bbec0c49ba0fbbc19412
3
+ metadata.gz: c385709f2357966e81fa9abbb82e21fc94b259d3
4
+ data.tar.gz: 5717ab324dc3a1897b23eb156f3f61bdd220cf65
5
5
  SHA512:
6
- metadata.gz: a7959ddb284add3b568e822d9d068e50110e9ea1bd2c42fbccbfdd6db6dd809ea27a3b65773cd9e8ae3588eb8ed8a91be1602c17179453b1c5a38d65e31bdada
7
- data.tar.gz: f15ca1764681a7a08b8406078dba9f6cc6b05a65cd9cbc10b6d2637292d8f1ae9a240b47612025b2e5a0a1a7634678d8a75e3adf5a88809501e58c8c2c292f62
6
+ metadata.gz: f89e37f145e4507d3c448726dee2435dabc8041ceb2bc9fcfa239562eb0ee83e5e25b4e3c6f6b9c8177098a9c326d1d4c7ddf1a6f860f072cd507a9beb1c0016
7
+ data.tar.gz: 7ab89467da5e94e8283bb9031237927104e019359de913abe8546c6cbd991ff35376ec9d2612b45f967a12c4790d2c3e0770a92b6c121daaeaca0dbd14694547
Binary file
data.tar.gz.sig CHANGED
@@ -1,3 +1,3 @@
1
- ��^ۏŐ\'��ڞ�Y0,
2
- ?sF��(�~I;�9
3
- uF
1
+ a�[��o��e
2
+ �Dr
3
+ m��)5Ij @ CC
@@ -7,6 +7,8 @@ require 'rexle'
7
7
  require 'dynarex'
8
8
  require 'rdiscount'
9
9
 
10
+
11
+ # feature: 12-Aug-2013: unordered_list supported
10
12
  # feature: 31-Mar-2013: markdown inside a martile ordered list
11
13
  # is now converted to HTML
12
14
  # bug fix: 02-Nov-2012: within dynarex_to_table URLs containing a
@@ -23,10 +25,16 @@ class Martile
23
25
 
24
26
  def initialize(s)
25
27
  s2 = code_block_to_html(s)
26
- s3 = ordered_list_to_html(s2)
27
- s4 = dynarex_to_table(s3)
28
- s5 = table_to_html(s4)
29
- @to_html = s5
28
+
29
+ s3 = ordered_list_to_html(s2)
30
+
31
+ s4 = unordered_list_to_html(s3)
32
+
33
+ s5 = dynarex_to_table(s4)
34
+
35
+ s6 = table_to_html(s5)
36
+
37
+ @to_html = s6
30
38
  end
31
39
 
32
40
  private
@@ -70,17 +78,20 @@ class Martile
70
78
  end
71
79
  end
72
80
 
73
- def ordered_list_to_html(s)
81
+ def list_to_html(s,symbol='#')
82
+
83
+ return s unless s[/\[#{symbol}[^\]]+\]/]
84
+ tag = {'#' => 'ol', '\*' => 'ul'}[symbol]
74
85
 
75
- s.split(/(?=\[#|^##)/).map do |x|
86
+ s.split(/(?=\[#{symbol}|^#{symbol*2})/).map do |x|
76
87
 
77
- s2, remainder = [x[/\[#.*#[^\]]+\]/m], ($').to_s] if x.strip.length > 0
88
+ s2, remainder = [x[/\[#{symbol}.*#{symbol}[^\]]+\]/m], ($').to_s] if x.strip.length > 0
78
89
 
79
90
  if s2 then
80
91
 
81
- raw_list = s2[1..-2].split(/^#/).reject(&:empty?).map(&:strip)
82
- list = "<ol>%s</ol>" % raw_list.map {|x| \
83
- "<li>%s</li>" % RDiscount.new(x).to_html}.join
92
+ raw_list = s2[1..-2].split(/^#{symbol}/).reject(&:empty?).map(&:strip)
93
+ list = "<#{tag}>%s</#{tag}>" % raw_list.map {|x| \
94
+ "<li>%s</li>" % RDiscount.new(x).to_html[/<p>(.*)<\/p>/,1]}.join
84
95
  list + remainder.to_s
85
96
 
86
97
  else
@@ -91,7 +102,15 @@ class Martile
91
102
 
92
103
  end.join
93
104
 
105
+ end
106
+
107
+ def ordered_list_to_html(s)
108
+ list_to_html s, '#'
94
109
  end
110
+
111
+ def unordered_list_to_html(s)
112
+ list_to_html s, '\*'
113
+ end
95
114
 
96
115
  def table_to_html(s)
97
116
  # create any tables
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.1.14
4
+ version: 0.1.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
metadata.gz.sig CHANGED
Binary file