Class: Coradoc::Docx::Transform::Rules::HyperlinkRule
- Inherits:
-
Coradoc::Docx::Transform::Rule
- Object
- Coradoc::Docx::Transform::Rule
- Coradoc::Docx::Transform::Rules::HyperlinkRule
- Defined in:
- lib/coradoc/docx/transform/rules/hyperlink_rule.rb
Overview
Transforms w:hyperlink elements to CoreModel::InlineElement (link).
External hyperlinks have r:id (URL). Internal links have w:anchor (bookmark reference). Both are captured in the target attribute.
Instance Method Summary collapse
Methods inherited from Coradoc::Docx::Transform::Rule
Instance Method Details
#apply(hyperlink, context) ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/coradoc/docx/transform/rules/hyperlink_rule.rb', line 17 def apply(hyperlink, context) content = extract_content(hyperlink, context) text = flatten_to_string(content) Coradoc::CoreModel::InlineElement.new( format_type: 'link', target: resolve_target(hyperlink), content: text ) end |
#matches?(element) ⇒ Boolean
12 13 14 15 |
# File 'lib/coradoc/docx/transform/rules/hyperlink_rule.rb', line 12 def matches?(element) defined?(Uniword::Wordprocessingml::Hyperlink) && element.is_a?(Uniword::Wordprocessingml::Hyperlink) end |