rouge 1.2.0 → 1.3.0
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.
- data/bin/rougify +0 -1
- data/lib/rouge/cli.rb +10 -7
- data/lib/rouge/formatters/html.rb +2 -2
- data/lib/rouge/lexers/html.rb +1 -1
- data/lib/rouge/lexers/ocaml.rb +1 -1
- data/lib/rouge/plugins/redcarpet.rb +6 -1
- data/lib/rouge/theme.rb +0 -2
- data/lib/rouge/version.rb +1 -1
- metadata +2 -2
    
        data/bin/rougify
    CHANGED
    
    
    
        data/lib/rouge/cli.rb
    CHANGED
    
    | @@ -75,10 +75,14 @@ module Rouge | |
| 75 75 | 
             
                def initialize(options={})
         | 
| 76 76 | 
             
                end
         | 
| 77 77 |  | 
| 78 | 
            -
                def error!(msg, status=1)
         | 
| 78 | 
            +
                def self.error!(msg, status=1)
         | 
| 79 79 | 
             
                  raise Error.new(msg, status)
         | 
| 80 80 | 
             
                end
         | 
| 81 81 |  | 
| 82 | 
            +
                def error!(*a)
         | 
| 83 | 
            +
                  self.class.error!(*a)
         | 
| 84 | 
            +
                end
         | 
| 85 | 
            +
             | 
| 82 86 | 
             
                def self.class_from_arg(arg)
         | 
| 83 87 | 
             
                  case arg
         | 
| 84 88 | 
             
                  when 'version', '--version'
         | 
| @@ -237,20 +241,18 @@ module Rouge | |
| 237 241 | 
             
                    @lexer_opts = opts[:lexer_opts]
         | 
| 238 242 |  | 
| 239 243 | 
             
                    formatter_class = Formatter.find(opts[:formatter]) \
         | 
| 240 | 
            -
                      or error! | 
| 244 | 
            +
                      or error! "unknown formatter #{opts[:formatter]}"
         | 
| 241 245 |  | 
| 242 246 | 
             
                    @formatter = formatter_class.new(opts[:formatter_opts])
         | 
| 243 247 | 
             
                  end
         | 
| 244 248 |  | 
| 245 249 | 
             
                  def run
         | 
| 246 | 
            -
                    formatter.format(lexer.lex(input)) | 
| 247 | 
            -
                      print chunk
         | 
| 248 | 
            -
                    end
         | 
| 250 | 
            +
                    formatter.format(lexer.lex(input), &method(:print))
         | 
| 249 251 | 
             
                  end
         | 
| 250 252 |  | 
| 251 253 | 
             
                private
         | 
| 252 254 | 
             
                  def self.parse_cgi(str)
         | 
| 253 | 
            -
                    pairs = CGI.parse(str).map { |k, v| v.first }
         | 
| 255 | 
            +
                    pairs = CGI.parse(str).map { |k, v| [k.to_sym, v.first] }
         | 
| 254 256 | 
             
                    Hash[pairs]
         | 
| 255 257 | 
             
                  end
         | 
| 256 258 | 
             
                end
         | 
| @@ -289,7 +291,8 @@ module Rouge | |
| 289 291 | 
             
                  end
         | 
| 290 292 |  | 
| 291 293 | 
             
                  def initialize(opts)
         | 
| 292 | 
            -
                     | 
| 294 | 
            +
                    theme_name = opts.delete(:theme_name)
         | 
| 295 | 
            +
                    theme_class = Theme.find(theme_name) \
         | 
| 293 296 | 
             
                      or error! "unknown theme: #{theme_name}"
         | 
| 294 297 |  | 
| 295 298 | 
             
                    @theme = theme_class.new(opts)
         | 
| @@ -69,10 +69,10 @@ module Rouge | |
| 69 69 | 
             
                    end.join
         | 
| 70 70 |  | 
| 71 71 | 
             
                    yield "<div class=#{@css_class.inspect}>" if @wrap
         | 
| 72 | 
            -
                    yield  | 
| 72 | 
            +
                    yield '<table style="border-spacing: 0"><tbody><tr>'
         | 
| 73 73 |  | 
| 74 74 | 
             
                    # the "gl" class applies the style for Generic.Lineno
         | 
