Sha256: a3404e6def48e9bdf212656d30b402ce52c0938ee174f17b45dbe12268cfb7b4

Contents?: true

Size: 1.35 KB

Versions: 24

Compression:

Stored size: 1.35 KB

Contents

# -*- coding: utf-8 -*- #

# stdlib
require 'cgi'

module Rouge
  module Formatters
    # Transforms a token stream into HTML output.
    class HTMLLegacy < Formatter
      tag 'html_legacy'

      # @option opts [String] :css_class ('highlight')
      # @option opts [true/false] :line_numbers (false)
      # @option opts [Rouge::CSSTheme] :inline_theme (nil)
      # @option opts [true/false] :wrap (true)
      #
      # Initialize with options.
      #
      # If `:inline_theme` is given, then instead of rendering the
      # tokens as <span> tags with CSS classes, the styles according to
      # the given theme will be inlined in "style" attributes.  This is
      # useful for formats in which stylesheets are not available.
      #
      # Content will be wrapped in a tag (`div` if tableized, `pre` if
      # not) with the given `:css_class` unless `:wrap` is set to `false`.
      def initialize(opts={})
        @formatter = opts[:inline_theme] ? HTMLInline.new(opts[:inline_theme])
                   : HTML.new


        @formatter = HTMLTable.new(@formatter, opts) if opts[:line_numbers]

        if opts.fetch(:wrap, true)
          @formatter = HTMLPygments.new(@formatter, opts.fetch(:css_class, 'codehilite'))
        end
      end

      # @yield the html output.
      def stream(tokens, &b)
        @formatter.stream(tokens, &b)
      end
    end
  end
end

Version data entries

24 entries across 22 versions & 5 rubygems

Version Path
files.com-1.0.55 docs/vendor/bundle/ruby/2.5.0/gems/rouge-2.2.1/lib/rouge/formatters/html_legacy.rb
rouge-3.2.1 lib/rouge/formatters/html_legacy.rb
rouge-3.2.0 lib/rouge/formatters/html_legacy.rb
rouge_ecl-1.0.0 lib/rouge/formatters/html_legacy.rb
rouge_ecl-0.0.1 lib/rouge/formatters/html_legacy.rb
rouge-3.1.1 lib/rouge/formatters/html_legacy.rb
rouge-3.1.0 lib/rouge/formatters/html_legacy.rb
rouge-3.0.0 lib/rouge/formatters/html_legacy.rb
rouge-2.2.1 lib/rouge/formatters/html_legacy.rb
rouge-2.2.0 lib/rouge/formatters/html_legacy.rb
rougegal-2.1.2 lib/rouge/formatters/html_legacy.rb
tdiary-5.0.5 vendor/bundle/gems/tdiary-5.0.4/vendor/bundle/gems/rouge-2.0.7/lib/rouge/formatters/html_legacy.rb
tdiary-5.0.5 vendor/bundle/gems/rouge-2.0.7/lib/rouge/formatters/html_legacy.rb
tdiary-5.0.5 vendor/bundle/gems/rouge-2.1.1/lib/rouge/formatters/html_legacy.rb
rouge-2.1.1 lib/rouge/formatters/html_legacy.rb
rouge-2.1.0 lib/rouge/formatters/html_legacy.rb
tdiary-5.0.4 vendor/bundle/gems/rouge-2.0.7/lib/rouge/formatters/html_legacy.rb
rouge-2.0.7 lib/rouge/formatters/html_legacy.rb
rouge-2.0.6 lib/rouge/formatters/html_legacy.rb
rouge-2.0.5 lib/rouge/formatters/html_legacy.rb