jekyll_outline 1.2.3 → 1.2.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b279fb946cc9cd5d5fc092680a1f28c2af772dc2daa319a4d3c82f4946d5c731
4
- data.tar.gz: 0e1f714175edd37e7b06f07f499891d365dbb2ed01d2fe90923a54d6cac613b2
3
+ metadata.gz: 296c5201e11daec7ec2e91ae703662ba44cfb7ca592da27adf61c23943a3c100
4
+ data.tar.gz: 246e14ecb99ecf5a7510e7bcbd40eb5cfa58eb8e3cd740f33a726bc7b42cda78
5
5
  SHA512:
6
- metadata.gz: 4811c7012c0ab9fc504906886a29b4e27d83073f2a079d1cc7e1c9dcdec25acc14da1559e0b940556ba994e2edba45cfb510866c205829d92085a5fd936a02e2
7
- data.tar.gz: b79734ebe03d8facc9034e6be26bacf038609f74b9cfca6611297f16f90891f8c12dc9a88c3b6e82d00d8656f4ba24dd33ec2d46ccefa5173fa05f750b061948
6
+ metadata.gz: a3667c2afb14fb58fb6192149d51265ea54cbb745968ce0a04ba208bbf7a1cf807994a2f2057d38a57759d5679a89ac2a69cd52f829b1e61034c7daea158d02f
7
+ data.tar.gz: 04e34bcdd95b84affb8b9a73e7a638c9013bc978ba393d11591772a132e4191237c168374fc6d203ce51525945a76350c2f79e6b31f140723f988296678c2585
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Change Log
2
2
 
3
+ ## 1.2.4 / 2024-07-23
4
+
5
+ * Updated dependencies to rely on current `jekyll_draft`.
6
+ * Removes any leading whitespace in plugin content so the YAML is more likely to be well-formed.
7
+ * Handles poorly formed whitespace gracefully.
8
+
9
+
3
10
  ## 1.2.3 / 2024-07-23
4
11
 
5
12
  * Made compatible with jekyll_plugin_support v1.0.0
@@ -35,6 +35,6 @@ Gem::Specification.new do |spec|
35
35
  spec.version = JekyllOutlineVersion::VERSION
36
36
 
37
37
  spec.add_dependency 'jekyll', '>= 3.5.0'
38
- spec.add_dependency 'jekyll_draft', '>= 1.1.2'
38
+ spec.add_dependency 'jekyll_draft', '>= 2.0.2'
39
39
  spec.add_dependency 'jekyll_plugin_support', '>= 1.0.0'
40
40
  end
@@ -1,3 +1,3 @@
1
1
  module JekyllOutlineVersion
2
- VERSION = '1.2.3'.freeze
2
+ VERSION = '1.2.4'.freeze
3
3
  end
@@ -1,7 +1,2 @@
1
1
  require_relative 'outline_js'
2
2
  require_relative 'outline_tag'
3
-
4
- module Outline
5
- include OutlineTag
6
- include OutlineJsTag
7
- end
data/lib/outline_js.rb CHANGED
@@ -1,10 +1,10 @@
1
1
  require 'jekyll_plugin_support'
2
2
  require_relative 'jekyll_outline/version'
3
3
 
4
- module OutlineJsTag
4
+ module JekyllSupport
5
5
  PLUGIN_JS_NAME = 'outline_js'.freeze
6
6
 
7
- class OutlineJsTag < JekyllSupport::JekyllTag
7
+ class OutlineJsTag < JekyllTag
8
8
  include JekyllOutlineVersion
9
9
 
10
10
  def render_impl
@@ -35,6 +35,6 @@ module OutlineJsTag
35
35
  .join("\n")
36
36
  end
37
37
 
38
- ::JekyllSupport::JekyllPluginHelper.register(self, PLUGIN_JS_NAME)
38
+ JekyllPluginHelper.register(self, PLUGIN_JS_NAME)
39
39
  end
40
40
  end
data/lib/outline_tag.rb CHANGED
@@ -33,8 +33,9 @@ require_relative 'jekyll_outline/version'
33
33
  #
