Class: Coradoc::Input::Html::Converters::Li
- Defined in:
- lib/coradoc/html/input/converters/li.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 28 |
# File 'lib/coradoc/html/input/converters/li.rb', line 8 def to_coradoc(node, state = {}) id = node['id'] # Check if all children are <p> tags p_children = node.children.select { |child| child.name == 'p' } non_empty_children = node.children.reject { |c| c.text? && c.text.strip.empty? } content = if p_children.any? && p_children.size == non_empty_children.size && p_children.size == 1 # Single <p> tag - extract its content directly as inline content treat_children_coradoc(p_children.first, state) else treat_children_coradoc(node, state) end # Use CoreModel::ListItem with children for mixed content # content can be an array of inline elements or a single string Coradoc::CoreModel::ListItem.new( children: content, id: id ) end |