jekyll-liquid-debug 0.2.2

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 1109cf5a8b8b59ad63c3b67306271b5869d00bbd42ce493cd5e1acf8b80129ee
4
+ data.tar.gz: 0ea7545d75b22f72836a2f30ad7c860ab2523caea96cec7c423223165fead59f
5
+ SHA512:
6
+ metadata.gz: b88284680b4f74b5385d431464cd7fca10a988fdf5c5365f1a68d6d41f6ce240075cf97f782b014e0714f89c68e100cc9710178d1ef248df0f8f0576c33f439f
7
+ data.tar.gz: 7afff85a938255f81e48a3c26d9a046a88ca5de74eb1f2bce1fd83fa04f3e9b6f686fa8ee3935354381b845f16d51ba26d26e3ffba5313c95db852d900dfdd2f
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020 Xiang Zhong
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "jekyll-liquid-debug"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "jekyll-liquid-debug"
4
+
5
+ JekyllLiquidDebug.run
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,331 @@
1
+ ---
2
+ sort: 1
3
+ images:
4
+ - title: image-title
5
+ link: https://image-link.com
6
+ image: https://image-image.com
7
+ ---
8
+
9
+ # Markdown
10
+
11
+ This file is intentionally created for `liquid template` debugging.
12
+
13
+
14
+
15
+ # Line consecutive
16
+
17
+ line consecutive 1/3. There should be whitespace between paragraphs.
18
+ line consecutive 2/3. There should be whitespace between paragraphs.
19
+ line consecutive 3/3. There should be whitespace between paragraphs.
20
+
21
+
22
+
23
+ # Line horizontal
24
+
25
+ horizontal line -- 1/3
26
+
27
+ ----------------------
28
+
29
+ horizontal line -- 2/3
30
+
31
+ ----------------------
32
+
33
+ horizontal line -- 3/3
34
+
35
+ ----------------------
36
+
37
+ # Paragraph
38
+
39
+ paragraph 1/3. There should be whitespace between paragraphs.
40
+
41
+ paragraph 2/3. There should be whitespace between paragraphs.
42
+
43
+ paragraph 3/3. There should be whitespace between paragraphs.
44
+
45
+
46
+
47
+ # Text
48
+
49
+ text decoration 1/3. Text can be `code`, **bold**, _italic_, or ~~strikethrough~~. [Links](https://github.com)
50
+
51
+ text decoration 2/3. Text can be `code`, **bold**, _italic_, or ~~strikethrough~~. [Links](https://github.com)
52
+
53
+ text decoration 3/3. Text can be `code`, **bold**, _italic_, or ~~strikethrough~~. [Links](https://github.com)
54
+
55
+
56
+
57
+ # Blockquote
58
+
59
+ > blockquote 1/3 should be a lighter gray with a gray border along the left side.
60
+ > consecutive top
61
+ >
62
+ > another line
63
+
64
+ > blockquote 2/3 should be a lighter gray with a gray border along the left side.
65
+ > consecutive top
66
+ >
67
+ > another line
68
+
69
+ > blockquote 3/3 should be a lighter gray with a gray border along the left side.
70
+ > consecutive top
71
+ >
72
+ > another line
73
+
74
+
75
+
76
+ # Headers
77
+
78
+ # Header 1 -- 1/3
79
+
80
+ head-1-content -- 1/3
81
+
82
+ # Header 1 -- 2/3
83
+
84
+ head-1-content -- 2/3
85
+
86
+ # Header 1 -- 3/3
87
+
88
+ head-1-content -- 3/3
89
+
90
+
91
+
92
+ ## Header 2 -- 1/3
93
+
94
+ head-2-content -- 1/3
95
+
96
+ ## Header 2 -- 2/3
97
+
98
+ head-2-content -- 2/3
99
+
100
+ ## Header 2 -- 3/3
101
+
102
+ head-2-content -- 3/3
103
+
104
+
105
+
106
+ ### Header 3 -- 1/3
107
+
108
+ head-3-content -- 1/3
109
+
110
+ ### Header 3 -- 2/3
111
+
112
+ head-3-content -- 2/3
113
+
114
+ ### Header 3 -- 3/3
115
+
116
+ head-3-content -- 3/3
117
+
118
+
119
+
120
+ #### Header 4 -- 1/3
121
+
122
+ head-4-content -- 1/3
123
+
124
+ #### Header 4 -- 2/3
125
+
126
+ head-4-content -- 2/3
127
+
128
+ #### Header 4 -- 3/3
129
+
130
+ head-4-content -- 3/3
131
+
132
+
133
+
134
+ ##### Header 5 -- 1/3
135
+
136
+ head-5-content -- 1/3
137
+
138
+ ##### Header 5 -- 2/3
139
+
140
+ head-5-content -- 2/3
141
+
142
+ ##### Header 5 -- 3/3
143
+
144
+ head-5-content -- 3/3
145
+
146
+
147
+
148
+ ###### Header 6 -- 1/3
149
+
150
+ head-6-content -- 1/3
151
+
152
+ ###### Header 6 -- 2/3
153
+
154
+ head-6-content -- 2/3
155
+
156
+ ###### Header 6 -- 3/3
157
+
158
+ head-6-content -- 3/3
159
+
160
+
161
+
162
+ # Code block without header
163
+
164
+ ```
165
+ code block without header 1/3
166
+ ```
167
+
168
+ ```
169
+ code block without header 2/3
170
+ ```
171
+
172
+ ```
173
+ code block without header 3/3
174
+ ```
175
+
176
+
177
+
178
+ # Code block with header
179
+
180
+ ```header
181
+ code block with header 1/3
182
+ ```
183
+
184
+ ```header
185
+ code block with header 2/3
186
+ ```
187
+
188
+ ```header
189
+ code block with header 3/3
190
+ ```
191
+
192
+
193
+
194
+ # List Unordered
195
+
196
+ * This is an unordered list 1/6
197
+ * This is an unordered list 2/6
198
+ * This is an unordered list 3/6
199
+
200
+ * This is an unordered list 4/6
201
+
202
+ * This is an unordered list 5/6
203
+
204
+ * This is an unordered list 6/6
205
+
206
+
207
+
208
+ # List Ordered
209
+
210
+ 1. This is an ordered list 1/6
211
+ 2. This is an ordered list 2/6
212
+ 3. This is an ordered list 3/6
213
+
214
+ 4. This is an ordered list 4/6
215
+
216
+ 5. This is an ordered list 5/6
217
+
218
+ 6. This is an ordered list 6/6
219
+
220
+
221
+
222
+ # List checking
223
+
224
+ - [x] checked list
225
+
226
+ - [ ] unchecked list
227
+
228
+ - [x] checked list
229
+
230
+ 1. [ ] unchecked list
231
+
232
+ 2. [x] checked list
233
+
234
+ 3. [ ] unchecked list
235
+
236
+
237
+
238
+ # List nested
239
+
240
+ * unordered list
241
+ * unordered list
242
+ * unordered list
243
+ * unordered list
244
+ 1. ordered list
245
+ 1. ordered list
246
+ 2. ordered list
247
+ 2. ordered list
248
+
249
+ * unordered list
250
+ * unordered list
251
+ * unordered list
252
+ * unordered list
253
+ 1. ordered list
254
+ 1. ordered list
255
+ 2. ordered list
256
+ 2. ordered list
257
+
258
+ * unordered list
259
+ * unordered list
260
+ * unordered list
261
+ * unordered list
262
+ 1. ordered list
263
+ 1. ordered list
264
+ 2. ordered list
265
+ 2. ordered list
266
+
267
+
268
+
269
+ # Description table
270
+
271
+ <dl>
272
+ <dt>Song</dt>
273
+ <dd>Hello</dd>
274
+ <dt>Planet</dt>
275
+ <dd>Earth</dd>
276
+ </dl>
277
+
278
+
279
+ <dl>
280
+ <dt>Song</dt>
281
+ <dd>Hello</dd>
282
+ <dt>Planet</dt>
283
+ <dd>Earth</dd>
284
+ </dl>
285
+
286
+
287
+ <dl>
288
+ <dt>Song</dt>
289
+ <dd>Hello</dd>
290
+ <dt>Planet</dt>
291
+ <dd>Earth</dd>
292
+ </dl>
293
+
294
+
295
+
296
+ # Table
297
+
298
+ | What | Header | Note |
299
+ |--------|----------|----------|
300
+ | entry | content | 1/3 |
301
+
302
+
303
+ | What | Header | Note |
304
+ |--------|----------|----------|
305
+ | entry | content | 2/3 |
306
+
307
+
308
+ | What | Header | Note |
309
+ |--------|----------|----------|
310
+ | entry | content | 3/3 |
311
+
312
+
313
+
314
+ # Mixing
315
+
316
+ `code in line`, **`bold code`**, ~~`stroke through code`~~, ~~_italic stroke through_~~
317
+
318
+ `code in line`, **`bold code`**, ~~`stroke through code`~~, ~~_italic stroke through_~~
319
+
320
+ `code in line`, **`bold code`**, ~~`stroke through code`~~, ~~_italic stroke through_~~
321
+
322
+
323
+
324
+ # Image here-rendering
325
+
326
+ ![Octocat](https://github.githubassets.com/images/icons/emoji/octocat.png)
327
+
328
+ ![Octocat](https://github.githubassets.com/images/icons/emoji/octocat.png)
329
+
330
+ ![Octocat](https://github.githubassets.com/images/icons/emoji/octocat.png)
331
+
@@ -0,0 +1,17 @@
1
+ require_relative "lib/jekyll-liquid-debug/version"
2
+
3
+ Gem::Specification.new do |s|
4
+ s.required_ruby_version = ">= 2.5.0"
5
+ s.name = "jekyll-liquid-debug"
6
+ s.version = VERSION
7
+ s.authors = ["Xiang Zhong"]
8
+ s.email = ["zhongxiang117@gmail.com"]
9
+ s.summary = "Light Weight Jekyll Liquid Template Debug Package"
10
+ s.license = "MIT"
11
+ s.homepage = "https://github.com/zhongxiang117/jekyll-liquid-debug"
12
+ s.files = Dir["bin/*","data/*","lib/**/*", "jekyll-liquid-debug.gemspec", "LICENSE"]
13
+ s.require_paths = ["lib"]
14
+
15
+ s.add_dependency("liquid", "~> 4.0.0")
16
+ s.add_dependency("kramdown", "~> 2.3.0")
17
+ end
@@ -0,0 +1,116 @@
1
+ require "liquid"
2
+ require "kramdown"
3
+ require "optparse"
4
+ require_relative "jekyll-liquid-debug/version"
5
+
6
+ class JekyllLiquidDebug
7
+ class Parser
8
+ def self.parse(options)
9
+ # Hash to contain all settings
10
+ # it is needed to set default values, to help use Struct make Hash dottable.
11
+ # because Struct does not have method to check whether key exists
12
+ args = {file:false, html:false, kmd:false, outhtml:false, outmd:false}
13
+ OptionParser.new do |opt|
14
+ opt.banner = "Usage: jekyll-liquid-debug [options]"
15
+ opt.separator ""
16
+ opt.separator "Input files:"
17
+
18
+ opt.on("-f", "--file [FILE]", String, "input liquid template") do |v|
19
+ args[:file] = Parser.func_set_file(v)
20
+ end
21
+
22
+ opt.on("-t", "--html [FILE]", String, "input html template") do |v|
23
+ args[:html] = Parser.func_set_file(v)
24
+ end
25
+
26
+ opt.on("-k", "--md [FILE]", String, "input raw markdown file, precedent for option `-t'") do |v|
27
+ args[:kmd] = Parser.func_set_file(v)
28
+ end
29
+
30
+ opt.on("--out-html", TrueClass, "output html file, overwrite may happen") do |v|
31
+ args[:outhtml] = true
32
+ end
33
+
34
+ opt.on("--out-md", TrueClass, "output markdown file, overwrite may happen") do |v|
35
+ args[:outmd] = true
36
+ end
37
+
38
+ opt.separator ""
39
+ opt.separator "Common options:"
40
+ opt.on_tail("-h", "--help", "Show help message") do
41
+ puts opt
42
+ exit
43
+ end
44
+ opt.on_tail("-v", "--version", "Show version") do
45
+ puts "Version #{VERSION}"
46
+ exit
47
+ end
48
+ opt.on_tail("--feature", "Show development feature") do
49
+ FEATURE.each { |x| puts x }
50
+ exit
51
+ end
52
+ end.parse!(options)
53
+
54
+ return args
55
+ end
56
+
57
+ def self.func_set_file(file)
58
+ if File.file?(file)
59
+ return file
60
+ else
61
+ puts "Fatal: < #{file} > is not a file"
62
+ exit
63
+ end
64
+ end
65
+ end
66
+
67
+
68
+ def self.run
69
+ args = Parser.parse(ARGV)
70
+ # make Hash dottable
71
+ args = Struct.new(*args.keys).new(*args.values)
72
+
73
+ if args.kmd
74
+ puts "Note: using input markdown file < #{args.kmd} >"
75
+ # read input markdown
76
+ fmd = File.open(args.kmd).read
77
+ # html conversion
78
+ content = Kramdown::Document.new(fmd).to_html
79
+ fbase = File.basename(args.kmd,".*")
80
+ elsif args.html
81
+ puts "Note: using input html file < #{args.html} >"
82
+ fmd = false
83
+ content = File.open(args.html).read
84
+ fbase = File.basename(args.html,".*")
85
+ else
86
+ puts "Note: using default markdown file < jekyll-markdown.md >"
87
+ fmd = File.open(File.expand_path("../../data/jekyll-markdown.md",__FILE__)).read
88
+ content = Kramdown::Document.new(fmd).to_html
89
+ fbase = 'jekyll-markdown'
90
+ end
91
+
92
+ # output html
93
+ if args.outhtml
94
+ name = fbase + ".html"
95
+ puts "Note: writing < html > to file < #{name} >"
96
+ File.new(name,'w').write(content)
97
+ end
98
+
99
+ # output markdown
100
+ if args.outmd
101
+ if args.html
102
+ name = "jekyll-markdown.md"
103
+ FileUtils.cp(File.expand_path("../../data/jekyll-markdown.md",__FILE__), '.')
104
+ else
105
+ name = fbase + ".md"
106
+ File.new(name,'w').write(fmd)
107
+ end
108
+ puts "Note: writing < markdown > to file < #{name} >"
109
+ end
110
+
111
+ if args.file
112
+ liquid = File.open(args.file).read
113
+ puts Liquid::Template.parse(liquid).render("content" => content)
114
+ end
115
+ end
116
+ end
@@ -0,0 +1,8 @@
1
+ VERSION = '0.2.2'
2
+
3
+ FEATURE = [
4
+ '* Version 0.1.0: Ruby-liquid Debug',
5
+ '* Version 0.2.0: Add Kramdown conversion',
6
+ '* Version 0.2.1: Change args type from Struct to Hash',
7
+ '* Version 0.2.2: Optimize the combination of options',
8
+ ]
metadata ADDED
@@ -0,0 +1,80 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jekyll-liquid-debug
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.2
5
+ platform: ruby
6
+ authors:
7
+ - Xiang Zhong
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-09-30 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: liquid
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 4.0.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 4.0.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: kramdown
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 2.3.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 2.3.0
41
+ description:
42
+ email:
43
+ - zhongxiang117@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - LICENSE
49
+ - bin/console
50
+ - bin/jekyll-liquid-debug
51
+ - bin/setup
52
+ - data/jekyll-markdown.md
53
+ - jekyll-liquid-debug.gemspec
54
+ - lib/jekyll-liquid-debug.rb
55
+ - lib/jekyll-liquid-debug/version.rb
56
+ homepage: https://github.com/zhongxiang117/jekyll-liquid-debug
57
+ licenses:
58
+ - MIT
59
+ metadata: {}
60
+ post_install_message:
61
+ rdoc_options: []
62
+ require_paths:
63
+ - lib
64
+ required_ruby_version: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: 2.5.0
69
+ required_rubygems_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ requirements: []
75
+ rubyforge_project:
76
+ rubygems_version: 2.7.6
77
+ signing_key:
78
+ specification_version: 4
79
+ summary: Light Weight Jekyll Liquid Template Debug Package
80
+ test_files: []