subroutineadmonition_blockrecursiveprivate
recursive subroutine admonition_block(t, parent, block, stack, n)
An admonition: a line @note Type, then indented text.
Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
| t | type(tree_t) | inout | the conversion | |
| parent | integer | in | the node | |
| block | character(len=*) | in | the chunk | |
| stack | type(string_t) | inout | allocatabledimension(:) | the chunks left |
| n | integer | inout | how many there are |
Calls
Source
Show the code
recursive subroutine admonition_block(t, parent, block, stack, n)
type(tree_t), intent(inout) :: t !! the conversion
integer, intent(in) :: parent !! the node
character(len=*), intent(in) :: block !! the chunk
type(string_t), allocatable, intent(inout) :: stack(:) !! the chunks left
integer, intent(inout) :: n !! how many there are
character(len=:), allocatable :: kind, css, inner
integer :: at, node, title
at = index(block, NL)
if (at == 0) at = len(block) + 1
kind = strip(block(7:at - 1))
select case (lowercase(kind))
case ('note'); css = 'info'
case ('warning'); css = 'warning'
case ('todo'); css = 'success'
case ('bug'); css = 'danger'
case default; css = 'history'
end select
call new_node(t, parent, 'div', node)
t%nodes(node)%attrs = ' class="alert alert-'//css//'"'
call new_node(t, node, 'p', title)
t%nodes(title)%attrs = ' class="alert-title h4"'
t%nodes(title)%text = kind
inner = ''
if (at < len(block)) call loose_detab(block(at + 1:), 1, inner)
call set_state(t, 'detabbed')
if (len(inner) > 0) call parse_one(t, node, inner)
do while (n > 0)
! the following indented chunks belong to it
if (.not. starts_with(stack(n)%s, ' ')) then
if (len(stack(n)%s) == 0 .and. n > 1) then
if (starts_with(stack(n - 1)%s, ' ')) then
n = n - 1
cycle
end if
end if
exit
end if
call loose_detab(stack(n)%s, 1, inner)
n = n - 1
call parse_one(t, node, inner)
end do
call reset_state(t)
end subroutine admonition_block