fdoc

subroutineinline_backslashprivate

subroutine inline_backslash(text, i, out, used)

Handle a backslash: math, or an escaped character.

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_backslash(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
    integer :: close, k

    used = 0
    if (i == len(text)) return
    associate (c => text(i + 1:i + 1))
        if (c == '(' .or. c == '[') then
            close = index(text(i + 2:), '\'//merge(')', ']', c == '('))
            if (close > 0) then
                call math(text(i + 2:i + close), c == '[', out)
                used = close + 3
                return
            end if
        end if
        if (i + 6 <= len(text)) then
            if (text(i:i + 6) == '\begin{') then
                close = index(text(i:), '}')
                k = index(text(i:), '\end'//text(i + 6:i + close - 1))
                if (close > 0 .and. k > 0) then
                    used = k + 4 + close - 7 + 1
                    call math(text(i:i + used - 1), .true., out)
                    return
                end if
            end if
        end if
        if (index(ESCAPED, c) > 0) then
            call html_escape(c, out, .false.)
            used = 2
        end if
    end associate
end subroutine inline_backslash

Graphs

Calls

Called by