Multipurpouse module, derived from Module:Nap, as a multilanguage version of it (while Module:Nap id mainly focused to nap.wikisource). It is called without any parameter.

The core of the module is, to get the whole wiki code of the page as a plain text:

....
local title=mw.title.getCurrentTitle()
local text=title:getContent()
....

Then the text can be parsed by Lua string functions and freely used. The best results come from standard pages like nsIndex, where contents of MediaWiki:Proofreadpage index template can be used for any fine-tuned categorization using form data and any their combination.


local p = {}


function p.indexCat( frame )
	local title=mw.title.getCurrentTitle()
	local text=title:getContent()
	if title.namespace~=106 and title.namespace~=104 then
		return
	end
	
	local codedText=string.gsub(text,'<div class="pagetext">','(div class="pagetext")')
	--local codedText=string.gsub(codedText,"</noinclude>","")
	local result= '<pre style="display:none;" class="rawcode">'..mw.text.jsonEncode(codedText)..'</pre>'
	--local result=""
	-- caso namespace=Index (106)
	if title.namespace==106 then
		
		local language=string.match(text,"|Language=(.-)\n")
		if string.find(language,"[Nn]ap")~=nil then

			local author=string.match(text,"|Author=(.-)\n")
			
			-- caso link autore piuttosto che nome autore
			if string.find(author,"Author:")~=nil then
				author=string.match(author,'Author:(.-)[|%]]')
			end
			-- trasformazione in tabella per gli autori multipli
			author=mw.text.split(author,"/")
			local year=string.match(text,"|Year=(.-)\n")
			local editor=string.match(text,"|Publisher=(.-)\n")
			if editor=="" then 
				editor=string.match(text,"|Editor=(.-)\n") 
			end
			local progress=string.match(text,"|Progress=(.-)\n")
			
			if string.find(editor,"?")==nil then
				result=result.."[[Category:Editore "..editor.."]]"
			else
				result=result.."[[Category:Editore incertu]]"
			end
			for k,aut in ipairs(author) do 
				if string.find(aut,"?")==nil then
					result=result.."[[Category:Fatiche 'e "..aut.."]]"
				else
					result=result.."[[Category:Fatiche 'e autore incertu]]"
				end
			end
			if progress=="OCR" then 
				result=result.."[[Category:Innece napulitane co' OCR da ffa']]"
			elseif progress=="T" then
				result=result.."[[Category:Innece napulitane fernute]]"
			elseif progress=="V" then
				result=result.."[[Category:Innece napulitane rileggiute]]"
			elseif progress=="C" then
				result=result.."[[Category:Innece napulitane da rileggere]]"
			elseif progress=="MS" then
				result=result.."[[Category:Innece napulitane co' M&S da ffa']]"
			elseif progress=="L" then
				result=result.."[[Category:Innece napulitane co' immaggine da sistemare]]"
			elseif progress=="X" then
				result=result.."[[Category:Innece napulitane co' stato sconosciuto]]"
			else
				result=result.."[[Category:Innece napulitane co' stato sconosciuto]]"
			end
			--return result
		end
	elseif title.namespace==104 then
	-- caso namespace Page (104)
	
		local pagename=string.gsub(title.rootText,"%.djvu","")
		pagename=string.gsub(pagename,"%.pdf","")
		result=result.."[[Category:"..pagename.."]]"
		--return result
	--else
		--return result
	end
	return result
end
return p