lib/asciidoctor/table.rb in asciidoctor-1.5.7.1 vs lib/asciidoctor/table.rb in asciidoctor-1.5.8
- old
+ new
@@ -246,11 +246,11 @@
if column
cell_style = column.attributes['style'] unless (in_header_row = column.table.header_row?)
# REVIEW feels hacky to inherit all attributes from column
update_attributes column.attributes
end
- # NOTE if attributes is defined, we know this is a psv cell; implies text should be stripped
+ # NOTE if attributes is defined, we know this is a psv cell; implies text needs to be stripped
if attributes
if attributes.empty?
@colspan = @rowspan = nil
else
@colspan, @rowspan = (attributes.delete 'colspan'), (attributes.delete 'rowspan')
@@ -278,10 +278,14 @@
# NOTE AsciidoctorJ uses nil cell_text to create an empty cell
cell_text = cell_text ? cell_text.strip : ''
end
else
@colspan = @rowspan = nil
+ if cell_style == :asciidoc
+ asciidoc = true
+ inner_document_cursor = opts[:cursor]
+ end
end
# NOTE only true for non-header rows
if asciidoc
# FIXME hide doctitle from nested document; temporary workaround to fix
# nested document seeing doctitle and assuming it has its own document title
@@ -585,17 +589,21 @@
else
cell_text = @buffer.strip
@buffer = ''
cellspec = nil
repeat = 1
- if @format == 'csv'
- if !cell_text.empty? && cell_text.include?('"')
- # this may not be perfect logic, but it hits the 99%
- if cell_text.start_with?('"') && cell_text.end_with?('"')
- # unquote
- cell_text = cell_text.slice(1, cell_text.length - 2).strip
+ if @format == 'csv' && !cell_text.empty? && cell_text.include?('"')
+ # this may not be perfect logic, but it hits the 99%
+ if cell_text.start_with?('"') && cell_text.end_with?('"')
+ # unquote
+ if (cell_text = cell_text.slice(1, cell_text.length - 2))
+ # trim whitespace and collapse escaped quotes
+ cell_text = cell_text.strip.squeeze('"')
+ else
+ logger.error message_with_context 'unclosed quote in CSV data; setting cell to empty', :source_location => @reader.cursor_at_prev_line
+ cell_text = ''
end
-
+ else
# collapse escaped quotes
cell_text = cell_text.squeeze('"')
end
end
end