Non-ASCII Lists

Fix a bug in Maruku's
list-parsing.

Also fix a test broken
by latest Rack + Ruby 1.9.
This commit is contained in:
Jacques Distler 2011-06-01 13:17:23 -05:00
parent 7e5dbe5854
commit c9ad2c0c6e
4 changed files with 19 additions and 5 deletions

View file

@ -690,7 +690,7 @@ class WikiControllerTest < ActionController::TestCase
a = ''.respond_to?(:force_encoding) ? "\u{1D538}\u00FCthorOfNewPage" :
"\360\235\224\270\303\274thorOfNewPage"
assert_equal a, new_page.author
assert_equal "\xF0\x9D\x94\xB8\xC3\xBCthorOfNewPage".as_bytes, r.cookies['author']
assert_equal a, r.cookies['author']
end
def test_save_not_utf8

View file

@ -230,6 +230,20 @@ END_THM
end
def test_utf8_in_lists
assert_markup_parsed_as(
"<ul>\n<li>\u041E\u0434\u0438\u043D</li>\n\n<li>\u0414" +
"\u0432\u0430</li>\n\n<li>\u0422\u0440\u0438</li>\n</ul>",
"* \u041E\u0434\u0438\u043D\n* \u0414\u0432\u0430\n* \u0422\u0440\u0438\n")
assert_markup_parsed_as(
"<ol>\n<li>\u041E\u0434\u0438\u043D</li>\n\n<li>\u0414"+
"\u0432\u0430</li>\n\n<li>\u0422\u0440\u0438</li>\n</ol>",
"1. \u041E\u0434\u0438\u043D\n2. \u0414\u0432\u0430\n3. \u0422\u0440\u0438\n")
end
def test_have_latest_itex2mml
assert_markup_parsed_as(

View file

@ -204,8 +204,8 @@ Disabled by default because of security concerns.
# Select all text elements of e
XPath.match(e, "//text()" ).each { |original_text|
s = original_text.value.strip
if s.size > 0
s = original_text.value
if s.strip.size > 0
# puts "Parsing #{s.inspect} as blocks: #{parse_blocks} (#{e.name}, #{e.attributes['markdown']}) "

View file

@ -53,8 +53,8 @@ module MaRuKu; module Strings
# Something is wrong with how we parse lists! :-(
#return :ulist if l =~ /^[ ]{0,3}([\*\-\+])\s+.*\w+/
#return :olist if l =~ /^[ ]{0,3}\d+\..*\w+/
return :ulist if l =~ /^[ ]{0,1}([\*\-\+])\s+.*\w+/
return :olist if l =~ /^[ ]{0,1}\d+\..*\w+/
return :ulist if l =~ /^[ ]{0,1}([\*\-\+])\s+.*/
return :olist if l =~ /^[ ]{0,1}\d+\..*/
return :header1 if l =~ /^(=)+/
return :header2 if l =~ /^([-\s])+$/
return :header3 if l =~ /^(#)+\s*\S+/