RedCloth 4.2.3-x86-mswin32-60 → 4.2.4.pre2-x86-mswin32-60
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of RedCloth might be problematic. Click here for more details.
- data/.gitignore +25 -0
- data/.rspec +1 -0
- data/.rvmrc +1 -0
- data/CHANGELOG +6 -1
- data/Gemfile +2 -0
- data/Gemfile.lock +33 -0
- data/README +18 -9
- data/Rakefile +7 -254
- data/doc/textile_reference.html +631 -0
- data/lib/redcloth.rb +8 -7
- data/lib/redcloth/formatters/latex_entities.yml +8 -8
- data/lib/redcloth/version.rb +6 -5
- data/redcloth.gemspec +48 -0
- data/spec/benchmark_spec.rb +15 -0
- data/spec/fixtures/code.yml +6 -6
- data/spec/fixtures/table.yml +2 -2
- data/spec/fixtures/textism.yml +3 -3
- data/spec/fixtures/threshold.yml +3 -3
- data/spec/spec_helper.rb +26 -32
- data/tasks/compile.rake +47 -0
- data/tasks/gems.rake +38 -0
- data/tasks/ragel_extension_task.rb +127 -0
- data/tasks/release.rake +15 -0
- data/tasks/rspec.rake +11 -0
- data/tasks/rvm.rake +43 -0
- data/test/ragel_profiler.rb +73 -0
- data/test/validate_fixtures.rb +74 -0
- metadata +129 -47
- data/RedCloth.gemspec +0 -35
- data/ext/redcloth_scan/extconf.rb +0 -9
- data/lib/redcloth_scan.so +0 -0
- data/spec/differs/inline.rb +0 -48
- data/spec/spec.opts +0 -3
    
        data/lib/redcloth.rb
    CHANGED
    
    | @@ -5,15 +5,16 @@ | |
| 5 5 | 
             
            # appears to be fixed in Edge Rails [51e4106].
         | 
| 6 6 | 
             
            Object.send(:remove_const, :RedCloth) if Object.const_defined?(:RedCloth) && RedCloth.is_a?(Class)
         | 
| 7 7 |  | 
| 8 | 
            -
             | 
| 9 | 
            -
              class NotCompiledError < LoadError; end
         | 
| 10 | 
            -
            end
         | 
| 11 | 
            -
             | 
| 8 | 
            +
            require 'rbconfig'
         | 
| 12 9 | 
             
            begin
         | 
| 13 | 
            -
               | 
| 14 | 
            -
             | 
| 15 | 
            -
               | 
| 10 | 
            +
              prefix = Config::CONFIG['arch'] =~ /mswin|mingw/ ? "#{Config::CONFIG['MAJOR']}.#{Config::CONFIG['MINOR']}/" : ''
         | 
| 11 | 
            +
              lib = "#{prefix}redcloth_scan"
         | 
| 12 | 
            +
              require lib
         | 
| 13 | 
            +
            rescue LoadError => e
         | 
