mastalk 0.2.1 → 0.3.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: 5e2063c03e65f608a762f45f94e1bcfa4e4f3370
4
- data.tar.gz: d113627da0b8674984686b0c0d796518af1a68fb
3
+ metadata.gz: 136987e072f7dbb42f90aa743569ebb46ccb04cd
4
+ data.tar.gz: 4796f36466e0e694f928f276fcdbfce9480beda1
5
5
  SHA512:
6
- metadata.gz: b9e54c8a0e561b110ba704d680d4d6b9ec1f0cf7bb1712b1f1197494bc191e64dde730a69a4fa8ba6552d7ec6f4704dd7b6dc62d59ed1ecee07d7d3628dd5bf3
7
- data.tar.gz: c8c1a02e4c9a5a6280b07cda883c1ecc4fc2dae956e03de946777f211e4bd02b76f40ace9bf49ac29dc63a3434407cf8bfc4eaa6d60c692f0e2c2768846e09d0
6
+ metadata.gz: 3ba14294c02fca4805c2d22c8bb50b06e85de901166007a9a43890658b6f6c990ecde65b1f0be982f374a63abcef9c1d3fda2f0f7fc086452ef8ff9dc53738ec
7
+ data.tar.gz: 3704b1aa7c8d3e53d5679a69d1fe9c452ec3fcf30305af350e589e14a3e9a40f0f85944788f941c8991df11604a352aef775e2d22735b71095f257b53182bdc0
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
@@ -12,10 +12,10 @@ module Mastalk
12
12
  SNIPPETS_FOLDER=File.join(File.dirname(__FILE__), 'snippets')
13
13
  @@extensions = []
14
14
 
15
- def extension(start, stop = nil, new_line = false, &block)
15
+ def extension(start, stop = nil, &block)
16
16
  re_start = Regexp.escape(start)
17
- re_stop = stop == '$' ? stop : Regexp.escape(stop || start)
18
- regex = Regexp.new("#{re_start}(.*?)(#{re_stop}+)", new_line ? 0 : Regexp::MULTILINE)
17
+ re_stop = Regexp.escape(stop || start)
18
+ regex = Regexp.new("#{re_start}(.*?)(#{re_stop}+)", Regexp::MULTILINE)
19
19
  @@extensions << [regex, block]
20
20
  end
21
21
 
@@ -25,8 +25,8 @@ module Mastalk
25
25
  Dir.foreach(SNIPPETS_FOLDER) do |file|
26
26
  next if file == '.' || file == '..'
27
27
  content = File.read(File.join(SNIPPETS_FOLDER, file))
28
- start, stop, new_line = args(content)
29
- extension(start, stop, new_line == 'false') do |body|
28
+ start, stop = args(content)
29
+ extension(start, stop) do |body|
30
30
  ERB.new(remove_syntax_from(content)).result(binding)
31
31
  end
32
32
  end
@@ -1,3 +1,3 @@
1
- # [n], $, false
1
+ # [n], [/n]
2
2
 
3
- <li class='no'><%= body.strip.gsub("\n", '') %></li>
3
+ <li class='no'><%= Kramdown::Document.new(body.strip).to_html.gsub(/<p>|<\/p>|\n/, '') %></li>
@@ -1,5 +1,3 @@
1
1
  # $yes-no, $end
2
2
 
3
- <ul class='yes-no'>
4
- <%= body %>
5
- </ul>
3
+ <ul class='yes-no'><%= Mastalk::Document.new(body.strip).to_html.gsub(/<p>|<\/p>|\n/, '') %></ul>
@@ -1,3 +1,3 @@
1
- # [y], $, false
1
+ # [y], [/y]
2
2
 
3
- <li class='yes'><%= body.strip.gsub("\n", '') %></li>
3
+ <li class='yes'><%= Kramdown::Document.new(body.strip).to_html.gsub(/<p>|<\/p>|\n/, '') %></li>
data/lib/mastalk.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'kramdown'
2
+ require 'htmlentities'
2
3
  require_relative 'mastalk/extensions'
3
4
 
4
5
  module Mastalk
@@ -14,7 +15,7 @@ module Mastalk
14
15
  end
15
16
 
16
17
  def to_html
17
- kramdown.to_html
18
+ ::HTMLEntities.new.decode( kramdown.to_html )
18
19
  end
19
20
 
20
21
  private
@@ -26,7 +27,7 @@ module Mastalk
26
27
  def preprocess(source)
27
28
  extensions.map do |regex, block|
