Sha256: e3303da17e585e927d4cb2a8063860361c61049f723cee7dc49c303dda44d7eb
Contents?: true
Size: 1.13 KB
Versions: 1
Compression:
Stored size: 1.13 KB
Contents
# frozen_string_literal: true require 'pygments.rb' # rubocop:disable Style/RedundantFileExtensionInRequire module Pygments module Ext module BlockStyles BlockSelectorRx = /^\.highlight *\{([^}]+?)\}/ HighlightBackgroundColorRx = /^\.highlight +\.hll +{ *background(?:-color)?: *#([a-fA-F0-9]{6})/ HexColorRx = /^#[a-fA-F0-9]{6}$/ @cache = ::Hash.new do |cache, key| styles = {} if BlockSelectorRx =~ (css = ::Pygments.css '.highlight', style: key) ($1.strip.split ';').each do |style| pname, pval = (style.split ':', 2).map(&:strip) case pname when 'background', 'background-color' styles[:background_color] = pval.slice 1, pval.length if HexColorRx.match? pval when 'color' styles[:font_color] = pval.slice 1, pval.length if HexColorRx.match? pval end end end styles[:highlight_background_color] = $1 if HighlightBackgroundColorRx =~ css @cache = cache.merge key => styles styles end def self.for style @cache[style] end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
asciidoctor-pdf-1.5.4 | lib/asciidoctor/pdf/ext/pygments.rb |