| 14 | 
            +
              e.message << %{\nCouldn't load #{lib}\nThe $LOAD_PATH was:\n#{$LOAD_PATH.join("\n")}}
         | 
| 15 | 
            +
              raise e
         | 
| 16 16 | 
             
            end
         | 
| 17 | 
            +
             | 
| 17 18 | 
             
            require 'redcloth/version'
         | 
| 18 19 | 
             
            require 'redcloth/textile_doc'
         | 
| 19 20 | 
             
            require 'redcloth/formatters/base'
         | 
| @@ -180,10 +180,10 @@ lsquor: "," | |
| 180 180 | 
             
            "8218": ","
         | 
| 181 181 | 
             
            #DOUBLE LOW-9 QUOTATION MARK
         | 
| 182 182 | 
             
            #requires fontenc:T1
         | 
| 183 | 
            -
            ldquor: ,,
         | 
| 183 | 
            +
            ldquor: ',,'
         | 
| 184 184 | 
             
            #DOUBLE LOW-9 QUOTATION MARK
         | 
| 185 185 | 
             
            #requires fontenc:T1
         | 
| 186 | 
            -
            "8222": ,,
         | 
| 186 | 
            +
            "8222": ',,'
         | 
| 187 187 | 
             
            #LATIN SMALL LIGATURE FF
         | 
| 188 188 | 
             
            "64256": ff
         | 
| 189 189 | 
             
            #LATIN SMALL LIGATURE FI
         | 
| @@ -197,9 +197,9 @@ ldquor: ,, | |
| 197 197 | 
             
            #LATIN SMALL LIGATURE FL
         | 
| 198 198 | 
             
            "64258": fl
         | 
| 199 199 | 
             
            #DOUBLE HIGH-REVERSED-9 QUOTATION MARK
         | 
| 200 | 
            -
            "8223": ``
         | 
| 200 | 
            +
            "8223": '``'
         | 
| 201 201 | 
             
            #SINGLE HIGH-REVERSED-9 QUOTATION MARK
         | 
| 202 | 
            -
            "8219": `
         | 
| 202 | 
            +
            "8219": '`'
         | 
| 203 203 | 
             
            #VERTICAL ELLIPSIS
         | 
| 204 204 | 
             
            "8942": \vdots{}
         | 
| 205 205 | 
             
            #HYPHEN BULLET
         | 
| @@ -502,17 +502,17 @@ raquo: \guillemotright{} | |
| 502 502 | 
             
            #requires fontenc:T1
         | 
| 503 503 | 
             
            "187": \guillemotright{}
         | 
| 504 504 | 
             
            #LEFT SINGLE QUOTATION MARK
         | 
| 505 | 
            -
            lsquo: `
         | 
| 505 | 
            +
            lsquo: '`'
         | 
| 506 506 | 
             
            #LEFT SINGLE QUOTATION MARK
         | 
| 507 | 
            -
            "8216": `
         | 
| 507 | 
            +
            "8216": '`'
         | 
| 508 508 | 
             
            #RIGHT SINGLE QUOTATION MARK
         | 
| 509 509 | 
             
            rsquo: "'"
         | 
| 510 510 | 
             
            #RIGHT SINGLE QUOTATION MARK
         | 
| 511 511 | 
             
            "8217": "'"
         | 
| 512 512 | 
             
            #LEFT DOUBLE QUOTATION MARK
         | 
| 513 | 
            -
            ldquo: ``
         | 
| 513 | 
            +
            ldquo: '``'
         | 
| 514 514 | 
             
            #LEFT DOUBLE QUOTATION MARK
         | 
| 515 | 
            -
            "8220": ``
         | 
| 515 | 
            +
            "8220": '``'
         | 
| 516 516 | 
             
            #RIGHT DOUBLE QUOTATION MARK
         | 
| 517 517 | 
             
            rdquo: "''"
         | 
| 518 518 | 
             
            #RIGHT DOUBLE QUOTATION MARK
         | 
    
        data/lib/redcloth/version.rb
    CHANGED
    
    | @@ -2,10 +2,10 @@ module RedCloth | |
| 2 2 | 
             
              module VERSION
         | 
| 3 3 | 
             
                MAJOR = 4
         | 
| 4 4 | 
             
                MINOR = 2
         | 
| 5 | 
            -
                TINY  =  | 
| 6 | 
            -
                RELEASE_CANDIDATE =  | 
| 5 | 
            +
                TINY  = 4
         | 
| 6 | 
            +
                RELEASE_CANDIDATE = "pre2"
         | 
| 7 7 |  | 
| 8 | 
            -
                STRING = [MAJOR, MINOR, TINY].join('.')
         | 
| 8 | 
            +
                STRING = [MAJOR, MINOR, TINY, RELEASE_CANDIDATE].join('.')
         | 
| 9 9 | 
             
                TAG = "REL_#{[MAJOR, MINOR, TINY, RELEASE_CANDIDATE].compact.join('_')}".upcase.gsub(/\.|-/, '_')
         | 
| 10 10 | 
             
                FULL_VERSION = "#{[MAJOR, MINOR, TINY, RELEASE_CANDIDATE].compact.join('.')}"
         | 
| 11 11 |  | 
| @@ -26,8 +26,9 @@ module RedCloth | |
| 26 26 | 
             
              description = "Textile parser for Ruby."
         | 
| 27 27 |  | 
| 28 28 | 
             
              if RedCloth.const_defined?(:EXTENSION_LANGUAGE)
         | 
| 29 | 
            -
                 | 
| 29 | 
            +
                SUMMARY = "#{NAME}-#{VERSION::FULL_VERSION}-#{EXTENSION_LANGUAGE}"
         | 
| 30 30 | 
             
              else
         | 
| 31 | 
            -
                 | 
| 31 | 
            +
                SUMMARY = "#{NAME}-#{VERSION::FULL_VERSION}"
         | 
| 32 32 | 
             
              end
         | 
| 33 | 
            +
              DESCRIPTION = SUMMARY + " - #{description}\n#{URL}"
         | 
| 33 34 | 
             
            end
         | 
    
        data/redcloth.gemspec
    ADDED
    
    | @@ -0,0 +1,48 @@ | |
| 1 | 
            +
            # -*- encoding: utf-8 -*-
         | 
| 2 | 
            +
            redcloth_dir = Dir.pwd =~ /redcloth\/tmp/ ? File.expand_path("../../../..", Dir.pwd) : File.expand_path("..", __FILE__)
         | 
| 3 | 
            +
            $LOAD_PATH.unshift File.join(redcloth_dir, 'lib')
         | 
| 4 | 
            +
            require "redcloth/version"
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            Gem::Specification.new do |s|
         | 
| 7 | 
            +
              s.name        = "RedCloth"
         | 
| 8 | 
            +
              s.version     = RedCloth::VERSION.to_s
         | 
| 9 | 
            +
              s.authors     = ["Jason Garber", "why the lucky stiff", "Ola Bini"]
         | 
| 10 | 
            +
              s.description = "Textile parser for Ruby."
         | 
| 11 | 
            +
              s.summary     = RedCloth::SUMMARY
         | 
| 12 | 
            +
              s.email       = "redcloth-upwards@rubyforge.org"
         | 
| 13 | 
            +
              s.homepage    = "http://redcloth.org"
         | 
| 14 | 
            +
              s.rubyforge_project = "redcloth"
         | 
| 15 | 
            +
             | 
| 16 | 
            +
              s.rubygems_version   = "1.3.7"
         | 
| 17 | 
            +
              s.default_executable = "redcloth"
         | 
| 18 | 
            +
             | 
| 19 | 
            +
              s.files            = `git ls-files`.split("\n")
         | 
| 20 | 
            +
              s.test_files       = `git ls-files -- {spec}/*`.split("\n")
         | 
| 21 | 
            +
              s.executables      = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
         | 
| 22 | 
            +
              s.extra_rdoc_files = ["COPYING", "README", "CHANGELOG"]
         | 
| 23 | 
            +
              s.rdoc_options     = ["--charset=UTF-8"]
         | 
| 24 | 
            +
              s.require_path     = "lib"
         | 
| 25 | 
            +
             | 
| 26 | 
            +
              s.files -= Dir['ext/**/*']
         | 
| 27 | 
            +
              s.files -= Dir['ragel/*']
         | 
| 28 | 
            +
              s.files -= Dir['lib/redcloth.jar']
         | 
| 29 | 
            +
              s.files -= Dir['lib/**/*.dll']
         | 
| 30 | 
            +
              s.files -= Dir['lib/**/*.bundle']
         | 
| 31 | 
            +
              s.files -= Dir['lib/**/*.so']
         | 
| 32 | 
            +
              
         | 
| 33 | 
            +
              s.platform = RUBY_PLATFORM[/java/] || 'ruby'
         | 
| 34 | 
            +
              case s.platform.to_s
         | 
| 35 | 
            +
              when /java/
         | 
| 36 | 
            +
                s.files += ['lib/redcloth_scan.jar']
         | 
| 37 | 
            +
              else # MRI or Rubinius
         | 
| 38 | 
            +
                s.files += %w[attributes inline scan].map {|f| "ext/redcloth_scan/redcloth_#{f}.c"}
         | 
| 39 | 
            +
                s.files += ["ext/redcloth_scan/redcloth.h"]
         | 
| 40 | 
            +
                s.extensions = Dir['ext/**/extconf.rb']
         | 
| 41 | 
            +
                s.add_development_dependency('rvm')
         | 
| 42 | 
            +
              end
         | 
| 43 | 
            +
             | 
| 44 | 
            +
              s.add_development_dependency('rake', '~> 0.8.7')
         | 
| 45 | 
            +
              s.add_development_dependency('rspec', '~> 2.1')
         | 
| 46 | 
            +
              s.add_development_dependency('diff-lcs')
         | 
| 47 | 
            +
              s.add_development_dependency('rake-compiler', '~> 0.7.1')
         | 
| 48 | 
            +
            end
         | 
| @@ -0,0 +1,15 @@ | |
| 1 | 
            +
            require File.dirname(__FILE__) + '/spec_helper'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            describe "Benchmarking", :type => :formatter do
         | 
| 4 | 
            +
              version = RedCloth::VERSION.is_a?(Module) ? RedCloth::VERSION::STRING : RedCloth::VERSION
         | 
| 5 | 
            +
              platform = RedCloth.const_defined?(:EXTENSION_LANGUAGE) ? RedCloth::EXTENSION_LANGUAGE : (version < "4.0.0" ? "ruby-regex" : "C")
         | 
| 6 | 
            +
              
         | 
| 7 | 
            +
              it "should not be too slow" do
         | 
| 8 | 
            +
                puts "Benchmarking version #{version} compiled in #{platform}..."
         | 
| 9 | 
            +
                fixtures.each do |name, doc|
         | 
| 10 | 
            +
                  if doc['html']
         | 
| 11 | 
            +
                    RedCloth.new(doc['in']).to_html
         | 
| 12 | 
            +
                  end
         | 
| 13 | 
            +
                end
         | 
| 14 | 
            +
              end
         | 
| 15 | 
            +
            end
         | 
    
        data/spec/fixtures/code.yml
    CHANGED
    
    | @@ -219,18 +219,18 @@ html: '<pre><code>Can I talk about <h2>Headings</h2> here?</code></p | |
| 219 219 | 
             
            name: escape latex standard symbols 
         | 
| 220 220 | 
             
            in: "standard symbols # $ % & _ { }" 
         | 
| 221 221 | 
             
            latex: "standard symbols \\# \\$ \\% \\& \\_ \\{ \\}\n\n" 
         | 
| 222 | 
            -
            --- | 
| 222 | 
            +
            ---
         | 
| 223 223 | 
             
            name: escape latex text symbols 
         | 
| 224 224 | 
             
            in: "text symbols \\ ~ ^" 
         | 
| 225 225 | 
             
            latex: "text symbols \\textbackslash{} \\~{} \\^{}\n\n" 
         | 
| 226 | 
            -
            --- | 
| 226 | 
            +
            ---
         | 
| 227 227 | 
             
            name: named html entities to latex 
         | 
| 228 228 | 
             
            in: "… ½" 
         | 
| 229 | 
            -
            latex: " | 
| 230 | 
            -
            --- | 
| 229 | 
            +
            latex: "\\ldots{} \\sfrac{1}{2}\n\n" 
         | 
| 230 | 
            +
            ---
         | 
| 231 231 | 
             
            name: numeric html entities to latex 
         | 
| 232 232 | 
             
            in: "… ½" 
         | 
| 233 | 
            -
            latex: " | 
| 233 | 
            +
            latex: "\\ldots{} \\sfrac{1}{2}\n\n"
         | 
| 234 234 | 
             
            ---
         | 
| 235 235 | 
             
            name: unclosed pre tag
         | 
| 236 236 | 
             
            in: '<pre><code>This is a pre that will go unfinished'
         | 
| @@ -249,7 +249,7 @@ latex: "\\verb@some_method(some_params, some => test);@ Oh dear this fails\n\n" | |
| 249 249 | 
             
            ---
         | 
| 250 250 | 
             
            name: code preserves initial square brackets
         | 
| 251 251 | 
             
            description: usually square brackets are used for the language (English, French, Spanish...), but that doesn't make sense for code and apparently is needed for some computer languages.
         | 
| 252 | 
            -
            in: @[project]_dff.skjd@ | 
| 252 | 
            +
            in: "@[project]_dff.skjd@"
         | 
| 253 253 | 
             
            html: <p><code>[project]_dff.skjd</code></p>
         | 
| 254 254 | 
             
            ---
         | 
| 255 255 | 
             
            name: following also bracketed code in same line
         | 
    
        data/spec/fixtures/table.yml
    CHANGED
    
    | @@ -348,7 +348,7 @@ html: |- | |
| 348 348 | 
             
              </table>
         | 
| 349 349 | 
             
            ---
         | 
| 350 350 | 
             
            name: with cell attributes
         | 
| 351 | 
            -
            in: |[en]. lang-ok|{color:red;}. style-ok|(myclass). class-ok|
         | 
| 351 | 
            +
            in: "|[en]. lang-ok|{color:red;}. style-ok|(myclass). class-ok|"
         | 
| 352 352 | 
             
            html: |-
         | 
| 353 353 | 
             
              <table>
         | 
| 354 354 | 
             
              	<tr>
         | 
| @@ -359,7 +359,7 @@ html: |- | |
| 359 359 | 
             
              </table>
         | 
| 360 360 | 
             
            ---
         | 
| 361 361 | 
             
            name: with improper cell attributes
         | 
| 362 | 
            -
            in: |[en]lang-bad|{color:red;}style-bad|(myclass)class-bad|
         | 
| 362 | 
            +
            in: "|[en]lang-bad|{color:red;}style-bad|(myclass)class-bad|"
         | 
| 363 363 | 
             
            html: |-
         | 
| 364 364 | 
             
              <table>
         | 
| 365 365 | 
             
              	<tr>
         | 
    
        data/spec/fixtures/textism.yml
    CHANGED
    
    | @@ -150,14 +150,14 @@ in: ~a phrase~ | |
| 150 150 | 
             
            html: <p><sub>a phrase</sub></p>
         | 
| 151 151 | 
             
            latex: "\\textsubscript{a phrase}\n\n"
         | 
| 152 152 | 
             
            ---
         | 
| 153 | 
            -
            in: %(myclass)SPAN%
         | 
| 153 | 
            +
            in: "%(myclass)SPAN%"
         | 
| 154 154 | 
             
            html: <p><span class="myclass"><span class="caps">SPAN</span></span></p>
         | 
| 155 155 | 
             
            no_span_caps_html: <p><span class="myclass">SPAN</span></p>
         | 
| 156 156 | 
             
            ---
         | 
| 157 | 
            -
            in: %{color:red}red%
         | 
| 157 | 
            +
            in: "%{color:red}red%"
         | 
| 158 158 | 
             
            html: <p><span style="color:red;">red</span></p>
         | 
| 159 159 | 
             
            ---
         | 
| 160 | 
            -
            in: %[fr]rouge%
         | 
| 160 | 
            +
            in: "%[fr]rouge%"
         | 
| 161 161 | 
             
            html: <p><span lang="fr">rouge</span></p>
         | 
| 162 162 | 
             
            ---
         | 
| 163 163 | 
             
            in: _(big)red_
         | 
    
        data/spec/fixtures/threshold.yml
    CHANGED
    
    | @@ -588,7 +588,7 @@ html: |- | |
| 588 588 | 
             
            ---
         | 
| 589 589 | 
             
            name: tables
         | 
| 590 590 | 
             
            desc: Tables can be constructed using | “pipe” symbols to separate cells.
         | 
| 591 | 
            -
            in: |a|simple|table|
         | 
| 591 | 
            +
            in: "|a|simple|table|"
         | 
| 592 592 | 
             
            html: |-
         | 
| 593 593 | 
             
              <table>
         | 
| 594 594 | 
             
              	<tr>
         | 
| @@ -619,7 +619,7 @@ html: |- | |
| 619 619 | 
             
            ---
         | 
| 620 620 | 
             
            name: cell attributes
         | 
| 621 621 | 
             
            desc: Attributes may be applied separately to individual cells, rows, and entire tables. Cell attributes are placed within each cell.
         | 
| 622 | 
            -
            in: |a|{color:red}. styled|cell|
         | 
| 622 | 
            +
            in: "|a|{color:red}. styled|cell|"
         | 
| 623 623 | 
             
            html: |-
         | 
| 624 624 | 
             
              <table>
         | 
| 625 625 | 
             
              	<tr>
         | 
| @@ -663,7 +663,7 @@ html: |- | |
| 663 663 | 
             
            ---
         | 
| 664 664 | 
             
            name: vertical alignment
         | 
| 665 665 | 
             
            desc: Special alignment symbols are available for vertical alignment within table cells.
         | 
| 666 | 
            -
            in: |^. top alignment|
         | 
| 666 | 
            +
            in: "|^. top alignment|"
         | 
| 667 667 | 
             
            html: |-
         | 
| 668 668 | 
             
              <table>
         | 
| 669 669 | 
             
              	<tr>
         | 
    
        data/spec/spec_helper.rb
    CHANGED
    
    | @@ -1,42 +1,36 @@ | |
| 1 1 | 
             
            $:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
         | 
| 2 2 | 
             
            require 'redcloth'
         | 
| 3 3 | 
             
            require 'yaml'
         | 
| 4 | 
            -
             | 
| 5 | 
            -
            class FormatterExampleGroup < Spec::Example::ExampleGroup
         | 
| 6 4 |  | 
| 7 | 
            -
             | 
| 8 | 
            -
             | 
| 9 | 
            -
             | 
| 10 | 
            -
                
         | 
| 11 | 
            -
                fixtures.each do |name, doc|
         | 
| 12 | 
            -
                  if doc[formatter]
         | 
| 13 | 
            -
                    example("should output #{formatter} for #{name}") do
         | 
| 14 | 
            -
                      output = method("format_as_#{formatter}").call(doc)
         | 
| 15 | 
            -
                      output.should == doc[formatter]
         | 
| 16 | 
            -
                    end
         | 
| 17 | 
            -
                  else
         | 
| 18 | 
            -
                    example("should not raise errors when rendering #{formatter} for #{name}") do
         | 
| 19 | 
            -
                      lambda { method("format_as_#{formatter}").call(doc) }.should_not raise_error
         | 
| 20 | 
            -
                    end
         | 
| 21 | 
            -
                  end
         | 
| 22 | 
            -
                end
         | 
| 23 | 
            -
              end
         | 
| 5 | 
            +
            def examples_from_yaml(&block)
         | 
| 6 | 
            +
              formatter = description.downcase
         | 
| 7 | 
            +
              define_method("format_as_#{formatter}", &block)
         | 
| 24 8 |  | 
| 25 | 
            -
               | 
| 26 | 
            -
                 | 
| 27 | 
            -
             | 
| 28 | 
            -
             | 
| 29 | 
            -
             | 
| 30 | 
            -
                   | 
| 31 | 
            -
             | 
| 32 | 
            -
             | 
| 33 | 
            -
                     | 
| 34 | 
            -
                    num += 1
         | 
| 9 | 
            +
              fixtures.each do |name, doc|
         | 
| 10 | 
            +
                if doc[formatter]
         | 
| 11 | 
            +
                  example("should output #{formatter} for #{name}") do
         | 
| 12 | 
            +
                    output = method("format_as_#{formatter}").call(doc)
         | 
| 13 | 
            +
                    output.should == doc[formatter]
         | 
| 14 | 
            +
                  end
         | 
| 15 | 
            +
                else
         | 
| 16 | 
            +
                  example("should not raise errors when rendering #{formatter} for #{name}") do
         | 
| 17 | 
            +
                    lambda { method("format_as_#{formatter}").call(doc) }.should_not raise_error
         | 
| 35 18 | 
             
                  end
         | 
| 36 19 | 
             
                end
         | 
| 37 | 
            -
                @fixtures
         | 
| 38 20 | 
             
              end
         | 
| 39 | 
            -
              
         | 
| 40 21 | 
             
            end
         | 
| 41 22 |  | 
| 42 | 
            -
             | 
| 23 | 
            +
            def fixtures
         | 
| 24 | 
            +
              return @fixtures if @fixtures
         | 
| 25 | 
            +
              @fixtures = {}
         | 
| 26 | 
            +
              Dir[File.join(File.dirname(__FILE__), *%w[fixtures *.yml])].each do |testfile|
         | 
| 27 | 
            +
                testgroup = File.basename(testfile, '.yml')
         | 
| 28 | 
            +
                num = 0
         | 
| 29 | 
            +
                YAML::load_documents(File.open(testfile)) do |doc|
         | 
| 30 | 
            +
                  name = doc['name'] || num
         | 
| 31 | 
            +
                  @fixtures["#{testgroup} #{name}"] = doc
         | 
| 32 | 
            +
                  num += 1
         | 
| 33 | 
            +
                end
         | 
| 34 | 
            +
              end
         | 
| 35 | 
            +
              @fixtures
         | 
| 36 | 
            +
            end
         | 
    
        data/tasks/compile.rake
    ADDED
    
    | @@ -0,0 +1,47 @@ | |
| 1 | 
            +
            CLEAN.include [
         | 
| 2 | 
            +
              'tmp',
         | 
| 3 | 
            +
              '**/*.{o,obj,class,pdb,lib,def,exp,log,rbc}',
         | 
| 4 | 
            +
              'ext/redcloth_scan/**/redcloth_*.rb', 
         | 
| 5 | 
            +
              'ext/redcloth_scan/Makefile',  'ext/redcloth_scan/extconf.rb',
         | 
| 6 | 
            +
            ]
         | 
| 7 | 
            +
            CLOBBER.include [
         | 
| 8 | 
            +
              'pkg',
         | 
| 9 | 
            +
              '**/*.{c}',
         | 
| 10 | 
            +
              'lib/*.{bundle,so,o,obj,pdb,lib,def,exp,jar}', 
         | 
| 11 | 
            +
              'lib/redcloth_scan.rb', 
         | 
| 12 | 
            +
            ]
         | 
| 13 | 
            +
             | 
| 14 | 
            +
            # Load the Gem specification for the current platform (Ruby or JRuby).
         | 
| 15 | 
            +
            def gemspec(platform = RUBY_PLATFORM[/java/] || 'ruby')
         | 
| 16 | 
            +
              Gem::Specification.load(File.expand_path('../../redcloth.gemspec', __FILE__))
         | 
| 17 | 
            +
            end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
            require 'rake/extensiontask'
         | 
| 20 | 
            +
            require 'rake/javaextensiontask'
         | 
| 21 | 
            +
            require File.dirname(__FILE__) + '/ragel_extension_task'
         | 
| 22 | 
            +
             | 
| 23 | 
            +
            if defined?(JRUBY_VERSION)
         | 
| 24 | 
            +
              Rake::JavaRagelExtensionTask.new('redcloth_scan', gemspec)
         | 
| 25 | 
            +
            else  
         | 
| 26 | 
            +
              extconf = "ext/redcloth_scan/extconf.rb"
         | 
| 27 | 
            +
              file extconf do
         | 
| 28 | 
            +
                FileUtils.mkdir(File.dirname(extconf)) unless File.directory?(File.dirname(extconf))
         | 
| 29 | 
            +
                File.open(extconf, "w") do |io|
         | 
| 30 | 
            +
                  io.write(<<-EOF)
         | 
| 31 | 
            +
            require 'mkmf'
         | 
| 32 | 
            +
            CONFIG['warnflags'].gsub!(/-Wshorten-64-to-32/, '') if CONFIG['warnflags']
         | 
| 33 | 
            +
            $CFLAGS << ' -O0 -Wall' if CONFIG['CC'] =~ /gcc/
         | 
| 34 | 
            +
            dir_config("redcloth_scan")
         | 
| 35 | 
            +
            have_library("c", "main")
         | 
| 36 | 
            +
            create_makefile("redcloth_scan")
         | 
| 37 | 
            +
                  EOF
         | 
| 38 | 
            +
                end
         | 
| 39 | 
            +
              end
         | 
| 40 | 
            +
             | 
| 41 | 
            +
              Rake::RagelExtensionTask.new("redcloth_scan", gemspec) do |ext|    
         | 
| 42 | 
            +
                if ENV['RUBY_CC_VERSION']
         | 
| 43 | 
            +
                  ext.cross_compile = true
         | 
| 44 | 
            +
                  ext.cross_platform = ['i386-mingw32', 'i386-mswin32-60']
         | 
| 45 | 
            +
                end
         | 
| 46 | 
            +
              end
         | 
| 47 | 
            +
            end
         | 
    
        data/tasks/gems.rake
    ADDED
    
    | @@ -0,0 +1,38 @@ | |
| 1 | 
            +
            Rake::Task['build'].prerequisites.unshift('compile')
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            namespace :build do
         | 
| 4 | 
            +
                desc "Generate Windows binary gems"
         | 
| 5 | 
            +
                task :win do
         | 
| 6 | 
            +
                  unless File.directory?(File.expand_path('~/.rake-compiler'))
         | 
| 7 | 
            +
                    STDERR.puts <<-EOM
         | 
| 8 | 
            +
             | 
| 9 | 
            +
              You must install Windows rubies to ~/.rake-compiler with:
         | 
| 10 | 
            +
             | 
| 11 | 
            +
                rake-compiler cross-ruby VERSION=1.8.6-p398
         | 
| 12 | 
            +
                # (Later 1.9.1 patch levels don't compile on mingw) 
         | 
| 13 | 
            +
                rake-compiler cross-ruby VERSION=1.9.1-p243
         | 
| 14 | 
            +
              EOM
         | 
| 15 | 
            +
                    exit(1)
         | 
| 16 | 
            +
                  end
         | 
| 17 | 
            +
                  # rvm and mingw ruby versions have to match to avoid errors
         | 
| 18 | 
            +
                  sh "rvm ruby-1.8.6-p398@redcloth rake cross compile RUBY_CC_VERSION=1.8.6"
         | 
| 19 | 
            +
                  sh "rvm ruby-1.9.1-p243@redcloth rake cross compile RUBY_CC_VERSION=1.9.1"
         | 
| 20 | 
            +
                  # This will copy the .so files to the proper place
         | 
| 21 | 
            +
                  sh "rake cross native gem RUBY_CC_VERSION=1.8.6:1.9.1"
         | 
| 22 | 
            +
                end
         | 
| 23 | 
            +
             | 
| 24 | 
            +
                desc 'Generate JRuby binary gem'
         | 
| 25 | 
            +
                task :jruby do
         | 
| 26 | 
            +
                  sh "rvm jruby@redcloth rake java gem"
         | 
| 27 | 
            +
                end
         | 
| 28 | 
            +
             | 
| 29 | 
            +
                desc "Build ruby, windows, and jruby gems into the pkg directory"
         | 
| 30 | 
            +
                task :all => [
         | 
| 31 | 
            +
                  "rvm:bundle",
         | 
| 32 | 
            +
                  :clobber,
         | 
| 33 | 
            +
                  :spec,
         | 
| 34 | 
            +
                  :jruby,
         | 
| 35 | 
            +
                  :win,
         | 
| 36 | 
            +
                  :build
         | 
| 37 | 
            +
                ]
         | 
| 38 | 
            +
            end
         | 
| @@ -0,0 +1,127 @@ | |
| 1 | 
            +
            module Rake
         | 
| 2 | 
            +
              module RagelGenerationTasks
         | 
| 3 | 
            +
                RAGEL_INCLUDE_PATTERN = /include \w+ "([^"]+)";/
         | 
