Module:Section link: Difference between revisions
Detect anchors in page parameter, other code cleanup
m>Ahecht (implement display= parameter) |
m>Ahecht (Detect anchors in page parameter, other code cleanup) |
||
Line 12: | Line 12: | ||
local function normalizeTitle(title) | local function normalizeTitle(title) | ||
title = mw.ustring.gsub(title,"'","") | title = mw.ustring.gsub(mw.ustring.gsub(title,"'",""),'"','') | ||
return mw.title.new(mw.ustring.gsub(title,"%b<>","")).prefixedText | |||
title | |||
end | end | ||
Line 50: | Line 48: | ||
if isShowingPage then | if isShowingPage then | ||
page = page or title.prefixedText | page = page or title.prefixedText | ||
if displaytitle then | if displaytitle and displaytitle ~= '' then | ||
if normalizeTitle(displaytitle) == normalizeTitle(page) then | if normalizeTitle(displaytitle) == normalizeTitle(page) then | ||
display = displaytitle .. ' ' .. display | display = displaytitle .. ' ' .. display | ||
Line 122: | Line 120: | ||
options[k] = v | options[k] = v | ||
end | end | ||
end | |||
-- Extract section from page, if present | |||
if page then | |||
local p, s = page:match('^(.-)#(.*)$') | |||
if p then page, sections[1] = p, s end | |||
end | end | ||