Class: Coradoc::Input::Html::Converters::Head

Inherits:
Base
  • Object
show all
Defined in:
lib/coradoc/html/input/converters/head.rb

Instance Method Summary collapse

Methods inherited from Base

#convert, #escape_text, #extract_leading_trailing_whitespace, #node_has_ancestor?, #textnode_after_start_with?, #textnode_before_end_with?, #treat, #treat_children, #treat_children_coradoc, #treat_coradoc, #unconstrained_after?, #unconstrained_before?

Instance Method Details

#extract_title(node) ⇒ Object



18
19
20
21
22
23
# File 'lib/coradoc/html/input/converters/head.rb', line 18

def extract_title(node)
  title = node.at('./title')
  return '(???)' if title.nil?

  title.text
end

#to_coradoc(node, _state = {}) ⇒ Object



8
9
10
11
12
13
14
15
16
# File 'lib/coradoc/html/input/converters/head.rb', line 8

def to_coradoc(node, _state = {})
  title = extract_title(node)
  # Use StructuralElement with element_type "document" for document header
  Coradoc::CoreModel::StructuralElement.new(
    element_type: 'document',
    title: title,
    level: 0
  )
end