Module:User:Theknightwho/links
Jump to navigation
Jump to search
- This module sandbox lacks a documentation subpage. You may create it.
- Useful links: root page • root page’s subpages • links • transclusions • testcases • user page • user talk page • userspace
This is a private module sandbox of Theknightwho, for their own experimentation. Items in this module may be added and removed at Theknightwho's discretion; do not rely on this module's stability.
local parser = require("Module:User:Theknightwho/wikitext parser")
local export = {}
local function iterate_links(text)
text:new_iter("next_node")
-- If text is itself a template object, return it on the first iteration.
local self_ret, node = text.type == "wikilink"
return function()
if self_ret then
self_ret = false
return text
end
repeat
node = text:iterate()
until not node or node.type == "wikilink"
if node then
return node
end
end
end
function export.language_link(data, allow_self_link)
if type(data) ~= "table" then
error("The first argument to the function language_link must be a table. See Module:links/documentation for more information.")
-- Nothing to process, return nil.
elseif not (data.term or data.alt) then
return nil
end
local term, alt
if data.term then
term = parser.parse_link_template(data.term)
if data.alt then
alt = parser.parse_nowiki(data.alt, true)
end
elseif data.alt then
alt = parser.parse(data.alt, true)
end
for link in iterate_links(term) do
end
end
return export