fdoc

subroutineattribute_listprivate

subroutine attribute_list(text, attrs)

Turn the contents of an attribute list, #id .class key=value, into HTML attributes.

Arguments

NameTypeIntentAttributesDescription
textcharacter(len=*)in

the list

attrscharacter(len=:)outallocatable

the attributes

Calls

Source

Show the code
subroutine attribute_list(text, attrs)
    character(len=*), intent(in) :: text                !! the list
    character(len=:), allocatable, intent(out) :: attrs !! the attributes
    type(string_t), allocatable :: words(:)
    character(len=:), allocatable :: classes, id, others
    integer :: k, at

    words = split_words(text)
    classes = ''
    id = ''
    others = ''
    do k = 1, size(words)
        associate (w => words(k)%s)
            if (w(1:1) == '#') then
                id = w(2:)
            else if (w(1:1) == '.') then
                if (len(classes) > 0) classes = classes//' '
                classes = classes//w(2:)
            else
                at = index(w, '=')
                if (at > 0) others = others//' '//w(:at)//'"'//w(at + 1:)//'"'
            end if
        end associate
    end do
    attrs = others
    if (len(classes) > 0) attrs = ' class="'//classes//'"'//attrs
    if (len(id) > 0) attrs = attrs//' id="'//id//'"'
end subroutine attribute_list

Graphs

Calls

Called by