Class: Uniword::Mhtml::StylesConfiguration

Inherits:
Lutaml::Model::Serializable
  • Object
show all
Defined in:
lib/uniword/mhtml/styles_configuration.rb

Overview

MHTML-specific Styles Configuration class

This is SEPARATE from OOXML WordprocessingML StylesConfiguration. MHTML uses HTML/CSS for styling, not OOXML style parts.

This class manages style definitions for MHTML documents and provides CSS output for MHTML serialization.

Instance Method Summary collapse

Instance Method Details

#add_style(name, properties) ⇒ Object

MHTML-specific: Add a style

Parameters:

  • name (String)

    Style name

  • properties (Hash)

    CSS properties



45
46
47
# File 'lib/uniword/mhtml/styles_configuration.rb', line 45

def add_style(name, properties)
  styles[name.to_s] = properties
end

#style(name) ⇒ Hash?

MHTML-specific: Get style by name

Parameters:

  • name (String)

    Style name

Returns:

  • (Hash, nil)

    Style properties



37
38
39
# File 'lib/uniword/mhtml/styles_configuration.rb', line 37

def style(name)
  styles[name.to_s]
end

#to_cssString

MHTML-specific: Convert styles to CSS

Returns:

  • (String)

    CSS stylesheet content



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/uniword/mhtml/styles_configuration.rb', line 21

def to_css
  css = +""
  styles.each do |name, properties|
    css << ".#{name} {\n"
    properties.each do |prop, value|
      css << "  #{prop_to_css(prop)}: #{value};\n"
    end
    css << "}\n\n"
  end
  css
end