fdoc

subroutinelist_blockrecursiveprivate

recursive subroutine list_block(t, parent, block, tag)

The list processors.

Arguments

NameTypeIntentAttributesDescription
ttype(tree_t)inout

the conversion

parentintegerin

the node

blockcharacter(len=*)in

the chunk

tagcharacter(len=*)in

ol or ul

Calls

Source

Show the code
recursive subroutine list_block(t, parent, block, tag)
    type(tree_t), intent(inout) :: t        !! the conversion
    integer, intent(in) :: parent           !! the node
    character(len=*), intent(in) :: block   !! the chunk
    character(len=*), intent(in) :: tag     !! `ol` or `ul`
    type(string_t), allocatable :: items(:)
    integer :: sibling, list, item, last, p, k, first

    call list_items(block, items)
    sibling = last_child(t, parent)
    first = 1
    list = 0
    if (sibling > 0) then
        if (is_list(t%nodes(sibling)%tag)) list = sibling
    end if
    if (list > 0) then
        last = last_child(t, list)
        if (last > 0) then
            if (len(t%nodes(last)%text) > 0) then
                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
        end if
        call new_node(t, list, 'li', item)
        call set_state(t, 'looselist')
        call parse_one(t, item, items(1)%s)
        call reset_state(t)
        first = 2
    else if (is_list(t%nodes(parent)%tag)) then
        list = parent
    else
        call new_node(t, parent, tag, list)
    end if

    call set_state(t, 'list')
    do k = first, size(items)
        if (starts_with(items(k)%s, '    ')) then
            call parse_one(t, last_child(t, list), items(k)%s)
        else
            call new_node(t, list, 'li', item)
            call parse_one(t, item, items(k)%s)
        end if
    end do
    call reset_state(t)
end subroutine list_block

Graphs

Calls

Called by