Module:DYK queue formatting check
Appearance
-- Verifies [[WP:DYKMOS]]
-- https://en.wikipedia.org/wiki/Wikipedia:Main_Page/Errors#c-Ravenpuff-20250321152600-Current_DYK
local p = {}
local plainText = require("Module:Plain text")._main
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 (or bold italic) text and " ..
"the apostrophe distinct using {{`s}}/{{'s}} respectively"
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
local frame = mw.getCurrentFrame()
-- Counting starts from after the space following the three dots
local hookCount = 0
for wikitextLine in content:gmatch("\n%* %.%.%. ([^\n]*)") do
local byteCount = -1 -- and ends at the question mark
if string.find(wikitextLine, "''%([^)]+%)''") then
-- The eleven characters in a ''(pictured)'' tag do not count
byteCount = byteCount - 11
end
local expandedLine = plainText(frame:preprocess(wikitextLine), false)
byteCount = byteCount + #expandedLine
if byteCount > 200 then
return "WP:DYK200: The hook cannot exceed 200 prose characters. " ..
"It is currently " .. count .. " characters: " .. expandedLine
end
hookCount = hookCount + 1
if hookCount ~= 1 then
if string.find(wikitextLine, "''%([^)]+%)''") then
return "WP:DYKIMG/WP:DYKMOS: " ..
"Extra ''(pictured)'' or alternative: " .. expandedLine
end
else
-- Separate to avoid false positives like
-- [[Special:Diff/1282220478]]
if not string.find(wikitextLine, "%([^)]+%)") then
return "WP:DYKIMG/WP:DYKMOS: " ..
"Missing ''(pictured)'' or alternative: " .. expandedLine
end
end
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