shortcode 1.0.0 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.ruby-version +1 -0
- data/.travis.yml +9 -10
- data/Appraisals +7 -7
- data/CHANGELOG.md +22 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +41 -39
- data/README.md +23 -7
- data/gemfiles/rails_3.1.gemfile +2 -2
- data/gemfiles/rails_3.2.gemfile +3 -3
- data/gemfiles/rails_4.0.gemfile +3 -3
- data/gemfiles/rails_4.1.gemfile +3 -3
- data/gemfiles/rails_4.2.gemfile +8 -0
- data/lib/shortcode.rb +1 -0
- data/lib/shortcode/parser.rb +4 -4
- data/lib/shortcode/railtie.rb +1 -1
- data/lib/shortcode/tag.rb +5 -23
- data/lib/shortcode/template_binding.rb +33 -0
- data/lib/shortcode/version.rb +1 -1
- data/shortcode.gemspec +6 -6
- data/spec/parser_spec.rb +2 -2
- data/spec/support/fixtures/block_with_whitespace.txt +2 -0
- data/spec/support/fixtures/block_with_whitespace_output.html +2 -0
- data/spec/support/fixtures/quote_with_extras_output.html +1 -1
- data/spec/transformer_spec.rb +27 -16
- metadata +35 -46
- data/.rbenv-version +0 -1
- data/gemfiles/rails_3.0.gemfile +0 -8
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b80627fe9d3741eb1e8ad562aab6789697b83c98
|
4
|
+
data.tar.gz: f495da02fb8c29dfb02e4244dce8724b301c7b10
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 99d81eba4857e42a19de407c9930304e34413e21ac60f97f72b9a0d9e31bad8f802bbb1c77e50b710f680be770b553922d159d603cd4617f525bf90e78a7ca58
|
7
|
+
data.tar.gz: 6dc1697bb5106c5e37450a82117937393e3e0e1223c57afea3102d02e963413fad9d85316c5909e9b96aae1aa00f21d69d13a258eb3d95b6a587aed3018530ca
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.1.3
|
data/.travis.yml
CHANGED
@@ -1,27 +1,26 @@
|
|
1
1
|
language: ruby
|
2
|
+
|
2
3
|
rvm:
|
3
|
-
- 1.9.
|
4
|
-
-
|
5
|
-
- 2.
|
6
|
-
- 2.
|
4
|
+
- 1.9.3-p551
|
5
|
+
- 2.0.0-p598
|
6
|
+
- 2.1.5
|
7
|
+
- 2.2.0
|
7
8
|
- ruby-head
|
8
9
|
- jruby-19mode
|
9
10
|
- jruby-head
|
11
|
+
|
12
|
+
sudo: false
|
13
|
+
|
10
14
|
script: bundle exec rspec
|
11
15
|
|
12
16
|
matrix:
|
13
17
|
allow_failures:
|
14
18
|
- rvm: ruby-head
|
15
19
|
- rvm: jruby-head
|
16
|
-
exclude:
|
17
|
-
- rvm: 1.9.2
|
18
|
-
gemfile: gemfiles/rails_4.0.gemfile
|
19
|
-
- rvm: 1.9.2
|
20
|
-
gemfile: gemfiles/rails_4.1.gemfile
|
21
20
|
|
22
21
|
gemfile:
|
23
|
-
- gemfiles/rails_3.0.gemfile
|
24
22
|
- gemfiles/rails_3.1.gemfile
|
25
23
|
- gemfiles/rails_3.2.gemfile
|
26
24
|
- gemfiles/rails_4.0.gemfile
|
27
25
|
- gemfiles/rails_4.1.gemfile
|
26
|
+
- gemfiles/rails_4.2.gemfile
|
data/Appraisals
CHANGED
@@ -1,19 +1,19 @@
|
|
1
|
-
appraise "rails-3.0" do
|
2
|
-
gem "rails", "~> 3.0.20"
|
3
|
-
end
|
4
|
-
|
5
1
|
appraise "rails-3.1" do
|
6
2
|
gem "rails", "~> 3.1.12"
|
7
3
|
end
|
8
4
|
|
9
5
|
appraise "rails-3.2" do
|
10
|
-
gem "rails", "~> 3.2.
|
6
|
+
gem "rails", "~> 3.2.21"
|
11
7
|
end
|
12
8
|
|
13
9
|
appraise "rails-4.0" do
|
14
|
-
gem "rails", "~> 4.0.
|
10
|
+
gem "rails", "~> 4.0.13"
|
15
11
|
end
|
16
12
|
|
17
13
|
appraise "rails-4.1" do
|
18
|
-
gem "rails", "~> 4.1.
|
14
|
+
gem "rails", "~> 4.1.9"
|
15
|
+
end
|
16
|
+
|
17
|
+
appraise "rails-4.2" do
|
18
|
+
gem "rails", "4.2.0"
|
19
19
|
end
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,25 @@
|
|
1
|
+
## 1.0.2 (March 4, 2015)
|
2
|
+
|
3
|
+
Fixes:
|
4
|
+
|
5
|
+
- Whitespace after tags is now preserved
|
6
|
+
|
7
|
+
## 1.0.1 (January 21, 2015)
|
8
|
+
|
9
|
+
Features:
|
10
|
+
|
11
|
+
- Implemented a TemplateBinding class as the binding to templates to provide a clean interface
|
12
|
+
- Updated to parslet 1.6.2
|
13
|
+
- Updated to rspec 3.1
|
14
|
+
|
15
|
+
Misc:
|
16
|
+
|
17
|
+
- Testing against the latest versions of Rails 3.1, 3.2, 4.0, 4.1 & 4.2
|
18
|
+
- Testing against the latest versions of Ruby 1.9.3-p551, 2.0.0-p598, 2.1.5 & 2.2.0
|
19
|
+
- Dropped test support for Rails 3.0
|
20
|
+
- Dropped test support for run 1.9.2
|
21
|
+
- README improvements
|
22
|
+
|
1
23
|
## 1.0.0 (July 29, 2014)
|
2
24
|
|
3
25
|
Features:
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,70 +1,72 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
shortcode (1.0.
|
5
|
-
parslet (= 1.6.
|
4
|
+
shortcode (1.0.2)
|
5
|
+
parslet (= 1.6.2)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
appraisal (1.0.
|
10
|
+
appraisal (1.0.2)
|
11
11
|
bundler
|
12
12
|
rake
|
13
13
|
thor (>= 0.14.0)
|
14
|
-
blankslate (
|
15
|
-
coveralls (0.7.
|
16
|
-
multi_json (~> 1.
|
17
|
-
rest-client
|
18
|
-
simplecov (
|
19
|
-
term-ansicolor
|
20
|
-
thor
|
14
|
+
blankslate (3.1.3)
|
15
|
+
coveralls (0.7.3)
|
16
|
+
multi_json (~> 1.10)
|
17
|
+
rest-client (~> 1.7)
|
18
|
+
simplecov (~> 0.9.1)
|
19
|
+
term-ansicolor (~> 1.3)
|
20
|
+
thor (~> 0.19.1)
|
21
21
|
diff-lcs (1.2.5)
|
22
|
-
docile (1.1.
|
23
|
-
haml (4.0.
|
22
|
+
docile (1.1.5)
|
23
|
+
haml (4.0.6)
|
24
24
|
tilt
|
25
|
-
mime-types (2.
|
25
|
+
mime-types (2.4.3)
|
26
26
|
multi_json (1.10.1)
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
rspec-
|
36
|
-
|
37
|
-
rspec-
|
38
|
-
rspec-
|
27
|
+
netrc (0.10.2)
|
28
|
+
parslet (1.6.2)
|
29
|
+
blankslate (>= 2.0, <= 4.0)
|
30
|
+
rake (10.4.2)
|
31
|
+
rest-client (1.7.2)
|
32
|
+
mime-types (>= 1.16, < 3.0)
|
33
|
+
netrc (~> 0.7)
|
34
|
+
rspec (3.1.0)
|
35
|
+
rspec-core (~> 3.1.0)
|
36
|
+
rspec-expectations (~> 3.1.0)
|
37
|
+
rspec-mocks (~> 3.1.0)
|
38
|
+
rspec-core (3.1.7)
|
39
|
+
rspec-support (~> 3.1.0)
|
40
|
+
rspec-expectations (3.1.2)
|
39
41
|
diff-lcs (>= 1.2.0, < 2.0)
|
40
|
-
rspec-support (~> 3.
|
41
|
-
rspec-mocks (3.
|
42
|
-
rspec-support (~> 3.
|
43
|
-
rspec-support (3.
|
44
|
-
simplecov (0.
|
42
|
+
rspec-support (~> 3.1.0)
|
43
|
+
rspec-mocks (3.1.3)
|
44
|
+
rspec-support (~> 3.1.0)
|
45
|
+
rspec-support (3.1.2)
|
46
|
+
simplecov (0.9.1)
|
45
47
|
docile (~> 1.1.0)
|
46
|
-
multi_json
|
48
|
+
multi_json (~> 1.0)
|
47
49
|
simplecov-html (~> 0.8.0)
|
48
50
|
simplecov-html (0.8.0)
|
49
|
-
slim (
|
50
|
-
temple (~> 0.
|
51
|
+
slim (3.0.1)
|
52
|
+
temple (~> 0.7.3)
|
51
53
|
tilt (>= 1.3.3, < 2.1)
|
52
|
-
temple (0.
|
54
|
+
temple (0.7.5)
|
53
55
|
term-ansicolor (1.3.0)
|
54
56
|
tins (~> 1.0)
|
55
|
-
thor (0.
|
57
|
+
thor (0.19.1)
|
56
58
|
tilt (2.0.1)
|
57
|
-
tins (1.3.
|
59
|
+
tins (1.3.3)
|
58
60
|
|
59
61
|
PLATFORMS
|
60
62
|
ruby
|
61
63
|
|
62
64
|
DEPENDENCIES
|
63
|
-
appraisal (= 1.0.
|
65
|
+
appraisal (= 1.0.2)
|
64
66
|
bundler (~> 1.3)
|
65
67
|
coveralls
|
66
68
|
haml (~> 4.0)
|
67
69
|
rake
|
68
|
-
rspec (~> 3.
|
70
|
+
rspec (~> 3.1.0)
|
69
71
|
shortcode!
|
70
|
-
slim (~>
|
72
|
+
slim (~> 3.0)
|
data/README.md
CHANGED
@@ -27,8 +27,8 @@ Or install it yourself as:
|
|
27
27
|
$ gem install shortcode
|
28
28
|
```
|
29
29
|
|
30
|
-
Shortcode is tested against ruby version 1.9.2 and
|
31
|
-
Rails versions 3.
|
30
|
+
Shortcode is tested against ruby version 1.9.3, 2.0, 2.1, and 2.2 as well as jruby, it will not work with ruby 1.8. Shortcode rails integration is tested against
|
31
|
+
Rails versions 3.1, 3.2, 4.0, 4.1 and 4.2.
|
32
32
|
|
33
33
|
## Usage
|
34
34
|
|
@@ -40,6 +40,17 @@ Shortcode is very simple to use, simply call the `process` method and pass it a
|
|
40
40
|
Shortcode.process("[quote]Hello World[/quote]")
|
41
41
|
```
|
42
42
|
|
43
|
+
### Tags
|
44
|
+
|
45
|
+
Any tags you wish to use with Shortcode need to be configured in the setup block, there are 2 types of tag, `block_tags` and `self_closing_tags`. Block tags have a matching open and close tag such as `[quote]A quote[/quote]`, self closing tags have no close tag, for example `[gallery]`. To define the tags Shortcode should parse do so in the configuration as follows:
|
46
|
+
|
47
|
+
```ruby
|
48
|
+
Shortcode.setup do |config|
|
49
|
+
config.block_tags = [:quote, :list]
|
50
|
+
config.self_closing_tags = [:gallery, :widget]
|
51
|
+
end
|
52
|
+
```
|
53
|
+
|
43
54
|
### Templates
|
44
55
|
|
45
56
|
Each shortcode tag needs a template in order to translate the shortcode into html (or other output). Templates can be written in erb, haml or slim and work in
|
@@ -83,11 +94,13 @@ block as strings.
|
|
83
94
|
#### Templates loaded from the file system
|
84
95
|
|
85
96
|
Simply create files with the extension or .erb, .haml, or .slim with a filename the same as the shortcode tag, e.g. gallery.html.erb would render a [gallery] shortcode tag. The default
|
86
|
-
location for template files is `app/views/shortcode_templates`, if you want to load
|
97
|
+
location for template files is `app/views/shortcode_templates`, if you want to load templates from a different location use the `template_path` config option.
|
98
|
+
|
99
|
+
Note: only 1 template parser is supported at a time, if using haml for instance all templates must be haml.
|
87
100
|
|
88
101
|
#### Templates set as configuration options
|
89
102
|
|
90
|
-
The alternative way to define
|
103
|
+
The alternative way to define templates is to set them using the `templates` config option, this option can take a hash with keys of the same name as the shortcode tags and
|
91
104
|
values containing a template string. For instance:
|
92
105
|
|
93
106
|
```ruby
|
@@ -99,9 +112,11 @@ end
|
|
99
112
|
If the `templates` config option is set all templates will be loaded from this hash, if a shortcode is encountered without a matching key in the `templates` config option
|
100
113
|
an exception will be raised.
|
101
114
|
|
115
|
+
Note: it's NOT possible to load templates from a config option AND from the file system, you must either load all templates from the file system or define all templates in a config option.
|
116
|
+
|
102
117
|
### Custom Helpers
|
103
118
|
|
104
|
-
If you wish to use custom helper modules in templates you can do so by specifying the helpers in a setup block which should be an array. Methods in the helper modules will then become available within all
|
119
|
+
If you wish to use custom helper modules in templates you can do so by specifying the helpers in a setup block which should be an array. Methods in the helper modules will then become available within all templates.
|
105
120
|
|
106
121
|
```ruby
|
107
122
|
Shortcode.setup do |config|
|
@@ -204,7 +219,7 @@ Shortcode.setup do |config|
|
|
204
219
|
# above template_path option. The default is nil
|
205
220
|
config.templates = { gallery: 'template code' }
|
206
221
|
|
207
|
-
# an array of helper modules to make available within
|
222
|
+
# an array of helper modules to make available within templates
|
208
223
|
config.helpers = [CustomerHelper]
|
209
224
|
|
210
225
|
# a list of block tags to support e.g. [quote]Hello World[/quote]
|
@@ -216,7 +231,8 @@ Shortcode.setup do |config|
|
|
216
231
|
# the type of quotes to use for attribute values, default is double quotes (")
|
217
232
|
config.attribute_quote_type = '"'
|
218
233
|
|
219
|
-
# Allows quotes around attributes to be omitted
|
234
|
+
# Allows quotes around attributes to be omitted
|
235
|
+
# Defaults to true, quotes must be present around attribute values
|
220
236
|
config.use_attribute_quotes = true
|
221
237
|
end
|
222
238
|
```
|
data/gemfiles/rails_3.1.gemfile
CHANGED
data/gemfiles/rails_3.2.gemfile
CHANGED
data/gemfiles/rails_4.0.gemfile
CHANGED
data/gemfiles/rails_4.1.gemfile
CHANGED
data/lib/shortcode.rb
CHANGED
@@ -40,6 +40,7 @@ require 'shortcode/configuration'
|
|
40
40
|
require 'shortcode/parser'
|
41
41
|
require 'shortcode/presenter'
|
42
42
|
require 'shortcode/processor'
|
43
|
+
require 'shortcode/template_binding'
|
43
44
|
require 'shortcode/transformer'
|
44
45
|
require 'shortcode/tag'
|
45
46
|
require 'shortcode/exceptions'
|
data/lib/shortcode/parser.rb
CHANGED
@@ -8,8 +8,8 @@ class Shortcode::Parser < Parslet::Parser
|
|
8
8
|
rule(:space) { str(' ').repeat(1) }
|
9
9
|
rule(:space?) { space.maybe }
|
10
10
|
rule(:newline) { (str("\r\n") | str("\n")) >> space? }
|
11
|
+
rule(:newline?) { newline.maybe }
|
11
12
|
rule(:whitespace) { (space | newline).repeat(1) }
|
12
|
-
rule(:whitespace?) { whitespace.maybe }
|
13
13
|
|
14
14
|
rule(:key) { match('[a-zA-Z0-9\-_]').repeat(1) }
|
15
15
|
|
@@ -21,9 +21,9 @@ class Shortcode::Parser < Parslet::Parser
|
|
21
21
|
rule(:options) { (str(' ') >> option).repeat(1) }
|
22
22
|
rule(:options?) { options.repeat(0, 1) }
|
23
23
|
|
24
|
-
rule(:open) { str('[') >> block_tag.as(:open) >> options?.as(:options) >> str(']') >>
|
25
|
-
rule(:close) { str('[/') >> block_tag.as(:close) >> str(']') >>
|
26
|
-
rule(:open_close) { str('[') >> self_closing_tag.as(:open_close) >> options?.as(:options) >> str(']') >>
|
24
|
+
rule(:open) { str('[') >> block_tag.as(:open) >> options?.as(:options) >> str(']') >> newline? }
|
25
|
+
rule(:close) { str('[/') >> block_tag.as(:close) >> str(']') >> newline? }
|
26
|
+
rule(:open_close) { str('[') >> self_closing_tag.as(:open_close) >> options?.as(:options) >> str(']') >> newline? }
|
27
27
|
|
28
28
|
rule(:text) { ((close | block | open_close).absent? >> any).repeat(1).as(:text) }
|
29
29
|
rule(:block) { (open >> (block | text | open_close).repeat.as(:inner) >> close) }
|
data/lib/shortcode/railtie.rb
CHANGED
data/lib/shortcode/tag.rb
CHANGED
@@ -1,17 +1,8 @@
|
|
1
1
|
class Shortcode::Tag
|
2
2
|
|
3
3
|
def initialize(name, attributes=[], content='', additional_attributes=nil)
|
4
|
-
|
5
|
-
@
|
6
|
-
presenter = Shortcode::Presenter.new name, set_attributes(attributes), content, additional_attributes
|
7
|
-
@attributes = presenter.attributes
|
8
|
-
@content = presenter.content
|
9
|
-
end
|
10
|
-
|
11
|
-
def set_attributes(attributes)
|
12
|
-
hash = {}
|
13
|
-
attributes.each { |o| hash[o[:key].to_sym] = o[:value] }
|
14
|
-
hash
|
4
|
+
@name = name.downcase
|
5
|
+
@binding = Shortcode::TemplateBinding.new(@name, attributes, content, additional_attributes)
|
15
6
|
end
|
16
7
|
|
17
8
|
def markup
|
@@ -28,23 +19,14 @@ class Shortcode::Tag
|
|
28
19
|
|
29
20
|
private
|
30
21
|
|
31
|
-
def include_helper_modules
|
32
|
-
return unless Shortcode.configuration.helpers.any?
|
33
|
-
class << self
|
34
|
-
Shortcode.configuration.helpers.each do |helper|
|
35
|
-
include helper
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
22
|
def render_template
|
41
23
|
case Shortcode.configuration.template_parser
|
42
24
|
when :erb
|
43
|
-
ERB.new(markup).result(binding)
|
25
|
+
ERB.new(markup).result(@binding.get_binding)
|
44
26
|
when :haml
|
45
|
-
Haml::Engine.new(markup, ugly: true).render(binding)
|
27
|
+
Haml::Engine.new(markup, ugly: true).render(@binding)
|
46
28
|
when :slim
|
47
|
-
Slim::Template.new { markup }.render(
|
29
|
+
Slim::Template.new { markup }.render(@binding)
|
48
30
|
else
|
49
31
|
raise Shortcode::TemplateParserNotSupported, Shortcode.configuration.template_parser
|
50
32
|
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
class Shortcode::TemplateBinding
|
2
|
+
|
3
|
+
def initialize(name, attributes=[], content='', additional_attributes=nil)
|
4
|
+
include_helper_modules
|
5
|
+
presenter = Shortcode::Presenter.new name, set_attributes(attributes), content, additional_attributes
|
6
|
+
@name = name
|
7
|
+
@attributes = presenter.attributes
|
8
|
+
@content = presenter.content
|
9
|
+
end
|
10
|
+
|
11
|
+
# Expose private binding() method for use with erb templates
|
12
|
+
def get_binding
|
13
|
+
binding
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def set_attributes(attributes)
|
19
|
+
hash = {}
|
20
|
+
attributes.each { |o| hash[o[:key].to_sym] = o[:value] }
|
21
|
+
hash
|
22
|
+
end
|
23
|
+
|
24
|
+
def include_helper_modules
|
25
|
+
return unless Shortcode.configuration.helpers.any?
|
26
|
+
class << self
|
27
|
+
Shortcode.configuration.helpers.each do |helper|
|
28
|
+
include helper
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
data/lib/shortcode/version.rb
CHANGED
data/shortcode.gemspec
CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ["Jamie Dyer"]
|
10
10
|
spec.email = ["jamie@kernowsoul.com"]
|
11
11
|
spec.description = "Gem for parsing wordpress style shortcodes"
|
12
|
-
spec.summary = "Gem for parsing wordpress style shortcodes"
|
12
|
+
spec.summary = "Gem for parsing wordpress style shortcodes in ruby projects"
|
13
13
|
spec.homepage = "https://github.com/kernow/shortcode"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
@@ -18,12 +18,12 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_dependency "parslet", "1.6.
|
21
|
+
spec.add_dependency "parslet", "1.6.2"
|
22
22
|
|
23
23
|
spec.add_development_dependency "bundler", "~> 1.3"
|
24
|
-
spec.add_development_dependency "rake"
|
25
|
-
spec.add_development_dependency "rspec", "~> 3.
|
26
|
-
spec.add_development_dependency "coveralls"
|
27
|
-
spec.add_development_dependency "slim", "~>
|
24
|
+
spec.add_development_dependency "rake", "~> 0"
|
25
|
+
spec.add_development_dependency "rspec", "~> 3.1"
|
26
|
+
spec.add_development_dependency "coveralls", "~> 0"
|
27
|
+
spec.add_development_dependency "slim", "~> 3.0"
|
28
28
|
spec.add_development_dependency "haml", "~> 4.0"
|
29
29
|
end
|
data/spec/parser_spec.rb
CHANGED
@@ -118,7 +118,7 @@ describe Shortcode::Parser do
|
|
118
118
|
inner: [{ text: "A quote" }],
|
119
119
|
close: "quote"
|
120
120
|
},
|
121
|
-
{ text: "<br> blah blah\n" }
|
121
|
+
{ text: " <br> blah blah\n" }
|
122
122
|
])
|
123
123
|
end
|
124
124
|
|
@@ -259,7 +259,7 @@ describe Shortcode::Parser do
|
|
259
259
|
}],
|
260
260
|
close: "collapsible_list"
|
261
261
|
},
|
262
|
-
{ text: "<p>Some more text</p>\n" }
|
262
|
+
{ text: "\n<p>Some more text</p>\n" }
|
263
263
|
])
|
264
264
|
end
|
265
265
|
end
|
data/spec/transformer_spec.rb
CHANGED
@@ -7,27 +7,29 @@ describe Shortcode do
|
|
7
7
|
let(:parser) { Shortcode::Parser.new }
|
8
8
|
let(:transformer) { Shortcode::Transformer.new }
|
9
9
|
|
10
|
-
let(:simple_quote)
|
11
|
-
let(:full_quote)
|
12
|
-
let(:quote_with_extras)
|
13
|
-
let(:simple_list)
|
14
|
-
let(:timeline_event)
|
15
|
-
let(:timeline_info)
|
16
|
-
let(:timeline_person)
|
17
|
-
let(:complex_snippet)
|
10
|
+
let(:simple_quote) { load_fixture :simple_quote }
|
11
|
+
let(:full_quote) { load_fixture :full_quote }
|
12
|
+
let(:quote_with_extras) { load_fixture :quote_with_extras }
|
13
|
+
let(:simple_list) { load_fixture :simple_list }
|
14
|
+
let(:timeline_event) { load_fixture :timeline_event }
|
15
|
+
let(:timeline_info) { load_fixture :timeline_info }
|
16
|
+
let(:timeline_person) { load_fixture :timeline_person }
|
17
|
+
let(:complex_snippet) { load_fixture :complex_snippet }
|
18
|
+
let(:block_with_whitespace) { load_fixture :block_with_whitespace }
|
18
19
|
|
19
20
|
let(:quotes) { [simple_quote, full_quote, quote_with_extras] }
|
20
21
|
let(:collapsible_lists) { [simple_list] }
|
21
22
|
let(:timelines) { [timeline_event, timeline_info, timeline_person] }
|
22
23
|
|
23
|
-
let(:simple_quote_output)
|
24
|
-
let(:full_quote_output)
|
25
|
-
let(:quote_with_extras_output)
|
26
|
-
let(:simple_list_output)
|
27
|
-
let(:timeline_event_output)
|
28
|
-
let(:timeline_info_output)
|
29
|
-
let(:timeline_person_output)
|
30
|
-
let(:complex_snippet_output)
|
24
|
+
let(:simple_quote_output) { load_fixture :simple_quote_output, :html }
|
25
|
+
let(:full_quote_output) { load_fixture :full_quote_output, :html }
|
26
|
+
let(:quote_with_extras_output) { load_fixture :quote_with_extras_output, :html }
|
27
|
+
let(:simple_list_output) { load_fixture :simple_list_output, :html }
|
28
|
+
let(:timeline_event_output) { load_fixture :timeline_event_output, :html }
|
29
|
+
let(:timeline_info_output) { load_fixture :timeline_info_output, :html }
|
30
|
+
let(:timeline_person_output) { load_fixture :timeline_person_output, :html }
|
31
|
+
let(:complex_snippet_output) { load_fixture :complex_snippet_output, :html }
|
32
|
+
let(:block_with_whitespace_output) { load_fixture :block_with_whitespace_output, :html }
|
31
33
|
|
32
34
|
context "simple_quote" do
|
33
35
|
|
@@ -108,4 +110,13 @@ describe Shortcode do
|
|
108
110
|
expect(html.gsub("\n",'')).to eq(simple_quote_output)
|
109
111
|
end
|
110
112
|
end
|
113
|
+
|
114
|
+
context 'whitespace' do
|
115
|
+
|
116
|
+
it 'is preserved after a block tag' do
|
117
|
+
html = transformer.apply(parser.parse(block_with_whitespace), additional_attributes: nil)
|
118
|
+
expect(html.gsub("\n",'')).to eq(block_with_whitespace_output)
|
119
|
+
end
|
120
|
+
|
121
|
+
end
|
111
122
|
end
|
metadata
CHANGED
@@ -1,126 +1,111 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shortcode
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
5
|
-
prerelease:
|
4
|
+
version: 1.0.2
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Jamie Dyer
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2015-03-04 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: parslet
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
17
|
- - '='
|
20
18
|
- !ruby/object:Gem::Version
|
21
|
-
version: 1.6.
|
19
|
+
version: 1.6.2
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
24
|
- - '='
|
28
25
|
- !ruby/object:Gem::Version
|
29
|
-
version: 1.6.
|
26
|
+
version: 1.6.2
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: bundler
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- - ~>
|
31
|
+
- - "~>"
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: '1.3'
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- - ~>
|
38
|
+
- - "~>"
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: '1.3'
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: rake
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- -
|
45
|
+
- - "~>"
|
52
46
|
- !ruby/object:Gem::Version
|
53
47
|
version: '0'
|
54
48
|
type: :development
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
|
-
- -
|
52
|
+
- - "~>"
|
60
53
|
- !ruby/object:Gem::Version
|
61
54
|
version: '0'
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
56
|
name: rspec
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
58
|
requirements:
|
67
|
-
- - ~>
|
59
|
+
- - "~>"
|
68
60
|
- !ruby/object:Gem::Version
|
69
|
-
version: 3.
|
61
|
+
version: '3.1'
|
70
62
|
type: :development
|
71
63
|
prerelease: false
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
65
|
requirements:
|
75
|
-
- - ~>
|
66
|
+
- - "~>"
|
76
67
|
- !ruby/object:Gem::Version
|
77
|
-
version: 3.
|
68
|
+
version: '3.1'
|
78
69
|
- !ruby/object:Gem::Dependency
|
79
70
|
name: coveralls
|
80
71
|
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
72
|
requirements:
|
83
|
-
- -
|
73
|
+
- - "~>"
|
84
74
|
- !ruby/object:Gem::Version
|
85
75
|
version: '0'
|
86
76
|
type: :development
|
87
77
|
prerelease: false
|
88
78
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
79
|
requirements:
|
91
|
-
- -
|
80
|
+
- - "~>"
|
92
81
|
- !ruby/object:Gem::Version
|
93
82
|
version: '0'
|
94
83
|
- !ruby/object:Gem::Dependency
|
95
84
|
name: slim
|
96
85
|
requirement: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
86
|
requirements:
|
99
|
-
- - ~>
|
87
|
+
- - "~>"
|
100
88
|
- !ruby/object:Gem::Version
|
101
|
-
version: '
|
89
|
+
version: '3.0'
|
102
90
|
type: :development
|
103
91
|
prerelease: false
|
104
92
|
version_requirements: !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
93
|
requirements:
|
107
|
-
- - ~>
|
94
|
+
- - "~>"
|
108
95
|
- !ruby/object:Gem::Version
|
109
|
-
version: '
|
96
|
+
version: '3.0'
|
110
97
|
- !ruby/object:Gem::Dependency
|
111
98
|
name: haml
|
112
99
|
requirement: !ruby/object:Gem::Requirement
|
113
|
-
none: false
|
114
100
|
requirements:
|
115
|
-
- - ~>
|
101
|
+
- - "~>"
|
116
102
|
- !ruby/object:Gem::Version
|
117
103
|
version: '4.0'
|
118
104
|
type: :development
|
119
105
|
prerelease: false
|
120
106
|
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
none: false
|
122
107
|
requirements:
|
123
|
-
- - ~>
|
108
|
+
- - "~>"
|
124
109
|
- !ruby/object:Gem::Version
|
125
110
|
version: '4.0'
|
126
111
|
description: Gem for parsing wordpress style shortcodes
|
@@ -130,9 +115,9 @@ executables: []
|
|
130
115
|
extensions: []
|
131
116
|
extra_rdoc_files: []
|
132
117
|
files:
|
133
|
-
- .gitignore
|
134
|
-
- .
|
135
|
-
- .travis.yml
|
118
|
+
- ".gitignore"
|
119
|
+
- ".ruby-version"
|
120
|
+
- ".travis.yml"
|
136
121
|
- Appraisals
|
137
122
|
- CHANGELOG.md
|
138
123
|
- Gemfile
|
@@ -140,11 +125,11 @@ files:
|
|
140
125
|
- LICENSE.txt
|
141
126
|
- README.md
|
142
127
|
- Rakefile
|
143
|
-
- gemfiles/rails_3.0.gemfile
|
144
128
|
- gemfiles/rails_3.1.gemfile
|
145
129
|
- gemfiles/rails_3.2.gemfile
|
146
130
|
- gemfiles/rails_4.0.gemfile
|
147
131
|
- gemfiles/rails_4.1.gemfile
|
132
|
+
- gemfiles/rails_4.2.gemfile
|
148
133
|
- lib/shortcode.rb
|
149
134
|
- lib/shortcode/configuration.rb
|
150
135
|
- lib/shortcode/exceptions.rb
|
@@ -153,6 +138,7 @@ files:
|
|
153
138
|
- lib/shortcode/processor.rb
|
154
139
|
- lib/shortcode/railtie.rb
|
155
140
|
- lib/shortcode/tag.rb
|
141
|
+
- lib/shortcode/template_binding.rb
|
156
142
|
- lib/shortcode/transformer.rb
|
157
143
|
- lib/shortcode/version.rb
|
158
144
|
- shortcode.gemspec
|
@@ -163,6 +149,8 @@ files:
|
|
163
149
|
- spec/shortcode_spec.rb
|
164
150
|
- spec/spec_helper.rb
|
165
151
|
- spec/support/fixtures.rb
|
152
|
+
- spec/support/fixtures/block_with_whitespace.txt
|
153
|
+
- spec/support/fixtures/block_with_whitespace_output.html
|
166
154
|
- spec/support/fixtures/complex_snippet.txt
|
167
155
|
- spec/support/fixtures/complex_snippet_output.html
|
168
156
|
- spec/support/fixtures/custom_helper.txt
|
@@ -216,28 +204,27 @@ files:
|
|
216
204
|
homepage: https://github.com/kernow/shortcode
|
217
205
|
licenses:
|
218
206
|
- MIT
|
207
|
+
metadata: {}
|
219
208
|
post_install_message:
|
220
209
|
rdoc_options: []
|
221
210
|
require_paths:
|
222
211
|
- lib
|
223
212
|
required_ruby_version: !ruby/object:Gem::Requirement
|
224
|
-
none: false
|
225
213
|
requirements:
|
226
|
-
- -
|
214
|
+
- - ">="
|
227
215
|
- !ruby/object:Gem::Version
|
228
216
|
version: '0'
|
229
217
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
230
|
-
none: false
|
231
218
|
requirements:
|
232
|
-
- -
|
219
|
+
- - ">="
|
233
220
|
- !ruby/object:Gem::Version
|
234
221
|
version: '0'
|
235
222
|
requirements: []
|
236
223
|
rubyforge_project:
|
237
|
-
rubygems_version:
|
224
|
+
rubygems_version: 2.4.5
|
238
225
|
signing_key:
|
239
|
-
specification_version:
|
240
|
-
summary: Gem for parsing wordpress style shortcodes
|
226
|
+
specification_version: 4
|
227
|
+
summary: Gem for parsing wordpress style shortcodes in ruby projects
|
241
228
|
test_files:
|
242
229
|
- spec/parser_spec.rb
|
243
230
|
- spec/performance_spec.rb
|
@@ -246,6 +233,8 @@ test_files:
|
|
246
233
|
- spec/shortcode_spec.rb
|
247
234
|
- spec/spec_helper.rb
|
248
235
|
- spec/support/fixtures.rb
|
236
|
+
- spec/support/fixtures/block_with_whitespace.txt
|
237
|
+
- spec/support/fixtures/block_with_whitespace_output.html
|
249
238
|
- spec/support/fixtures/complex_snippet.txt
|
250
239
|
- spec/support/fixtures/complex_snippet_output.html
|
251
240
|
- spec/support/fixtures/custom_helper.txt
|
data/.rbenv-version
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
1.9.3-p392
|