fdoc

subroutineparagraphprivate

subroutine paragraph(t, parent, block)

The paragraph processor. In a tight list an item's text stays in the item.

Arguments

NameTypeIntentAttributesDescription
ttype(tree_t)inout

the conversion

parentintegerin

the node

blockcharacter(len=*)in

the chunk

Calls

Source

Show the code
subroutine paragraph(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 :: text, attrs
    integer :: node, sibling, at

    text = block
    if (verify(text, ' '//NL) == 0) return
    if (in_state(t, 'list')) then
        sibling = last_child(t, parent)
        if (sibling > 0) then
            ! text after a sublist
            call new_node(t, parent, 'p', node)
            t%nodes(node)%text = adjustl_text(text)
        else if (len(t%nodes(parent)%text) > 0) then
            t%nodes(parent)%text = t%nodes(parent)%text//NL//text
        else
            t%nodes(parent)%text = adjustl_text(text)
        end if
        return
    end if
    attrs = ''
    at = index(text, NL//'{:', back=.true.)
    if (at > 0 .and. ends_with(strip(text), '}')) then
        call attribute_list(strip(text(at + 3:len_trim(text) - 1)), attrs)
        text = text(:at - 1)
    end if
    call new_node(t, parent, 'p', node)
    t%nodes(node)%text = adjustl_text(text)
    t%nodes(node)%attrs = attrs
end subroutine paragraph

Graphs

Calls

Called by