giblish 0.7.6 → 0.8.0

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.
@@ -5,22 +5,21 @@ require "asciidoctor-pdf"
5
5
  require_relative "utils"
6
6
 
7
7
  module Giblish
8
-
9
8
  # Base class for document converters. It contains a hash of
10
9
  # conversion options used by derived classes
11
10
  class DocConverter
12
11
  # a common set of converter options used for all output formats
13
12
  COMMON_CONVERTER_OPTS = {
14
- safe: Asciidoctor::SafeMode::UNSAFE,
15
- header_footer: true,
16
- mkdirs: true
13
+ safe: Asciidoctor::SafeMode::UNSAFE,
14
+ header_footer: true,
15
+ mkdirs: true
17
16
  }.freeze
18
17
 
19
18
  # the giblish attribute defaults used if nothing else
20
19
  # is required by the user
21
20
  DEFAULT_ATTRIBUTES = {
22
- "source-highlighter" => "rouge",
23
- "xrefstyle" => "short"
21
+ "source-highlighter" => "rouge",
22
+ "xrefstyle" => "short"
24
23
  }.freeze
25
24
 
26
25
  # setup common options that are used regardless of the
@@ -54,27 +53,26 @@ module Giblish
54
53
  #
55
54
  # Returns: The resulting Asciidoctor::Document object
56
55
  def convert(filepath, logger: nil)
57
- unless filepath.is_a?(Pathname)
58
- raise ArgumentError, "Trying to invoke convert with non-pathname!"
59
- end
56
+ raise ArgumentError, "Trying to invoke convert with non-pathname!" unless filepath.is_a?(Pathname)
60
57
 
61
- Giblog.logger.info {"Processing: #{filepath}"}
58
+ Giblog.logger.info { "Processing: #{filepath}" }
62
59
 
63
60
  # update the relevant options for each specific document
64
- set_common_doc_specific_options(filepath,logger)
61
+ set_common_doc_specific_options(filepath, logger)
65
62
 
66
63
  # give derived classes the opportunity to set doc specific attributes
67
- add_doc_specific_attributes(filepath,true, @converter_options[:attributes])
64
+ add_doc_specific_attributes(filepath, true, @converter_options[:attributes])
68
65
 
69
- Giblog.logger.debug {"converter_options: #{@converter_options}"}
66
+ Giblog.logger.debug { "converter_options: #{@converter_options}" }
70
67
 
71
68
  # do the actual conversion
72
69
  doc = Asciidoctor.convert_file filepath, @converter_options
73
70
 
74
71
  # bail out if asciidoctor failed to convert the doc
75
- if logger && logger.max_severity && logger.max_severity > Logger::Severity::WARN
76
- raise RuntimeError, "Failed to convert the file #{filepath}"
72
+ if logger&.max_severity && logger.max_severity > Logger::Severity::WARN
73
+ raise "Failed to convert the file #{filepath}"
77
74
  end
75
+
78
76
  doc
79
77
  end
80
78
 
@@ -86,8 +84,7 @@ module Giblish
86
84
  # to disk.
87
85
  # Returns: whether any errors occured during conversion (true) or
88
86
  # not (false).
89
- def convert_str(src_str, dst_dir, basename,logger: nil)
90
-
87
+ def convert_str(src_str, dst_dir, basename, logger: nil)
91
88
  index_opts = @converter_options.dup
92
89
 
93
90
  # use the same options as when converting all docs
@@ -96,15 +93,13 @@ module Giblish
96
93
  # necessary to change
97
94
  index_opts[:to_dir] = dst_dir.to_s
98
95
  index_opts[:base_dir] = dst_dir.to_s
99
- index_opts.delete_if {|k, _v| %i[to_file].include? k}
96
+ index_opts.delete_if { |k, _v| %i[to_file].include? k }
100
97
 
101
98
  # give derived classes the opportunity to set doc specific attributes
102
99
  index_filepath = dst_dir + "#{basename}.#{index_opts[:fileext]}"
103
- add_doc_specific_attributes(index_filepath,false, index_opts[:attributes])
100
+ add_doc_specific_attributes(index_filepath, false, index_opts[:attributes])
104
101
 
105
102
  # load and convert the document using the converter options
106
- doc = nil, output = nil
107
-
108
103
  begin
109
104
  conv_error = false
