Changeset 87
- Timestamp:
- 09/01/08 15:24:13 (3 months ago)
- Location:
- trunk
- Files:
-
- 2 added
- 1 removed
- 8 modified
-
LICENSE (added)
-
README (modified) (1 diff)
-
Rakefile (modified) (3 diffs)
-
lib/bluecloth.rb (modified) (2 diffs)
-
spec/bluecloth_spec.rb (modified) (1 diff)
-
spec/bugfix_spec.rb (modified) (1 diff)
-
spec/contributions_spec.rb (modified) (1 diff)
-
spec/lib/helpers.rb (added)
-
spec/lib/matchers.rb (modified) (4 diffs)
-
spec/markdowntest_spec.rb (modified) (2 diffs)
-
tests (deleted)
Legend:
- Unmodified
- Added
- Removed
-
trunk/README
r75 r87 106 106 107 107 Ruby 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. 118 109 119 110 [1]: http://daringfireball.net/projects/markdown/ -
trunk/Rakefile
r86 r87 40 40 PKGDIR = BASEDIR + 'pkg' 41 41 42 PKG_NAME = 'bluecloth' 42 PROJECT_NAME = 'BlueCloth' 43 PKG_NAME = PROJECT_NAME.downcase 43 44 PKG_SUMMARY = 'BlueCloth is a Ruby implementation of Markdown' 44 45 VERSION_FILE = LIBDIR + 'bluecloth.rb' … … 108 109 109 110 # Documentation constants 111 RDOCDIR = DOCSDIR + 'api' 110 112 RDOC_OPTIONS = [ 111 113 '-w', '4', … … 174 176 end 175 177 end 178 179 # Manual-generation config 180 MANUALDIR = DOCSDIR + 'manual' 176 181 177 182 $trace = Rake.application.options.trace ? true : false -
trunk/lib/bluecloth.rb
r86 r87 131 131 132 132 # The tag-closing string -- set to '>' for HTML 133 EMPTY_ELEMENT_SUFFIX = " />";133 EMPTY_ELEMENT_SUFFIX = " />"; 134 134 135 135 # Table of MD5 sums for escaped characters … … 942 942 943 943 # Pattern to match strong emphasis in Markdown text 944 BoldRegexp = %r{ (\*\*|__) (\S|\S. +?\S) \1 }x944 BoldRegexp = %r{ (\*\*|__) (\S|\S.*?\S) \1 }x 945 945 946 946 # Pattern to match normal emphasis in Markdown text 947 ItalicRegexp = %r{ (\*|_) (\S|\S. +?\S) \1 }x947 ItalicRegexp = %r{ (\*|_) (\S|\S.*?\S) \1 }x 948 948 949 949 ### Transform italic- and bold-encoded text in a copy of the specified +str+ -
trunk/spec/bluecloth_spec.rb
r86 r87 32 32 describe BlueCloth, "-- Markdown" do 33 33 include BlueCloth::TestConstants, 34 BlueCloth Matchers34 BlueCloth::Matchers 35 35 36 36 -
trunk/spec/bugfix_spec.rb
r86 r87 32 32 describe BlueCloth, "bugfixes" do 33 33 include BlueCloth::TestConstants, 34 BlueCloth Matchers34 BlueCloth::Matchers 35 35 36 36 before( :all ) do -
trunk/spec/contributions_spec.rb
r86 r87 32 32 describe BlueCloth, " contributed features" do 33 33 include BlueCloth::TestConstants, 34 BlueCloth Matchers34 BlueCloth::Matchers 35 35 36 36 ### HTML filter options contributed by Florian Gross. -
trunk/spec/lib/matchers.rb
r86 r87 1 1 #!/usr/bin/env ruby 2 2 3 require 'bluecloth' 4 require 'spec/matchers' 3 begin 4 require 'bluecloth' 5 require 'diff/lcs' 6 require 'diff/lcs/callbacks' 7 require 'spec/lib/constants' 8 rescue LoadError 9 unless Object.const_defined?( :Gem ) 10 require 'rubygems' 11 retry 12 end 13 raise 14 end 15 5 16 6 17 ### Fixturing functions 7 module BlueCloth Matchers18 module BlueCloth::Matchers 8 19 9 20 class TransformMatcher … … 19 30 @bluecloth = bluecloth 20 31 @output_html = bluecloth.to_html 21 return @output_html == @html32 return @output_html.strip == @html.strip 22 33 end 23 34 24 35 ### Build a failure message for the matching case. 25 36 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 ] 28 40 end 29 41 … … 33 45 [ @output_html, @html ] 34 46 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 35 73 end 36 74 … … 87 125 end 88 126 89 return BlueCloth Matchers::TransformMatcher.new( html )127 return BlueCloth::Matchers::TransformMatcher.new( html ) 90 128 end 91 129 92 130 ### Generate a matcher that expects to match the given +regexp+. 93 131 def be_transformed_into_html_matching( regexp ) 94 return BlueCloth Matchers::TransformMatcher.new( regexp )132 return BlueCloth::Matchers::TransformMatcher.new( regexp ) 95 133 end 96 134 97 end 135 end # module BlueCloth::Matchers 98 136 99 -
trunk/spec/markdowntest_spec.rb
r86 r87 12 12 begin 13 13 require 'spec/runner' 14 require 'logger' 14 15 15 require 'bluecloth' 16 16 require 'spec/lib/constants' 17 require 'spec/lib/helpers' 17 18 require 'spec/lib/matchers' 18 19 rescue LoadError … … 32 33 describe BlueCloth, "-- MarkdownTest 1.0: " do 33 34 include BlueCloth::TestConstants, 34 BlueCloth Matchers35 BlueCloth::Matchers 35 36 36 37 markdowntest_dir = Pathname.new( __FILE__ ).dirname + 'data/markdowntest'
