Class: Coradoc::Input::Html::Converters::Ol
- Inherits:
-
Base
- Object
- Base
- Coradoc::Input::Html::Converters::Ol
show all
- Defined in:
- lib/coradoc/html/input/converters/ol.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
#get_list_type(node, _state) ⇒ Object
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/coradoc/html/input/converters/ol.rb', line 26
def get_list_type(node, _state)
case node.name
when 'ol'
'ordered'
when 'ul'
'unordered'
when 'dir'
'unordered'
else
'unordered'
end
end
|
#to_coradoc(node, state = {}) ⇒ Object
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/coradoc/html/input/converters/ol.rb', line 8
def to_coradoc(node, state = {})
id = node['id']
ol_count = state.fetch(:ol_count, 0) + 1
items = treat_children_coradoc(
node,
state.merge(ol_count: ol_count)
)
marker_type = get_list_type(node, state)
Coradoc::CoreModel::ListBlock.new(
marker_type: marker_type,
items: items,
id: id,
start: node['start']&.to_i
)
end
|