Module:HTMLParse: Difference between revisions

16 bytes added ,  01:17, 5 January 2021
m
no edit summary
(capitalize...?)
mNo edit summary
 
(2 intermediate revisions by the same user not shown)
Line 25: Line 25:
         htmlString = frame:preprocess(htmlString)  --expand any templates that may have been passed to this module
         htmlString = frame:preprocess(htmlString)  --expand any templates that may have been passed to this module
     end
     end
     prefix, postfix = htmlString:match'(<.*>)(.*%a)'  --split string at the first alphabetic character that appears immediately after a starting html tag <...>
     --split string at the first alphabetic character that appears immediately after a starting html tag <...>
    prefix = htmlString:match'([^/]*>)' or ''
     if (prefix == nil or prefix == '') then
     if (prefix == nil or prefix == '') then
     if (postfix == nil or postfix == '') then
     return conjugate.capitalize(htmlString)  
    return htmlString  --return unmodified string
        else
        return conjugate.capitalize(htmlString)  
        end
     else
     else
      return (prefix .. conjugate.capitalize(postfix))
    _, a = htmlString:find'([^/]*>)'
    postfix = htmlString:sub(a + 1) or ''
    mw.log('prefix: ' .. prefix)
    mw.log('postfix: ' .. postfix)
    return (prefix .. conjugate.capitalize(postfix))
     end
     end
end
end