| 4 | 
            +
                RAGEL_VERSION_COMMAND = "ragel -v"
         | 
| 5 | 
            +
                
         | 
| 6 | 
            +
                attr_accessor :rl_dir
         | 
| 7 | 
            +
                attr_accessor :machines
         | 
| 8 | 
            +
                
         | 
| 9 | 
            +
                def init(name = nil, gem_spec = nil)
         | 
| 10 | 
            +
                  super
         | 
| 11 | 
            +
                  
         | 
| 12 | 
            +
                  @rl_dir = "ragel"
         | 
| 13 | 
            +
                  @machines = %w(scan inline attributes)
         | 
| 14 | 
            +
                end
         | 
| 15 | 
            +
                
         | 
| 16 | 
            +
                def lang
         | 
| 17 | 
            +
                  raise NotImplementedError
         | 
| 18 | 
            +
                end
         | 
| 19 | 
            +
                
         | 
| 20 | 
            +
                def source_files
         | 
| 21 | 
            +
                  @source_files ||= machines.map {|m| target(m) }
         | 
| 22 | 
            +
                end
         | 
| 23 | 
            +
                
         | 
| 24 | 
            +
                def define
         | 
| 25 | 
            +
                  super
         | 
| 26 | 
            +
                  define_ragel_tasks
         | 
