nanoc-conref-fs 0.1.0 → 0.1.1

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: 3b9b74d13a2d5e87fcc3a90d5072c25ad3dd82b2
4
- data.tar.gz: 0a943c2e008ecd7b8f22e0b4fc4f7fcac64e867e
3
+ metadata.gz: d3a726e64721a3b46fba7d2c2127e5a32443e32e
4
+ data.tar.gz: 4029668164382b87e6e6214a43a6799ab6bbe9b1
5
5
  SHA512:
6
- metadata.gz: 51ce48cb1edf56f86eb87d398c8626ab38e437c9b41b790e9274624d666cfe254aaf41453fc9738b90363077144f6eed0533d249c01d70d9f23c627e9d4ee5cd
7
- data.tar.gz: 1414c576b31ece94c1bc30c38e56b3a443a02407c0b75b6eb3b6783f351665134ee861dc391222d5057d81592858c732eb0c77d55496bfa7a6f3945d5d4050c9
6
+ metadata.gz: 721c545407580610d9e5837274e4255b948e2258b9282ed01e84c2d7a7e59ad8f130d38a1def79cb1f789cdf3eac58f9c1cd3f4f4082790a1729268da35ff5b5
7
+ data.tar.gz: 2d02ae7a354ed8660f4a78b43bfc7fa0cb16966fada9c662ab829fe4c557150c1c79d0554ee3c28477d63e8723b710144c89e849b27b10f0167082d221bb838b
@@ -68,14 +68,16 @@ class ConrefFS < Nanoc::DataSource
68
68
  return data unless filename.start_with?('content')
69
69
 
70
70
  # we must obfuscate essential ExtendedMarkdownFilter content
