subroutineinline_angleprivate
subroutine inline_angle(text, i, out, used)
Handle <: an automatic link or inline HTML.
Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
| 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_angle(text, i, out, used)
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 :: inner
integer :: close, k
used = 0
close = index(text(i:), '>')
if (close < 3) return
inner = text(i + 1:i + close - 2)
if (index(inner, '<') > 0) return
if (starts_with(lowercase(inner), 'http://') .or. starts_with(lowercase(inner), 'https://') .or. &
starts_with(lowercase(inner), 'ftp://') .or. starts_with(lowercase(inner), 'ftps://')) then
call add(out, '<a href="')
call html_escape(inner, out, .true.)
call add(out, '">')
call html_escape(inner, out, .false.)
call add(out, '</a>')
used = close
return
end if
k = index(inner, '@')
if (k > 1 .and. k < len(inner) .and. index(inner, ' ') == 0 .and. index(inner, '!') == 0) then
call add(out, '<a href="')
call encoded('mailto:'//inner, out)
call add(out, '">')
call encoded(inner, out)
call add(out, '</a>')
used = close
return
end if
if (starts_with(inner, '!--') .or. scan(inner(1:1), 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ/') == 1) then
if (index(first_word(inner), '@') > 0) return
call add(out, text(i:i + close - 1))
used = close
end if
end subroutine inline_angle