Class: Coradoc::Docx::Transform::Rules::BookmarkRule
- Inherits:
-
Coradoc::Docx::Transform::Rule
- Object
- Coradoc::Docx::Transform::Rule
- Coradoc::Docx::Transform::Rules::BookmarkRule
- Defined in:
- lib/coradoc/docx/transform/rules/bookmark_rule.rb
Overview
Transforms w:bookmarkStart to a metadata hash for attaching to the next CoreModel element.
Bookmarks in OOXML are position markers (not content containers). The orchestrator collects bookmark IDs and attaches them as element attributes on the containing paragraph/section.
Instance Method Summary collapse
-
#apply(element, _context) ⇒ Object
Returns a hash with bookmark metadata, not a CoreModel node.
- #matches?(element) ⇒ Boolean
Methods inherited from Coradoc::Docx::Transform::Rule
Instance Method Details
#apply(element, _context) ⇒ Object
Returns a hash with bookmark metadata, not a CoreModel node. The orchestrator uses this to set the id on the parent element.
23 24 25 26 27 28 29 |
# File 'lib/coradoc/docx/transform/rules/bookmark_rule.rb', line 23 def apply(element, _context) if element.is_a?(Uniword::Wordprocessingml::BookmarkStart) { id: element.id&.to_s, name: element.name&.to_s } else nil # BookmarkEnd — no useful data end end |
#matches?(element) ⇒ Boolean
14 15 16 17 18 19 |
# File 'lib/coradoc/docx/transform/rules/bookmark_rule.rb', line 14 def matches?(element) return false unless defined?(Uniword::Wordprocessingml) element.is_a?(Uniword::Wordprocessingml::BookmarkStart) || element.is_a?(Uniword::Wordprocessingml::BookmarkEnd) end |