Jump to content

Module:DYK queue formatting check

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by 216.58.25.209 (talk) at 19:18, 25 March 2025 (detect https://en.wikipedia.org/w/index.php?title=Template:Did_you_know/Preparation_area_5&diff=prev&oldid=1282059255). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
-- Verifies [[WP:DYKMOS]]
-- https://en.wikipedia.org/wiki/Wikipedia:Main_Page/Errors#c-Ravenpuff-20250321152600-Current_DYK

local p = {}

function p._check(content)
	if string.find(content, "|''[^]]+''%]") then
		return "WP:DYKMOS: Markup should go on the outside of the link if possible"
	end
	if string.find(content, "%(''[^)]+''%)") then
		return "WP:DYKMOS: Note that the italics sit outside the parentheses"
	end
	if (string.find(content, "[^']''%?")
		or string.find(content, "''''%?")
		or string.find(content, "[ ;?]%?")) then
		return "WP:DYKMOS: There should not be a space before the question mark, " ..
		"but if the text directly preceding it is italicized, " ..
		"the {{-?}} tag can offset it."
	end
	if string.find(content, "''s") then
		return "WP:DYKMOS: Keep the bold/italic text and the apostrophe distinct"
	end
	if (string.find(content, "''''{{`") -- Use {{'}} with bold italic
		or string.find(content, "[^']''{{`") -- Use {{'}} with italic
		or string.find(content, "[^']'''{{'")) then -- Use {{`}} with bold
		-- Adapted from [[Template:Quotation mark templates]]
		return "WP:DYKMOS: {{`}} (or {{`s}}) is for adjacent bold markup; " ..
		"{{'}} (or {{'s}}) is for adjacent italic (or bold italic)"
	end
end

function p.main(frame)
	local message = p._check(mw.title.getCurrentTitle().content)
	if message then
		return require("Module:Error").error{message}
	end
end

return p