jekyll_from_to_until 1.0.4 → 1.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: df28899e4d0c5ef83e25c224bf13ab963540f5329fdb901e57810fc8959f6c8e
4
- data.tar.gz: 1e6159cef57b71549fb95a94052e46a535d5f9a9d05bc45aa8749102c7af9774
3
+ metadata.gz: 9831e3896befd48a89069726c44c2f1c724c890c4b63fedf398ed54259ecd889
4
+ data.tar.gz: e0401ec8f430b9cfabb6bb13cf3f77d179aadeca1c7ae1c3fc76357c575afdb7
5
5
  SHA512:
6
- metadata.gz: ff87af96660512fa9e48546598ff7a0130db3ff83e8ed4ab6945e5261ddbd88257904a343345ec999f076be98e444a51c6ce78cc0281454fe5eec69f2a40a184
7
- data.tar.gz: 4f44c850b030ee09f151ffa98af5e2442f0285a396f004d38e637b7011c9572d894052e582c70e4bc5627295537665e7d1b6c4f336e61391cbda4642b683e332
6
+ metadata.gz: b4092ea3fa73c237a380573c942be5ae11191af3704f277a3ec51430c0cebbc03a242a47a7d06eb3193cfe3e8167d6279746271b5bf79f358b50a644e5d01d23
7
+ data.tar.gz: 336d908450a37b2239e9ec3f31999b975466769648cc443d4576de8f7e3f89e973d02f3e03442bee571ab7ff560a036d7ffa1532f4442ac70ee8d87803406ac9
data/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # Change Log
2
2
 
3
+ ## 1.0.6 / 2024-12-16
4
+
5
+ * Fixed callability issue
6
+
7
+
8
+ ## 1.0.5 / 2024-08-22
9
+
10
+ * Fixed method forwarding
11
+ * Regexes are now subjected to an HTML unescape, so special characters are now supported,
12
+ such as the right closing squiggly bracket:
13
+
14
+ ```html
15
+ {{ css | from: '.error' | to: '}' | strip }}
16
+ ```
17
+
18
+
3
19
  ## 1.0.4 / 2023-11-18
4
20
 
5
21
  * Now callable from any Ruby program
