subroutinerender_tablerecursiveprivate
recursive subroutine render_table(t, block, options, out)
Write a table.
Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
| t | type(tree_t) | inout | the conversion | |
| block | character(len=*) | in | the chunk | |
| options | type(markdown_options_t) | in | what rendering depends on | |
| out | type(buffer_t) | inout | the HTML |
Calls
Source
Show the code
recursive subroutine render_table(t, block, options, out)
type(tree_t), intent(inout) :: t !! the conversion
character(len=*), intent(in) :: block !! the chunk
type(markdown_options_t), intent(in) :: options !! what rendering depends on
type(buffer_t), intent(inout) :: out !! the HTML
type(string_t), allocatable :: lines(:), cells(:), align(:), header(:)
integer :: k, c, columns
lines = split_on(block, NL)
call row_cells(lines(1)%s, header)
call row_cells(lines(2)%s, cells)
columns = size(header)
allocate (align(columns))
do c = 1, columns
align(c)%s = ''
if (c > size(cells)) cycle
associate (d => cells(c)%s)
if (len(d) == 0) cycle
if (d(1:1) == ':' .and. d(len(d):len(d)) == ':') then
align(c)%s = ' style="text-align: center;"'
else if (d(1:1) == ':') then
align(c)%s = ' style="text-align: left;"'
else if (d(len(d):len(d)) == ':') then
align(c)%s = ' style="text-align: right;"'
end if
end associate
end do
call add(out, '<table>'//NL//'<thead>'//NL)
call table_row(t, header, 'th', align, options, out)
call add(out, '</thead>'//NL//'<tbody>'//NL)
do k = 3, size(lines)
call row_cells(lines(k)%s, cells)
call table_row(t, cells, 'td', align, options, out)
end do
call add(out, '</tbody>'//NL//'</table>')
end subroutine render_table