Class: Coradoc::Docx::Transform::Rules::TextRule

Inherits:
Coradoc::Docx::Transform::Rule show all
Defined in:
lib/coradoc/docx/transform/rules/text_rule.rb

Overview

Transforms w:t (Text) elements to plain strings.

Text is returned as a raw string — not wrapped in a CoreModel node. The caller (RunRule) is responsible for wrapping in InlineElement when formatting is present.

Instance Method Summary collapse

Methods inherited from Coradoc::Docx::Transform::Rule

#priority

Instance Method Details

#apply(text, _context) ⇒ Object



18
19
20
# File 'lib/coradoc/docx/transform/rules/text_rule.rb', line 18

def apply(text, _context)
  text.content.to_s
end

#matches?(element) ⇒ Boolean

Returns:

  • (Boolean)


13
14
15
16
# File 'lib/coradoc/docx/transform/rules/text_rule.rb', line 13

def matches?(element)
  defined?(Uniword::Wordprocessingml::Text) &&
    element.is_a?(Uniword::Wordprocessingml::Text)
end