fdoc

subroutinerender_codeprivate

subroutine render_code(text, html)

The HTML of an indented code block, whose first line may name its language.

Arguments

NameTypeIntentAttributesDescription
textcharacter(len=*)in

the code

htmlcharacter(len=:)outallocatable

the HTML

Calls

Source

Show the code
subroutine render_code(text, html)
    character(len=*), intent(in) :: text                !! the code
    character(len=:), allocatable, intent(out) :: html  !! the HTML
    character(len=:), allocatable :: lang, first
    integer :: at

    at = index(text, NL)
    if (at == 0) at = len(text) + 1
    first = strip(text(:at - 1))
    lang = ''
    if (starts_with(first, ':::')) then
        lang = strip(first(4:))
        call code_block_html(text(min(at + 1, len(text) + 1):), lang, html)
    else if (starts_with(first, '#!') .and. index(first, ' ') == 0 .and. index(first, '/') == 0) then
        lang = first(3:)
        call code_block_html(text(min(at + 1, len(text) + 1):), lang, html)
    else
        call code_block_html(text, '', html)
    end if
end subroutine render_code

Graphs

Calls

Called by