110
105
  # set a specific logger instance to-be-used by asciidoctor
@@ -112,14 +107,16 @@ module Giblish
112
107
  doc = Asciidoctor.load src_str, index_opts
113
108
  output = doc.convert index_opts
114
109
 
115
- if logger && logger.max_severity && logger.max_severity > Logger::Severity::WARN
116
- raise RuntimeError, "Failed to convert string to asciidoc!! Will _not_ generate #{index_filepath.to_s}"
110
+ if logger&.max_severity && logger.max_severity > Logger::Severity::WARN
111
+ raise "Failed to convert string to asciidoc!! "\
112
+ "Will _not_ generate #{index_filepath}"
117
113
  end
118
114
 
119
115
  # write the converted document to an index file located at the
120
116
  # destination root
121
117
  doc.write output, index_filepath.to_s
122
- rescue Exception => e
118
+ rescue StandardError => e
119
+ puts e.backtrace
123
120
  Giblog.logger.error(e)
124
121
  conv_error = true
125
122
  end
@@ -148,21 +145,19 @@ module Giblish
148
145
 
149
146
  # Hook for specific converters to inject attributes on a per-doc
150
147
  # basis
151
- def add_doc_specific_attributes(filepath, is_src, attributes)
152
-
153
- end
148
+ def add_doc_specific_attributes(filepath, is_src, attributes); end
154
149
 
155
150
  private
156
151
 
157
- def set_common_doc_specific_options(src_filepath,logger)
152
+ def set_common_doc_specific_options(src_filepath, logger)
158
153
  # create an asciidoc doc object and convert to requested
159
154
  # output using current conversion options
160
155
  @converter_options[:to_dir] = @paths.adoc_output_dir(src_filepath).to_s
161
156
  @converter_options[:base_dir] =
162
- Giblish::PathManager.closest_dir(src_filepath).to_s
157
+ Giblish::PathManager.closest_dir(src_filepath).to_s
163
158
  @converter_options[:to_file] =
164
- Giblish::PathManager.get_new_basename(src_filepath,
165
- @converter_options[:fileext])
159
+ Giblish::PathManager.get_new_basename(src_filepath,
160
+ @converter_options[:fileext])
166
161
  @converter_options[:logger] = logger unless logger.nil?
167
162
  end
168
163
  end
@@ -178,9 +173,9 @@ module Giblish
178
173
  validate_and_copy_resources @dst_asset_dir
179
174
 
180
175
  # identify ourselves as an html converter
181
- add_backend_options({backend: "html5", fileext: "html"})
176
+ add_backend_options({ backend: "html5", fileext: "html" })
182
177
  # setup the attributes specific for this converter
183
- add_backend_attributes(get_common_attributes)
178
+ add_backend_attributes(common_attributes)
184
179
  end
185
180
 
186
181
  protected
@@ -190,11 +185,11 @@ module Giblish
190
185
  if @paths.resource_dir_abs
191
186
  # user has given a resource dir, use the css from that dir
192
187
  doc_attrib.merge!(
193
- {
194
- "linkcss" => 1,
195
- "stylesheet" => @user_style ||= "giblish.css",
196
- "copycss!" => 1
197
- }
188
+ {
189
+ "linkcss" => 1,
190
+ "stylesheet" => @user_style ||= "giblish.css",
191
+ "copycss!" => 1
192
+ }
198
193
  )
199
194
  if @deployment_info.web_path.nil?
200
195
  # user wants to deploy without web server, the css
@@ -204,8 +199,8 @@ module Giblish
204
199
  css_rel_dir = if is_src_file
205
200
  # the filepath is a src path
206
201
  @paths.relpath_to_dir_after_generate(
207
- filepath,
208
- dst_css_dir
202
+ filepath,
203
+ dst_css_dir
209
204
  )
210
205
  else
211
206
  # the given file path is the destination path of
@@ -221,21 +216,20 @@ module Giblish
221
216
  doc_attrib["stylesdir"] = @deployment_info.web_path.join("css").cleanpath.to_s
222
217
  end
223
218
  end
224
- Giblog.logger.debug {"Rendered docs expect a css at: #{doc_attrib["stylesdir"]}"}
225
- Giblog.logger.debug {"The expected css is named: #{doc_attrib["stylesheet"]}"}
219
+ Giblog.logger.debug { "Rendered docs expect a css at: #{doc_attrib['stylesdir']}" }
220
+ Giblog.logger.debug { "The expected css is named: #{doc_attrib['stylesheet']}" }
226
221
 