| 75 | 
            -
                    yield '<td class="gutter gl">'
         | 
| 75 | 
            +
                    yield '<td class="gutter gl" style="text-align: right">'
         | 
| 76 76 | 
             
                    yield numbers
         | 
| 77 77 | 
             
                    yield '</td>'
         | 
| 78 78 |  | 
    
        data/lib/rouge/lexers/html.rb
    CHANGED
    
    | @@ -14,7 +14,7 @@ module Rouge | |
| 14 14 | 
             
                  state :root do
         | 
| 15 15 | 
             
                    rule /[^<&]+/m, Text
         | 
| 16 16 | 
             
                    rule /&\S*?;/, Name::Entity
         | 
| 17 | 
            -
                    rule /<!DOCTYPE .*?>/ | 
| 17 | 
            +
                    rule /<!DOCTYPE .*?>/im, Comment::Preproc
         | 
| 18 18 | 
             
                    rule /<!\[CDATA\[.*?\]\]>/m, Comment::Preproc
         | 
| 19 19 | 
             
                    rule /<!--/, Comment, :comment
         | 
| 20 20 | 
             
                    rule /<\?.*?\?>/m, Comment::Preproc # php? really?
         | 
    
        data/lib/rouge/lexers/ocaml.rb
    CHANGED
    
    
| @@ -15,12 +15,17 @@ module Rouge | |
| 15 15 | 
             
                      code.gsub! /^    /, "\t"
         | 
| 16 16 | 
             
                    end
         | 
| 17 17 |  | 
| 18 | 
            -
                    formatter =  | 
| 18 | 
            +
                    formatter = rouge_formatter(
         | 
| 19 19 | 
             
                      :css_class => "highlight #{lexer.tag}"
         | 
| 20 20 | 
             
                    )
         | 
| 21 21 |  | 
| 22 22 | 
             
                    formatter.format(lexer.lex(code))
         | 
| 23 23 | 
             
                  end
         | 
| 24 | 
            +
             | 
| 25 | 
            +
                protected
         | 
| 26 | 
            +
                  def rouge_formatter(opts={})
         | 
| 27 | 
            +
                    Formatters::HTML.new(opts)
         | 
| 28 | 
            +
                  end
         | 
| 24 29 | 
             
                end
         | 
| 25 30 | 
             
              end
         | 
| 26 31 | 
             
            end
         | 
    
        data/lib/rouge/theme.rb
    CHANGED
    
    | @@ -140,10 +140,8 @@ module Rouge | |
| 140 140 | 
             
                  return enum_for(:render).to_a.join("\n") unless b
         | 
| 141 141 |  | 
| 142 142 | 
             
                  # shared styles for tableized line numbers
         | 
| 143 | 
            -
                  yield "#{@scope} table { border-spacing: 0; }"
         | 
| 144 143 | 
             
                  yield "#{@scope} table td { padding: 5px; }"
         | 
| 145 144 | 
             
                  yield "#{@scope} table pre { margin: 0; }"
         | 
| 146 | 
            -
                  yield "#{@scope} table .gutter { text-align: right; }"
         | 
| 147 145 |  | 
| 148 146 | 
             
                  styles.each do |tok, style|
         | 
| 149 147 | 
             
                    style.render(css_selector(tok), &b)
         | 
    
        data/lib/rouge/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: rouge
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 1. | 
| 4 | 
            +
              version: 1.3.0
         | 
| 5 5 | 
             
              prerelease: 
         | 
| 6 6 | 
             
            platform: ruby
         | 
| 7 7 | 
             
            authors:
         | 
| @@ -9,7 +9,7 @@ authors: | |
| 9 9 | 
             
            autorequire: 
         | 
| 10 10 | 
             
            bindir: bin
         | 
| 11 11 | 
             
            cert_chain: []
         | 
| 12 | 
            -
            date: 2013- | 
| 12 | 
            +
            date: 2013-12-23 00:00:00.000000000 Z
         | 
| 13 13 | 
             
            dependencies: []
         | 
| 14 14 | 
             
            description: Rouge aims to a be a simple, easy-to-extend drop-in replacement for pygments.
         | 
| 15 15 | 
             
            email:
         |