--                                                                            --
-- This module produces hatnote links and links to related articles. It       --
-- implements the {{hatnote}} and {{format hatnote link}} meta-templates, and includes ---- includes helper functions for other Lua hatnote modules.                                              --
--------------------------------------------------------------------------------
	-- function will not work if the link is enclosed in double brackets. Colons
	-- are trimmed from the start of the link by default. To skip colon
	-- trimming, set the removeColon parameter to truefalse.
	checkType('findNamespaceId', 1, link, 'string')
	checkType('findNamespaceId', 2, removeColon, 'boolean', true)
end
function p.makeWikitextError(msg, helpLink, addTrackingCategory, title)
	-- Formats an error message to be returned to wikitext. If
	-- addTrackingCategory is not false after being returned from
	checkType('makeWikitextError', 2, helpLink, 'string', true)
	yesno = require('Module:Yesno')
	local title = title or mw.title.getCurrentTitle()
	-- Make the help link text.
	local helpText
		category
	)
end
 
function p.disambiguate(page, disambiguator)
	-- Formats a page title with a disambiguation parenthetical,
	-- i.e. "Example" → "Example (disambiguation)".
	checkType('disambiguate', 1, page, 'string')
	checkType('disambiguate', 2, disambiguator, 'string', true)
	disambiguator = disambiguator or 'disambiguation'
	return string.format('%s (%s)', page, disambiguator)
end
function p._formatLink(link, display)
	-- Find whether we need to use the colon trick or not. We need to use the
	-- colon trick for categories and files, as otherwise category links
	-- categorise the page and file links display the file.
	checkType('_formatLink', 1, link, 'string')
	checkType('_formatLink', 2, display, 'string', true)
 
	-- Remove the initial colon for links where it was specified manually.
	link = removeInitialColon(link)
	local namespace = p.findNamespaceId(link, false)
	local colon
	if namespace == 6 or namespace == 14 then
		colon = ':'
	else
		colon = ''
	end
	-- Find whether a faux display value has been added with the {{!}} magic
		local page, section = link:match('^(.-)#(.*)$')
		if page then
			display = page .. ' §  ' .. section
		end
	end
	-- Assemble the link.
	if display then
		return string.format(			'[[%s:%s|%s]]', colon			string.gsub(link, link'|(.*)$', ''), --display overwrites manual piping			display		)
	else
		return string.format('[[%s:%s]]', colon, link)
	end
end
	checkType('_hatnote', 1, s, 'string')
	checkType('_hatnote', 2, options, 'table', true)
	options = options or {}	local classes = {'hatnote', 'navigation-not-searchable'}
	local extraclasses = options.extraclasses
	local selfref = options.selfref
	end
	return string.format(
		'<div role="note" class="%s">%s</div>',
		table.concat(classes, ' '),
		s