subroutinerender_codeprivate
subroutine render_code(text, html)
The HTML of an indented code block, whose first line may name its language.
Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
| text | character(len=*) | in | the code | |
| html | character(len=:) | out | allocatable | 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