| 27 | 
            +
                end
         | 
| 28 | 
            +
                
         | 
| 29 | 
            +
                def define_ragel_tasks
         | 
| 30 | 
            +
                  machines.each do |machine|
         | 
| 31 | 
            +
                    file target(machine) => [*ragel_sources(machine)] do
         | 
| 32 | 
            +
                      mkdir_p(File.dirname(target(machine))) unless File.directory?(File.dirname(target(machine)))
         | 
| 33 | 
            +
                      ensure_ragel_version
         | 
| 34 | 
            +
                      sh "ragel #{flags} #{lang_ragel(machine)} -o #{target(machine)}"
         | 
| 35 | 
            +
                    end
         | 
| 36 | 
            +
                    
         | 
| 37 | 
            +
                    file extconf => [target(machine)] if lang == 'c'
         | 
| 38 | 
            +
                  end
         | 
| 39 | 
            +
                end
         | 
| 40 | 
            +
             | 
| 41 | 
            +
                def target(machine)
         | 
| 42 | 
            +
                  {
         | 
| 43 | 
            +
                    'scan' => {
         | 
| 44 | 
            +
                      'c'    => "#{@ext_dir}/redcloth_scan.c",
         | 
| 45 | 
            +
                      'java' => "#{@ext_dir}/RedclothScanService.java",
         | 
| 46 | 
            +
                      'rb'   => "#{@ext_dir}/redcloth_scan.rb"
         | 
| 47 | 
            +
                    },
         | 
| 48 | 
            +
                    'inline' => {
         | 
| 49 | 
            +
                      'c'    => "#{@ext_dir}/redcloth_inline.c",
         | 
| 50 | 
            +
                      'java' => "#{@ext_dir}/RedclothInline.java",
         | 
| 51 | 
            +
                      'rb'   => "#{@ext_dir}/redcloth_inline.rb"
         | 
| 52 | 
            +
                    },
         | 
| 53 | 
            +
                    'attributes' => {
         | 
| 54 | 
            +
                      'c'    => "#{@ext_dir}/redcloth_attributes.c",
         | 
| 55 | 
            +
                      'java' => "#{@ext_dir}/RedclothAttributes.java",
         | 
| 56 | 
            +
                      'rb'   => "#{@ext_dir}/redcloth_attributes.rb"
         | 
| 57 | 
            +
                    }
         | 
| 58 | 
            +
                  }[machine][lang]
         | 
