Class: Coradoc::Html::Drop::InlineElementDrop
- Inherits:
-
Base
- Object
- Liquid::Drop
- Base
- Coradoc::Html::Drop::InlineElementDrop
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
Instance Method Details
#css_class ⇒ Object
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.metadata('class')
end
end
|
21
22
23
|
# File 'lib/coradoc/html/drop/inline_element_drop.rb', line 21
def format_type
@model.resolve_format_type
end
|
#href ⇒ Object
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.metadata('href') || '#'
when 'xref'
target = @model.target || @model.metadata('href') || ''
"##{target}"
end
end
|
#html_tag ⇒ Object
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_ref ⇒ Object
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
|
#text ⇒ Object
44
45
46
|
# File 'lib/coradoc/html/drop/inline_element_drop.rb', line 44
def text
Escape.escape_html((@model.content))
end
|