subroutinerender_headingrecursiveprivate
recursive subroutine render_heading(t, tag, attrs, text, options, out)
Write a heading or definition term. With the toc extension headings get ids.
Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
| t | type(tree_t) | inout | the conversion | |
| tag | character(len=*) | in | the tag | |
| attrs | character(len=*) | in | its attributes | |
| text | character(len=*) | in | its text | |
| 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_heading(t, tag, attrs, text, options, out)
type(tree_t), intent(inout) :: t !! the conversion
character(len=*), intent(in) :: tag !! the tag
character(len=*), intent(in) :: attrs !! its attributes
character(len=*), intent(in) :: text !! its text
type(markdown_options_t), intent(in) :: options !! what rendering depends on
type(buffer_t), intent(inout) :: out !! the HTML
type(buffer_t) :: inner
character(len=:), allocatable :: html, id, final_attrs
call inline(t, text, options, inner, 0)
call take(inner, html)
final_attrs = attrs
if (options%toc .and. tag /= 'dt') then
if (index(attrs, ' id="') == 0) then
call unique_id(t, html, id)
final_attrs = final_attrs//' id="'//id//'"'
else
id = attrs(index(attrs, ' id="') + 5:)
id = id(:index(id, '"') - 1)
end if
t%headings = [t%headings, heading_t(iachar(tag(2:2)) - iachar('0'), id, html)]
end if
call add(out, '<'//tag//final_attrs//'>')
call add(out, html)
call add(out, '</'//tag//'>')
end subroutine render_heading