Skip to content

Commit 735ca65

Browse files
committed
Minor tweaks to TOC code
1 parent 5a2cb15 commit 735ca65

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

lib/contents.rb

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,13 @@ def site_page_files
3131
parseable_site_files.reject { |file| File.basename(file).start_with?('_') }
3232
end
3333

34+
def content_for filename
35+
open("#{site_dir}/#{filename}").read()
36+
end
37+
3438
def subpages_for filename
3539
links = []
36-
content = open("#{site_dir}/#{filename}").read()
40+
content = content_for(filename)
3741

3842
# (markdown) links of the form: [link text](link_page)
3943
content.scan /\[.*?\]\((.*?)\)/ do |link, _|
@@ -57,7 +61,7 @@ def subpages_for filename
5761
end
5862

5963
def next_step_for filename
60-
content = open("#{site_dir}/#{filename}").read()
64+
content = content_for(filename)
6165

6266
# (stepfiles) links of the form: stepfile "next page"
6367
content.scan /next_step\s*["'](.*?)["']/ do |link, _|
@@ -211,12 +215,11 @@ def toc_list toc_items, level = 0
211215
end
212216

213217
def has_collapsables toc_items
214-
toc_items.each do |toc_item|
218+
toc_items.any? do |toc_item|
215219
if toc_item.instance_of? Array
216220
return true
217221
end
218222
end
219-
return false
220223
end
221224

222225
def content

0 commit comments

Comments
 (0)