subroutineford_linkprivate
subroutine ford_link(text, i, options, out, used)
Handle [[name(type):child(type)]], a link to an entity.
Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
| text | character(len=*) | in | the text | |
| i | integer | in | where it is | |
| options | type(markdown_options_t) | in | what rendering depends on | |
| out | type(buffer_t) | inout | the HTML | |
| used | integer | out | how much was used |
Calls
Source
Show the code
subroutine ford_link(text, i, options, out, used)
character(len=*), intent(in) :: text !! the text
integer, intent(in) :: i !! where it is
type(markdown_options_t), intent(in) :: options !! what rendering depends on
type(buffer_t), intent(inout) :: out !! the HTML
integer, intent(out) :: used !! how much was used
character(len=:), allocatable :: inner, name, entity, child, child_entity, url, label
integer :: close, colon
logical :: found
used = 0
if (.not. associated(options%resolver)) return
close = index(text(i:), ']]')
if (close < 4) return
inner = remove_blanks(text(i + 2:i + close - 2))
if (verify(inner, WORD_CHARS//'.():') /= 0) return
colon = index(inner, ':')
child = ''
child_entity = ''
if (colon > 0) then
call name_and_entity(inner(colon + 1:), child, child_entity)
inner = inner(:colon - 1)
end if
call name_and_entity(inner, name, entity)
call options%resolver(options%resolver_data, name, entity, child, child_entity, url, label, found)
used = close + 1
if (.not. found) then
call warn('Could not substitute link '//text(i:i + close)//", '"//name//"' not found")
call add(out, '<a>'//name//'</a>')
return
end if
call add(out, '<a href="')
call html_escape(url, out, .true.)
call add(out, '">')
call html_escape(label, out, .false.)
call add(out, '</a>')
end subroutine ford_link