131,292
עריכות
(מודול לחיקוי #קטע (Labeled Section Transclusion) לטקסטים שהועתקו מוויקיטקסט) |
(הוספת פונקציה exclude (חיקוי #בלי קטע)) |
||
| שורה 52: | שורה 52: | ||
end | end | ||
return frame:preprocess(cleanTransclusion(table.concat(parts, '\n'))) | return frame:preprocess(cleanTransclusion(table.concat(parts, '\n'))) | ||
end | |||
function p.exclude(frame) | |||
local args = frame.args | |||
local pageName = trim(args[1]) | |||
local label = trim(args[2]) | |||
if pageName == '' then | |||
return '' | |||
end | |||
local title = mw.title.new(pageName) | |||
if not title then | |||
return '' | |||
end | |||
local content = title:getContent() | |||
if not content then | |||
return '' | |||
end | |||
if label ~= '' then | |||
local startMark = '<!--קטע התחלה=' .. label .. '-->' | |||
local endMark = '<!--קטע סוף=' .. label .. '-->' | |||
while true do | |||
local s, e = string.find(content, startMark, 1, true) | |||
if not s then | |||
break | |||
end | |||
local s2, e2 = string.find(content, endMark, e + 1, true) | |||
if s2 then | |||
content = string.sub(content, 1, s - 1) .. string.sub(content, e2 + 1) | |||
else | |||
content = string.sub(content, 1, s - 1) | |||
break | |||
end | |||
end | |||
end | |||
return frame:preprocess(cleanTransclusion(content)) | |||
end | end | ||
return p | return p | ||