From b0ba205532e98f09a291a249db153bbcab739be5 Mon Sep 17 00:00:00 2001 From: kristi Date: Mon, 14 May 2012 00:38:27 -0700 Subject: [PATCH] Remove :header_hashtags option and adjust tests --- lib/gollum/frontend/app.rb | 1 - lib/gollum/markup.rb | 2 +- lib/gollum/wiki.rb | 7 ------- test/test_markup.rb | 15 ++++++++------- test/test_page.rb | 2 +- test/test_wiki.rb | 22 ++++------------------ 6 files changed, 14 insertions(+), 35 deletions(-) diff --git a/lib/gollum/frontend/app.rb b/lib/gollum/frontend/app.rb index 9d0a7068..5bc93f3c 100644 --- a/lib/gollum/frontend/app.rb +++ b/lib/gollum/frontend/app.rb @@ -14,7 +14,6 @@ require 'gollum/frontend/views/editable' # require 'gollum/frontend/app' # Precious::App.set(:wiki_options, { # :universal_toc => false, -# :header_hashtags => true # } # # See the wiki.rb file for more details on wiki options diff --git a/lib/gollum/markup.rb b/lib/gollum/markup.rb index 4e05f634..28a53d45 100644 --- a/lib/gollum/markup.rb +++ b/lib/gollum/markup.rb @@ -83,7 +83,7 @@ module Gollum anchor['class'] = 'anchor' anchor['id'] = id anchor['href'] = '#' + id - h.child.before(anchor) + h.add_child(anchor) # Build TOC toc ||= Nokogiri::XML::Node.new('ul', doc) diff --git a/lib/gollum/wiki.rb b/lib/gollum/wiki.rb index a77d8c7c..517ace93 100644 --- a/lib/gollum/wiki.rb +++ b/lib/gollum/wiki.rb @@ -139,9 +139,6 @@ module Gollum # site. # options - Optional Hash: # :universal_toc - Table of contents on all pages. Default: false - # :header_hashtags - Show links to headers. Default: true - # (Pages may be rendered slightly faster without - # the toc and hashtags) # :base_path - String base path for all Wiki links. # Default: "/" # :page_class - The page Class. Default: Gollum::Page @@ -175,7 +172,6 @@ module Gollum @history_sanitization = options[:history_sanitization] || self.class.history_sanitization @universal_toc = options.fetch(:universal_toc, false) - @header_hashtags = options.fetch(:header_hashtags, true) end # Public: check whether the wiki's git repo exists on the filesystem. @@ -542,9 +538,6 @@ module Gollum # Toggles display of universal table of contents attr_reader :universal_toc - # Create hashtag link for headers to jump to sections - attr_reader :header_hashtags - # Normalize the data. # # data - The String data to be normalized. diff --git a/test/test_markup.rb b/test/test_markup.rb index bf4e64c9..41539de9 100644 --- a/test/test_markup.rb +++ b/test/test_markup.rb @@ -6,7 +6,7 @@ context "Markup" do @path = testpath("examples/test.git") FileUtils.rm_rf(@path) Grit::Repo.init_bare(@path) - Gollum::Wiki.default_options = {:header_hashtags => false, :universal_toc => false} + Gollum::Wiki.default_options = {:universal_toc => false} @wiki = Gollum::Wiki.new(@path) end @@ -556,14 +556,15 @@ np.array([[2,2],[1,3]],np.float) test "id with prefix ok" do content = "h2(example#wiki-foo). xxxx" - output = %(

xxxx

) - compare(content, output, :textile) - end +output = %(

xxxx

) +compare(content, output, :textile) +end test "id prefix added" do content = "h2(#foo). xxxx[1]\n\nfn1.footnote" output = "

xxxx" + - "1

" + + "1" + + "" + "\n

1 footnote

" compare(content, output, :textile) end @@ -601,11 +602,11 @@ np.array([[2,2],[1,3]],np.float) ######################################################################### test "asciidoc header" do - compare("= Book Title\n\n== Heading", '

Heading

', 'asciidoc') + compare("= Book Title\n\n== Heading", '

Heading

', 'asciidoc') end test "internal links with asciidoc" do - compare("= Book Title\n\n[[anid]]\n== Heading", '

Heading

', 'asciidoc') + compare("= Book Title\n\n[[anid]]\n== Heading", '

Heading

', 'asciidoc') end diff --git a/test/test_page.rb b/test/test_page.rb index 9adf4660..c81b1187 100644 --- a/test/test_page.rb +++ b/test/test_page.rb @@ -16,7 +16,7 @@ context "Page" do page = @wiki.page('Bilbo Baggins') assert_equal Gollum::Page, page.class assert page.raw_data =~ /^# Bilbo Baggins\n\nBilbo Baggins/ - assert page.formatted_data =~ /

Bilbo Baggins<\/h1>\n\n

Bilbo Baggins/ + assert page.formatted_data =~ %r{

Bilbo Baggins\n

\n\n

Bilbo Baggins} assert_equal 'Bilbo-Baggins.md', page.path assert_equal :markdown, page.format assert_equal @wiki.repo.commits.first.id, page.version.id diff --git a/test/test_wiki.rb b/test/test_wiki.rb index 93e8622a..3ec25a04 100644 --- a/test/test_wiki.rb +++ b/test/test_wiki.rb @@ -92,14 +92,14 @@ end context "Wiki page previewing" do setup do @path = testpath("examples/lotr.git") - Gollum::Wiki.default_options = {:header_hashtags => false, :universal_toc => false} + Gollum::Wiki.default_options = {:universal_toc => false} @wiki = Gollum::Wiki.new(@path) end test "preview_page" do page = @wiki.preview_page("Test", "# Bilbo", :markdown) assert_equal "# Bilbo", page.raw_data - assert_equal "

Bilbo

", page.formatted_data + assert_equal %Q{

Bilbo\n

}, page.formatted_data assert_equal "Test.md", page.filename assert_equal "Test", page.name end @@ -108,32 +108,18 @@ end context "Wiki TOC" do setup do @path = testpath("examples/lotr.git") - options = {:header_hashtags => false, :universal_toc => true} + options = {:universal_toc => true} @wiki = Gollum::Wiki.new(@path, options) end test "toc_generation" do page = @wiki.preview_page("Test", "# Bilbo", :markdown) assert_equal "# Bilbo", page.raw_data - assert_equal '

Bilbo

', page.formatted_data.gsub(/\n/,"") + assert_equal '

Bilbo

', page.formatted_data.gsub(/\n/,"") assert_equal '', page.toc_data.gsub(/\n */,"") end end -context "Wiki header hashtags" do - setup do - @path = testpath("examples/lotr.git") - options = {:header_hashtags => true, :universal_toc => false} - @wiki = Gollum::Wiki.new(@path, options) - end - - test "header_hashtags" do - page = @wiki.preview_page("Test", "# Bilbo", :markdown) - assert_equal "# Bilbo", page.raw_data - assert_equal '

Bilbo

', page.formatted_data.gsub(/\n/,"") - end -end - context "Wiki page writing" do setup do @path = testpath("examples/test.git")