From ae30b23d34a3c98895d8ed5e34d1d7041b86ea23 Mon Sep 17 00:00:00 2001 From: kristi Date: Sun, 13 May 2012 18:48:02 -0700 Subject: [PATCH] insert a comment if no TOC headers found --- lib/gollum/markup.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/gollum/markup.rb b/lib/gollum/markup.rb index 25e7b685..42dcef1f 100644 --- a/lib/gollum/markup.rb +++ b/lib/gollum/markup.rb @@ -69,7 +69,6 @@ module Gollum end def process_headers(doc) - toc = nil doc.css('h1,h2,h3,h4,h5,h6').each do |h| id = CGI::escape(h.content.gsub(' ','-')) level = h.name.gsub(/[hH]/,'').to_i @@ -86,7 +85,7 @@ module Gollum tail ||= toc tail_level ||= 1 - while tail_level < level do + while tail_level < level node = Nokogiri::XML::Node.new('ul', doc) tail = tail.add_child(node) tail_level += 1 @@ -99,6 +98,7 @@ module Gollum node.add_child("#{h.content}") tail.add_child(node) end + toc ||= Nokogiri::XML::DocumentFragment.parse('') [doc, toc] end