Skip to content
Browse files

Escape " in headers

  • Loading branch information...
1 parent 82913ce commit 87c08f561378e5ac6af1f8249d2ed60e13e10d73 @bootstraponline bootstraponline committed Oct 14, 2012
Showing with 7 additions and 6 deletions.
  1. +2 −1 lib/gollum/markup.rb
  2. +5 −5 test/test_unicode.rb
View
3 lib/gollum/markup.rb
@@ -95,7 +95,8 @@ def render(no_follow = false, encoding = nil)
def process_headers(doc)
toc = nil
doc.css('h1,h2,h3,h4,h5,h6').each do |h|
- h_name = h.content.gsub(' ','-')
+ # must escape "
+ h_name = h.content.gsub(' ','-').gsub('"','%22')
level = h.name.gsub(/[hH]/,'').to_i
View
10 test/test_unicode.rb
@@ -42,21 +42,21 @@ def utf8(str)
end
test "create and read non-latin page with anchor 2" do
- @wiki.write_page("test", :markdown, "# La faune d'Édiacara")
+ @wiki.write_page("test", :markdown, "# \"La\" faune d'Édiacara")
page = @wiki.page("test")
assert_equal Gollum::Page, page.class
- assert_equal "# La faune d'Édiacara", utf8(page.raw_data)
+ assert_equal "# \"La\" faune d'Édiacara", utf8(page.raw_data)
- # markup.rb
+ # markup.rb test: ', ", É
doc = Nokogiri::HTML page.formatted_data
h1s = doc / :h1
h1 = h1s.first
anchors = h1 / :a
assert_equal 1, h1s.size
assert_equal 1, anchors.size
- assert_equal %q(#La-faune-d'Édiacara), anchors[0]['href']
- assert_equal %q(La-faune-d'Édiacara), anchors[0]['id']
+ assert_equal %q(#%22La%22-faune-d'Édiacara), anchors[0]['href']
+ assert_equal %q(%22La%22-faune-d'Édiacara), anchors[0]['id']
assert_equal 'anchor', anchors[0]['class']
assert_equal '', anchors[0].text
end

0 comments on commit 87c08f5

Please sign in to comment.
Something went wrong with that request. Please try again.