Sha256: 0ce04160489947c2680c54cd0f9059c677543afdef5fddf56e22eed2c754ffef
Contents?: true
Size: 633 Bytes
Versions: 24
Compression:
Stored size: 633 Bytes
Contents
# -*- coding: utf-8 -*- # # frozen_string_literal: true module Rouge module Formatters class HTMLLinewise < Formatter def initialize(formatter, opts={}) @formatter = formatter @tag_name = opts.fetch(:tag_name, 'div') @class_format = opts.fetch(:class, 'line-%i') end def stream(tokens, &b) lineno = 0 token_lines(tokens) do |line_tokens| yield %(<#{@tag_name} class="#{sprintf @class_format, lineno += 1}">) @formatter.stream(line_tokens) {|formatted| yield formatted } yield %(\n</#{@tag_name}>) end end end end end
Version data entries
24 entries across 24 versions & 1 rubygems