Class: Coradoc::Html::Drop::InlineElementDrop

Inherits:
Base
  • Object
show all
Defined in:
lib/coradoc/html/drop/inline_element_drop.rb

Constant Summary collapse

FORMAT_TAG_MAP =
{
  'bold' => 'strong',
  'italic' => 'em',
  'monospace' => 'code',
  'superscript' => 'sup',
  'subscript' => 'sub',
  'underline' => 'u',
  'strikethrough' => 'del',
  'highlight' => 'mark',
  'quotation' => 'q',
  'small' => 'small',
  'stem' => 'code'
}.freeze

Instance Attribute Summary

Attributes inherited from Base

#model

Instance Method Summary collapse

Methods inherited from Base

#id, #initialize, #template_type, #title, #to_liquid

Constructor Details

This class inherits a constructor from Coradoc::Html::Drop::Base

Instance Method Details

#css_classObject



48
49
50
51
52
53
54
# File 'lib/coradoc/html/drop/inline_element_drop.rb', line 48

def css_class
  case format_type
  when 'stem' then 'stem'
  when 'term' then 'term'
  when 'span' then @model.('class')
  end
end

#format_typeObject



21
22
23
# File 'lib/coradoc/html/drop/inline_element_drop.rb', line 21

def format_type
  @model.resolve_format_type
end

#hrefObject



34
35
36
37
38
39
40
41
42
# File 'lib/coradoc/html/drop/inline_element_drop.rb', line 34

def href
  case format_type
  when 'link'
    @model.target || @model.('href') || '#'
  when 'xref'
    target = @model.target || @model.('href') || ''
    "##{target}"
  end
end

#html_tagObject



25
26
27
28
29
30
31
32
# File 'lib/coradoc/html/drop/inline_element_drop.rb', line 25

def html_tag
  case format_type
  when 'link', 'xref' then 'a'
  when 'footnote' then 'sup'
  when 'span', 'term' then 'span'
  else FORMAT_TAG_MAP[format_type]
  end
end

#term_refObject



56
57
58
# File 'lib/coradoc/html/drop/inline_element_drop.rb', line 56

def term_ref
  @model.content.to_s if format_type == 'term'
end

#textObject



44
45
46
# File 'lib/coradoc/html/drop/inline_element_drop.rb', line 44

def text
  Escape.escape_html(extract_text(@model.content))
end