jekyll_flexible_include 2.0.11 → 2.0.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/README.md +1 -0
- data/jekyll_flexible_include_plugin.gemspec +3 -2
- data/lib/flexible_include/version.rb +1 -1
- data/lib/flexible_include.rb +27 -2
- data/lib/jekyll_tag_helper.rb +6 -2
- metadata +8 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 235134772b0ff492ec61e24e71a8094977ae43e740c338dabfd65e92cd8ac416
|
4
|
+
data.tar.gz: c89b5985bde7ec87ef12870cf27369d1f2c6194de9ef8459064675f13402d87f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '094fae8fef148dd4801710911d8d0bde33e45a3ef0c7b5f5417e0a5baea1cc8d24d975d3b9e02e76ed96fca375651bd06074bf5a21a72ca1ee3343f960ab9aec'
|
7
|
+
data.tar.gz: 810afd58a9df5f7d7d88f97de0bbbb5547cbe400d0a09a25dff8ada24bdc4ad313cb0a535571388d6990edc125e3fca9d07c3a71bf33f0868a057cc451f47bc6
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
## 2.0.14 / 2022-09-27
|
2
|
+
* Added `key-value-parser` as a dependency
|
3
|
+
|
4
|
+
## 2.0.13 / 2022-04-24
|
5
|
+
* Added `highlight` regex option, for highlighting
|
6
|
+
* Added `number` option, for numbered lines
|
7
|
+
|
8
|
+
## 2.0.12 / 2022-04-22
|
9
|
+
* Exits with an error message if an environment variable included in the value of `FLEXIBLE_INCLUDE_PATHS` is undefined.
|
10
|
+
|
1
11
|
## 2.0.11 / 2022-04-15
|
2
12
|
* Added & => & to the escaped characters
|
3
13
|
|
data/README.md
CHANGED
@@ -37,6 +37,7 @@ Note that the [square brackets] merely indicate optional parameters and are not
|
|
37
37
|
|
38
38
|
### Options
|
39
39
|
* `do_not_escape` includes the content without HTML escaping it.
|
40
|
+
* `highlight='regex pattern here'` wraps content matching the regex pattern within a `<span class='bg_yellow'></span>` tag.
|
40
41
|
* `pre` causes the included file to be wrapped inside a <pre></pre> tag, no label is generated. The <pre></pre> tag has an `data-lt-active="false"` attribute, so [LanguageTool](https://forum.languagetool.org/t/avoid-spell-check-on-certain-html-inputs-manually/3944) does not check the spelling or grammar of the contents.
|
41
42
|
|
42
43
|
The following options imply `pre`:
|
@@ -39,10 +39,11 @@ Gem::Specification.new do |spec|
|
|
39
39
|
|
40
40
|
spec.add_dependency "jekyll", ">= 3.5.0"
|
41
41
|
spec.add_dependency "jekyll_plugin_logger", '~> 2.1.0'
|
42
|
+
spec.add_dependency "key-value-parser"
|
42
43
|
|
43
|
-
spec.add_development_dependency "debase"
|
44
|
+
# spec.add_development_dependency "debase"
|
44
45
|
# spec.add_development_dependency "rubocop-jekyll"
|
45
46
|
# spec.add_development_dependency "rubocop-rake"
|
46
47
|
# spec.add_development_dependency "rubocop-rspec"
|
47
|
-
spec.add_development_dependency "ruby-debug-ide"
|
48
|
+
# spec.add_development_dependency "ruby-debug-ide"
|
48
49
|
end
|
data/lib/flexible_include.rb
CHANGED
@@ -11,13 +11,16 @@ module JekyllFlexibleIncludeName
|
|
11
11
|
PLUGIN_NAME = "flexible_include"
|
12
12
|
end
|
13
13
|
|
14
|
+
class FlexibleError < StandardError
|
15
|
+
end
|
16
|
+
|
14
17
|
class FlexibleInclude < Liquid::Tag
|
15
18
|
FlexibleIncludeError = Class.new(Liquid::Error)
|
16
19
|
|
17
20
|
@read_regexes = nil
|
18
21
|
|
19
22
|
def self.normalize_path(path)
|
20
|
-
JekyllTagHelper.expand_env(path)
|
23
|
+
JekyllTagHelper.expand_env(path, die_if_undefined: true)
|
21
24
|
.gsub("~", Dir.home)
|
22
25
|
end
|
23
26
|
|
@@ -44,6 +47,20 @@ class FlexibleInclude < Liquid::Tag
|
|
44
47
|
@read_regexes.find { |regex| regex.match(normalize_path(path)) }
|
45
48
|
end
|
46
49
|
|
50
|
+
def self.number_content(content)
|
51
|
+
lines = content.split("\n")
|
52
|
+
digits = lines.length.to_s.length
|
53
|
+
i = 0
|
54
|
+
numbered_content = lines.map do |line|
|
55
|
+
i += 1
|
56
|
+
number = i.to_s.rjust(digits, " ")
|
57
|
+
"<span class='unselectable numbered_line'> #{number}: </span>#{line}"
|
58
|
+
end
|
59
|
+
result = numbered_content.join("\n")
|
60
|
+
result += "\n" unless result.end_with?("\n")
|
61
|
+
result
|
62
|
+
end
|
63
|
+
|
47
64
|
# @param tag_name [String] the name of the tag, which we already know.
|
48
65
|
# @param markup [String] the arguments from the tag, as a single string.
|
49
66
|
# @param parse_context [Liquid::ParseContext] hash that stores Liquid options.
|
@@ -65,10 +82,12 @@ class FlexibleInclude < Liquid::Tag
|
|
65
82
|
@do_not_escape = @helper.parameter_specified? "do_not_escape"
|
66
83
|
@download = @helper.parameter_specified? "download"
|
67
84
|
@dark = " dark" if @helper.parameter_specified?("dark")
|
85
|
+
@highlight_pattern = @helper.parameter_specified? "highlight"
|
68
86
|
@label = @helper.parameter_specified? "label"
|
87
|
+
@number_lines = @helper.parameter_specified? "number"
|
69
88
|
@label_specified = @label
|
70
89
|
@copy_button = @helper.parameter_specified? "copyButton"
|
71
|
-
@pre = @copy_button || @dark || @download || @label_specified || @helper.parameter_specified?("pre") # Download or label implies pre
|
90
|
+
@pre = @copy_button || @dark || @download || @label_specified || @number_lines || @helper.parameter_specified?("pre") # Download or label implies pre
|
72
91
|
|
73
92
|
filename = @helper.parameter_specified? "file"
|
74
93
|
filename ||= @helper.params.first # Do this after all options have been checked for
|
@@ -117,6 +136,10 @@ class FlexibleInclude < Liquid::Tag
|
|
117
136
|
"<p style='color: white; background-color: red; padding: 2pt 1em 2pt 1em;'>#{msg}</p>"
|
118
137
|
end
|
119
138
|
|
139
|
+
def highlight(content, pattern)
|
140
|
+
content.gsub(Regexp::new(pattern), "<span class='bg_yellow'>\\0</span>")
|
141
|
+
end
|
142
|
+
|
120
143
|
def read_file(file)
|
121
144
|
File.read(file)
|
122
145
|
end
|
@@ -130,6 +153,8 @@ class FlexibleInclude < Liquid::Tag
|
|
130
153
|
def render_completion(path, contents)
|
131
154
|
contents ||= read_file(path)
|
132
155
|
contents2 = @do_not_escape ? contents : JekyllTagHelper.escape_html(contents)
|
156
|
+
contents2 = highlight(contents2, @highlight_pattern) if @highlight_pattern
|
157
|
+
contents2 = FlexibleInclude.number_content(contents2) if @number_lines
|
133
158
|
@pre ? wrap_in_pre(path, contents2) : contents2
|
134
159
|
end
|
135
160
|
|
data/lib/jekyll_tag_helper.rb
CHANGED
@@ -14,8 +14,12 @@ class JekyllTagHelper
|
|
14
14
|
end
|
15
15
|
|
16
16
|
# Expand a environment variable reference
|
17
|
-
def self.expand_env(str)
|
18
|
-
str.gsub(/\$([a-zA-Z_][a-zA-Z0-9_]*)|\${\g<1>}|%\g<1>%/)
|
17
|
+
def self.expand_env(str, die_if_undefined=false)
|
18
|
+
str.gsub(/\$([a-zA-Z_][a-zA-Z0-9_]*)|\${\g<1>}|%\g<1>%/) do
|
19
|
+
envar = Regexp.last_match(1)
|
20
|
+
raise FlexibleError, "flexible_include error: #{envar} is undefined".red, [] if !ENV.key?(envar) && die_if_undefined # Suppress stack trace
|
21
|
+
ENV[envar]
|
22
|
+
end
|
19
23
|
end
|
20
24
|
|
21
25
|
# strip leading and trailing quotes if present
|
metadata
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll_flexible_include
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Slinn
|
8
8
|
- Tan Nhu
|
9
9
|
- Maarten Brakkee
|
10
|
-
autorequire:
|
10
|
+
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date: 2022-
|
13
|
+
date: 2022-09-27 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: jekyll
|
@@ -41,27 +41,13 @@ dependencies:
|
|
41
41
|
- !ruby/object:Gem::Version
|
42
42
|
version: 2.1.0
|
43
43
|
- !ruby/object:Gem::Dependency
|
44
|
-
name:
|
44
|
+
name: key-value-parser
|
45
45
|
requirement: !ruby/object:Gem::Requirement
|
46
46
|
requirements:
|
47
47
|
- - ">="
|
48
48
|
- !ruby/object:Gem::Version
|
49
49
|
version: '0'
|
50
|
-
type: :
|
51
|
-
prerelease: false
|
52
|
-
version_requirements: !ruby/object:Gem::Requirement
|
53
|
-
requirements:
|
54
|
-
- - ">="
|
55
|
-
- !ruby/object:Gem::Version
|
56
|
-
version: '0'
|
57
|
-
- !ruby/object:Gem::Dependency
|
58
|
-
name: ruby-debug-ide
|
59
|
-
requirement: !ruby/object:Gem::Requirement
|
60
|
-
requirements:
|
61
|
-
- - ">="
|
62
|
-
- !ruby/object:Gem::Version
|
63
|
-
version: '0'
|
64
|
-
type: :development
|
50
|
+
type: :runtime
|
65
51
|
prerelease: false
|
66
52
|
version_requirements: !ruby/object:Gem::Requirement
|
67
53
|
requirements:
|
@@ -118,8 +104,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
118
104
|
- !ruby/object:Gem::Version
|
119
105
|
version: '0'
|
120
106
|
requirements: []
|
121
|
-
rubygems_version: 3.
|
122
|
-
signing_key:
|
107
|
+
rubygems_version: 3.3.3
|
108
|
+
signing_key:
|
123
109
|
specification_version: 4
|
124
110
|
summary: Jekyll plugin supports various ways to include content into the generated
|
125
111
|
site.
|
@@ -127,3 +113,4 @@ test_files:
|
|
127
113
|
- spec/glob_spec.rb
|
128
114
|
- spec/spec_helper.rb
|
129
115
|
- spec/status_persistence.txt
|
116
|
+
...
|