fdoc

subroutineinline_dollarprivate

subroutine inline_dollar(text, i, out, used)

Handle $: display math or an environment variable.

Arguments

NameTypeIntentAttributesDescription
textcharacter(len=*)in

the text

iintegerin

where it is

outtype(buffer_t)inout

the HTML

usedintegerout

how much was used

Calls

Source

Show the code
subroutine inline_dollar(text, i, out, used)
    character(len=*), intent(in) :: text    !! the text
    integer, intent(in) :: i                !! where it is
    type(buffer_t), intent(inout) :: out    !! the HTML
    integer, intent(out) :: used            !! how much was used
    character(len=:), allocatable :: value
    integer :: close, n, stat

    used = 0
    if (i == len(text)) return
    if (text(i + 1:i + 1) == '$') then
        close = index(text(i + 2:), '$$')
        if (close > 1) then
            call math(text(i + 2:i + close), .true., out)
            used = close + 3
        end if
    else if (text(i + 1:i + 1) == '{') then
        close = index(text(i + 2:), '}')
        if (close > 1) then
            if (verify(text(i + 2:i + close), WORD_CHARS) /= 0) return
            call get_environment_variable(text(i + 2:i + close), length=n, status=stat)
            if (stat == 0 .and. n > 0) then
                allocate (character(len=n) :: value)
                call get_environment_variable(text(i + 2:i + close), value)
                call add(out, value)
            end if
            used = close + 2
        end if
    end if
end subroutine inline_dollar

Graphs

Calls

Called by