Changeset 87

Show
Ignore:
Timestamp:
09/01/08 15:24:13 (3 months ago)
Author:
deveiant
Message:
Location:
trunk
Files:
2 added
1 removed
8 modified

Legend:

Unmodified
Added
Removed
  • trunk/README

    r75 r87  
    106106 
    107107Ruby version:   
    108   This module is Open Source Software which is Copyright (c) 2004 by The FaerieMUD 
    109   Consortium. 
    110  
    111   You may use, modify, and/or redistribute this software under the same terms as 
    112   Ruby itself. 
    113  
    114   BlueCloth is distributed in the hope that it will be useful, but WITHOUT ANY 
    115   WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 
    116   PARTICULAR PURPOSE.  See the GNU General Public License for more details. 
    117  
     108  See the LICENSE file for details. 
    118109 
    119110[1]: http://daringfireball.net/projects/markdown/ 
  • trunk/Rakefile

    r86 r87  
    4040PKGDIR        = BASEDIR + 'pkg' 
    4141 
    42 PKG_NAME      = 'bluecloth' 
     42PROJECT_NAME  = 'BlueCloth' 
     43PKG_NAME      = PROJECT_NAME.downcase 
    4344PKG_SUMMARY   = 'BlueCloth is a Ruby implementation of Markdown' 
    4445VERSION_FILE  = LIBDIR + 'bluecloth.rb' 
     
    108109 
    109110# Documentation constants 
     111RDOCDIR = DOCSDIR + 'api' 
    110112RDOC_OPTIONS = [ 
    111113    '-w', '4', 
     
    174176    end 
    175177end 
     178 
     179# Manual-generation config 
     180MANUALDIR = DOCSDIR + 'manual' 
    176181 
    177182$trace = Rake.application.options.trace ? true : false 
  • trunk/lib/bluecloth.rb

    r86 r87  
    131131 
    132132    # The tag-closing string -- set to '>' for HTML 
    133     EMPTY_ELEMENT_SUFFIX = "/>"; 
     133    EMPTY_ELEMENT_SUFFIX = " />"; 
    134134 
    135135    # Table of MD5 sums for escaped characters 
     
    942942 
    943943    # Pattern to match strong emphasis in Markdown text 
    944     BoldRegexp = %r{ (\*\*|__) (\S|\S.+?\S) \1 }x 
     944    BoldRegexp = %r{ (\*\*|__) (\S|\S.*?\S) \1 }x 
    945945 
    946946    # Pattern to match normal emphasis in Markdown text 
    947     ItalicRegexp = %r{ (\*|_) (\S|\S.+?\S) \1 }x 
     947    ItalicRegexp = %r{ (\*|_) (\S|\S.*?\S) \1 }x 
    948948 
    949949    ### Transform italic- and bold-encoded text in a copy of the specified +str+ 
  • trunk/spec/bluecloth_spec.rb

    r86 r87  
    3232describe BlueCloth, "-- Markdown" do 
    3333    include BlueCloth::TestConstants, 
    34         BlueClothMatchers 
     34        BlueCloth::Matchers 
    3535 
    3636 
  • trunk/spec/bugfix_spec.rb

    r86 r87  
    3232describe BlueCloth, "bugfixes" do 
    3333    include BlueCloth::TestConstants, 
    34         BlueClothMatchers 
     34        BlueCloth::Matchers 
    3535 
    3636    before( :all ) do 
  • trunk/spec/contributions_spec.rb

    r86 r87  
    3232describe BlueCloth, " contributed features" do 
    3333    include BlueCloth::TestConstants, 
    34         BlueClothMatchers 
     34        BlueCloth::Matchers 
    3535 
    3636    ### HTML filter options contributed by Florian Gross. 
  • trunk/spec/lib/matchers.rb

    r86 r87  
    11#!/usr/bin/env ruby 
    22 
    3 require 'bluecloth' 
    4 require 'spec/matchers' 
     3begin 
     4    require 'bluecloth' 
     5    require 'diff/lcs' 
     6    require 'diff/lcs/callbacks' 
     7    require 'spec/lib/constants' 
     8rescue LoadError 
     9    unless Object.const_defined?( :Gem ) 
     10        require 'rubygems' 
     11        retry 
     12    end 
     13    raise 
     14end 
     15 
    516 
    617### Fixturing functions 
    7 module BlueClothMatchers 
     18module BlueCloth::Matchers 
    819 
    920    class TransformMatcher 
     
    1930            @bluecloth = bluecloth 
    2031            @output_html = bluecloth.to_html 
    21             return @output_html == @html 
     32            return @output_html.strip == @html.strip 
    2233        end 
    2334         
    2435        ### Build a failure message for the matching case. 
    2536        def failure_message 
    26             return "Expected the generated html:\n\n  %p\n\nto be the same as:\n\n  %p\n\n" % 
    27                 [ @output_html, @html ] 
     37            patch = self.make_patch( @html, @output_html ) 
     38            return "Expected the generated html:\n\n  %p\n\nto be the same as:\n\n  %p\n\nDiffs:\n\n%s" % 
     39                [ @output_html, @html, patch ] 
    2840        end 
    2941         
     
    3345                [ @output_html, @html ] 
    3446        end 
     47         
     48        ### Compute a patch between the given +expected+ output and the +actual+ output 
     49        ### and return it as a string. 
     50        def make_patch( expected, actual ) 
     51            diffs = Diff::LCS.sdiff( expected.split("\n"), actual.split("\n"), 
     52                Diff::LCS::ContextDiffCallbacks ) 
     53 
     54            maxcol = diffs.flatten. 
     55                collect {|d| [d.old_element.to_s.length, d.new_element.to_s.length ] }. 
     56                flatten.max || 0 
     57            maxcol += 4 
     58 
     59            patch = "              %#{maxcol}s | %s\n" % [ "Expected", "Actual" ] 
     60            patch << diffs.collect do |changeset| 
     61                changeset.collect do |change| 
     62                    "%s [%03d, %03d]: %#{maxcol}s | %-#{maxcol}s" % [ 
     63                        change.action, 
     64                        change.old_position, 
     65                        change.new_position, 
     66                        change.old_element.inspect, 
     67                        change.new_element.inspect, 
     68                    ] 
     69                end.join("\n") 
     70            end.join("\n---\n") 
     71        end 
     72         
    3573    end 
    3674 
     
    87125        end 
    88126         
    89         return BlueClothMatchers::TransformMatcher.new( html ) 
     127        return BlueCloth::Matchers::TransformMatcher.new( html ) 
    90128    end 
    91129     
    92130    ### Generate a matcher that expects to match the given +regexp+. 
    93131    def be_transformed_into_html_matching( regexp ) 
    94         return BlueClothMatchers::TransformMatcher.new( regexp ) 
     132        return BlueCloth::Matchers::TransformMatcher.new( regexp ) 
    95133    end 
    96134     
    97 end 
     135end # module BlueCloth::Matchers 
    98136 
    99  
  • trunk/spec/markdowntest_spec.rb

    r86 r87  
    1212begin 
    1313    require 'spec/runner' 
    14     require 'logger' 
     14 
    1515    require 'bluecloth' 
    1616    require 'spec/lib/constants' 
     17    require 'spec/lib/helpers' 
    1718    require 'spec/lib/matchers' 
    1819rescue LoadError 
     
    3233describe BlueCloth, "-- MarkdownTest 1.0: " do 
    3334    include BlueCloth::TestConstants, 
    34         BlueClothMatchers 
     35        BlueCloth::Matchers 
    3536 
    3637    markdowntest_dir = Pathname.new( __FILE__ ).dirname + 'data/markdowntest'