Module:HTMLParse: Difference between revisions

9 bytes added ,  17:39, 20 August 2019
m
no edit summary
(create module for general HTML parsing. Begin with a "pluralize" function that can be used in Favilink)
 
mNo edit summary
Line 3: Line 3:
function p.pluralize(frame)
function p.pluralize(frame)
     local htmlString = frame.args[1]
     local htmlString = frame.args[1]
     prefix, postfix = s:match'(.*%a)(</.*)'  --split string at the last alphabetic character that appears immediately before a closing html tag </...>
     prefix, postfix = htmlString:match'(.*%a)(</.*)'  --split string at the last alphabetic character that appears immediately before a closing html tag </...>
     if (prefix == nil or prefix == '' or postfix == nil or postfix == '') then
     if (prefix == nil or prefix == '' or postfix == nil or postfix == '') then
         return htmlString  --return unmodified string (couldn't find alpha character followed by closing HTML tag)
         return htmlString  --return unmodified string (couldn't find alpha character followed by closing HTML tag)