Fix Table of Contents menu for headers with spaces.

Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/commit/3c312cbc
Tree: 
http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/tree/3c312cbc
Diff: 
http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/diff/3c312cbc

Branch: refs/heads/master
Commit: 3c312cbc0adf965d00632c09cba0905adca0d908
Parents: 24c91a6
Author: Michael Brooks <mich...@michaelbrooks.ca>
Authored: Thu Jan 26 23:19:25 2012 -0800
Committer: Fil Maj <filip....@nitobi.com>
Committed: Fri Jan 27 16:38:38 2012 -0800

----------------------------------------------------------------------
 lib/phonegap/table_of_contents.rb |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-docs/blob/3c312cbc/lib/phonegap/table_of_contents.rb
----------------------------------------------------------------------
diff --git a/lib/phonegap/table_of_contents.rb 
b/lib/phonegap/table_of_contents.rb
index 94f52c6..4e62270 100644
--- a/lib/phonegap/table_of_contents.rb
+++ b/lib/phonegap/table_of_contents.rb
@@ -1,5 +1,6 @@
 require 'rubygems'
 require 'nokogiri'
+require 'uri'
 
 class TableOfContents
   def run(filename)
@@ -16,7 +17,7 @@ class TableOfContents
         current_h1 = tag.content
 
         option = Nokogiri::XML::Node.new 'option', doc
-        option['value'] = tag.child[:name]
+        option['value'] = URI.escape(tag.child[:name])
         option.content = tag.content
         option_set.push option
       else
@@ -25,7 +26,7 @@ class TableOfContents
         s = tag.content.gsub(/^\W+|\W+$/, '').gsub(/\W+/, '_').downcase
 
         option = Nokogiri::XML::Node.new 'option', doc
-        option['value'] = "#{current_h1}_#{s}"
+        option['value'] = URI.escape("#{current_h1}_#{s}")
         option.content = "#{indentation}- #{tag.content}"
         option_set.push option
 

Reply via email to