functionitem_textpureprivate
pure integer function item_text(line, ordered, bullet)
The position where the item text of a list line starts, or 0 if it is not one.
Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
| line | character(len=*) | in | the line | |
| ordered | logical | in | accept | |
| bullet | logical | in | accept |
Result
| Name | Type | Attributes | Description |
|---|---|---|---|
| item_text | integer |
Source
Show the code
pure integer function item_text(line, ordered, bullet)
character(len=*), intent(in) :: line !! the line
logical, intent(in) :: ordered !! accept `1.`
logical, intent(in) :: bullet !! accept `*`, `+` and `-`
integer :: first, k
item_text = 0
first = verify(line, ' ')
if (first == 0 .or. first > 4) return
k = first
if (bullet .and. scan(line(k:k), '*+-') == 1) then
k = k + 1
else if (ordered .and. scan(line(k:k), '0123456789') == 1) then
k = k + verify(line(k:)//' ', '0123456789') - 1
if (k > len(line)) return
if (line(k:k) /= '.') return
k = k + 1
else
return
end if
if (k > len(line)) return
if (line(k:k) /= ' ') return
item_text = k + verify(line(k:)//'x', ' ') - 1
end function item_text