def save_attributes
if (attrs = @attributes)['basebackend'] == 'docbook'
attrs['toc'] = '' unless attribute_locked?('toc') || @attributes_modified.include?('toc')
attrs['sectnums'] = '' unless attribute_locked?('sectnums') || @attributes_modified.include?('sectnums')
end
unless attrs.key?('doctitle') || !(val = doctitle)
attrs['doctitle'] = val
end
@id = attrs['css-signature'] unless @id
toc_position_val = if (toc_val = (attrs.delete('toc2') ? 'left' : attrs['toc']))
(toc_placement = attrs.fetch('toc-placement', 'macro')) && toc_placement != 'auto' ? toc_placement : attrs['toc-position']
else
nil
end
if toc_val && (!toc_val.empty? || !toc_position_val.nil_or_empty?)
default_toc_position = 'left'
default_toc_class = 'toc2'
if !toc_position_val.nil_or_empty?
position = toc_position_val
elsif !toc_val.empty?
position = toc_val
else
position = default_toc_position
end
attrs['toc'] = ''
attrs['toc-placement'] = 'auto'
case position
when 'left', '<', '<'
attrs['toc-position'] = 'left'
when 'right', '>', '>'
attrs['toc-position'] = 'right'
when 'top', '^'
attrs['toc-position'] = 'top'
when 'bottom', 'v'
attrs['toc-position'] = 'bottom'
when 'preamble', 'macro'
attrs['toc-position'] = 'content'
attrs['toc-placement'] = position
default_toc_class = nil
else
attrs.delete 'toc-position'
default_toc_class = nil
end
attrs['toc-class'] ||= default_toc_class if default_toc_class
end
if attrs.key? 'compat-mode'
attrs['source-language'] = attrs['language'] if attrs.has_key? 'language'
@compat_mode = true
else
@compat_mode = false
end
@outfilesuffix = attrs['outfilesuffix']
@header_attributes = attrs.dup
unless @parent_document
FLEXIBLE_ATTRIBUTES.each do |name|
if @attribute_overrides.key?(name) && @attribute_overrides[name]
@attribute_overrides.delete(name)
end
end
end
end