subroutinefind_rulepureprivate
pure subroutine find_rule(block, at, stop_at)
Find a line of block that is a horizontal rule.
Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
| block | character(len=*) | in | the chunk | |
| at | integer | out | where it starts, or 0 | |
| stop_at | integer | out | where it ends |
Calls
Source
Show the code
pure subroutine find_rule(block, at, stop_at)
character(len=*), intent(in) :: block !! the chunk
integer, intent(out) :: at !! where it starts, or 0
integer, intent(out) :: stop_at !! where it ends
integer :: i, j, last
at = 0
stop_at = 0
i = 1
do while (i <= len(block))
j = index(block(i:), NL)
last = merge(len(block), i + j - 2, j == 0)
if (is_rule(block(i:last))) then
at = i
stop_at = last
return
end if
if (j == 0) return
i = i + j
end do
end subroutine find_rule