Sha256: 0245600f7322d62443c8b958f995c0efeef8ed7676e0e390201dc0d7195069de
Contents?: true
Size: 903 Bytes
Versions: 1
Compression:
Stored size: 903 Bytes
Contents
# frozen_string_literal: true require 'rouge' module LsifParser # Highlight hovers class Highlight # HTML formatter for a hover class HTMLGitlab < Rouge::Formatters::HTML tag 'html_gitlab' def initialize(tag: nil) @line_number = 1 @tag = tag end def stream(tokens) is_first = true token_lines(tokens) do |line| yield "\n" unless is_first is_first = false yield %(<span id="LC#{@line_number}" class="line" lang="#{@tag}">) line.each { |token, value| yield span(token, value.chomp) } yield %(</span>) @line_number += 1 end end end def self.run(hover) lexer = Rouge::Lexer.find_fancy(hover['language']) tag = lexer.tag tokens = lexer.lex(hover['value'], continue: false) HTMLGitlab.format(tokens, tag: tag) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
lsif_parser-0.1.0 | lib/lsif_parser/highlight.rb |