71
- data = data.gsub(/\{\{#/, '[[#').gsub(/\{\{ octicon-/, '[[ octicon-')
71
+ data = data.gsub(/\{\{\s*#(\S+)\s*\}\}/, '[[#\1]]')
72
+ data = data.gsub(/\{\{\s*\/(\S+)\s*\}\}/, '[[/\1]]')
73
+ data = data.gsub(/\{\{\s*(octicon-\S+\s*[^\}]+)\s*\}\}/, '[[\1]]')
74
+
72
75
  # This first pass converts the frontmatter variables,
73
76
  # and inserts data variables into the body
74
77
  result = Conrefifier.apply_liquid(data, page_vars)
75
78
  # This second application renders the previously inserted
76
79
  # data conditionals within the body
77
80
  result = Conrefifier.apply_liquid(result, page_vars)
78
- result.gsub('[[#', '{{#').gsub('{{ octicon-', '[[ octicon-')
79
81
  rescue => e
80
82
  raise RuntimeError.new("Could not read #{filename}: #{e.inspect}")
81
83
  end
@@ -3,14 +3,14 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
3
 
4
4
  Gem::Specification.new do |spec|
5
5
  spec.name = 'nanoc-conref-fs'
6
- spec.version = '0.1.0'
6
+ spec.version = '0.1.1'
7
7
  spec.authors = ['Garen Torikian']
8
8
  spec.email = ['gjtorikian@gmail.com']
9
9
  spec.summary = 'A Nanoc filesystem to permit using conrefs/reusables in your content.'
10
10
  spec.homepage = 'https://github.com/gjtorikian/nanoc-conref-fs'
11
11
  spec.license = 'MIT'
12
12
 
13
- spec.files = `git ls-files`.split($/)
13
+ spec.files = `git ls-files -z`.split("\x0")
14
14
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
15
15
  spec.test_files = spec.files.grep(%r{^(test)/})
16
16
  spec.require_paths = ['lib']
@@ -97,4 +97,20 @@ class DatafilesTest < MiniTest::Test
97
97
  assert_equal output_file, test_file
98
98
  end
99
99
  end
100
+
101
+ def test_it_obfuscates_content
102
+ with_site(name: FIXTURES_DIR) do |site|
103
+
104
+ site = Nanoc::Int::SiteLoader.new.new_from_cwd
105
+ site.compile
106
+
107
+ output_file = read_output_file('obfuscation', 'admonitions')
108
+ test_file = read_test_file('obfuscation', 'admonitions')
109
+ assert_equal output_file, test_file
110
+
111
+ output_file = read_output_file('obfuscation', 'octicon')
112
+ test_file = read_test_file('obfuscation', 'octicon')
113
+ assert_equal output_file, test_file
114
+ end
115
+ end
100
116
  end
@@ -0,0 +1,40 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>
5
+
6
+ </title>
7
+ </head>
8
+
9
+ <body>
10
+
11
+ [[#tip]]
12
+
13
+ Here's a hot tip: **line one**
14
+ Here's a hot tip: line two
15
+
16
+ [[/tip]]
17
+
18
+ [[#note]]
19
+
20
+ This is something you should know! line one
21
+ This is something you should know! line two
22
+
23
+ [[/note]]
24
+
25
+ [[#warning]]
26
+
27
+ Yo, check this out: line one
28
+ Yo, check this out: line two
29
+
30
+ [[/warning]]
31
+
32
+ [[#danger]]
33
+
34
+ Sheeeeit, this is a problem: ~~line one~~
35
+ Sheeeeit, this is a problem: line two
36
+
37
+ [[/danger]]
38
+
39
+ </body>
40
+ </html>
@@ -0,0 +1,27 @@
1
+ {{#tip}}
2
+
3
+ Here's a hot tip: **line one**
4
+ Here's a hot tip: line two
5
+
6
+ {{/tip}}
7
+
8
+ {{#note}}
9
+
10
+ This is something you should know! line one
11
+ This is something you should know! line two
12
+
13
+ {{/note}}
14
+
15
+ {{#warning}}
16
+
17
+ Yo, check this out: line one
18
+ Yo, check this out: line two
19
+
20
+ {{/warning}}
21
+
22
+ {{#danger}}
23
+
24
+ Sheeeeit, this is a problem: ~~line one~~
25
+ Sheeeeit, this is a problem: line two
26
+
27
+ {{/danger}}
@@ -0,0 +1,16 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>
5
+
6
+ </title>
7
+ </head>
8
+
9
+ <body>
10
+
11
+ [[octicon-cat This is a cat]]
12
+
13
+ [Click [[octicon-gear Settings ]]](http://alink.com)
14
+
15
+ </body>
16
+ </html>
@@ -0,0 +1,5 @@
1
+ {{ octicon-cat This is a cat}}
2
+
3
+ {{ octicon dog This is nothing. }}
4
+
5
+ [Click {{ octicon-gear Settings }}](http://alink.com)
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.1.0
4
+ version: 0.1.1
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-10-20 00:00:00.000000000 Z
11
+ date: 2015-10-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nanoc
@@ -110,6 +110,10 @@ files:
110
110
  - test/fixtures/content/frontmatter/different.md
111
111
  - test/fixtures/content/frontmatter/title.html
112
112
  - test/fixtures/content/frontmatter/title.md
113
+ - test/fixtures/content/obfuscation/admonitions.html
114
+ - test/fixtures/content/obfuscation/admonitions.md
115
+ - test/fixtures/content/obfuscation/octicon.html
116
+ - test/fixtures/content/obfuscation/octicon.md
113
117
  - test/fixtures/content/parents/missing_title.html
114
118
  - test/fixtures/content/parents/missing_title.md
115
119
  - test/fixtures/content/parents/single_parent.html
@@ -160,6 +164,10 @@ test_files:
160
164
  - test/fixtures/content/frontmatter/different.md
161
165
  - test/fixtures/content/frontmatter/title.html
162
166
  - test/fixtures/content/frontmatter/title.md
167
+ - test/fixtures/content/obfuscation/admonitions.html
168
+ - test/fixtures/content/obfuscation/admonitions.md
169
+ - test/fixtures/content/obfuscation/octicon.html
170
+ - test/fixtures/content/obfuscation/octicon.md
163
171
  - test/fixtures/content/parents/missing_title.html
164
172
  - test/fixtures/content/parents/missing_title.md
165
173
  - test/fixtures/content/parents/single_parent.html