Mô đun:Mục từ cần viết

Từ điển mở Wiktionary
local p = {}
local v = require "Module:Quốc ngữ"
local dataPage = mw.title.new("Mục từ cần viết/Danh sách", "Template")

p["danh sách"] = function (frame)
    local data = dataPage:getContent()
    local titles = {}
    for name in mw.ustring.gmatch(data, "%[%[%s*(.-)%s*%]%]") do
    	local title = mw.title.new(name, 0)
        if title and not title.exists then
            table.insert(titles, name)
        end
    end
    table.sort(titles, v.comp)
    for i, title in ipairs(titles) do
        titles[i] = "[[" .. mw.ustring.gsub(title, " ", " ") .. "]]"
    end
    return table.concat(titles, ", ")
end

p["yêu cầu chưa"] = function (frame)
    local title = frame.args[1]
    local data = dataPage:getContent()
    if mw.ustring.find(data, "%[%[%s*" .. title .. "%s*%]%]") then
        return title
    end
    return ""
end

return p