5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/asciidoctor/reducer/conditional_directive_tracker.rb', line 5
def preprocess_conditional_directive keyword, target, delimiter, text
skip_active = @skipping
depth = @conditional_stack.size
directive_lineno = @lineno
result = super
return result if @skipping && skip_active
curr_inc_replacement = @include_replacements.current
drop = curr_inc_replacement[:drop] ||= []
adjusted_directive_lineno = directive_lineno - (curr_inc_replacement[:offset] ||= 0)
if (depth_change = @conditional_stack.size - depth) < 0
if skip_active
drop.push(*(drop.pop..adjusted_directive_lineno))
else
drop << adjusted_directive_lineno
end
elsif depth_change > 0 || directive_lineno == @lineno
drop << adjusted_directive_lineno
else
drop << [adjusted_directive_lineno, text]
end
result
end
|