34
34
  # Subclasses, such as jekyll_toc.rb, might generate other output.
35
35
 
36
- module OutlineTag
36
+ module JekyllSupport
37
37
  PLUGIN_NAME = 'outline'.freeze
38
+ OutlineError = JekyllSupport.define_error
38
39
 
39
40
  # Interleaves with docs
40
41
  # Duck type compatible with Jekyll doc
@@ -52,7 +53,7 @@ module OutlineTag
52
53
  end
53
54
  end
54
55
 
55
- class OutlineTag < JekyllSupport::JekyllBlock # rubocop:disable Metrics/ClassLength
56
+ class OutlineTag < JekyllBlock # rubocop:disable Metrics/ClassLength
56
57
  include JekyllOutlineVersion
57
58
 
58
59
  FIXNUM_MAX = (2**((0.size * 8) - 2)) - 1
@@ -64,7 +65,7 @@ module OutlineTag
64
65
  @fields = @helper.parameter_specified?('fields')&.split || ['title']
65
66
  @sort_by = @helper.parameter_specified?('sort_by_title') ? 'title' : 'order'
66
67
  @collection_name = @helper.remaining_markup
67
- abort 'OutlineTag: collection_name was not specified' unless @collection_name
68
+ raise OutlineError, 'collection_name was not specified' unless @collection_name
68
69
 
69
70
  @docs = obtain_docs(@collection_name)
70
71
  collection = headers + @docs
@@ -90,12 +91,19 @@ module OutlineTag
90
91
  end
91
92
 
92
93
  def make_headers(content)
93
- yaml = YAML.safe_load(remove_leading_zeros(content))
94
+ content = remove_leading_zeros remove_leading_spaces content
95
+ yaml = YAML.safe_load content
94
96
  yaml.map { |entry| Header.new entry }
97
+ rescue NoMethodError => e
98
+ raise OutlineError, "Invalid YAML within {% outline %} tag;<br>\nNoMethodError #{e.message}"
99
+ rescue Psych::SyntaxError => e
100
+ raise OutlineError, "Invalid YAML within {% outline %} tag;<br>\nPsych::SyntaxError #{e.message}"
101
+ rescue StandardError => e
102
+ raise OutlineError, e.message
95
103
  end
96
104
 
97
105
  # @section_state can have values: :head, :in_body
98
- # @param collection Array of Jekyll::Document and Outline::Header
106
+ # @param collection Array of Jekyll::Document and JekyllSupport::Header
99
107
  # @return Array of String
100
108
  def make_entries(collection)
101
109
  sorted = if @sort_by == 'order'
@@ -210,6 +218,14 @@ module OutlineTag
210
218
  array
211
219
  end
212
220
 
221
+ def remove_leading_spaces(multiline)
222
+ multiline
223
+ .strip
224
+ .split("\n")
225
+ .map { |x| x.gsub(/\A\s+/, '') }
226
+ .join("\n")
227
+ end
228
+
213
229
  def remove_leading_zeros(multiline)
214
230
  multiline
215
231
  .strip
@@ -218,6 +234,6 @@ module OutlineTag
218
234
  .join("\n")
219
235
  end
220
236
 
221
- ::JekyllSupport::JekyllPluginHelper.register(self, PLUGIN_NAME)
237
+ JekyllPluginHelper.register(self, PLUGIN_NAME)
222
238
  end
223
239
  end
data/spec/outline_spec.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require 'jekyll'
2
2
  require_relative '../lib/jekyll_outline'
3
3
 
4
- RSpec.describe(Outline) do
4
+ RSpec.describe(OutlineTag) do
5
5
  include Jekyll
6
6
 
7
7
  it 'never works first time', skip: 'Just a placeholder' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll_outline
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.3
4
+ version: 1.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Slinn
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-07-26 00:00:00.000000000 Z
11
+ date: 2024-07-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 1.1.2
33
+ version: 2.0.2
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: 1.1.2
40
+ version: 2.0.2
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: jekyll_plugin_support
43
43
  requirement: !ruby/object:Gem::Requirement