jekyll_outline 1.2.3 → 1.2.5

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: a31ba9e3b1f1b0962f5ac28695f41b2594acde555195fdcbbf0460fa220be66e
4
+ data.tar.gz: bdd1e6536607a24271019aa3cc24e5de35e71b1ac4c61b925f286bb41dd5521c
5
5
  SHA512:
6
- metadata.gz: 4811c7012c0ab9fc504906886a29b4e27d83073f2a079d1cc7e1c9dcdec25acc14da1559e0b940556ba994e2edba45cfb510866c205829d92085a5fd936a02e2
7
- data.tar.gz: b79734ebe03d8facc9034e6be26bacf038609f74b9cfca6611297f16f90891f8c12dc9a88c3b6e82d00d8656f4ba24dd33ec2d46ccefa5173fa05f750b061948
6
+ metadata.gz: e815455631865429afb66cfffce54187e4696e0ecb7e3571050ab98fa6991bd679791a212cdc9915b4e9a9d0c199bf6af0ca9d77a09babe89d7d5fa83a88fa4d
7
+ data.tar.gz: bcc3910b01ca8d3c99ed101764350f17c95826f3b375733215f35659a6027605452881b528197709d1143b576c7c52cf2b51aad3971c1781b03b97c414f8d1dc
data/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Change Log
2
2
 
3
+ ## 1.2.5 / 2024-08-20
4
+
5
+ * Added configurable error handling
6
+ * Updated to jekyll_plugin_support v1.0.2
7
+ * Defined `outline_error` CSS class in `demo/assets/css/jekyll_outline.css`.
8
+
9
+
10
+ ## 1.2.4 / 2024-07-23
11
+
12
+ * Updated dependencies to rely on current `jekyll_draft`.
13
+ * Removes any leading whitespace in plugin content so the YAML is more likely to be well-formed.
14
+ * Handles poorly formed whitespace gracefully.
15
+
16
+
3
17
  ## 1.2.3 / 2024-07-23
4
18
 
5
19
  * 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'
39
- spec.add_dependency 'jekyll_plugin_support', '>= 1.0.0'
38
+ spec.add_dependency 'jekyll_draft', '>= 2.0.2'
39
+ spec.add_dependency 'jekyll_plugin_support', '>= 1.0.2'
40
40
  end
@@ -1,3 +1,3 @@
1
1
  module JekyllOutlineVersion
2
- VERSION = '1.2.3'.freeze
2
+ VERSION = '1.2.5'.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
@@ -61,14 +62,24 @@ module OutlineTag
61
62
  headers = make_headers(super) # Process the block content.
62
63
 
63
64
  @helper.gem_file __FILE__
65
+
66
+ @die_on_outline_error = @tag_config['die_on_outline_error'] == true if @tag_config
67
+ @pry_on_outline_error = @tag_config['pry_on_outline_error'] == true if @tag_config
68
+
64
69
  @fields = @helper.parameter_specified?('fields')&.split || ['title']
65
70
  @sort_by = @helper.parameter_specified?('sort_by_title') ? 'title' : 'order'
66
71
  @collection_name = @helper.remaining_markup
67
- abort 'OutlineTag: collection_name was not specified' unless @collection_name
72
+ raise OutlineError, 'collection_name was not specified' unless @collection_name
68
73
 
69
74
  @docs = obtain_docs(@collection_name)
70
75
  collection = headers + @docs
71
76
  render_outline collection
77
+ rescue OutlineError => e # jekyll_plugin_support handles StandardError
78
+ @logger.error { JekyllPluginHelper.remove_html_tags e.logger_message }
79
+ binding.pry if @pry_on_outline_error # rubocop:disable Lint/Debugger
80
+ exit! 1 if @die_on_outline_error
81
+
82
+ e.html_message
72
83
  end
73
84
 
74
85
  # Overload this for a subclass
@@ -90,12 +101,26 @@ module OutlineTag
90
101
  end
91
102
 
92
103
  def make_headers(content)
93
- yaml = YAML.safe_load(remove_leading_zeros(content))
104
+ content = remove_leading_zeros remove_leading_spaces content
105
+ yaml = YAML.safe_load content
94
106
  yaml.map { |entry| Header.new entry }
107
+ rescue NoMethodError => e
108
+ raise OutlineError, <<~END_MSG
109
+ Invalid YAML within {% outline %} tag. The offending content was:
110
+
111
+ <pre>#{content}</pre>
112
+ END_MSG
113
+ rescue Psych::SyntaxError => e
114
+ msg = <<~END_MSG
115
+ Invalid YAML found within {% outline %} tag:<br>
116
+ <pre>#{e.message}</pre>
117
+ END_MSG
118
+ @logger.error { e.message }
119
+ raise OutlineError, msg
95
120
  end
96
121
 
97
122
  # @section_state can have values: :head, :in_body
98
- # @param collection Array of Jekyll::Document and Outline::Header
123
+ # @param collection Array of Jekyll::Document and JekyllSupport::Header
99
124
  # @return Array of String
100
125
  def make_entries(collection)
101
126
  sorted = if @sort_by == 'order'
@@ -210,6 +235,14 @@ module OutlineTag
210
235
  array
211
236
  end
212
237
 
238
+ def remove_leading_spaces(multiline)
239
+ multiline
240
+ .strip
241
+ .split("\n")
242
+ .map { |x| x.gsub(/\A\s+/, '') }
243
+ .join("\n")
244
+ end
245
+
213
246
  def remove_leading_zeros(multiline)
214
247
  multiline
215
248
  .strip
@@ -218,6 +251,6 @@ module OutlineTag
218
251
  .join("\n")
219
252
  end
220
253
 
221
- ::JekyllSupport::JekyllPluginHelper.register(self, PLUGIN_NAME)
254
+ JekyllPluginHelper.register(self, PLUGIN_NAME)
222
255
  end
223
256
  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.5
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-08-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -30,28 +30,28 @@ 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
44
44
  requirements:
45
45
  - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: 1.0.0
47
+ version: 1.0.2
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: 1.0.0
54
+ version: 1.0.2
55
55
  description: 'Jekyll tag plugin that creates a clickable table of contents.
56
56
 
57
57
  '
@@ -102,7 +102,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
102
102
  - !ruby/object:Gem::Version
103
103
  version: '0'
104
104
  requirements: []
105
- rubygems_version: 3.5.16
105
+ rubygems_version: 3.5.17
106
106
  signing_key:
107
107
  specification_version: 4
108
108
  summary: Jekyll tag plugin that creates a clickable table of contents.