「モジュール:See/core」の版間の差分
ナビゲーションに移動
検索に移動
Dummy index (トーク | 投稿記録) ページの作成:「local p = {} function p._isValidPageName(frame) local success, res = pcall(mw.title.new, frame.args[1]) if success and res then return "valid" else return "" end end function p.GetLink(frame) local link = frame.args[1] local display = frame.args[2] -- 第一引数の値が技術的に利用可能な記事名でない場合、 -- 第一引数の値をそのまま返す --local IsValidPageName = require('モジュール:IsValidPageName')…」 |
Dummy index (トーク | 投稿記録) 編集の要約なし |
||
| 17行目: | 17行目: | ||
-- 第一引数の値をそのまま返す | -- 第一引数の値をそのまま返す | ||
--local IsValidPageName = require('モジュール:IsValidPageName') | --local IsValidPageName = require('モジュール:IsValidPageName') | ||
if _isValidPageName(frame) == "" then | if p._isValidPageName(frame) == "" then | ||
return link | return link | ||
end | end | ||
2025年10月2日 (木) 15:35時点における最新版
このモジュールについての説明文ページを モジュール:See/core/doc に作成できます
local p = {}
function p._isValidPageName(frame)
local success, res = pcall(mw.title.new, frame.args[1])
if success and res then
return "valid"
else
return ""
end
end
function p.GetLink(frame)
local link = frame.args[1]
local display = frame.args[2]
-- 第一引数の値が技術的に利用可能な記事名でない場合、
-- 第一引数の値をそのまま返す
--local IsValidPageName = require('モジュール:IsValidPageName')
if p._isValidPageName(frame) == "" then
return link
end
if display == "" then
display = nil
end
return p._formatLink(link, display)
end
function p._formatLink(link, display)
-- Remove the initial colon for links where it was specified manually.
link = link:match('^:?(.*)')
-- Find whether a faux display value has been added with the {{!}} magic
-- word.
if not display then
local prePipe, postPipe = link:match('^(.-)|(.*)$')
link = prePipe or link
display = postPipe
end
-- Assemble the link.
if display then
return string.format(
'[[:%s|%s]]',
string.gsub(link, '|(.*)$', ''), --display overwrites manual piping
display
)
else
return string.format('[[:%s]]', link)
end
end
return p