fdoc

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

NameTypeIntentAttributesDescription
linecharacter(len=*)in

the line

orderedlogicalin

accept 1.

bulletlogicalin

accept *, + and -

Result

NameTypeAttributesDescription
item_textinteger

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

Graphs

Called by