Class: Coradoc::Input::Html::Converters::MediaBase

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

Direct Known Subclasses

Audio, Video

Instance Method Summary collapse

Methods inherited from Base

#extract_leading_trailing_whitespace, #extract_text_from_content, #node_has_ancestor?, #textnode_after_start_with?, #textnode_before_end_with?, #treat_children_coradoc, #treat_coradoc, #unconstrained_after?, #unconstrained_before?

Instance Method Details

#extract_title(node) ⇒ Object



22
23
24
25
26
27
# File 'lib/coradoc/html/input/converters/media_base.rb', line 22

def extract_title(node)
  track = node.at('./track') || node.at('.//source')
  return '' if track.nil?

  track['label'] || track['srclang'] || ''
end

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



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/coradoc/html/input/converters/media_base.rb', line 8

def to_coradoc(node, _state = {})
  src = node['src']
  id = node['id']
  title = extract_title(node)

  Coradoc::CoreModel::Block.new(
    block_semantic_type: semantic_type,
    content: src,
    title: title,
    id: id,
    element_attributes: build_attributes(node)
  )
end