Module:User:DTLHS/defs
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 DTLHS, for his own experimentation. Items in this module may be added and removed at DTLHS's discretion; do not rely on this module's stability.
local export = {}
function split(pString, pPattern)
local Table = {}
local fpat = "(.-)" .. pPattern
local last_end = 1
local s, e, cap = pString:find(fpat, 1)
while s do
if s ~= 1 or cap ~= "" then
table.insert(Table,cap)
end
last_end = e+1
s, e, cap = pString:find(fpat, last_end)
end
if last_end <= #pString then
cap = pString:sub(last_end)
table.insert(Table, cap)
end
return Table
end
function export.show(frame)
local ret = ""
local args = frame:getParent().args
local title = args[1]
local text = mw.title.makeTitle("", title):getContent()
local lines_ = split(text, "\n")
for i,v in ipairs(lines_) do
if string.sub(v, 1, 1) == "#" then
if ret == "" then
ret = ret..v
else
ret = ret.."\n"..v
end
end
end
ret = ret:gsub("{", " ")
ret = ret:gsub("}", " ")
ret = ret:gsub(" ", " ")
return ret
end
return export