Class: Coradoc::Docx::Transform::Rules::FootnoteRule

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

Overview

Transforms w:footnoteReference to CoreModel::FootnoteReference.

Footnote content is looked up from the context’s footnotes map, which is populated by the ToCoreModel orchestrator before transforming body elements.

Instance Method Summary collapse

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

#priority

Instance Method Details

#apply(ref, _context) ⇒ Object



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

def apply(ref, _context)
  id = ref.id&.to_s

  CoreModel::FootnoteReference.new(id: id)
end

#matches?(element) ⇒ Boolean

Returns:

  • (Boolean)


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

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