Content deleted Content added
or nil... |
m per edit request at Template talk:Cite CIA World Factbook#8 April 2024 edit request - position full stop within parentheses |
||
(5 intermediate revisions by 4 users not shown) | |||
Line 1:
local p = {}
local getArgs = require('Module:Arguments').getArgs
-- prefix of all World Factbook pages
local factbookPrefix = 'https://www.cia.gov/the-world-factbook/'
-- Format of archive link. Both %d represent the year of the archive
local
-- Function to turn a string into a URL fragment appropriate for CIA website
local function parseFragment(s)
if not s then
return ''
end
s = mw.ustring.lower(s)
s = mw.ustring.gsub(s,' ','-')
s = mw.ustring.gsub(s,',','')
return s
end
-- Function to fill in factbook link:
-- Arguments:
-- args.country: topic of page (optional)
-- args.section: section of page (optional)
-- Returns:
-- link to World Factbook page about country, with section anchor
function p._country(args)
if not args.country then
return factbookPrefix
end
local result = factbookPrefix..'countries/'..parseFragment(args.country)
if args.section then
return result..'/#'..parseFragment(args.section)
end
return result
end
-- Function to fill in archive link
-- Arguments:
-- args.archive: if non-empty, return nil
Line 28 ⟶ 59:
return year
end
if year
return false
end
return mw.ustring.format(
end
function p.country(frame)
local args = getArgs(frame)
return p._country(args)
end
|