-- This module counts table rows in NRHP tables that use Template:NRHP row.localp={}localgetArgsfunctionp.main(frame)ifnotgetArgsthengetArgs=require('Module:Arguments').getArgsendreturnp._main(getArgs(frame,{wrappers='Template:NRHP row counter'}))endfunctionp._main(args)-- Get the title object.localtitleObjdolocalsuccesssuccess,titleObj=pcall(mw.title.new,args.page)ifnotsuccessornottitleObjthentitleObj=mw.title.getCurrentTitle()endend-- Get the page content.localcontent=titleObj:getContent()ifnotcontentthenreturnnilend-- Find the wikitables on that page.localwikitables={}dolocaliWikitable=0locals1=content:match('^({{NRHP header.-\n|})')ifs1theniWikitable=iWikitable+1wikitables[iWikitable]=s1endforsincontent:gmatch('\n({{NRHP header.-\n|})')doiWikitable=iWikitable+1wikitables[iWikitable]=sendend-- Find the wikitable to work on.localwikitableifargs.idthenfori,sinipairs(wikitables)doifs:match('tableID *= *" *(%w+) *"')==args.idthenwikitable=sbreakendendelsewikitable=wikitables[tonumber(args.tableno)or1]endifnotwikitablethenreturnnilend-- Count the number of rows.localcountdolocaltemptemp,count=wikitable:gsub('NRHP row','NRHP row')endreturncountendreturnp