mastalk 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 220cf96953a354bbaf66f95e548280ea2f50608b
4
- data.tar.gz: bedca3b3cbdaa206841548a6f419dc92ce54cc38
3
+ metadata.gz: 20d1aaef80c7e2a2b51c613eee6e0df5ab6fbe9c
4
+ data.tar.gz: 1c3ea4b6799681f990a1ae55bd1f2440e982057c
5
5
  SHA512:
6
- metadata.gz: bc5650ba5306081a15c26257ac9b9c6c717e9580f3977414220a61766b56dfed9ad6fa549faae5ef5f95220d738881f49d80c09d914a64e5d1a40eb989f64c8c
7
- data.tar.gz: e268d79c98be558d3f0aa2f5da4f75a9bc67d08bb3f918a688904a552b8171d7e5addddf5ecab6f0b290fe9f819148ff6c845b2adc38bce39a11352d745605ec
6
+ metadata.gz: 2413d958bdfbfb7d8420c06b62496ca2b0b381ab9b1f0fc185bf88c3786310b50c1fbe7d792689d5ed20ceee303fa2fc63048b9d6559b222fc346f0747cb248d
7
+ data.tar.gz: 29371f00356396cf9d4ac9d02241460ce3274cbd519d7ce4c68880abd644b9661a35bea0129c010fc8390286672d5279970a03e6c8cf27c14c3d9dc451d9f00c
data/README.md CHANGED
@@ -35,11 +35,11 @@ Outputs:
35
35
  `.callout`
36
36
 
37
37
  ```
38
- $=callout
38
+ $~callout
39
39
  # Budgeting tips
40
40
  In 1985, average first-time buyers needed a deposit of 5% to buy a home - in 2012, this had increased to 20%
41
41
  *Source: HMS Treasury*
42
- =$
42
+ ~$
43
43
  ```
44
44
 
45
45
  Outputs:
@@ -15,7 +15,7 @@ module Mastalk
15
15
  def extension(start, stop = nil, new_line = false, &block)
16
16
  re_start = Regexp.escape(start)
17
17
  re_stop = stop == '$' ? stop : Regexp.escape(stop || start)
18
- regex = Regexp.new("#{re_start}(.*)(#{re_stop})", new_line ? 0 : Regexp::MULTILINE)
18
+ regex = Regexp.new("#{re_start}(.*?)(#{re_stop}+)", new_line ? 0 : Regexp::MULTILINE)
19
19
  @@extensions << [regex, block]
20
20
  end
21
21
 
@@ -1,5 +1,5 @@
1
1
  # $action, $item
2
2
 
3
3
  <div class='action-item'>
4
- <%= Mastalk::Document.new(body.strip).to_html %>
4
+ <%= body %>
5
5
  </div>
@@ -1,5 +1,5 @@
1
1
  # ^
2
2
 
3
3
  <div class='add-action'>
4
- <%= Mastalk::Document.new(body.strip).to_html %>
4
+ <%= Mastalk::Document.new(body.strip).to_html.gsub(/<p>|<\/p>/, '') %>
5
5
  </div>
@@ -1,4 +1,4 @@
1
- # $=callout, =$
1
+ # $~callout, ~$
2
2
 
3
3
  <div class='callout'>
4
4
  <%= Mastalk::Document.new(body.strip).to_html %>
@@ -1,5 +1,5 @@
1
1
  # $collapsable
2
2
 
3
3
  <div class='collapsable'>
4
- <%= Mastalk::Document.new(body.strip).to_html %>
4
+ <%= body.strip %>
5
5
  </div>
@@ -4,6 +4,6 @@
4
4
  <button class="unstyled-button">
5
5
  <span class="icon icon--toggle"></span>
6
6
  <span class="visually-hidden js-collapsable-hidden"></span>
7
- <%= Mastalk::Document.new(body).to_html %>
7
+ <%= body %>
8
8
  </button>
9
9
  </div>
@@ -1,5 +1,5 @@
1
1
  # $yes-no, $end
2
2
 
3
3
  <ul class='yes-no'>
4
- <%= Mastalk::Document.new(body).to_html %>
4
+ <%= body %>
5
5
  </ul>
data/lib/mastalk.rb CHANGED
@@ -26,9 +26,10 @@ module Mastalk
26
26
  def preprocess(source)
27
27
  extensions.map do |regex, block|
28
28
  if source.match(regex)
29
- source.gsub!(regex, block.call(Regexp.last_match.captures.first))
29
+ source.sub!(regex, block.call(Regexp.last_match.captures.first))
30
30
  end
31
31
  end
32
+ preprocess(source) if extensions.any? {|regex, _| source.match(regex)}
32
33
  source
33
34
  end
34
35
  end
data/mastalk.gemspec CHANGED
@@ -3,8 +3,8 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = 'mastalk'
6
- s.version = '0.1.2'
7
- s.date = '2014-10-31'
6
+ s.version = '0.2.0'
7
+ s.date = '2014-11-11'
8
8
  s.summary = 'mastalk'
9
9
  s.description = 'Mastalk markdown extension language'
10
10
  s.authors = ['Douglas Roper']
data/spec/mastalk_spec.rb CHANGED
@@ -73,7 +73,7 @@ describe Mastalk::Document do
73
73
  let(:source) { "$yes-no\n [y] yes \n [n] no \n $end $why\n###header\nbody\n$why" }
74
74
 
75
75
  let(:expected) do
76
- "<ul class=\"yes-no\">\n \n<li class=\"yes\">yes</li>\n\n<li class=\"no\">no</li>\n\n\n</ul>\n<div class=\"why\">
76
+ "<ul class=\"yes-no\">\n \n <li class=\"yes\">yes</li>\n\n <li class=\"no\">no</li>\n\n \n</ul>\n<div class=\"why\">
77
77
  <h3 id=\"header\">header</h3>\n<p>body</p>\n\n</div>\n"
78
78
  end
79
79
 
@@ -81,4 +81,28 @@ describe Mastalk::Document do
81
81
  expect(subject.to_html).to eq(expected)
82
82
  end
83
83
  end
84
+
85
+ context 'two matches after each other' do
86
+ let(:source) { "$yes-no\n [y] yes \n $end $yes-no\ [n] no \n $end" }
87
+
88
+ let(:expected) do
89
+ "<ul class=\"yes-no\">\n \n <li class=\"yes\">yes</li>\n\n \n</ul>\n<ul class=\"yes-no\">\n <li class=\"no\">no</li>\n\n \n</ul>\n"
90
+ end
91
+
92
+ it 'pre-processes correctly' do
93
+ expect(subject.to_html).to eq(expected)
94
+ end
95
+ end
96
+
97
+ context 'two callouts after each other' do
98
+ let(:source) { "$~callout\n ##yes ~$ $~callout\n ##yes ~$" }
99
+
100
+ let(:expected) do
101
+ "<div class=\"callout\">\n <h2 id=\"yes\">yes</h2>\n\n</div>\n<div class=\"callout\">\n <h2 id=\"yes\">yes</h2>\n\n</div>\n"
102
+ end
103
+
104
+ it 'pre-processes correctly' do
105
+ expect(subject.to_html).to eq(expected)
106
+ end
107
+ end
84
108
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mastalk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Douglas Roper
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-31 00:00:00.000000000 Z
11
+ date: 2014-11-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: kramdown