front_matter_parser 0.1.0 → 0.1.1
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 +4 -4
- data/CHANGELOG.md +9 -0
- data/README.md +3 -3
- data/lib/front_matter_parser/syntax_parser/indentation_comment.rb +1 -1
- data/lib/front_matter_parser/syntax_parser/multi_line_comment.rb +1 -1
- data/lib/front_matter_parser/syntax_parser/single_line_comment.rb +1 -1
- data/lib/front_matter_parser/version.rb +1 -1
- data/spec/front_matter_parser/loader/yaml_spec.rb +1 -1
- data/spec/front_matter_parser/syntax_parser/indentation_comment_spec.rb +20 -0
- data/spec/front_matter_parser/syntax_parser/multi_line_comment_spec.rb +18 -0
- data/spec/front_matter_parser/syntax_parser/single_line_comment_spec.rb +19 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5d5e6ab289e911c8eef0b4890f1dd8ff48f9d21a
|
4
|
+
data.tar.gz: 29aac6299a32dcfcc18bd770f3b078b440767455
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf889dea7373a1441d733deb02812fe0894aa1b549f53ddbad3229cb4ebeae1a108debc562e4bc7b0d6eb949ef6b8afcda9d7399c3cab6bca0979a30fed71954
|
7
|
+
data.tar.gz: 81803add1d8eea7140d4e9c8a3cd559ce8b2f2ab191e9bec3e98def6c28fb5780471b341cc476712aaf763a53801414c6a6eea5b334374ab35634c4702e14e27
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
# Change Log
|
2
|
+
All notable changes to this project will be documented in this file.
|
3
|
+
|
4
|
+
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
5
|
+
and this project adheres to [Semantic Versioning](http://semver.org/).
|
6
|
+
|
7
|
+
## [0.1.1] - 2017-07-19
|
8
|
+
### Fixed
|
9
|
+
- Don't be greedy with front matter end delimiters
|
data/README.md
CHANGED
@@ -95,7 +95,7 @@ You can as well parse a string providing manually the syntax:
|
|
95
95
|
|
96
96
|
```ruby
|
97
97
|
string = File.read('example.slim')
|
98
|
-
FrontMatterParser::Parser.new(:slim).
|
98
|
+
FrontMatterParser::Parser.new(:slim).call(string)
|
99
99
|
```
|
100
100
|
|
101
101
|
### Custom parsers
|
@@ -117,7 +117,7 @@ slim_parser = SlimParser.new
|
|
117
117
|
FrontMatterParser::Parser.parse_file('example.slim', syntax_parser: slim_parser)
|
118
118
|
|
119
119
|
# For a string
|
120
|
-
FrontMatterParser::Parser.new(slim_parser).
|
120
|
+
FrontMatterParser::Parser.new(slim_parser).call(string)
|
121
121
|
```
|
122
122
|
|
123
123
|
For more complex scenarios, a parser can be anything responding to a method `call(string)` which returns a hash interface with `:front_matter` and `:content` keys, or `nil` if no front matter is found.
|
@@ -133,7 +133,7 @@ json_loader = ->(string) { JSON.load(string) }
|
|
133
133
|
FrontMatterParser::Parser.parse_file('example.md', loader: json_loader)
|
134
134
|
|
135
135
|
# For a string
|
136
|
-
FrontMatterParser::Parser.new(:md, loader: json_loader).
|
136
|
+
FrontMatterParser::Parser.new(:md, loader: json_loader).call(string)
|
137
137
|
```
|
138
138
|
|
139
139
|
## Development
|
@@ -138,6 +138,26 @@ describe FrontMatterParser::SyntaxParser::IndentationComment do
|
|
138
138
|
end
|
139
139
|
end
|
140
140
|
|
141
|
+
context 'with front matter delimiter chars in the content' do
|
142
|
+
let(:syntax) { :slim }
|
143
|
+
let(:string) do
|
144
|
+
<<~eos
|
145
|
+
/
|
146
|
+
---
|
147
|
+
title: hello
|
148
|
+
---
|
149
|
+
Content
|
150
|
+
---
|
151
|
+
eos
|
152
|
+
end
|
153
|
+
|
154
|
+
it 'is not greedy' do
|
155
|
+
front_matter = { 'title' => 'hello' }
|
156
|
+
|
157
|
+
expect(parsed).to be_parsed_result_with(front_matter, "Content\n---\n")
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
141
161
|
it 'returns nil if no front matter is found' do
|
142
162
|
string = 'Content'
|
143
163
|
|
@@ -241,6 +241,24 @@ describe FrontMatterParser::SyntaxParser::MultiLineComment do
|
|
241
241
|
end
|
242
242
|
end
|
243
243
|
|
244
|
+
context 'with front matter delimiter chars in the content' do
|
245
|
+
let(:syntax) { :md }
|
246
|
+
let(:string) do
|
247
|
+
<<~eos
|
248
|
+
---
|
249
|
+
title: hello
|
250
|
+
---
|
251
|
+
Content---
|
252
|
+
eos
|
253
|
+
end
|
254
|
+
|
255
|
+
it 'is not greedy' do
|
256
|
+
front_matter = { 'title' => 'hello' }
|
257
|
+
|
258
|
+
expect(parsed).to be_parsed_result_with(front_matter, "Content---\n")
|
259
|
+
end
|
260
|
+
end
|
261
|
+
|
244
262
|
it 'returns nil if no front matter is found' do
|
245
263
|
string = 'Content'
|
246
264
|
|
@@ -148,6 +148,25 @@ describe FrontMatterParser::SyntaxParser::SingleLineComment do
|
|
148
148
|
end
|
149
149
|
end
|
150
150
|
|
151
|
+
context 'with front matter delimiter chars in the content' do
|
152
|
+
let(:syntax) { :sass }
|
153
|
+
let(:string) do
|
154
|
+
<<~eos
|
155
|
+
//---
|
156
|
+
//title: hello
|
157
|
+
//---
|
158
|
+
//---
|
159
|
+
Content
|
160
|
+
eos
|
161
|
+
end
|
162
|
+
|
163
|
+
it 'is not greedy' do
|
164
|
+
front_matter = { 'title' => 'hello' }
|
165
|
+
|
166
|
+
expect(parsed).to be_parsed_result_with(front_matter, "//---\nContent\n")
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
151
170
|
it 'returns nil if no front matter is found' do
|
152
171
|
string = 'Content'
|
153
172
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: front_matter_parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- marc
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-07-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -112,6 +112,7 @@ files:
|
|
112
112
|
- ".ruby-version"
|
113
113
|
- ".travis.yml"
|
114
114
|
- ".yardopts"
|
115
|
+
- CHANGELOG.md
|
115
116
|
- COPYING.LESSER
|
116
117
|
- COPYING.txt
|
117
118
|
- Dockerfile
|