lib/asciidoctor/block.rb in asciidoctor-1.5.7.1 vs lib/asciidoctor/block.rb in asciidoctor-1.5.8

- old
+ new

@@ -59,11 +59,11 @@ if subs == :default @default_subs = opts[:default_subs] # e.g., :subs => [:quotes] # subs attribute is not honored elsif ::Array === subs - @default_subs = subs.dup + @default_subs = subs.drop 0 @attributes.delete 'subs' # e.g., :subs => :normal or :subs => 'normal' # subs attribute is not honored else @default_subs = nil @@ -88,11 +88,11 @@ if (raw_source = opts[:source]).nil_or_empty? @lines = [] elsif ::String === raw_source @lines = Helpers.normalize_lines_from_string raw_source else - @lines = raw_source.dup + @lines = raw_source.drop 0 end end # Public: Get the converted result of the child blocks by converting the # children appropriate to content model that this block supports. @@ -107,23 +107,21 @@ def content case @content_model when :compound super when :simple - apply_subs @lines * LF, @subs + apply_subs((@lines.join LF), @subs) when :verbatim, :raw - #((apply_subs @lines * LF, @subs).sub StripLineWiseRx, '\1') - # QUESTION could we use strip here instead of popping empty lines? # maybe apply_subs can know how to strip whitespace? result = apply_subs @lines, @subs if result.size < 2 result[0] else result.shift while (first = result[0]) && first.rstrip.empty? result.pop while (last = result[-1]) && last.rstrip.empty? - result * LF + result.join LF end else logger.warn %(Unknown content model '#{@content_model}' for block: #{to_s}) unless @content_model == :empty nil end @@ -132,10 +130,10 @@ # Public: Returns the preprocessed source of this block # # Returns the a String containing the lines joined together or empty string # if there are no lines def source - @lines * LF + @lines.join LF end def to_s content_summary = @content_model == :compound ? %(blocks: #{@blocks.size}) : %(lines: #{@lines.size}) %(#<#{self.class}@#{object_id} {context: #{@context.inspect}, content_model: #{@content_model.inspect}, style: #{@style.inspect}, #{content_summary}}>)