Module:User:Yair rand
Jump to navigation
Jump to search
- This module lacks a documentation subpage. You may create it.
- Useful links: subpage list • links • transclusions • testcases • user page • user talk page • userspace
This is a private module sandbox of Yair rand, for his own experimentation. Items in this module may be added and removed at Yair rand's discretion; do not rely on this module's stability.
local p = {}
local languages = mw.loadData("Module:languages")
function p.getTree(lang, w) -- this ... is not well done. meh.
local treeName = "User:Yair rand/ine-pro/wódr̥"
local tree = "\n" .. mw.title.new( treeName ):getContent() .. "\n"
local branchlang = lang
local word = w
local branchname = languages[ branchlang ].names[1]
branchname = string.gsub( branchname, "^Proto%-", "")
local branch = string.sub( tree,
string.find( tree, word and ("|" .. branchlang .. "|" .. word) or ("* " .. branchname .. ": "), 1, true ) or error("Branch not found."),
-1 )
local ind = string.rep( "%*", string.len( string.match( branch, "\n%*+") ) - 2 )
local point = 1
while point ~= nil do
point = string.find(branch, "\n", point + 1)
if string.find(branch, "^\n%*" .. ind, point) == nil then
break
end
end
if point ~= nil then
branch = string.sub( branch, 1, point )
end
branch = string.gsub( branch, "^[^\n]+\n", "\n")
branch = string.gsub( branch, "\n" .. ind, "\n")
return branch, ind, point
end
return p