Class: Middleman::Syntax::Formatters::HTML
- Inherits:
-
Rouge::Formatter
- Object
- Rouge::Formatter
- Middleman::Syntax::Formatters::HTML
- Defined in:
- lib/middleman-syntax/formatters.rb
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ HTML
constructor
A new instance of HTML.
- #stream(tokens, &block) ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ HTML
Returns a new instance of HTML.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/middleman-syntax/formatters.rb', line 7 def initialize(opts={}) @formatter = if opts[:inline_theme] Rouge::Formatters::HTMLInline.new(opts[:inline_theme]) else Rouge::Formatters::HTML.new end @formatter = Rouge::Formatters::HTMLTable.new(@formatter, opts) if opts[:line_numbers] @formatter = Rouge::Formatters::HTMLLinewise.new(@formatter, class:'line-%i') if opts[:line_numbers_div] if opts.fetch(:wrap, true) css_class = opts.fetch(:css_class, 'codehilite') # Add custom classes to the pre element if opts[:extra_css_classes] && !opts[:extra_css_classes].empty? extra_css_classes = opts[:extra_css_classes].is_a?(Array) ? opts[:extra_css_classes] : opts[:extra_css_classes].to_s.split # Include the custom classes in the css_class parameter css_class = [css_class].concat(extra_css_classes).join(' ') end @formatter = Rouge::Formatters::HTMLPygments.new(@formatter, css_class) end end |
Instance Method Details
#stream(tokens, &block) ⇒ Object
32 33 34 |
# File 'lib/middleman-syntax/formatters.rb', line 32 def stream(tokens, &block) @formatter.stream(tokens, &block) end |