data/README.md CHANGED
@@ -22,7 +22,7 @@ More information is available on the [`jekyll_from_to_until` gem web page](https
22
22
  ### As a Jekyll Filter Plugin
23
23
 
24
24
  If you want to use this Ruby gem in a Jekyll application,
25
- add the following line to your application's Gemfile:
25
+ add the following line to your application's `Gemfile`:
26
26
 
27
27
  ```ruby
28
28
  group :jekyll_plugins do
@@ -100,7 +100,13 @@ All of these examples perform identically.
100
100
  {{ sourceOfLines | until: regex }}
101
101
  ```
102
102
 
103
- :warning: Important: the name of the filter must be followed by a colon (:). If you fail to do that an error will be generated and the Jekyll site building process will halt. The error message looks something like this: `Liquid Warning: Liquid syntax error (line 285): Expected end_of_string but found string in "{{ lines | from '2' | until: '4' | xml_escape }}" in /some_directory/some_files.html Liquid Exception: Liquid error (line 285): wrong number of arguments (given 1, expected 2) in /some_directory/some_file.html Error: Liquid error (line 285): wrong number of arguments (given 1, expected 2)`
103
+ :warning: Important: the name of the filter must be followed by a colon (:).
104
+ If you fail to do that an error will be generated and the Jekyll site building process will halt.
105
+ The error message looks something like this:
106
+ `Liquid Warning: Liquid syntax error (line 285): Expected end_of_string but found string in
107
+ "{{ lines | from '2' | until: '4' | xml_escape }}" in /some_directory/some_files.html Liquid Exception:
108
+ Liquid error (line 285): wrong number of arguments (given 1, expected 2) in /some_directory/some_file.
109
+ html Error: Liquid error (line 285): wrong number of arguments (given 1, expected 2)`
104
110
 
105
111
 
106
112
  ## Jekyll Usage
@@ -167,7 +173,9 @@ mslinn_aws.tar
167
173
 
168
174
  ### From the third line of string
169
175
 
170
- These examples return the lines of the file from the beginning of the until a line with the string "3" is found, including the matched line. The only difference between the examples is the delimiter around the regular expression.
176
+ These examples return the lines of the file from the beginning of the until a line with the string "3" is found,
177
+ including the matched line.
178
+ The only difference between the examples is the delimiter around the regular expression.
171
179
 
172
180
  ```html
173
181
  {{ lines | from: '3' }}
@@ -204,7 +212,9 @@ mslinn_aws.tar
204
212
 
205
213
  ### To the third line of string
206
214
 
207
- These examples return the lines of the file from the first line until a line with the string `"3"` is found, including the matched line. The only difference between the examples is the delimiter around the regular expression.
215
+ These examples return the lines of the file from the first line until a line with the string `"3"` is found,
216
+ including the matched line.
217
+ The only difference between the examples is the delimiter around the regular expression.
208
218
 
209
219
  ```html
210
220
  {{ lines | to: '3' }}
@@ -245,7 +255,8 @@ target/
245
255
 
246
256
  ### Until the third line of string
247
257
 
248
- These examples return the lines of the file until a line with the string `"3"` is found, excluding the matched line. The only difference between the examples is the delimiter around the regular expression.
258
+ These examples return the lines of the file until a line with the string `"3"` is found, excluding the matched line.
259
+ The only difference between the examples is the delimiter around the regular expression.
249
260
 
250
261
  ```html
251
262
  {{ lines | until: '3' }}
@@ -284,7 +295,8 @@ target/
284
295
 
285
296
  ### From the string "2" until the string "4"
286
297
 
287
- These examples return the lines of the file until a line with the string `"3"` is found, excluding the matched line. The only difference between the examples is the delimiter around the regular expression.
298
+ These examples return the lines of the file until a line with the string `"3"` is found, excluding the matched line.
299
+ The only difference between the examples is the delimiter around the regular expression.
288
300
 
289
301
  ```html
290
302
  {{ lines | from: '2' | until: '4' }}
@@ -302,7 +314,8 @@ line 3
302
314
 
303
315
  ### From Line In a File Containing 'idea' Until no match
304
316
 
305
- The `.gitignore` file does not contain the string `xx`. If we attempt to match against that string the remainder of the file is returned for the to and until filter, and the empty string is returned for the from filter.
317
+ The `.gitignore` file does not contain the string `xx`.
318
+ If we attempt to match against that string the remainder of the file is returned for the to and until filter.
306
319
 
307
320
  ```html
308
321
  {{ gitignore | from: 'PID' | until: 'xx' }}
@@ -338,6 +351,18 @@ mslinn_aws.tar
338
351
  ```
339
352
 
340
353
 
354
+ ### Encoding Special Characters
355
+
356
+ Special characters can be specified as HTML entities.
357
+ For example, `}` is `Open parenthesis. Belle par. A parent. 5 Resulting. OK. OK, so now what }`.
358
+
359
+ ```html
360
+ {{ css | from: '.error' | to: '}' | strip }}
361
+ ```
362
+
363
+ `demo/special.html` demonstrates this.
364
+
365
+
341
366
  ## Development
342
367
 
343
368
  After checking out the repo, run `bin/setup` to install dependencies.
@@ -349,7 +374,7 @@ You can also run `bin/console` for an interactive prompt that will allow you to
349
374
 
350
375
  To build and install this gem onto your local machine, run:
351
376
 
352
- ```shell
377
+ ```shellSoap. XboxXboxOur cub Our company outcome.XboxParent
353
378
  $ bundle exec rake install
354
379
  ```
355
380
 
@@ -32,6 +32,7 @@ Gem::Specification.new do |spec|
32
32
  spec.test_files = spec.files.grep(%r!^(test|spec|features)/!)
33
33
  spec.version = JekyllFromToUntilVersion::VERSION
34
34
 
35
+ spec.add_dependency 'htmlentities'
35
36
  spec.add_dependency 'jekyll', '>= 3.5.0'
36
37
  spec.add_dependency 'jekyll_plugin_logger'
37
38
  end
@@ -1,3 +1,3 @@
1
1
  module JekyllFromToUntilVersion
2
- VERSION = '1.0.4'.freeze
2
+ VERSION = '1.0.6'.freeze
3
3
  end
@@ -1,5 +1,6 @@
1
1
  # Jekyll filters for working with multiline strings.
2
2
 
3
+ require 'htmlentities'
3
4
  require_relative 'jekyll_from_to_until/version'
4
5
 
5
6
  module JekyllPluginFromToUntilName
@@ -96,7 +97,42 @@ module FromToUntil
96
97
  module_function :from, :to, :until, :check_parameters, :remove_quotations
97
98
  end
98
99
 
100
+ # See https://www.mslinn.com/jekyll/10400-jekyll-plugin-template-collection.html#module_function
101
+ module FromToUntilFilter
102
+ def from(input_strings, regex)
103
+ input_strings = extra_decode HTMLEntities.new.decode input_strings
104
+ regex = extra_decode HTMLEntities.new.decode regex
105
+ FromToUntil.from(input_strings, regex) # method forwarding
106
+ end
107
+
108
+ def to(input_strings, regex)
109
+ input_strings = extra_decode HTMLEntities.new.decode input_strings
110
+ regex = extra_decode HTMLEntities.new.decode regex
111
+ FromToUntil.to(input_strings, regex) # method forwarding
112
+ end
113
+
114
+ def until(input_strings, regex)
115
+ input_strings = extra_decode HTMLEntities.new.decode input_strings
116
+ regex = extra_decode HTMLEntities.new.decode regex
117
+ FromToUntil.until(input_strings, regex) # method forwarding
118
+ end
119
+
120
+ # HTMLEntities does not support enough HTML entities
121
+ def extra_decode(line)
122
+ line.gsub('{', '{')
123
+ .gsub('}', '}')
124
+ .gsub('(', '(')
125
+ .gsub(')', ')')
126
+ .gsub('&lparen;', '(')
127
+ .gsub('&rparen;', ')')
128
+ .gsub('[', '[')
129
+ .gsub(']', ']')
130
+ .gsub('[', '[')
131
+ .gsub(']', ']')
132
+ end
133
+ end
134
+
99
135
  if CALLED_FROM_JEKYLL
100
136
  PluginMetaLogger.instance.info { "Loaded #{JekyllPluginFromToUntilName::PLUGIN_NAME} v#{JekyllFromToUntilVersion::VERSION} plugin." }
101
- Liquid::Template.register_filter(FromToUntil)
137
+ Liquid::Template.register_filter(FromToUntilFilter)
102
138
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll_from_to_until
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Slinn
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-11-22 00:00:00.000000000 Z
11
+ date: 2024-12-16 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: htmlentities
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: jekyll
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -69,7 +83,7 @@ metadata:
69
83
  source_code_uri: https://github.com/mslinn/jekyll_from_to_until
70
84
  post_install_message: |2+
71
85
 
72
- Thanks for installing jekyll_from_to_until v1.0.4!
86
+ Thanks for installing jekyll_from_to_until v1.0.6!
73
87
 
74
88
  rdoc_options: []
75
89
  require_paths:
@@ -85,7 +99,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
85
99
  - !ruby/object:Gem::Version
86
100
  version: '0'
87
101
  requirements: []
88
- rubygems_version: 3.3.7
102
+ rubygems_version: 3.5.23
89
103
  signing_key:
90
104
  specification_version: 4
91
105
  summary: 'This Jekyll plugin provides 3 filters that return portions of a multiline