Open main menu
Home
Random
Donate
Recent changes
Special pages
Community portal
Preferences
About Stockhub
Disclaimers
Search
User menu
Talk
Contributions
Create account
Log in
Editing
Module:Check DYK hook
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
-- This module performs validation checks for [[WP:DYK]] hooks local libraryUtil = require('libraryUtil') local p = {} local validationPatternGroups = { { -- Check that hooks start with three periods, followed by an acceptable -- follow-on word. "^%.%.%. *that", "^%.%.%. *about", }, { -- Check that hooks end with a question mark, or another acceptable -- phrase. [[.%?%]*'*"?$]], [[.?</span>%]*'*"?$]], "[Yy]ou probably did%.+$", } } function p._isValidHook(hook) -- Whether the given hook is valid. -- We use the patterns in the validationPatternGroups table to find whether -- a hook is valid or not. Hooks are treated as valid if they match at least -- one pattern from each group. libraryUtil.checkType("_isValidHook", 1, hook, "string") for _, patternGroup in ipairs(validationPatternGroups) do local found = false for _, pattern in ipairs(patternGroup) do if mw.ustring.find(hook, pattern) then found = true break end end if not found then return false end end return true end function p.isValidHook(frame) local args = frame.args local hook = args.hook or args[1] if not hook then error("No hook specified") end hook = hook:match('^%s*(.-)%s*$') -- Trim whitespace if p._isValidHook(hook) then return "yes" else return "" end end return p
Summary:
Please note that all contributions to Stockhub may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Stockhub:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Templates used on this page:
Template:Para
(
edit
)
Template:Tl
(
edit
)
Module:Check DYK hook/doc
(
edit
)