Commit 3ac393c0 authored by Miguel Angel Reina Ortega's avatar Miguel Angel Reina Ortega
Browse files

Small fix for tables with no header

parent 188b7516
Loading
Loading
Loading
Loading
Loading
+3 −2
Original line number Original line Diff line number Diff line
@@ -284,7 +284,8 @@ module Banzai
        unless has_header
        unless has_header
          # Set default alignments from the first separator which takes the role of header
          # Set default alignments from the first separator which takes the role of header
          header_separator_index = 0
          header_separator_index = 0
          parts = lines[0].strip.delete_prefix("+").split("+")
          line  = lines.find { |l| !l.strip.empty? }  # first non-blank line
          parts = line.strip.delete_prefix("+").split("+")


          parts.each_with_index do |part, part_index|
          parts.each_with_index do |part, part_index|
            default_alignments << if part.start_with?(":") && !part.end_with?(":")
            default_alignments << if part.start_with?(":") && !part.end_with?(":")
@@ -296,7 +297,7 @@ module Banzai
                                    end
                                    end


            start_pos = part_index == 0 ? 0 : header_delimiter_positions[part_index - 1]
            start_pos = part_index == 0 ? 0 : header_delimiter_positions[part_index - 1]
            pos = lines[0][start_pos + 1..]&.index("+")
            pos = line[start_pos + 1..]&.index("+")
            header_delimiter_positions << (pos ? pos + start_pos + 1 : -1)
            header_delimiter_positions << (pos ? pos + start_pos + 1 : -1)
          end
          end
        end
        end