fdoc

subroutinehash_headerrecursiveprivate

recursive subroutine hash_header(t, parent, block, at, stop_at, stack, n)

The # header processor.

Arguments

NameTypeIntentAttributesDescription
ttype(tree_t)inout

the conversion

parentintegerin

the node

blockcharacter(len=*)in

the chunk

atintegerin

where the header starts

stop_atintegerin

where it ends

stacktype(string_t)inoutallocatabledimension(:)

the chunks left

nintegerinout

how many there are

Calls

Source

Show the code
recursive subroutine hash_header(t, parent, block, at, stop_at, stack, n)
    type(tree_t), intent(inout) :: t                        !! the conversion
    integer, intent(in) :: parent                           !! the node
    character(len=*), intent(in) :: block                   !! the chunk
    integer, intent(in) :: at                               !! where the header starts
    integer, intent(in) :: stop_at                          !! where it ends
    type(string_t), allocatable, intent(inout) :: stack(:)  !! the chunks left
    integer, intent(inout) :: n                             !! how many there are
    character(len=:), allocatable :: text
    integer :: level, node, last

    if (at > 1) call parse_one(t, parent, block(:at - 2))
    level = min(6, verify(block(at:stop_at)//' ', '#') - 1)
    text = block(at + level:stop_at)
    last = len_trim(text)
    do while (last > 0)
        if (text(last:last) /= '#') exit
        last = last - 1
    end do
    call new_node(t, parent, 'h'//achar(iachar('0') + level), node)
    t%nodes(node)%text = strip(text(:last))
    if (stop_at + 1 < len(block)) call push_back(stack, n, block(stop_at + 2:))
end subroutine hash_header

Graphs

Calls

Called by