| 59 | 
            +
                end
         | 
| 60 | 
            +
             | 
| 61 | 
            +
                def lang_ragel(machine)
         | 
| 62 | 
            +
                  "#{@rl_dir}/redcloth_#{machine}.#{lang}.rl"
         | 
| 63 | 
            +
                end
         | 
| 64 | 
            +
             | 
| 65 | 
            +
                def ragel_sources(machine)
         | 
| 66 | 
            +
                  deps = [lang_ragel(machine), ragel_file_dependencies(lang_ragel(machine))].flatten.dup
         | 
| 67 | 
            +
                  deps += ["#{@ext_dir}/redcloth.h"] if lang == 'c'
         | 
| 68 | 
            +
                  deps
         | 
| 69 | 
            +
                  # FIXME: merge that header file into other places so it can be eliminated?
         | 
| 70 | 
            +
                end
         | 
| 71 | 
            +
                
         | 
| 72 | 
            +
                def ragel_file_dependencies(ragel_file)
         | 
| 73 | 
            +
                  found = find_ragel_includes(ragel_file)
         | 
| 74 | 
            +
                  found + found.collect {|file| ragel_file_dependencies(file)}
         | 
| 75 | 
            +
                end
         | 
| 76 | 
            +
                
         | 
| 77 | 
            +
                def find_ragel_includes(file)
         | 
