subroutinecode_block_htmlprivate
subroutine code_block_html(code, lang, html)
The HTML of a code block.
Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
| code | character(len=*) | in | the code | |
| lang | character(len=*) | in | its language, or | |
| html | character(len=:) | out | allocatable | the HTML |
Calls
Source
Show the code
subroutine code_block_html(code, lang, html)
character(len=*), intent(in) :: code !! the code
character(len=*), intent(in) :: lang !! its language, or `''`
character(len=:), allocatable, intent(out) :: html !! the HTML
type(buffer_t) :: b
call add(b, '<div class="codehilite"><pre><code')
if (len(lang) > 0) then
call add(b, ' class="language-')
call html_escape(lang, b, .true.)
call add(b, '"')
end if
call add(b, '>')
select case (lowercase(lang))
case ('fortran', 'f90', 'f', 'fortranfixed')
call highlight_fortran(code, b, .false.)
case default
call html_escape(code, b, .false.)
end select
call add(b, '</code></pre></div>')
call take(b, html)
end subroutine code_block_html