fdoc

subroutineinlinerecursiveprivate

recursive subroutine inline(t, text, options, out, depth)

Write inline Markdown text as HTML.

Arguments

NameTypeIntentAttributesDescription
ttype(tree_t)inout

the conversion

textcharacter(len=*)in

the text

optionstype(markdown_options_t)in

what rendering depends on

outtype(buffer_t)inout

the HTML

depthintegerin

how deeply this is nested

Calls

Source

Show the code
recursive subroutine inline(t, text, options, out, depth)
    type(tree_t), intent(inout) :: t                !! the conversion
    character(len=*), intent(in) :: text            !! the text
    type(markdown_options_t), intent(in) :: options !! what rendering depends on
    type(buffer_t), intent(inout) :: out            !! the HTML
    integer, intent(in) :: depth                    !! how deeply this is nested
    integer :: i, n, used

    n = len(text)
    i = 1
    do while (i <= n)
        used = 0
        select case (text(i:i))
        case (STX)
            used = index(text(i:), ETX)
            if (used > 0) call add(out, text(i:i + used - 1))
        case ('\')
            call inline_backslash(text, i, out, used)
        case ('`')
            call inline_code(text, i, out, used)
        case ('[')
            call inline_bracket(t, text, i, options, out, depth, used)
        case ('!')
            if (i < n) then
                if (text(i + 1:i + 1) == '[') call inline_image(t, text, i, out, used)
            end if
        case ('<')
            call inline_angle(text, i, out, used)
            if (used == 0) then
                call add(out, '&lt;')
                used = 1
            end if
        case ('>')
            call add(out, '&gt;')
            used = 1
        case ('&')
            call inline_entity(text, i, out, used)
        case ('$')
            call inline_dollar(text, i, out, used)
        case ('*', '_')
            if (depth < MAX_DEPTH) call inline_emphasis(t, text, i, options, out, depth, used)
        case (' ')
            if (i + 2 <= n) then
                if (text(i:i + 2) == '  '//NL) then
                    call add(out, '<br>'//NL)
                    used = 3
                end if
            end if
        end select
        if (used > 0) then
            i = i + used
            cycle
        end if
        if (size(t%abbreviations) > 0) call inline_abbreviation(t, text, i, out, used)
        if (used > 0) then
            i = i + used
            cycle
        end if
        if (options%smarty) call inline_smart(text, i, out, used)
        if (used > 0) then
            i = i + used
            cycle
        end if
        call add(out, text(i:i))
        i = i + 1
    end do
end subroutine inline

Graphs

Calls

Called by