Module:Sandbox/Hellknowz/Test: Difference between revisions

Content deleted Content added
m typical
fix
Line 722:
-- Strips whitespace from an input
function trim(value)
returnlocal value:strip, count = string.gsub(value, '^%s*(.-)%s*$', '%1')
return strip
end
 
Line 729 ⟶ 730:
-- todo: do progressive scan like with that seek string just for ref tags and such
local matchNoRefmatchStrip = value:match('^([^<]+)<ref[^>]*>[^<]*</ref><ref[^>]*>[^<]*</ref><ref[^>]*>[^<]*</ref>$') -- basic refs
if (matchNoRefmatchStrip) then return trim(matchNoRefmatchStrip) end
 
matchNoRefmatchStrip = value:match('^([^<]+)<ref[^>]*>[^<]*</ref><ref[^>]*>[^<]*</ref>$') -- basic refs
if (matchNoRefmatchStrip) then return trim(matchNoRefmatchStrip) end
 
matchNoRefmatchStrip = value:match('^([^<]+)<ref[^>]*>[^<]*</ref>$') -- basic refs
if (matchNoRefmatchStrip) then return trim(matchNoRefmatchStrip) end
matchNoRefmatchStrip = value:match('^([^<]+)<ref[^>]*/><ref[^>]*/><ref[^>]*/>$') -- basic named ref
if (matchNoRefmatchStrip) then return trim(matchNoRefmatchStrip) end
matchNoRefmatchStrip = value:match('^([^<]+)<ref[^>]*/><ref[^>]*/>$') -- basic named ref
if (matchNoRefmatchStrip) then return trim(matchNoRefmatchStrip) end
matchNoRefmatchStrip = value:match('^([^<]+)<ref[^>]*/>$') -- basic named ref
if (matchNoRefmatchStrip) then return trim(matchNoRefmatchStrip) end
matchNoRefmatchStrip = value:match('^<!--.?--->([^<]+)$') -- comment before
if (matchNoRefmatchStrip) then return trim(matchNoRefmatchStrip) end
matchNoRefmatchStrip = value:match('^([^<]+)<!--.?--->$') -- comment after
if (matchNoRefmatchStrip) then return trim(matchNoRefmatchStrip) end
return value -- if we didn't match anything, abort now
end