subroutinefirst_paragraphpureprivate
pure subroutine first_paragraph(html, out)
The first paragraph of html, or ''.
Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
| html | character(len=*) | in | the HTML | |
| out | character(len=:) | out | allocatable | the paragraph |
Source
Show the code
pure subroutine first_paragraph(html, out)
character(len=*), intent(in) :: html !! the HTML
character(len=:), allocatable, intent(out) :: out !! the paragraph
integer :: a, b
out = ''
a = index(html, '<p>')
if (a == 0) a = index(html, '<p ')
if (a == 0) return
b = index(html(a:), '</p>')
if (b > 0) out = html(a:a + b + 2)
end subroutine first_paragraph