Module:User:Victar/sandbox
Appearance
- The following documentation is located at Module:User:Victar/sandbox/documentation. [edit]
- Useful links: root page • root page’s subpages • links • transclusions • testcases • sandbox of
Lua error at line 14: attempt to call field 'getFull' (a nil value)
local export = {}
local m_languages = require("Module:languages")
function export.sandbox()
local term = "lait"
local lang = "fro"
local id = "ugly"
lang = m_languages.getByCode(lang)
or require("Module:etymology languages").getByCode(lang)
or m_languages.err(lang, 1)
local entryLang = require("Module:etymology").getFull(lang)
local page = mw.title.new(require("Module:links").getLinkPage(term, lang))
local content = page:getContent()
if not content then
return ""
end
local _, index = mw.ustring.find(content, "\n==" .. lang:getCanonicalName() .. "==", nil, true)
if not index then
_, index = mw.ustring.find(content, "^==" .. require("Module:utilities").pattern_escape(lang:getCanonicalName()) .. "==", nil, false)
end
if not index then
error("Language not found: " .. lang:getCanonicalName() .. ".")
end
_, next_lang = mw.ustring.find(content, "\n==[^=\n]+==", index, false)
_, index = mw.ustring.find(content, "\n(=====?)Descendants%1", index, false)
if (not index) or (next_lang and next_lang < index) then
error("Descendants not found")
end
index = "^.*(\n==" .. lang:getCanonicalName() .. ".*)\n==[^=].*"
content = mw.ustring.match(content, index)
content = mw.ustring.gsub(content, "----", "") -- remove devider
local content = require("Module:string").matchToArray(content, "(\n=+[^=]*=+.-)\n=+[^=]")
--index = "^.*(\n=+Descendants=+\n[^=]*).*"
--content = mw.ustring.gsub(content, index, "%1") -- get first list of descendants
-- content = mw.ustring.gsub( content, "^.*{{senseid|" .. lang:getCode() .. "|" .. id .. "}}(.*)", "%1")
return content[5]
end
return export