def inline_quoted node
open, close, is_tag = QUOTE_TAGS[node.type]
if node.role
if is_tag
quoted_text = %(#{open.chop} class="#{node.role}">#{node.text}#{close})
else
quoted_text = %(<span class="#{node.role}">#{open}#{node.text}#{close}</span>)
end
else
quoted_text = %(#{open}#{node.text}#{close})
end
node.id ? %(<a id="#{node.id}"></a>#{quoted_text}) : quoted_text
end
def append_boolean_attribute name, xml
xml ? %( #{name}="#{name}") : %( #{name})
end
def encode_quotes val
(val.include? '"') ? (val.gsub '"', '"') : val
end
def read_svg_contents node, target
if (svg = node.read_contents target, :start => (node.document.attr 'imagesdir'), :normalize => true, :label => 'SVG')
svg = svg.sub SvgPreambleRx, '' unless svg.start_with? '<svg'
old_start_tag = new_start_tag = nil
# NOTE width, height and style attributes are removed if either width or height is specified
['width', 'height'].each do |dim|
if node.attr? dim
new_start_tag = (old_start_tag = (svg.match SvgStartTagRx)[0]).gsub DimensionAttributeRx, '' unless new_start_tag
# QUESTION should we add px since it's already the default?
new_start_tag = %(#{new_start_tag.chop} #{dim}="#{node.attr dim}px">)
end
end
svg = %(#{new_start_tag}#{svg[old_start_tag.length..-1]}) if new_start_tag
end
svg
end
end
end