subroutinelist_indentrecursiveprivate
recursive subroutine list_indent(t, parent, block)
The indented block processor: block continues a list.
Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
| t | type(tree_t) | inout | the conversion | |
| parent | integer | in | the node | |
| block | character(len=*) | in | the chunk |
Calls
Source
Show the code
recursive subroutine list_indent(t, parent, block)
type(tree_t), intent(inout) :: t !! the conversion
integer, intent(in) :: parent !! the node
character(len=*), intent(in) :: block !! the chunk
character(len=:), allocatable :: detabbed
integer :: level, sibling, last, p, kept
call indent_level(t, parent, block, level, sibling)
call loose_detab(block, level, detabbed)
call set_state(t, 'detabbed')
if (t%nodes(parent)%tag == 'li' .or. t%nodes(parent)%tag == 'dd') then
last = last_child(t, parent)
kept = parent
if (last > 0) then
if (is_list(t%nodes(last)%tag)) kept = last
end if
call parse_one(t, kept, detabbed)
else if (t%nodes(sibling)%tag == 'li') then
call parse_one(t, sibling, detabbed)
else if (last_child(t, sibling) > 0) then
last = last_child(t, sibling)
if (t%nodes(last)%tag == 'li') then
if (len(t%nodes(last)%text) > 0) then
! the item's text becomes a paragraph, before any sublist
call new_node(t, last, 'p', p)
t%nodes(p)%text = t%nodes(last)%text
t%nodes(last)%text = ''
t%nodes(last)%kids = [p, t%nodes(last)%kids(:size(t%nodes(last)%kids) - 1)]
end if
call parse_text(t, last, detabbed)
else
call new_node(t, sibling, 'li', p)
call parse_one(t, p, detabbed)
end if
else
call new_node(t, sibling, 'li', p)
call parse_one(t, p, detabbed)
end if
call reset_state(t)
end subroutine list_indent