28
29
  if source.match(regex)
29
- source.sub!(regex, block.call(Regexp.last_match.captures.first))
30
+ source.sub!(regex, block.call(Regexp.last_match.captures.first).strip)
30
31
  end
31
32
  end
32
33
  preprocess(source) if extensions.any? {|regex, _| source.match(regex)}
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.2.1'
7
- s.date = '2014-11-17'
6
+ s.version = '0.3.0'
7
+ s.date = '2014-11-24'
8
8
  s.summary = 'mastalk'
9
9
  s.description = 'Mastalk markdown extension language'
10
10
  s.authors = ['Douglas Roper']
@@ -14,6 +14,7 @@ Gem::Specification.new do |s|
14
14
  s.license = 'MIT'
15
15
 
16
16
  s.add_runtime_dependency 'kramdown', '~> 1.5.0', '>= 1.5.0'
17
+ s.add_runtime_dependency 'htmlentities', '~> 4.3.2', '>= 4.3.2'
17
18
  s.add_development_dependency 'rspec', '~> 3.1.0', '>= 3.1.0'
18
19
  s.add_development_dependency 'rake', '~> 10.3.2', '>= 10.3.2'
19
20
  end
data/spec/mastalk_spec.rb CHANGED
@@ -70,10 +70,10 @@ describe Mastalk::Document do
70
70
  end
71
71
 
72
72
  context 'with newline as end' do
73
- let(:source) { "$yes-no\n [y] yes \n [n] no \n $end $why\n###header\nbody\n$why" }
73
+ let(:source) { "$yes-no\n [y] yes [/y] \n [n] no [/n] \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\"><li class=\"yes\">yes</li><li class=\"no\">no</li></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
 
@@ -83,14 +83,14 @@ describe Mastalk::Document do
83
83
  end
84
84
 
85
85
  context 'two matches after each other' do
86
- let(:source) { "$yes-no\n [y] yes \n $end $yes-no\ [n] no \n $end" }
86
+ let(:source) { "$yes-no\n [y] **yes** [/y] \n $end $yes-no\ [n] **no** [/n] \n $end" }
87
87
 
88
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"
89
+ "<ul class=\"yes-no\"><li class=\"yes\"><strong>yes</strong></li></ul><ul class=\"yes-no\"><li class=\"no\"><strong>no</strong></li></ul>"
90
90
  end
91
91
 
92
92
  it 'pre-processes correctly' do
93
- expect(subject.to_html).to eq(expected)
93
+ expect(subject.to_html.gsub("\n", '')).to eq(expected)
94
94
  end
95
95
  end
96
96
 
@@ -105,4 +105,16 @@ describe Mastalk::Document do
105
105
  expect(subject.to_html).to eq(expected)
106
106
  end
107
107
  end
108
+
109
+ context 'ticks inside table' do
110
+ let(:source) { "|table|header|\n|$yes-no [y] yes [/y] $end|here|" }
111
+
112
+ let(:expected) do
113
+ "<table>\n <tbody>\n <tr>\n <td>table</td>\n <td>header</td>\n </tr>\n <tr>\n <td><ul class='yes-no'><li class=\"yes\">yes</li></ul></td>\n <td>here</td>\n </tr>\n </tbody>\n</table>\n"
114
+ end
115
+
116
+ it 'pre-processes correctly' do
117
+ expect(subject.to_html).to eq(expected)
118
+ end
119
+ end
108
120
  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.2.1
4
+ version: 0.3.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-11-17 00:00:00.000000000 Z
11
+ date: 2014-11-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: kramdown
@@ -30,6 +30,26 @@ dependencies:
30
30
  - - ">="
31
31
  - !ruby/object:Gem::Version
32
32
  version: 1.5.0
33
+ - !ruby/object:Gem::Dependency
34
+ name: htmlentities
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: 4.3.2
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: 4.3.2
43
+ type: :runtime
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: 4.3.2
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: 4.3.2
33
53
  - !ruby/object:Gem::Dependency
34
54
  name: rspec
35
55
  requirement: !ruby/object:Gem::Requirement
@@ -77,6 +97,7 @@ extensions: []
77
97
  extra_rdoc_files: []
78
98
  files:
79
99
  - ".gitignore"
100
+ - ".rspec"
80
101
  - ".travis.yml"
81
102
  - Gemfile
82
103
  - README.md
@@ -123,4 +144,3 @@ signing_key:
123
144
  specification_version: 4
124
145
  summary: mastalk
125
146
  test_files: []
126
- has_rdoc: