Permalink
Browse files

wiki table fixes

  • Loading branch information...
1 parent f75ed29 commit f91f7338ca7597cb3abef10091074c8d96ca3af5 @nricciar committed Apr 22, 2012
Showing with 17 additions and 3 deletions.
  1. +4 −3 lib/wikicloth/wiki_buffer/table.rb
  2. +13 −0 test/wiki_cloth_test.rb
@@ -61,7 +61,7 @@ def parse_attributes(data)
when (char == '"' || char == "'") && in_quotes == false && !attribute_name.nil?
in_quotes = true
quote_type = char
- when char == quote_type && in_quotes == true && prev_char != '\\'
+ when (char == quote_type && in_quotes == true && prev_char != '\\') || (char == ' ' && in_quotes == false && !d.blank?)
ret[attribute_name] = d if WikiBuffer::HTMLElement::ALLOWED_ATTRIBUTES.include?(attribute_name)
attribute_name = nil
in_quotes = false
@@ -105,7 +105,8 @@ def next_cell(type="td")
def new_char()
if @check_cell_data == 1
case
- when current_char != '|' && @start_caption == false && self.rows[-1][-1][:style].blank?
+ when current_char != '|' && @start_caption == false && (self.rows[-1][-1].nil? || self.rows[-1][-1][:style].blank?)
+ self.next_cell() if self.rows[-1][-1].nil?
self.rows[-1][-1][:style] = self.data
self.data = ""
when current_char != '|' && @start_caption == true && self.table_caption_attributes.blank?
@@ -118,7 +119,7 @@ def new_char()
case
# Next table cell in row (TD)
when current_char == "|" && (previous_char == "\n" || previous_char == "|") && @in_quotes == false
- self.data.chop!
+ self.data.chop! if self.data[-1,1] == "|"
self.next_cell() unless self.data.blank? && previous_char == "|"
self.data = ""
View
@@ -35,6 +35,19 @@ class WikiParser < WikiCloth::Parser
class WikiClothTest < ActiveSupport::TestCase
+ test "wiki table attributes without quotes" do
+ wiki = WikiParser.new(:data => "{| width=\"95%\"
+!colspan=2 style=\"background-color:#ffebac;\"|Heading
+|-
+|hello||world
+|}")
+ data = wiki.to_html
+ assert data.include?("<table width=\"95%\">")
+ assert data.include?("colspan=\"2\"")
+ assert data.include?("hello")
+ assert data.include?("world")
+ end
+
test "nested bold/italic markup" do
wiki = WikiParser.new(:data => "''Mars goes around the Sun once in a Martian '''year''', or 1.88 Earth '''years'''.''")
data = wiki.to_html

0 comments on commit f91f733

Please sign in to comment.