Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions docs/_plugins/include_example.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,20 +93,23 @@ def select_lines(code)
.select { |l, i| l.include? "$example off#{@snippet_label}$" }
.map { |l, i| i }

raise "Start indices amount is not equal to end indices amount, see #{@file}." \
raise "Start indices amount is not equal to end indices amount, "\
"see #{@file}, [labeled=#{@snippet_label}]." \
unless startIndices.size == endIndices.size

raise "No code is selected by include_example, see #{@file}." \
raise "No code is selected by include_example, see #{@file}, [labeled=#{@snippet_label}]." \
if startIndices.size == 0

# Select and join code blocks together, with a space line between each of two continuous
# blocks.
lastIndex = -1
result = ""
startIndices.zip(endIndices).each do |start, endline|
raise "Overlapping between two example code blocks are not allowed, see #{@file}." \
raise "Overlapping between two example code blocks are not allowed, "\
"see #{@file}, [labeled=#{@snippet_label}]." \
if start <= lastIndex
raise "$example on$ should not be in the same line with $example off$, see #{@file}." \
raise "$example on$ should not be in the same line with $example off$, "\
"see #{@file}, [labeled=#{@snippet_label}]." \
if start == endline
lastIndex = endline
range = Range.new(start + 1, endline - 1)
Expand Down
Loading