Sha256: 2b62b0e03bbf8b8f73b0ca0629946abcc56ece6248bd3e85ac5f0e18d552ef0c
Contents?: true
Size: 809 Bytes
Versions: 7
Compression:
Stored size: 809 Bytes
Contents
# frozen_string_literal: true module Asciidoctor module Image DataUriRx = /^data:image\/(?<fmt>png|jpe?g|gif|pdf|bmp|tiff);base64,(?<data>.*)$/ class << self def format path, attributes = nil (attributes && attributes['format']) || ((ext = ::File.extname path).downcase.slice 1, ext.length) end end def format (attr 'format', nil, false) || ((ext = ::File.extname(inline? ? target : (attr 'target'))).downcase.slice 1, ext.length) end def target_and_format image_path = inline? ? target : (attr 'target') if (image_path.start_with? 'data:') && (m = DataUriRx.match image_path) [(m[:data].extend ::Base64), m[:fmt]] else [image_path, (attr 'format', nil, false) || ((ext = ::File.extname image_path).downcase.slice 1, ext.length)] end end end end
Version data entries
7 entries across 7 versions & 1 rubygems