Line 21: |
Line 21: |
| title = mw.ustring.gsub(title, "%b<>", "") | | title = mw.ustring.gsub(title, "%b<>", "") |
| return mw.title.new(title).prefixedText | | return mw.title.new(title).prefixedText |
| + | end |
| + | |
| + | local function makeLHS(page, options, title, middle) |
| + | local lhs = middle |
| + | if not options.nopage then |
| + | page = page or title.prefixedText |
| + | if options.display and options.display ~= '' then |
| + | if normalizeTitle(options.display) == normalizeTitle(page) then |
| + | lhs = options.display .. ' ' .. lhs |
| + | else |
| + | error(string.format( |
| + | 'Display title "%s" was ignored since it is ' .. |
| + | "not equivalent to the page's actual title", |
| + | options.display |
| + | ), 0) |
| + | end |
| + | else |
| + | lhs = page .. ' ' .. lhs |
| + | end |
| + | end |
| + | return lhs |
| end | | end |
| | | |
Line 48: |
Line 69: |
| | | |
| -- Make the link(s). | | -- Make the link(s). |
− | local isShowingPage = not options.nopage
| |
| if #sections <= 1 then | | if #sections <= 1 then |
| local linkPage = page or '' | | local linkPage = page or '' |
| local section = sections[1] or 'Notes' | | local section = sections[1] or 'Notes' |
− | local display = '§ ' .. section | + | local display = makeLHS(page, options, title, '§ ') .. section |
− | if isShowingPage then
| |
− | page = page or title.prefixedText
| |
− | if options.display and options.display ~= '' then
| |
− | if normalizeTitle(options.display) == normalizeTitle(page) then
| |
− | display = options.display .. ' ' .. display
| |
− | else
| |
− | error(string.format(
| |
− | 'Display title "%s" was ignored since it is ' ..
| |
− | "not equivalent to the page's actual title",
| |
− | options.display
| |
− | ), 0)
| |
− | end
| |
− | else
| |
− | display = page .. ' ' .. display
| |
− | end
| |
− | end
| |
| return makeSectionLink(linkPage, section, display) | | return makeSectionLink(linkPage, section, display) |
| else | | else |
Line 90: |
Line 94: |
| | | |
| -- Add the intro text. | | -- Add the intro text. |
− | local intro = '§§ ' | + | ret = makeLHS(page, options, title, '§§ ') .. ret |
− | if isShowingPage then
| |
− | intro = (page or title.prefixedText) .. ' ' .. intro
| |
− | end
| |
− | ret = intro .. ret
| |
| | | |
| return ret | | return ret |