| 78 | 
            +
                  File.open(file).grep(RAGEL_INCLUDE_PATTERN) { $1 }.map do |file|
         | 
| 79 | 
            +
                    "#{@rl_dir}/#{file}"
         | 
| 80 | 
            +
                  end
         | 
| 81 | 
            +
                end
         | 
| 82 | 
            +
             | 
| 83 | 
            +
                def flags
         | 
| 84 | 
            +
                  code_style_flag = preferred_code_style ? " -" + preferred_code_style : ""
         | 
| 85 | 
            +
                  "-#{host_language_flag}#{code_style_flag}"
         | 
| 86 | 
            +
                end
         | 
| 87 | 
            +
             | 
| 88 | 
            +
                def host_language_flag
         | 
| 89 | 
            +
                  {
         | 
| 90 | 
            +
                    'c'      => 'C',
         | 
| 91 | 
            +
                    'java'   => 'J',
         | 
| 92 | 
            +
                    'rb'     => 'R'
         | 
| 93 | 
            +
                  }[lang]
         | 
| 94 | 
            +
                end
         | 
| 95 | 
            +
             | 
| 96 | 
            +
                def preferred_code_style
         | 
| 97 | 
            +
                  {
         | 
| 98 | 
            +
                    'c'      => 'T0',
         | 
| 99 | 
            +
                    'java'   => nil,
         | 
| 100 | 
            +
                    'rb'     => 'F1'
         | 
| 101 | 
            +
                  }[lang]
         | 
