Modul:Transcluder: Perbedaan antara revisi

Konten dihapus Konten ditambahkan
Update from master using Synchronizer
Update from master using #Synchronizer
 
(5 revisi perantara oleh 2 pengguna tidak ditampilkan)
Baris 1:
-- Module:Transcluder is a general-purpose transclusion engine
-- Central versionDocumentation and documentationmaster atversion: https://wwwen.mediawikiwikipedia.org/wiki/Module:Transcluder
-- ByAuthors: User:Sophivorus, User:Certes & others
-- License: CC-BY-SA-3.0
-- Version 1.4.1
-- License CC-BY-SA-3.0
 
local p = {}
Baris 156 ⟶ 155:
-- For file pages, returns the content of the file description page
local function getText(page, noFollow)
page = mw.text.decode(page)
local title = mw.title.new(page)
if not title then return false, false end
Baris 243:
for template in string.gmatch(text, '{%b{}}') do
if string.sub(template, 1, 3) ~= '{{#' then -- skip parser functions like #if
name = mw.text.trim( string.match(template, '{{([^}|\n]+)') or "" ) -- get the template name
countif =name count~= +"" 1then
count = count + 1
if not blacklist and ( not flags or flags[count] or matchFlag(name, flags) )
or blacklist and flags and not flags[count] and not matchFlag(name, flags) then
table.insert(templates, template)
else
text = removeString(text, template)
end
end
end
Baris 267 ⟶ 269:
local params, count, parts, key, value
for template in string.gmatch(text, '{%b{}}') do
params = string.match(template, '{{[^|}]-|(.+*)}}')
if params then
count = 0
-- Temporarily replace pipes in subtemplates, tables and links to avoid chaos
for subtemplate in string.gmatch(params, '{%b{}}') do
params = string.gsub(params, escapeString(subtemplate), string.gsub(subtemplate, ".", {["%"]="%%", ["|"]="@@:@@", ["="]="@@_@@"}) )
end
Baris 280 ⟶ 282:
parts = mw.text.split(parameter, '=')
key = mw.text.trim(parts[1])
valueif = table.concat(#parts, '=',= 1 2)then
if value == '' then
value = key
count = count + 1
key = count
else
value = mw.text.trim(valuetable.concat(parts, '=', 2))
end
value = string.gsub(string.gsub(value, '@@:@@', '|'), '@@_@@', '=')
Baris 338 ⟶ 339:
elements, temp = getFiles(temp, 0) -- remove files
temp = mw.text.trim((temp
:gsub('\n%b{} *\n', '\n%0\n') -- add spacing between tables and block templates
:gsub('\n%b{} *\n', '\n') -- remove tables and block templates
:gsub('\n==+[^=]+==+ *\n', '\n') -- remove section titles
))
 
Baris 584 ⟶ 585:
local function removeLinks(text)
text = text
:gsub('%[%[[^%]|]+|([^]]+)%]%]', '%1')
:gsub('%[%[([^]]+)%]%]', '%1')
:gsub('%[[^ ]+ ([^]]+)%]', '%1')
Baris 616 ⟶ 617:
if not page then return throwError('no-page') end
page = mw.text.trim(page)
page = mw.text.decode(page)
if page == '' then return throwError('no-page') end
local page, hash, section = string.match(page, '([^#]+)(#?)(.*)')
local text, pagetemp = getText(page, options.noFollow)
if not pagetemp then return throwError('noinvalid-pagetitle', page) end
page = temp
if not text then return throwError('page-not-found', page) end
local full = text -- save the full text for fixReferences below
Baris 684 ⟶ 687:
local ok, text = pcall(get, page, args)
if not ok then return getError(text) end
local raw = args['raw']
if raw then return text end
return frame:preprocess(text)
end