nanoc-conref-fs 0.4.4 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +0 -1
- data/lib/nanoc-conref-fs/conref-fs.rb +25 -28
- data/lib/nanoc-conref-fs/conrefifier.rb +1 -1
- data/nanoc-conref-fs.gemspec +1 -3
- data/test/conref_fs_test.rb +26 -0
- data/test/fixtures/content/liquid/multiple_versions.html +16 -0
- data/test/fixtures/content/liquid/multiple_versions.md +19 -0
- data/test/fixtures/content/liquid/raw.html +20 -0
- data/test/fixtures/content/liquid/raw.md +15 -0
- data/test/fixtures/nanoc.yaml +5 -0
- metadata +10 -3
- data/lib/nanoc-conref-fs/version.rb +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 35dc702fdbe8ffa00711be829afcf827fe5565fe
|
4
|
+
data.tar.gz: 83767a5ade9f4945c99f25d3a03122e1ff3467e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf4dd287a13d192f38777a6dc31211976ba3e6398ce7b9f53a06769740086dc706217788e05b1a954c35425863b75a41bea4937eaaa801eef7a2c87487b56289
|
7
|
+
data.tar.gz: 37c643e5e0b2ac33cb40aa87025146d3549aad0d48f7215ce4cbb5f41aa79a65f2580104e4ae78fd7a54343fe5c466b1a6eb70a657e10d83b0c6b98256d69d62
|
data/Gemfile
CHANGED
@@ -158,44 +158,41 @@ class ConrefFS < Nanoc::DataSource
|
|
158
158
|
end
|
159
159
|
|
160
160
|
begin
|
161
|
-
result =
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
end
|
167
|
-
else
|
168
|
-
content
|
169
|
-
end
|
170
|
-
|
171
|
-
# This pass converts the frontmatter variables,
|
172
|
-
# and inserts data variables into the body
|
173
|
-
if result =~ Conrefifier::SINGLE_SUB
|
174
|
-
result = result.gsub(Conrefifier::SINGLE_SUB) do |match|
|
175
|
-
resolution = Conrefifier.apply_liquid(match, page_vars).strip
|
176
|
-
if resolution.start_with?('*')
|
177
|
-
if resolution[1] != '*'
|
178
|
-
resolution = resolution.sub(/\*(.+?)\*/, '<em>\1</em>')
|
179
|
-
else
|
180
|
-
resolution = resolution.sub(/\*{2}(.+?)\*{2}/, '<strong>\1</strong>')
|
181
|
-
end
|
182
|
-
end
|
183
|
-
resolution
|
184
|
-
end
|
161
|
+
result = content
|
162
|
+
|
163
|
+
# This pass replaces any matched conditionals
|
164
|
+
if result =~ Conrefifier::BLOCK_SUB || result =~ Conrefifier::SINGLE_SUB
|
165
|
+
result = Conrefifier.apply_liquid(result, page_vars)
|
185
166
|
end
|
186
167
|
|
187
168
|
# This second pass renders any previously inserted
|
188
|
-
# data conditionals within the body
|
169
|
+
# data conditionals within the body. If a Liquid parse
|
170
|
+
# returns a blank string, we'll return the original
|
189
171
|
if result =~ Conrefifier::SINGLE_SUB
|
190
172
|
result = result.gsub(Conrefifier::SINGLE_SUB) do |match|
|
191
|
-
Conrefifier.apply_liquid(match, page_vars)
|
173
|
+
liquified = Conrefifier.apply_liquid(match, page_vars)
|
174
|
+
liquified.empty? ? match : liquified
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
# This converts ": *" frontmatter strings into HTML equivalents;
|
179
|
+
# otherwise, ": *" messes the YAML parsing
|
180
|
+
result = result.gsub(/\A---\s*\n(.*?\n?)^---\s*$\n?/m) do |frontmatter|
|
181
|
+
frontmatter.gsub(/:\s*(\*.+)/) do |_|
|
182
|
+
asterisk_match = Regexp.last_match[1]
|
183
|
+
if asterisk_match[1] != '*'
|
184
|
+
asterisk_match = asterisk_match.sub(/\*(.+?)\*/, ': <em>\1</em>')
|
185
|
+
else
|
186
|
+
asterisk_match = asterisk_match.sub(/\*{2}(.+?)\*{2}/, ': <strong>\1</strong>')
|
187
|
+
end
|
188
|
+
asterisk_match
|
192
189
|
end
|
193
190
|
end
|
194
191
|
|
195
192
|
result
|
196
|
-
rescue Liquid::SyntaxError
|
193
|
+
rescue Liquid::SyntaxError => e
|
197
194
|
# unrecognized Liquid, so just return the content
|
198
|
-
|
195
|
+
STDERR.puts "Could not convert #{filename}: #{e.message}"
|
199
196
|
result
|
200
197
|
rescue => e
|
201
198
|
raise "#{e.message}: #{e.inspect}"
|
@@ -18,6 +18,6 @@ module Conrefifier
|
|
18
18
|
|
19
19
|
def self.apply_liquid(content, data_vars)
|
20
20
|
data_vars['page'] = data_vars[:page].stringify_keys
|
21
|
-
|
21
|
+
Liquid::Template.parse(content, :error_mode => :warn).render(data_vars)
|
22
22
|
end
|
23
23
|
end
|
data/nanoc-conref-fs.gemspec
CHANGED
@@ -1,11 +1,9 @@
|
|
1
1
|
lib = File.expand_path('../lib', __FILE__)
|
2
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
3
|
|
4
|
-
require 'nanoc-conref-fs/version'
|
5
|
-
|
6
4
|
Gem::Specification.new do |spec|
|
7
5
|
spec.name = 'nanoc-conref-fs'
|
8
|
-
spec.version =
|
6
|
+
spec.version = '0.5.0'
|
9
7
|
spec.authors = ['Garen Torikian']
|
10
8
|
spec.email = ['gjtorikian@gmail.com']
|
11
9
|
spec.summary = 'A Nanoc filesystem to permit using conrefs/reusables in your content.'
|
data/test/conref_fs_test.rb
CHANGED
@@ -212,4 +212,30 @@ class DatafilesTest < MiniTest::Test
|
|
212
212
|
assert_equal output_file, test_file
|
213
213
|
end
|
214
214
|
end
|
215
|
+
|
216
|
+
def test_raw_tags
|
217
|
+
with_site(name: FIXTURES_DIR) do |site|
|
218
|
+
|
219
|
+
site = Nanoc::Int::SiteLoader.new.new_from_cwd
|
220
|
+
site.compile
|
221
|
+
|
222
|
+
output_file = read_output_file('liquid', 'raw')
|
223
|
+
test_file = read_test_file('liquid', 'raw')
|
224
|
+
|
225
|
+
assert_equal output_file, test_file
|
226
|
+
end
|
227
|
+
end
|
228
|
+
|
229
|
+
def test_multiple_version_blocks
|
230
|
+
with_site(name: FIXTURES_DIR) do |site|
|
231
|
+
|
232
|
+
site = Nanoc::Int::SiteLoader.new.new_from_cwd
|
233
|
+
site.compile
|
234
|
+
|
235
|
+
output_file = read_output_file('liquid', 'multiple_versions')
|
236
|
+
test_file = read_test_file('liquid', 'multiple_versions')
|
237
|
+
|
238
|
+
assert_equal output_file, test_file
|
239
|
+
end
|
240
|
+
end
|
215
241
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>
|
5
|
+
Raw
|
6
|
+
</title>
|
7
|
+
</head>
|
8
|
+
|
9
|
+
<body>
|
10
|
+
|
11
|
+
For example, to list a project's name, you might write something like `The project is called {{ site.github.project_title }}` or to list an organization's open source repositories, you might use the following:
|
12
|
+
|
13
|
+
``` liquid
|
14
|
+
{% for repository in site.github.public_repositories %}
|
15
|
+
* [{{ repository.name }}]({{ repository.html_url }})
|
16
|
+
{% endfor %}
|
17
|
+
```
|
18
|
+
|
19
|
+
</body>
|
20
|
+
</html>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
title: Raw
|
3
|
+
---
|
4
|
+
|
5
|
+
For example, to list a project's name, you might write something like `The project is called {% raw %}{{ site.github.project_title }}{% endraw %}` or to list an organization's open source repositories, you might use the following:
|
6
|
+
|
7
|
+
{% raw %}
|
8
|
+
|
9
|
+
``` liquid
|
10
|
+
{% for repository in site.github.public_repositories %}
|
11
|
+
* [{{ repository.name }}]({{ repository.html_url }})
|
12
|
+
{% endfor %}
|
13
|
+
```
|
14
|
+
|
15
|
+
{% endraw %}
|
data/test/fixtures/nanoc.yaml
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nanoc-conref-fs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Garen Torikian
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-11-
|
11
|
+
date: 2015-11-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nanoc
|
@@ -111,7 +111,6 @@ files:
|
|
111
111
|
- lib/nanoc-conref-fs/conref-fs.rb
|
112
112
|
- lib/nanoc-conref-fs/conrefifier.rb
|
113
113
|
- lib/nanoc-conref-fs/datafiles.rb
|
114
|
-
- lib/nanoc-conref-fs/version.rb
|
115
114
|
- nanoc-conref-fs.gemspec
|
116
115
|
- script/bootstrap
|
117
116
|
- test/conref_fs_test.rb
|
@@ -135,6 +134,10 @@ files:
|
|
135
134
|
- test/fixtures/content/frontmatter/different.md
|
136
135
|
- test/fixtures/content/frontmatter/title.html
|
137
136
|
- test/fixtures/content/frontmatter/title.md
|
137
|
+
- test/fixtures/content/liquid/multiple_versions.html
|
138
|
+
- test/fixtures/content/liquid/multiple_versions.md
|
139
|
+
- test/fixtures/content/liquid/raw.html
|
140
|
+
- test/fixtures/content/liquid/raw.md
|
138
141
|
- test/fixtures/content/maliciousness/asterisk_double.html
|
139
142
|
- test/fixtures/content/maliciousness/asterisk_double.md
|
140
143
|
- test/fixtures/content/maliciousness/asterisk_single.html
|
@@ -213,6 +216,10 @@ test_files:
|
|
213
216
|
- test/fixtures/content/frontmatter/different.md
|
214
217
|
- test/fixtures/content/frontmatter/title.html
|
215
218
|
- test/fixtures/content/frontmatter/title.md
|
219
|
+
- test/fixtures/content/liquid/multiple_versions.html
|
220
|
+
- test/fixtures/content/liquid/multiple_versions.md
|
221
|
+
- test/fixtures/content/liquid/raw.html
|
222
|
+
- test/fixtures/content/liquid/raw.md
|
216
223
|
- test/fixtures/content/maliciousness/asterisk_double.html
|
217
224
|
- test/fixtures/content/maliciousness/asterisk_double.md
|
218
225
|
- test/fixtures/content/maliciousness/asterisk_single.html
|