gibier 0.8.5 → 0.8.6
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/lib/gibier/{render.rb → renderer.rb} +20 -17
- data/lib/gibier/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5e1e19e5b708b1d18ac1a3fd54aaf5ebd49fd4c6
|
4
|
+
data.tar.gz: 22554ca8386ddd1cca524844cb7cbe278c575448
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b5b35b215e15116e1be7d5d1313c86c87d19e28f2740179bb6f613079d392c2c3fc0e7062ecc99ab166d9344d429fc2fc46803cc6c1091f7dee9b1244b56ac3a
|
7
|
+
data.tar.gz: f4668c4cb8bfdb1b1077bb2f307f5839249a24c468c4e51db7e6c1f106245f60c0d3ca9bdaf3eab7258f5318c6383970aca028601f17a600f6e7b1cac06dce1f
|
@@ -4,16 +4,19 @@ require 'redcarpet'
|
|
4
4
|
|
5
5
|
class String
|
6
6
|
def escape
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
7
|
+
"\"#{self.gsub(/\"/, "\\\"").gsub(/\\/, "\\\\")}\""
|
8
|
+
end
|
9
|
+
|
10
|
+
def expand_tag
|
11
|
+
m = /\A(?<head>.*?)(?<body><(?<tag>\w+)( (?<attrs>{(\w+:.+?)(, \w:.+?)*}))?>(?<inner>.*?)<\/\k<tag>>)(?<tail>.*?)\z/.match(self)
|
12
|
+
if m
|
13
|
+
arr = []
|
14
|
+
arr << m[:head].escape unless m[:head].empty?
|
15
|
+
arr << "#{m[:tag]}(#{m[:attrs] || "nil"}, #{m[:inner].expand_tag})" unless m[:body].empty?
|
16
|
+
arr << m[:tail].expand_tag unless m[:tail].empty?
|
17
|
+
arr.join(',')
|
15
18
|
else
|
16
|
-
|
19
|
+
self.escape
|
17
20
|
end
|
18
21
|
end
|
19
22
|
end
|
@@ -99,7 +102,7 @@ EOD
|
|
99
102
|
clear_list_state
|
100
103
|
|
101
104
|
if header_level > 3
|
102
|
-
return " children << h#{header_level}(nil, #{text.
|
105
|
+
return " children << h#{header_level}(nil, #{text.expand_tag})\n"
|
103
106
|
end
|
104
107
|
|
105
108
|
"".tap do |result|
|
@@ -126,7 +129,7 @@ EOD
|
|
126
129
|
<<EOD
|
127
130
|
class Gibier::Page#{@page_count} < Gibier::PageBase
|
128
131
|
def header
|
129
|
-
h#{header_level}(nil, #{text.
|
132
|
+
h#{header_level}(nil, #{text.expand_tag})
|
130
133
|
end
|
131
134
|
|
132
135
|
def content
|
@@ -151,11 +154,11 @@ EOD
|
|
151
154
|
def list_item(item, orderd)
|
152
155
|
"".tap do |result|
|
153
156
|
if item =~ /.*\n +children << /
|
154
|
-
result << item.sub(/(.*)\n +children << /) { " li(nil, #{$1.strip.
|
157
|
+
result << item.sub(/(.*)\n +children << /) { " li(nil, #{$1.strip.expand_tag}),\n " }.rstrip
|
155
158
|
result << ",\n"
|
156
159
|
@enter_list = false
|
157
160
|
else
|
158
|
-
result << " li(nil, #{item.strip.
|
161
|
+
result << " li(nil, #{item.strip.expand_tag}),\n"
|
159
162
|
end
|
160
163
|
end
|
161
164
|
end
|
@@ -171,12 +174,12 @@ EOD
|
|
171
174
|
|
172
175
|
def link(link, title, content)
|
173
176
|
link or return
|
174
|
-
"<a
|
177
|
+
"<a {href:#{link.escape}, target:\"_blank\"}>#{content}</a>"
|
175
178
|
end
|
176
179
|
|
177
180
|
def image(link, title, alt_text)
|
178
181
|
href = "\#{Gibier.assets_path}/images/#{link}"
|
179
|
-
"<p
|
182
|
+
"<p {class:\"#{alt_text}\"}><img {src:#{href.escape}}></img></p>"
|
180
183
|
end
|
181
184
|
|
182
185
|
def block_code(code, language)
|
@@ -213,9 +216,9 @@ EOD
|
|
213
216
|
if text[0] == '%'
|
214
217
|
class_name = text[1...text.index(':')]
|
215
218
|
lines[0] = lines.first[(lines.first.index(':') + 1)...lines.first.length].lstrip
|
216
|
-
" children << p({className:\"#{class_name}\"}, #{lines.map{|l| l.
|
219
|
+
" children << p({className:\"#{class_name}\"}, #{lines.map{|l| l.expand_tag}.join(',Hyalite.create_element(\'br\'),')})\n"
|
217
220
|
else
|
218
|
-
" children << p(nil, #{lines.map{|l| l.
|
221
|
+
" children << p(nil, #{lines.map{|l| l.expand_tag}.join(',Hyalite.create_element(\'br\'),')})\n"
|
219
222
|
end
|
220
223
|
end
|
221
224
|
|
data/lib/gibier/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gibier
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- youchan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-08-
|
11
|
+
date: 2017-08-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sinatra
|
@@ -264,7 +264,7 @@ files:
|
|
264
264
|
- lib/gibier.rb
|
265
265
|
- lib/gibier/cli.rb
|
266
266
|
- lib/gibier/haml_helper.rb
|
267
|
-
- lib/gibier/
|
267
|
+
- lib/gibier/renderer.rb
|
268
268
|
- lib/gibier/slide_helper.rb
|
269
269
|
- lib/gibier/slide_loader.rb
|
270
270
|
- lib/gibier/static_generator.rb
|