Module:Taxonbar/exists/sandbox: Difference between revisions
Appearance
Content deleted Content added
Tom.Reding (talk | contribs) step |
Tom.Reding (talk | contribs) showall |
||
Line 15: | Line 15: | ||
local found = string.match(content, v) |
local found = string.match(content, v) |
||
if found then |
if found then |
||
local |
local v_cmt_before0 = '....'..v |
||
local v_cmt_before1 = '%<...'..v |
|||
local v_cmt_before2 = '.%!..'..v |
|||
local v_cmt_before3 = '..%-.'..v |
|||
local v_cmt_before4 = '..%-%-'..v |
|||
local v_cmt_before5 = '...%-'..v |
|||
local v_cmt_after = v..'[^{}]*}}%s*-->' |
local v_cmt_after = v..'[^{}]*}}%s*-->' |
||
local found_cmt = mw.ustring.match(content, v_cmt_before) or mw.ustring.match(content, v_cmt_after) |
local found_cmt = mw.ustring.match(content, v_cmt_before) or mw.ustring.match(content, v_cmt_after) |
||
if true then |
if true then --debug |
||
return '# '..v_cmt_before0..' '..(mw.ustring.match(content, v_cmt_before0) or 'no match0')..'\n'.. |
|||
'# '..v_cmt_before1..' '..(mw.ustring.match(content, v_cmt_before1) or 'no match1')..'\n'.. |
|||
'# '..v_cmt_before2..' '..(mw.ustring.match(content, v_cmt_before2) or 'no match2')..'\n'.. |
|||
'# '..v_cmt_before3..' '..(mw.ustring.match(content, v_cmt_before3) or 'no match3')..'\n'.. |
|||
'# '..v_cmt_before4..' '..(mw.ustring.match(content, v_cmt_before4) or 'no match4')..'\n'.. |
|||
'# '..v_cmt_before5..' '..(mw.ustring.match(content, v_cmt_before5) or 'no match5')..'\n' |
|||
end |
|||
if found_cmt then return 'commented' |
if found_cmt then return 'commented' |
||
else return true end |
else return true end |
Revision as of 14:03, 17 April 2024
![]() | This is the module sandbox page for Module:Taxonbar/exists (diff). |
![]() | This Lua module is used on approximately 471,000 pages, or roughly 1% of all pages. To avoid major disruption and server load, any changes should be tested in the module's /sandbox or /testcases subpages, or in your own module sandbox. The tested changes can be added to this page in a single edit. Consider discussing changes on the talk page before implementing them. |
![]() | This module depends on the following other modules: |
Related pages |
---|
About
Checks the page for transclusions of {{Taxonbar}} and its redirects, returning true
or false
.
Usage
local taxonbarExists = require('Module:Taxonbar/exists').check
See also
- {{Taxonbar/candidate}}
- {{Taxobox/core}}
local p = {}
function p.check( frame )
local pagename = mw.title.getCurrentTitle().baseText
local content = mw.title.new(pagename):getContent() or ''
-------sandbox only: do not include this if-statement in the live module!-------
if string.match(pagename, 'sandbox') or
string.match(pagename, 'testcases') then
content = mw.title.new(pagename, 'Template'):getContent() or ''
end
-------sandbox only: do not include this if-statement in the live module!-------
local getRegex = require('Module:Template redirect regex').main
local tregex = getRegex('Taxonbar')
for _, v in pairs (tregex) do
local found = string.match(content, v)
if found then
local v_cmt_before0 = '....'..v
local v_cmt_before1 = '%<...'..v
local v_cmt_before2 = '.%!..'..v
local v_cmt_before3 = '..%-.'..v
local v_cmt_before4 = '..%-%-'..v
local v_cmt_before5 = '...%-'..v
local v_cmt_after = v..'[^{}]*}}%s*-->'
local found_cmt = mw.ustring.match(content, v_cmt_before) or mw.ustring.match(content, v_cmt_after)
if true then --debug
return '# '..v_cmt_before0..' '..(mw.ustring.match(content, v_cmt_before0) or 'no match0')..'\n'..
'# '..v_cmt_before1..' '..(mw.ustring.match(content, v_cmt_before1) or 'no match1')..'\n'..
'# '..v_cmt_before2..' '..(mw.ustring.match(content, v_cmt_before2) or 'no match2')..'\n'..
'# '..v_cmt_before3..' '..(mw.ustring.match(content, v_cmt_before3) or 'no match3')..'\n'..
'# '..v_cmt_before4..' '..(mw.ustring.match(content, v_cmt_before4) or 'no match4')..'\n'..
'# '..v_cmt_before5..' '..(mw.ustring.match(content, v_cmt_before5) or 'no match5')..'\n'
end
if found_cmt then return 'commented'
else return true end
end
end
return false
end
return p