227
222
  attributes.merge!(doc_attrib)
228
223
  end
229
224
 
230
225
  private
231
226
 
232
- def get_common_attributes
227
+ def common_attributes
233
228
  # Setting 'data-uri' makes asciidoctor embed images in the resulting
234
229
  # html file
235
- html_attrib = {
236
- "data-uri" => 1,
230
+ {
231
+ "data-uri" => 1
237
232
  }
238
- html_attrib
239
233
  end
240
234
 
241
235
  def copy_resource_dir(dst_dir)
@@ -263,46 +257,50 @@ module Giblish
263
257
  if @user_style
264
258
  # Make sure that a user supplied stylesheet ends with .css or .CSS
265
259
  @user_style && @user_style =
266
- /\.(css|CSS)$/ =~ @user_style ? @user_style : "#{@user_style}.css"
260
+ /\.(css|CSS)$/ =~ @user_style ? @user_style : "#{@user_style}.css"
267
261
 
268
262
  # bail out if we can not find the given css file
269
- src_css_path = @paths.resource_dir_abs.
270
- join("css").join(Pathname.new(@user_style))
271
- raise RuntimeError, "Could not find the specified " +
272
- "css file at: #{src_css_path}" unless src_css_path.exist?
263
+ src_css_path = @paths.resource_dir_abs
264
+ .join("css").join(Pathname.new(@user_style))
265
+ unless src_css_path.exist?
266
+ raise "Could not find the specified "\
267
+ "css file at: #{src_css_path}"
268
+ end
273
269
  end
274
270
 
275
271
  copy_resource_dir dst_dir
276
272
  end
277
273
  end
278
274
 
275
+ # Converts adoc into pdf
279
276
  class PdfConverter < DocConverter
280
277
  def initialize(paths, deployment_info, options)
281
278
  super paths, deployment_info, options
279
+ require "asciidoctor-mathematical"
282
280
 
283
281
  # identify ourselves as a pdf converter
284
- add_backend_options({backend: "pdf", fileext: "pdf"})
282
+ add_backend_options({ backend: "pdf", fileext: "pdf" })
285
283
  # setup the attributes specific for this converter
286
284
  add_backend_attributes(setup_pdf_attribs)
287
285
  end
288
286
 
289
287
  private
290
288
 
291
- def setup_pdf_attribs()
289
+ def setup_pdf_attribs
292
290
  # only set this up if user has specified a resource dir
293
291
  return {} unless @paths.resource_dir_abs
294
292
 
295
293
  pdf_attrib = {
296
- "pdf-stylesdir" => "#{@paths.resource_dir_abs}/themes",
297
- "pdf-style" => "giblish.yml",
298
- "pdf-fontsdir" => "#{@paths.resource_dir_abs}/fonts",
299
- "icons" => "font"
294
+ "pdf-stylesdir" => "#{@paths.resource_dir_abs}/themes",
295
+ "pdf-style" => "giblish.yml",
296
+ "pdf-fontsdir" => "#{@paths.resource_dir_abs}/fonts",
297
+ "icons" => "font"
300
298
  }
301
299
 
302
300
  # Make sure that the stylesheet ends with .yml or YML
303
301
  @user_style &&
304
- pdf_attrib["pdf-style"] =
305
- /\.(yml|YML)$/ =~ @user_style ? @user_style : "#{@user_style}.yml"
302
+ pdf_attrib["pdf-style"] =
303
+ /\.(yml|YML)$/ =~ @user_style ? @user_style : "#{@user_style}.yml"
306
304
 
307
305
  pdf_attrib
308
306
  end
data/lib/giblish/docid.rb CHANGED
@@ -1,8 +1,8 @@
1
-
2
1
  require_relative "./utils"
3
2
  require "asciidoctor"
4
3
  require "asciidoctor/extensions"
5
4
 
5
+ # put docid stuff in the giblish namespace
6
6
  module Giblish
7
7
  # Parse all adoc files for :docid: attributes
8
8
  class DocidCollector < Asciidoctor::Extensions::Preprocessor
@@ -15,13 +15,7 @@ module Giblish
15
15
  @docid_deps = {}
16
16
 
17
17
  class << self
18
- def docid_cache
19
- @docid_cache
20
- end
21
-
22
- def docid_deps
23
- @docid_deps
24
- end
18
+ attr_reader :docid_cache, :docid_deps
25
19
 
26
20
  def clear_cache
27
21
  @docid_cache = {}
@@ -64,6 +58,7 @@ module Giblish
64
58
  # add a new source document to the docid_deps
65
59
  def add_source_dep(src_path)
66
60
  return if docid_deps.key? src_path
61
+
67
62
  docid_deps[src_path] = []
68
63
  end
69
64
 
@@ -123,9 +118,7 @@ module Giblish
123
118
  # Get the relative path from the src doc to the
124
119
  # doc with the given doc id
125
120
  def get_rel_path(src_path, doc_id)
126
- unless docid_cache.key? doc_id
127
- raise ArgumentError("unknown doc id: #{doc_id}")
128
- end
121
+ raise ArgumentError("unknown doc id: #{doc_id}") unless docid_cache.key? doc_id
129
122
 
130
123
  rel_path = docid_cache[doc_id]
131
124
  .dirname
@@ -176,7 +169,6 @@ module Giblish
176
169
  end
177
170
  end
178
171
 
179
-
180
172
  # Helper method to register the docid preprocessor extension with
181
173
  # the asciidoctor engine.
182
174
  def register_docid_extension
@@ -4,52 +4,26 @@ module Giblish
4
4
  # Container class for bundling together the data we cache for
5
5
  # each asciidoc file we come across
6
6
  class DocInfo
7
- # Cache git info
7
+ # History info from git
8
8
  class DocHistory
9
- attr_accessor :date
10
- attr_accessor :author
11
- attr_accessor :message
9
+ attr_accessor :date, :author, :message
12
10
  end
13
11
 
14
- attr_accessor :converted
15
- attr_accessor :doc_id
16
- attr_accessor :purpose_str
17
- attr_accessor :status
18
- attr_accessor :history
19
- attr_accessor :error_msg
20
- attr_accessor :stderr
12
+ attr_accessor :converted, :doc_id, :purpose_str, :status, :history, :error_msg, :stderr
13
+ attr_reader :title, :rel_path, :src_file
21
14
 
22
15
  # these members can have encoding issues when
23
16
  # running in a mixed Windows/Linux setting.
24
17
  # that is why we explicitly encodes them when
25
18
  # writing to them
26
- def title
27
- @title
28
- end
19
+
29
20
  def title=(rhs)
30
21
  @title = rhs.nil? ? nil : rhs.encode("utf-8")
31
22
  end
32
- def rel_path
33
- @rel_path
34
- end
35
- # attr_accessor :rel_path
36
- def src_file
37
- @src_file
38
- end
23
+
39
24
  def src_file=(rhs)
40
25
  @src_file = rhs.nil? ? nil : rhs.encode("utf-8")
41
26
  end
42
- # attr_accessor :src_file
43
-
44
- # def relPath_utf8
45
- # return nil if @rel_path.nil?
46
- # @rel_path.to_s.encode("utf-8")
47
- # end
48
- #
49
- # def srcFile_utf8
50
- # return nil if @src_file.nil?
51
- # @src_file.to_s.encode("utf-8")
52
- # end
53
27
 
54
28
  def initialize(adoc: nil, dst_root_abs: nil, adoc_stderr: "")
55
29
  @src_file = nil
@@ -63,14 +37,14 @@ module Giblish
63
37
 
64
38
  # fill in doc meta data
65
39
  d_attr = adoc.attributes
66
- self.src_file=(d_attr["docfile"])
67
- self.title=(adoc.doctitle)
40
+ self.src_file = (d_attr["docfile"])
41
+ self.title = (adoc.doctitle)
68
42
  @doc_id = d_attr["docid"]
69
43
  return if dst_root_abs.nil?
70
44
 
71
45
  # Get the relative path beneath the root dir to the doc
72
46
  @rel_path = Pathname.new(
73
- "#{d_attr['outdir']}/#{d_attr['docname']}#{d_attr['docfilesuffix']}".encode("utf-8")
47
+ "#{d_attr['outdir']}/#{d_attr['docname']}#{d_attr['docfilesuffix']}".encode("utf-8")
74
48
  ).relative_path_from(dst_root_abs)
75
49
  end
76
50
 
@@ -82,19 +56,20 @@ module Giblish
82
56
 
83
57
  def get_purpose_info(adoc)
84
58
  # Get the 'Purpose' section if it exists
85
- purpose_str = ""
59
+ purpose_str = String.new("")
86
60
  adoc.blocks.each do |section|
87
61
  next unless section.is_a?(Asciidoctor::Section) &&
88
- (section.level == 1) &&
89
- (section.name =~ /^Purpose$/)
62
+ (section.level == 1) &&
63
+ (section.name =~ /^Purpose$/)
90
64
 
91
65
  # filter out 'odd' text, such as lists etc...
92
66
  section.blocks.each do |bb|
93
67
  next unless bb.is_a?(Asciidoctor::Block)
68
+
94
69
  purpose_str << "#{bb.source}\n+\n"
95
70
  end
96
71
  end
97
72
  purpose_str
98
73
  end
99
74
  end
100
- end
75
+ end
@@ -5,15 +5,13 @@ module Giblish
5
5
  # A home-grown interface class to git. Used for situations when the
6
6
  # 'official' ruby git gem does not support an operation that is needed.
7
7
  class GitItf
8
- attr_reader :repo_root
9
- attr_reader :git_dir
8
+ attr_reader :repo_root, :git_dir
10
9
 
11
10
  def initialize(path)
12
11
  @repo_root = Giblish::PathManager.find_gitrepo_root(path)
13
- if @repo_root.nil?
14
- raise ArgumentError("The path: @{path} is not within a git repo!")
15
- end
16
- @git_dir = @repo_root + ".git"
12
+ raise ArgumentError("The path: @{path} is not within a git repo!") if @repo_root.nil?
13
+
14
+ @git_dir = @repo_root / ".git"
17
15
  end
18
16
 
19
17
  # Get the log history of the supplied file as an array of
@@ -4,8 +4,8 @@ require "asciidoctor"
4
4
  require "asciidoctor/extensions"
5
5
  require_relative "./utils"
6
6
 
7
+ # put the indexing in the giblish namespace
7
8
  module Giblish
8
-
9
9
  # This hook is called by Asciidoctor once for each document _before_
10
10
  # Asciidoctor processes the adoc content.
11
11
  #
@@ -36,29 +36,26 @@ module Giblish
36
36
  # }]
37
37
  # }
38
38
  class IndexHeadings < Asciidoctor::Extensions::Preprocessor
39
-
40
39
  # Use a class-global heading_index dict since asciidoctor creates a new instance
41
40
  # of this class for each processed file
42
- @heading_index = {"file_infos" => []}
41
+ @heading_index = { "file_infos" => [] }
43
42
 
44
43
  # prio order:
45
44
  # 1. values in this hash
46
45
  # 2. values taken from the document
47
46
  # 3. default values
48
47
  @id_elements = {
49
- # prefix: "_",
50
- # separator: "_"
48
+ # prefix: "_",
49
+ # separator: "_"
51
50
  }
52
51
 
53
52
  class << self
54
53
  attr_accessor :id_elements
55
54
 
56
- def heading_index
57
- @heading_index
58
- end
55
+ attr_reader :heading_index
59
56
 
60
57
  def clear_index
61
- @heading_index = {"file_infos" => []}
58
+ @heading_index = { "file_infos" => [] }
62
59
  end
63
60
 
64
61
  # write the index to a file in dst_dir and remove the base_dir
@@ -73,11 +70,11 @@ module Giblish
73
70
  # remove the base_dir part of the file path
74
71
  heading_index["file_infos"].each do |file_info|
75
72
  file_info["filepath"] = Pathname.new(file_info["filepath"])
76
- .relative_path_from(base_dir)
73
+ .relative_path_from(base_dir)
77
74
  end
78
75
  end
79
76
 
80
- Giblog.logger.info { "writing json to #{dst_dir.join("heading_index.json").to_s}" }
77
+ Giblog.logger.info { "writing json to #{dst_dir.join('heading_index.json')}" }
81
78
  File.open(dst_dir.join("heading_index.json").to_s, "w") do |f|
82
79
  f.write(heading_index.to_json)
83
80
  end
@@ -100,15 +97,15 @@ module Giblish
100
97
 
101
98
  # make sure we use the correct id elements when indexing
102
99
  # sections
103
- opts = set_id_attributes(reader.lines)
100
+ opts = find_id_attributes(reader.lines)
104
101
 
105
102
  # Index all headings in the doc
106
103
  Giblog.logger.debug { "indexing headings in #{src_path}" }
107
104
  sections = []
108
105
  file_info_hash = {
109
- "filepath" => src_path,
110
- "title" => title,
111
- "sections" => sections
106
+ "filepath" => src_path,
107
+ "title" => title,
108
+ "sections" => sections
112
109
  }
113
110
 
114
111
  index_sections(reader, file_info_hash, opts)
@@ -152,17 +149,21 @@ module Giblish
152
149
  m = heading_regex.match(line)
153
150
  if m
154
151
  # we have an anchor and got a heading as expected, index it
155
- section = {"id" => match_str}
152
+ section = { "id" => match_str }
156
153
  section["title"] = m[1].strip
157
154
  section["line_no"] = line_no
158
155
  sections << section
159
156
  else
160
- Giblog.logger.debug { "Did not index the anchor: #{match_str} at line #{line_no}, probably not associated with a heading." }
157
+ Giblog.logger.debug do
158
+ "Did not index the anchor: #{match_str} at "\
159
+ "line #{line_no}, probably not associated "\
160
+ "with a heading."
161
+ end
161
162
  end
162
163
  state = :text
163
164
  when :heading
164
165
  # we got a heading without an accompanying anchor, index it
165
- section = {"id" => get_unique_id(file_info_hash, match_str, opts)}
166
+ section = { "id" => get_unique_id(file_info_hash, match_str, opts) }
166
167
  section["title"] = m[1].strip
167
168
  section["line_no"] = line_no
168
169
  sections << section
@@ -187,43 +188,38 @@ module Giblish
187
188
  # 1. values in class variable
188
189
  # 2. values taken from doc
189
190
  # 3. default values
190
- def set_id_attributes(lines)
191
- # default values
192
- result = {
193
- id_prefix: "_",
194
- id_separator: "_"
195
- }
196
-
191
+ def find_id_attributes(lines)
192
+ result = {}
193
+ # prio 1
194
+ result[:id_prefix] = IndexHeadings.id_elements.fetch(:id_prefix, nil)
195
+ result[:id_separator] = IndexHeadings.id_elements.fetch(:id_separator, nil)
196
+ return result if result[:id_prefix] && result[:id_separator]
197
+
198
+ # prio 2
197
199
  # check if the doc specifies id attributes
198
200
  Giblish.process_header_lines(lines) do |line|
199
201
  m = /^:idprefix:(.*)$/.match(line)
200
202
  n = /^:idseparator:(.*)$/.match(line)
201
- if m
203
+ if m && !result[:id_prefix]
202
204
  # We found a id prefix
203
205
  result[:id_prefix] = m[1].strip
204
206
  end
205
- if n
207
+ if n && !result[:id_separator]
206
208
  # We found a id separator
207
209
  result[:id_separator] = n[1].strip
208
210
  end
209
211
  end
210
212
 
211
-
212
- if IndexHeadings.id_elements.has_key?(:id_prefix)
213
- result[:id_prefix] = IndexHeadings.id_elements[:id_prefix]
214
- end
215
-
216
- if IndexHeadings.id_elements.has_key?(:id_separator)
217
- result[:id_separator] = IndexHeadings.id_elements[:id_separator]
218
- end
219
-
213
+ # prio 3
214
+ # default values
215
+ result[:id_prefix] = "_" unless result[:id_prefix]
216
+ result[:id_separator] = "_" unless result[:id_separator]
220
217
  result
221
218
  end
222
219
 
223
220
  def get_unique_id(doc_heading_dict, heading_str, opts)
224
-
225
221
  id_base = Giblish.to_valid_id(heading_str, opts[:id_prefix], opts[:id_separator])
226
- return id_base if !doc_heading_dict.key? id_base
222
+ return id_base unless doc_heading_dict.key? id_base
227
223
 
228
224
  # handle the case with several sections with the same name
229
225
  idx = 1
@@ -234,7 +230,7 @@ module Giblish
234
230
  # some code here
235
231
  break unless doc_heading_dict.key? heading_id
236
232
  end
237
- return heading_id
233
+ heading_id
238
234
  end
239
235
 
240
236
  # Helper method to shorten calls to the heading_index from instance methods