Модуль:Поиск шаблона страницы: различия между версиями

мНет описания правки
мНет описания правки
Строка 5: Строка 5:
     local searchText = args[1] or ""
     local searchText = args[1] or ""


     searchText = searchText:gsub("^<nowiki>(.-)</nowiki>$", "%1")
     searchText = searchText:match("^%s*(.-)%s*$")
   
    if searchText == "" then
        return "Нет"
    end


     local title = mw.title.getCurrentTitle()
     local title = mw.title.getCurrentTitle()
     local content = title:getContent()
     local content = title:getContent()
     if not content then
     if not content then
         return "Нет"
         return "Нет"
Строка 15: Строка 18:


     local cleanedContent = content:gsub("{{#invoke:Поиск строк страницы|main|[^}]+}}", "")
     local cleanedContent = content:gsub("{{#invoke:Поиск строк страницы|main|[^}]+}}", "")
    cleanedContent = cleanedContent:gsub("<code>.-</code>", "")
    cleanedContent = cleanedContent:gsub("<nowiki>.-</nowiki>", "")


     if not cleanedContent:match(searchText) then
    local pattern = "%f[%w]" .. searchText .. "%f[%W]"
     if not cleanedContent:match(pattern) then
         return "Нет"
         return "Нет"
     end
     end