Class: Coradoc::Input::Html::Converters::Pre

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

Instance Method Summary collapse

Methods inherited from Base

#convert, #escape_text, #extract_leading_trailing_whitespace, #extract_title, #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

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



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/coradoc/html/input/converters/pre.rb', line 8

def to_coradoc(node, _state = {})
  id = node['id']
  lang = language(node)
  content = extract_text_content(node)

  if lang
    Coradoc::CoreModel::SourceBlock.new(
      element_type: 'source',
      content: content,
      id: id,
      language: lang
    )
  else
    Coradoc::CoreModel::LiteralBlock.new(
      element_type: 'literal',
      content: content,
      id: id
    )
  end
end