subroutineinline_smartpureprivate
pure subroutine inline_smart(text, i, out, used)
Handle the punctuation that the smarty extension changes.
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
pure subroutine inline_smart(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
logical :: opening
used = 0
opening = i == 1
if (.not. opening) opening = scan(text(i - 1:i - 1), ' '//NL//'([{-') == 1
select case (text(i:i))
case ('-')
if (i + 2 <= len(text)) then
if (text(i:i + 2) == '---') then
call add(out, '—')
used = 3
return
end if
end if
if (i + 1 <= len(text)) then
if (text(i:i + 1) == '--') then
call add(out, '–')
used = 2
end if
end if
case ('.')
if (i + 2 <= len(text)) then
if (text(i:i + 2) == '...') then
call add(out, '…')
used = 3
end if
end if
case ('"')
call add(out, merge('“', '”', opening))
used = 1
case ("'")
call add(out, merge('‘', '’', opening))
used = 1
end select
end subroutine inline_smart