Модуль:Сущность: различия между версиями

мНет описания правки
мНет описания правки
Строка 613: Строка 613:
     local valueReplace = mw.text.unstripNoWiki(args.value_replace or "\\1")
     local valueReplace = mw.text.unstripNoWiki(args.value_replace or "\\1")


     local globalPattern = mw.text.unstripNoWiki(args.pattern or args.Pattern or "")
     local pairPattern = mw.text.unstripNoWiki(args.pattern or "")
     local globalReplace = mw.text.unstripNoWiki(args.replace or args.Replace or "\\1")
     local pairReplace = mw.text.unstripNoWiki(args.replace or "\\1")


     local out = {}
     local out = {}
Строка 640: Строка 640:
                 text = apply_pattern(text, patt, repl)
                 text = apply_pattern(text, patt, repl)


                local line
                 if outputType == "enum" then
                 if outputType == "enum" then
                     table.insert(out, text)
                     line = text
                 else
                 else
                     table.insert(out, bullet .. text)
                     line = bullet .. text
                 end
                 end
                if pairPattern ~= "" then
                    line = apply_pattern(line, pairPattern, pairReplace)
                end
                table.insert(out, line)
             end
             end
         end
         end
Строка 684: Строка 691:


             if vStr ~= "" then
             if vStr ~= "" then
                local line
                 if outputType == "enum" then
                 if outputType == "enum" then
                     table.insert(out, vStr .. " " .. keyStr)
                     line = vStr .. " " .. keyStr
                 else
                 else
                     table.insert(out, bullet .. keyStr .. sep .. vStr)
                     line = bullet .. keyStr .. sep .. vStr
                 end
                 end
                if pairPattern ~= "" then
                    line = apply_pattern(line, pairPattern, pairReplace)
                end
                table.insert(out, line)
             end
             end
         end
         end
     end
     end


    local result
     if outputType == "enum" then
     if outputType == "enum" then
         result = table.concat(out, ", ")
         return frame:preprocess(table.concat(out, ", "))
     else
     else
         result = table.concat(out, "\n")
         return frame:preprocess(table.concat(out, "\n"))
    end
 
    if globalPattern and globalPattern ~= "" then
        result = apply_pattern(result, globalPattern, globalReplace)
     end
     end
    return frame:preprocess(result)
end
end


return p
return p