subroutineunstashprivate
subroutine unstash(t, html)
Put stashed HTML back into html.
Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
| t | type(tree_t) | in | the conversion | |
| html | character(len=:) | inout | allocatable | the HTML |
Calls
Source
Show the code
subroutine unstash(t, html)
type(tree_t), intent(in) :: t !! the conversion
character(len=:), allocatable, intent(inout) :: html !! the HTML
type(buffer_t) :: b
integer :: i, j, k, number, ios
logical :: changed
do
if (index(html, STX) == 0) return
changed = .false.
i = 1
do while (i <= len(html))
if (html(i:i) /= STX) then
k = index(html(i:), STX)
if (k == 0) k = len(html) - i + 2
call add(b, html(i:i + k - 2))
i = i + k - 1
cycle
end if
j = index(html(i:), ETX)
if (j == 0) then
i = i + 1
cycle
end if
call digits_value(html(i + 1:i + j - 2), number, ios)
if (ios == 0 .and. number >= 1 .and. number <= size(t%stash)) then
call add(b, t%stash(number)%s)
changed = .true.
end if
i = i + j
end do
call take(b, html)
if (.not. changed) return
end do
end subroutine unstash