Sha256: 30daa697a47955a7245e31af228818b8f3d6e598d095225f21b76a07d911e765

Contents?: true

Size: 893 Bytes

Versions: 4

Compression:

Stored size: 893 Bytes

Contents

# frozen_string_literal: true

module Asciidoctor::Reducer
  module ConditionalDirectiveTracker
    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] ||= []
      directive_lineno -= (curr_inc_replacement[:offset] ||= 0)
      if (depth_change = @conditional_stack.size - depth) < 0
        if skip_active
          drop.push(*(drop.pop..directive_lineno))
        else
          drop << directive_lineno
        end
      elsif depth_change > 0 || directive_lineno == @lineno
        drop << directive_lineno
      else
        drop << [directive_lineno, text]
      end
      result
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
asciidoctor-reducer-1.0.5 lib/asciidoctor/reducer/conditional_directive_tracker.rb
asciidoctor-reducer-1.0.4 lib/asciidoctor/reducer/conditional_directive_tracker.rb
asciidoctor-reducer-1.0.3 lib/asciidoctor/reducer/conditional_directive_tracker.rb
asciidoctor-reducer-1.0.2 lib/asciidoctor/reducer/conditional_directive_tracker.rb