| 102 | 
            +
                end
         | 
| 103 | 
            +
             | 
| 104 | 
            +
                def ensure_ragel_version
         | 
| 105 | 
            +
                  @ragel_v ||= `ragel -v`[/(version )(\S*)/,2].split('.').map{|s| s.to_i}
         | 
| 106 | 
            +
                  raise unless @ragel_v[0] > 6 || (@ragel_v[0] == 6 && @ragel_v[1] >= 3)
         | 
| 107 | 
            +
                rescue
         | 
| 108 | 
            +
                  STDERR.puts "Ragel 6.3 or greater is required."
         | 
| 109 | 
            +
                  exit(1)
         | 
| 110 | 
            +
                end
         | 
| 111 | 
            +
                
         | 
| 112 | 
            +
              end
         | 
| 113 | 
            +
              class RagelExtensionTask < ExtensionTask
         | 
| 114 | 
            +
                include RagelGenerationTasks
         | 
| 115 | 
            +
             | 
| 116 | 
            +
                def lang
         | 
| 117 | 
            +
                  "c"
         | 
| 118 | 
            +
                end
         | 
| 119 | 
            +
              end  
         | 
| 120 | 
            +
              class JavaRagelExtensionTask < JavaExtensionTask
         | 
| 121 | 
            +
                include RagelGenerationTasks
         | 
| 122 | 
            +
                
         | 
| 123 | 
            +
                def lang
         | 
| 124 | 
            +
                  "java"
         | 
| 125 | 
            +
                end
         | 
| 126 | 
            +
              end
         | 
| 127 | 
            +
            end
         |