subroutineinline_imageprivate
subroutine inline_image(t, text, i, out, used)
Handle ![: an image.
Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
| t | type(tree_t) | in | the conversion | |
| text | character(len=*) | in | the text | |
| i | integer | in | where it is | |
| out | type(buffer_t) | inout | the HTML | |
| used | integer | out | how much was used |
Calls
Source
Show the code
subroutine inline_image(t, text, i, out, used)
type(tree_t), intent(in) :: t !! the conversion
character(len=*), intent(in) :: text !! the text
integer, intent(in) :: i !! where it is
type(buffer_t), intent(inout) :: out !! the HTML
integer, intent(out) :: used !! how much was used
character(len=:), allocatable :: url, title
integer :: close, k, target
used = 0
close = bracket_end(text, i + 1)
if (close == 0) return
k = 0
url = ''
title = ''
if (close < len(text)) then
if (text(close + 1:close + 1) == '(') then
call link_target(text, close + 1, url, title, k)
else if (text(close + 1:close + 1) == '[') then
k = bracket_end(text, close + 1)
if (k > 0) then
target = find_reference(t, text(close + 2:k - 1))
if (target == 0) return
url = t%refs(target)%url
title = t%refs(target)%title
end if
end if
end if
if (k == 0) return
call add(out, '<img alt="')
call html_escape(text(i + 2:close - 1), out, .true.)
call add(out, '" src="')
call html_escape(url, out, .true.)
call add(out, '"')
if (len(title) > 0) then
call add(out, ' title="')
call html_escape(title, out, .true.)
call add(out, '"')
end if
call add(out, '>')
used = k - i + 1
end subroutine inline_image