Module:inline: Difference between revisions

Jump to navigation Jump to search
ਕੋਈ ਸੋਧ ਸਾਰ ਨਹੀਂ
No edit summary
No edit summary
Line 3: Line 3:
function export.parse(term)
function export.parse(term)
     local args = {}
     local args = {}
     local i, key, value = 1
     for inline in mw.ustring.gmatch(term, "<([^>]+)>") do
    while i < #term do
    if mw.ustring.find(inline, "%:") then
        key, value, i = mw.ustring.match(term, "<([a-zA-Z]+):([^>]+)>()", i)
    local arg, def = mw.ustring.match(inline, "^([^%:]+)%:([^%:]+)$")
        if key and value then args[key] = value else break end
    args[arg] = def
    else
    args[inline] = true
    end
     end
     end
     return mw.ustring.gsub(term, "<[a-zA-Z]+:[^>]+>", ""), args
     return mw.ustring.gsub(term, "<[^>]+>", ""), args
end
end


return export
return export

Navigation menu