subroutinehash_headerrecursiveprivate
recursive subroutine hash_header(t, parent, block, at, stop_at, stack, n)
The # header processor.
Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
| t | type(tree_t) | inout | the conversion | |
| parent | integer | in | the node | |
| block | character(len=*) | in | the chunk | |
| at | integer | in | where the header starts | |
| stop_at | integer | in | where it ends | |
| stack | type(string_t) | inout | allocatabledimension(:) | the chunks left |
| n | integer | inout | 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