diff --git a/lib/gollum/markup.rb b/lib/gollum/markup.rb
index 1e3b0595..f2de7593 100644
--- a/lib/gollum/markup.rb
+++ b/lib/gollum/markup.rb
@@ -76,7 +76,7 @@ module Gollum
doc,toc = process_headers(doc)
@toc = @sub_page ? ( @parent_page ? @parent_page.toc_data : "[[_TOC_]]" ) : toc
yield doc if block_given?
- data = doc.to_html
+ data = doc.to_xhtml
data = process_toc_tags(data)
data = process_tex(data)
@@ -95,16 +95,12 @@ module Gollum
def process_headers(doc)
toc = nil
doc.css('h1,h2,h3,h4,h5,h6').each do |h|
- id = encodeURIComponent(h.content.gsub(' ','-'))
+ h_name = h.content.gsub(' ','-')
+
level = h.name.gsub(/[hH]/,'').to_i
# Add anchors
- anchor = Nokogiri::XML::Node.new('a', doc)
- anchor['class'] = 'anchor'
- anchor['id'] = id
- # % -> %25 so anchors work on Firefox. See issue #475
- anchor['href'] = '#' + id.gsub('%', '%25')
- h.add_child(anchor)
+ h.add_child(%Q{})
# Build TOC
toc ||= Nokogiri::XML::DocumentFragment.parse('
')
@@ -122,7 +118,7 @@ module Gollum
end
node = Nokogiri::XML::Node.new('li', doc)
# % -> %25 so anchors work on Firefox. See issue #475
- node.add_child(%Q{#{h.content}})
+ node.add_child(%Q{#{h.content}})
tail.add_child(node)
end
toc = toc.to_xhtml if toc != nil
diff --git a/test/test_unicode.rb b/test/test_unicode.rb
index 8b478436..c6999a39 100644
--- a/test/test_unicode.rb
+++ b/test/test_unicode.rb
@@ -38,10 +38,33 @@ context "Unicode Support" do
anchors = h1 / :a
assert_equal 1, h1s.size
assert_equal 1, anchors.size
- assert_equal '#%25ED%2595%259C%25EA%25B8%2580', anchors[0]['href']
- assert_equal '%ED%95%9C%EA%B8%80', anchors[0]['id']
- assert_equal 'anchor', anchors[0]['class']
- assert_equal '', anchors[0].text
+ assert_equal '#한글', anchors[0]['href']
+ assert_equal '한글', anchors[0]['id']
+ assert_equal 'anchor', anchors[0]['class']
+ assert_equal '', anchors[0].text
+ end
+
+ test "create and read non-latin page with anchor 2" do
+ @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)
+
+ # markup.rb
+ # #简介
+ # href.gsub('%', '%25') so the anchor works in Firefox.
+ #
+ 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 'anchor', anchors[0]['class']
+ assert_equal '', anchors[0].text
end
test "unicode with existing format rules" do