Sha256: 23f7bdd8c6b802c26ee7f07f429a61326e56361c495a365f93b1b460668c8781
Contents?: true
Size: 726 Bytes
Versions: 3
Compression:
Stored size: 726 Bytes
Contents
# -*- coding: utf-8 -*- # module Rouge module Formatters class HTMLLinewise < Formatter def initialize(formatter, opts={}) @formatter = formatter @class_format = opts.fetch(:class, '%i') end def stream(tokens, &b) yield "<span class=#{next_line_class}>" tokens.each do |tok, val| val.scan /\n|[^\n]+/ do |s| if s == "\n" yield "</span>\n<span class=#{next_line_class}>" else @formatter.span(tok, s) end end end yield "</span>" end def next_line_class @lineno ||= -1 sprintf(@class_format, @lineno += 1).inspect end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
rouge-1.10.1 | lib/rouge/formatters/html_linewise.rb |
rouge-1.10.0 | lib/rouge/formatters/html_linewise.rb |
rouge-1.9.1 | lib/rouge/formatters/html_linewise.rb |