11.314
suntingan
dw>WOSlinker (use require('strict') instead of require('Module:No globals')) |
(←Membuat halaman berisi '-- This module implements {{section link}}. local checkType = require('libraryUtil').checkType local p = {} local function makeSectionLink(page, section, display) display = display or section page = page or '' return string.format('%s', page, section, display) end local function normalizeTitle(title) title = mw.ustring.gsub(mw.ustring.gsub(title,"'",""),'"','') return mw.title.new(mw.ustring.gsub(title,"%b<>","")).prefixedText end function p._...') |
||
| Baris 1: | Baris 1: | ||
-- This module implements {{section link}}. | -- This module implements {{section link}}. | ||
local checkType = require('libraryUtil').checkType | local checkType = require('libraryUtil').checkType | ||
| Baris 9: | Baris 8: | ||
display = display or section | display = display or section | ||
page = page or '' | page = page or '' | ||
return string.format('[[%s#%s|%s]]', page, section, display) | return string.format('[[%s#%s|%s]]', page, section, display) | ||
end | end | ||
local function normalizeTitle(title) | local function normalizeTitle(title) | ||
title = mw.ustring.gsub(mw.ustring.gsub(title, "'", ""), '"', '') | title = mw.ustring.gsub(mw.ustring.gsub(title,"'",""),'"','') | ||
title | return mw.title.new(mw.ustring.gsub(title,"%b<>","")).prefixedText | ||
end | end | ||
| Baris 51: | Baris 44: | ||
if #sections <= 1 then | if #sections <= 1 then | ||
local linkPage = page or '' | local linkPage = page or '' | ||
local section = sections[1] or ' | local section = sections[1] or 'Catatan' | ||
local display = '§ ' .. section | local display = '§ ' .. section | ||
if isShowingPage then | if isShowingPage then | ||
| Baris 60: | Baris 53: | ||
else | else | ||
error(string.format( | error(string.format( | ||
' | 'Judul tampilan "%s" diabaikan karena ' .. | ||
" | "tidak sama dengan judul halaman yang sebenarnya", | ||
options.display | options.display | ||
), 0) | ), 0) | ||
| Baris 101: | Baris 94: | ||
function p.main(frame) | function p.main(frame) | ||
local args = require('Module:Arguments').getArgs(frame, { | local args = require('Module:Arguments').getArgs(frame, { | ||
wrappers = 'Template:Section link', | wrappers = 'Template:Section link', | ||
| Baris 112: | Baris 104: | ||
end | end | ||
}) | }) | ||
-- Sort the arguments. | -- Sort the arguments. | ||
| Baris 130: | Baris 112: | ||
-- Doing this in the loop because of a bug in [[Module:Arguments]] | -- Doing this in the loop because of a bug in [[Module:Arguments]] | ||
-- when using pairs with deleted arguments. | -- when using pairs with deleted arguments. | ||
page = mw.text.decode(v, | page = mw.text.decode(v, decodeNamedEntities) | ||
elseif type(k) == 'number' then | elseif type(k) == 'number' then | ||
sections[k] = v | sections[k] = v | ||
| Baris 137: | Baris 119: | ||
end | end | ||
end | end | ||
-- Extract section from page, if present | -- Extract section from page, if present | ||