blog-generator 0.3 → 0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/blog-generator/post.rb +8 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 156e5179eab439dfe19f7585b0d9bafb7eef00a1
|
4
|
+
data.tar.gz: a5363bf3adf5ac5b2d3393427ae29fb4704b90d9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8339ffc7bcc28ce14951ee12e1fdc56cabbed290f45f0676c2aa5bd961fcbb255339f43c2df4ac83b5f9aaee80d321843491621ff225eaacdba0bf0a1de594fd
|
7
|
+
data.tar.gz: 003eff2cdbbc1ad041ff6bc887692d7dbbd9fcd180472d99ee1e6d96860bf8b3857e3535d07efdbd789dcf5ff48a2bae61aa7ce9ef66dddfe16244873ea0a197
|
data/lib/blog-generator/post.rb
CHANGED
@@ -97,12 +97,16 @@ module BlogGenerator
|
|
97
97
|
|
98
98
|
# This is a terrible hack to make unescaped code possible.
|
99
99
|
def post_process_body(text)
|
100
|
-
regexp = /<code lang="(\w+)"
|
101
|
-
original_body_matches = self.raw_body.scan(regexp)
|
100
|
+
regexp = /<code lang="(\w+)"(?: file="([^"]+)")?>\n?(.*?)<\/code>/m
|
101
|
+
p original_body_matches = self.raw_body.scan(regexp)
|
102
102
|
|
103
103
|
text.gsub(regexp).with_index do |pre, index|
|
104
|
-
language, code = original_body_matches[index]
|
105
|
-
|
104
|
+
language, file, code = original_body_matches[index]
|
105
|
+
if file
|
106
|
+
"<figure><figcaption class='filepath'>#{file}</figcaption><pre><code class=\"#{language}\">#{CGI.escapeHTML(code)}</code></pre></figure>"
|
107
|
+
else
|
108
|
+
"<pre><code class=\"#{language}\">#{CGI.escapeHTML(code)}</code></pre>"
|
109
|
+
end
|
106
110
|
end
|
107
111
|
end
|
108
112
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blog-generator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.4'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James C Russell
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-02-
|
11
|
+
date: 2017-02-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|