Sha256: 830be62dd2df2b7f8531b1316f84deffde56ea680e66a729dc52e3cf47e898fb

Contents?: true

Size: 527 Bytes

Versions: 1

Compression:

Stored size: 527 Bytes

Contents

module Repper
  module Format
    # A structured and colorized format with annotations about token types.
    Annotated = ->(tokens, theme) do
      table = Tabulo::Table.new(tokens.reject(&:whitespace?), **TABULO_STYLE)
      table.add_column(
        :indented_text,
        styler: ->(_, string, cell) { theme.colorize(string, cell.source.type) }
      )
      table.add_column(
        :annotation,
        styler: ->(_, string, cell) { theme.colorize(string, :annotation) }
      )
      table.pack.to_s
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
repper-1.1.0 lib/repper/format/annotated.rb