Class: Coradoc::Docx::Transform::Rules::ParagraphRule
- Inherits:
-
Coradoc::Docx::Transform::Rule
- Object
- Coradoc::Docx::Transform::Rule
- Coradoc::Docx::Transform::Rules::ParagraphRule
- Includes:
- OrderedContent
- Defined in:
- lib/coradoc/docx/transform/rules/paragraph_rule.rb
Overview
Transforms regular paragraphs to CoreModel::Block.
Handles paragraph-style detection for block types: quote, source, literal, example, or plain paragraph.
This is the default rule for paragraphs. The orchestrator dispatches heading and list item paragraphs directly, so this rule only sees regular paragraphs.
Instance Method Summary collapse
Methods included from OrderedContent
#extract_plain_text, #transform_paragraph_content
Instance Method Details
#apply(paragraph, context) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/coradoc/docx/transform/rules/paragraph_rule.rb', line 27 def apply(paragraph, context) role = context.style_resolver.role_from_style(paragraph) block_type = block_type_for(role) children = transform_paragraph_content(paragraph, context) id = extract_bookmark_id(paragraph) block = CoreModel::Block.new( element_type: block_type, content: extract_plain_text(children) ) block.children = children block.id = id if id block end |
#matches?(element) ⇒ Boolean
22 23 24 25 |
# File 'lib/coradoc/docx/transform/rules/paragraph_rule.rb', line 22 def matches?(element) defined?(Uniword::Wordprocessingml::Paragraph) && element.is_a?(Uniword::Wordprocessingml::Paragraph) end |
#priority ⇒ Object
18 19 20 |
# File 'lib/coradoc/docx/transform/rules/paragraph_rule.rb', line 18 def priority 0 end |