buildr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From boisv...@apache.org
Subject svn commit: r1006313 - in /buildr/trunk: CHANGELOG rakelib/doc.rake
Date Sun, 10 Oct 2010 15:49:48 GMT
Author: boisvert
Date: Sun Oct 10 15:49:48 2010
New Revision: 1006313

URL: http://svn.apache.org/viewvc?rev=1006313&view=rev
Log:
BUILDR-526 Gracefully handle h2 sections with no id in documentation (Peter Donald)

Modified:
    buildr/trunk/CHANGELOG
    buildr/trunk/rakelib/doc.rake

Modified: buildr/trunk/CHANGELOG
URL: http://svn.apache.org/viewvc/buildr/trunk/CHANGELOG?rev=1006313&r1=1006312&r2=1006313&view=diff
==============================================================================
--- buildr/trunk/CHANGELOG (original)
+++ buildr/trunk/CHANGELOG Sun Oct 10 15:49:48 2010
@@ -10,6 +10,7 @@
 * Fixed:  BUILDR-515 -update-snapshot doesn't work as expected
 * Fixed:  BUILDR-525 Documentation refers to repositories.upload_to rather than
           repositories.release_to (Peter Donald)
+* Fixed:  BUILDR-526 Gracefully handle h2 sections with no id in documentation (Peter Donald)
 * Fixed:  BUILDR-527 package(:war) if libs passed are files (instead of artifacts)
 * Fixed:  JavaRebel was previously not correctly detected.
 

Modified: buildr/trunk/rakelib/doc.rake
URL: http://svn.apache.org/viewvc/buildr/trunk/rakelib/doc.rake?rev=1006313&r1=1006312&r2=1006313&view=diff
==============================================================================
--- buildr/trunk/rakelib/doc.rake (original)
+++ buildr/trunk/rakelib/doc.rake Sun Oct 10 15:49:48 2010
@@ -49,11 +49,18 @@ begin
   require 'jekylltask'
   module TocFilter
     def toc(input)
-      input.scan(/<(h2)(?:>|\s+(.*?)>)([^<]*)<\/\1\s*>/mi).inject(%{<ol
class="toc">}) { |toc, entry|
-        id = entry[1][/^id=(['"])(.*)\1$/, 2]
+      output = "<ol class=\"toc\">"
+      input.scan(/<(h2)(?:>|\s+(.*?)>)([^<]*)<\/\1\s*>/mi).each do |entry|
+        id = (entry[1][/^id=(['"])(.*)\1$/, 2] rescue nil)
         title = entry[2].gsub(/<(\w*).*?>(.*?)<\/\1\s*>/m, '\2').strip
-        toc << %{<li><a href="##{id}">#{title}</a></li>}
-      } << "</ol>"
+        if id
+          output << %{<li><a href="##{id}">#{title}</a></li>}
+        else
+          output << %{<li>#{title}</li>}
+        end
+      end
+      output << "</ol>"
+      output
     end
   end
   Liquid::Template.register_filter(TocFilter)



Mime
View raw message