Module:toc-test/param

Από Βικιλεξικό
Μετάβαση στην πλοήγηση Πήδηση στην αναζήτηση

Module:toc-test »     Module:toc-test/param     « Module:toc-test/τεκμηρίωση/documentation
test at Template:toc-test     -     full numbering at wikt:el:Template:toc/style.css


---------------------------------------------- SPLIT param pages (with ifs) By [[w:en:User talk:Trappist the monk]] at wikipedia
-- examples: [[wikt:el:Module:grc-nouns-decl/param]]
-- ========== Module:xxx/param  === parameters of Module:xxx ========== --
-- INSTRUCTIONS:
-- Call if from the central declension module by placing EXACTLY where it is needed:
	-- require ('Module:xxx/param').param (args)
	-- DO NOT change anything else. DO NOT add at top of page a m_main = require this and that.
	
-- USE: local for the functions
export = {}
-- COPY HERE what is needed for THIS page, from the Module 
pos = require("Module:PartOfSpeech/pos")


--[[--------------------------< I S _ S E T >------------ 
Returns true if argument is set; false otherwise. Argument is 'set' when it exists (not nil) or when it is not an empty string.
]]
--[=[ explanation:
The is_set() function may be added so that tests like this:
	if args['ακε'] ~= '' and args['ακε'] ~= nil then args['ακε'] = args['ακε'] else args['ακε'] = '' end
can be reduced to:
	if not is_set (args['ακε']) then args['ακε'] = '' end
]=]--

local function is_set (var)
	return not (var == nil or var == '');
end

---------------------------------------------------------------------------
-- ========================MAIN FUNCTION================================ --
---------------------------------------------------------------------------
local function param (args) -- this is closed at the end of this page
--	local xxxx = args['ωωω'] or ''
	-- if this, do that, end e.g.

--	local output = {}

	local page = mw.title.getCurrentTitle()
	
--	local header_numbered = {}
--	local header_count = {}
	
	local content = page:getContent()
	for start_equals, header, end_equals in content:gmatch("%f[^\n%z](=+)([^=\n]+)(=+)") do
		header = mw.text.trim(header)
		
		local start_level, end_level = #start_equals, #end_equals
 
		
---------------------------------------------------------------------------
-- ============== START HERE ALL PARAMETERS ============== --
---------------------------------------------------------------------------


	-- ADD BLOCK HERE

--[=[ the headers in el.wikt mainspace are standard and repetitve. They may be unnmbered or numbered
STANDARD UNNUMBERED
unnumbered templates
{{-xx-}}		heading = language templates as in [[Module:Languages]] keyowrd: link
				these are alwyas UNnumbered
{{xxx|cc}}		heading = as the Template xxx at [[Module:PartOfSpeech/pos]]
{{xxx}}			heading = as the template xxx
	only in talk pages any phrase including also
	NOT MAINSPACE {{λ|zzz|cc|xxx}}	heading = [[#xxx|xxx]]	
	NOT MAINSPACE {{λ|xxx|cc}}	heading = [[#xxx|xxx]]
unnumbered simple
[[zzz|xxx]]		heading = [[#xxx|xxx]]
[[xxx]]			heading = [[#xxx|xxx]]
xxx xx			heading = [[#xxx_xx|xxx xx]] (I think the underscores are automatic)
xxx				heading = [[#xxx|xxx]]
NUMBERED
unnumbered+space+number		heading = [[#headingofunnumbered+space+number|headingofunnumbered+space+number]]
REPEATED standard:
the 1st header		heading = heading
the 2nd same header	heading = heading_2
the 3rd same header	heading = heading_3
]=]--

-- ========================== HEADINGS at el.wiktionary =============================== --

-- ========================== head  = headers in templates =============================== --	



local head = '' -- for header = head + numbered like {{ετυμολογία}} 1
-- standard templates for headings of el.wiktionary as in [[Help:Δομή λημμάτων]] plus alias
			-- extract header from templates (they will be links as simple-text headers)
		if mw.ustring.find(header, "^{{άλλες γραφές") then head = 'Άλλες γραφές'
	elseif mw.ustring.find(header, "^{{άλλη γραφή") then head = 'Άλλες γραφές'
	elseif mw.ustring.find(header, "^{{αλλόγλωσσα") then head = 'Αλλόγλωσσα παράγωγα'
	elseif mw.ustring.find(header, "^{{αναγραμματισμοί") then head = 'Αναγραμματισμοί'
	elseif mw.ustring.find(header, "^{{αναφορές") then head = 'Αναφορές'
	elseif mw.ustring.find(header, "^{{αντώνυμα") then head = 'Αντώνυμα'
	elseif mw.ustring.find(header, "^{{απόγονοι") then head = 'Απόγονοι'
	elseif mw.ustring.find(header, "^{{βλέπε") then head = 'Δείτε επίσης'
	elseif mw.ustring.find(header, "^{{εκφράσεις") then head = 'Εκφράσεις'
	elseif mw.ustring.find(header, "^{{ετυμολογία") then head = 'Ετυμολογία'
	elseif mw.ustring.find(header, "^{{κλίση") then head = 'Κλίση'
	elseif mw.ustring.find(header, "^{{μεγεθυντικά") then head = 'Μεγεθυντικά'
	elseif mw.ustring.find(header, "^{{μερώνυμα") then head = 'Μερώνυμα'
	elseif mw.ustring.find(header, "^{{μεταγραφές") then head = 'Μεταγραφές'
	elseif mw.ustring.find(header, "^{{μεταφράσεις") then head = 'Μεταφράσεις'
	elseif mw.ustring.find(header, "^{{μορφές") then head = 'Άλλες μορφές'
	elseif mw.ustring.find(header, "^{{ομώνυμα") then head = 'Ομώνυμα / Ομόηχα'
	elseif mw.ustring.find(header, "^{{παράγωγα") then head = 'Παράγωγα'
	elseif mw.ustring.find(header, "^{{παροιμίες") then head = 'Παροιμίες'
	elseif mw.ustring.find(header, "^{{παρώνυμα") then head = 'Παρώνυμα'
	elseif mw.ustring.find(header, "^{{πηγές") then head = 'Πηγές'
	elseif mw.ustring.find(header, "^{{πηγή") then head = 'Πηγές'
	elseif mw.ustring.find(header, "^{{πολυλεκτικοί όροι") then head = 'Πολυλεκτικοί όροι'
	elseif mw.ustring.find(header, "^{{προφορά") then head = 'Προφορά'
	elseif mw.ustring.find(header, "^{{συγγενικά") then head = 'Συγγενικά'
	elseif mw.ustring.find(header, "^{{σημειώσεις") then head = 'Σημειώσεις'
	elseif mw.ustring.find(header, "^{{σημείωση") then head = 'Σημειώσεις'
	elseif mw.ustring.find(header, "^{{σύνθετα") then head = 'Σύνθετα'
	elseif mw.ustring.find(header, "^{{συνώνυμα") then head = 'Συνώνυμα'
	elseif mw.ustring.find(header, "^{{σχετικό λεξικόγιο") then head = 'Σχετικό λεξιλόγιο'
	elseif mw.ustring.find(header, "^{{ταυτόσημα") then head = 'Ταυτόσημα'
	elseif mw.ustring.find(header, "^{{υπερώνυμα") then head = 'Υπερώνυμα'
	elseif mw.ustring.find(header, "^{{υποκοριστικά") then head = 'Υποκοριστικά'
	elseif mw.ustring.find(header, "^{{υπώνυμα") then head = 'Υπώνυμα'
	

		
-- PartofSpeech POS headings, with language code too
		--  {{xxx|zz}} require("Module:PartOfSpeech/pos")
		-- require("Module:PartOfSpeech/pos")['ουσιαστικό']['link']
		-- Can i do them all together?
	elseif mw.ustring.find(header, "^{{αντωνυμία") then head = pos['αντωνυμία']['link']
	elseif mw.ustring.find(header, "^{{απαρέμφατο") then head = pos['απαρέμφαγο']['link']
	elseif mw.ustring.find(header, "^{{άρθρο") then head = pos['άρθρο']['link']
	elseif mw.ustring.find(header, "^{{αριθμητικό") then head = pos['αριθμητικό']['link']
	elseif mw.ustring.find(header, "^{{βιβλίο φράσεων") then head = pos['βιβλίο φράσεων']['link']
	elseif mw.ustring.find(header, "^{{γερουνδιακό") then head = pos['γερουνδιακό']['link']
	elseif mw.ustring.find(header, "^{{γερούνιο") then head = pos['γερούνδιο']['link']
	elseif mw.ustring.find(header, "^{{έκφραση") then head = pos['έκφραση']['link']
	elseif mw.ustring.find(header, "^{{ένθημα") then head = pos['ένθημα']['link']
	elseif mw.ustring.find(header, "^{{επίθετο") then head = pos['επίθετο']['link']
	elseif mw.ustring.find(header, "^{{επίθημα") then head = pos['επίθημα']['link']
	elseif mw.ustring.find(header, "^{{επίρρημα") then head = pos['επίρρημα']['link']
	elseif mw.ustring.find(header, "^{{επιρρηματική έκφραση") then head = pos['επιρρηματική έκφραση']['link']
	elseif mw.ustring.find(header, "^{{επιφώνημα") then head = pos['επιφώνημα']['link']
	elseif mw.ustring.find(header, "^{{κύριο όνομα") then head = pos['κύριο όνομα']['link']
	elseif mw.ustring.find(header, "^{{μεταγραφή") then head = pos['μεταγραφή']['link']
	elseif mw.ustring.find(header, "^{{μετοχή") then head = pos['μετοχή']['link']
	elseif mw.ustring.find(header, "^{{μόριο") then head = pos['μόριο']['link']
	elseif mw.ustring.find(header, "^{{ουσιαστικό") then head = pos['ουσιαστικό']['link']
	elseif mw.ustring.find(header, "^{{παροιμία") then head = pos['παροιμία']['link']
	elseif mw.ustring.find(header, "^{{πολυλεκτικός όρος") then head = pos['πολυλεκτικός όρος']['link']
	elseif mw.ustring.find(header, "^{{πρόθεση") then head = pos['πρόθεση']['link']
	elseif mw.ustring.find(header, "^{{πρόθημα") then head = pos['πρόθημα']['link']
	elseif mw.ustring.find(header, "^{{προσδιοριστής") then head = pos['προσδιοριστής']['link']
	elseif mw.ustring.find(header, "^{{πρόσφυμα") then head = pos['πρόσφυμα']['link']
	elseif mw.ustring.find(header, "^{{ρήμα") then head = pos['ρήμα']['link']
	elseif mw.ustring.find(header, "^{{ρηματική έκφραση") then head = pos['ρηματική έκφραση']['link']
	elseif mw.ustring.find(header, "^{{ρίζα") then head = pos['ρίζα']['link']
	elseif mw.ustring.find(header, "^{{σουπίνο") then head = pos['σουπίνο']['link']
	elseif mw.ustring.find(header, "^{{συγχώνευση") then head = pos['συγχώνευση']['link']
	elseif mw.ustring.find(header, "^{{σύμβολο") then head = pos['σύμβολο']['link']
	elseif mw.ustring.find(header, "^{{σύνδεσμος") then head = pos['σύνδεσμος']['link']
	elseif mw.ustring.find(header, "^{{συντομομορφή") then head = pos['συντομομορφή']['link']
	elseif mw.ustring.find(header, "^{{φράση") then head = pos['φράση']['link']
	elseif mw.ustring.find(header, "^{{χαρακτήρας") then head = pos['χαρακτήρας']['link']
	
-- τύποι
	elseif mw.ustring.find(header, "^{{μορφή αντωνυμίας") then head = pos['μορφή αντωνυμίας']['link']
	elseif mw.ustring.find(header, "^{{μορφή αριθμητικού") then head = pos['μορφή αριθμητικού']['link']
	elseif mw.ustring.find(header, "^{{μορφή άρθρου") then head = pos['μορφή άρθρου']['link']
	elseif mw.ustring.find(header, "^{{μορφή γερουνδιακού") then head = pos['μορφή γερουνδιακού']['link']
	elseif mw.ustring.find(header, "^{{μορφή επιθέτου") then head = pos['μορφή επιθέτου']['link']
	elseif mw.ustring.find(header, "^{{μορφή επιθήματος") then head = pos['μορφή επιθήματος']['link']
	elseif mw.ustring.find(header, "^{{μορφή επιρρήματος") then head = pos['μορφή επιρρήματος']['link']
	elseif mw.ustring.find(header, "^{{μορφή κυρίου ονόματος") then head = pos['μορφή κυρίου ονόματος']['link']
	elseif mw.ustring.find(header, "^{{μορφή μετοχής") then head = pos['μορφή μετοχής']['link']
	elseif mw.ustring.find(header, "^{{μορφή ουσιαστικού") then head = pos['μορφή ουσιαστικού']['link']
	elseif mw.ustring.find(header, "^{{μορφή πολυλεκτικού όρου") then head = pos['μορφή πολυλεκτικού όρου']['link']
	elseif mw.ustring.find(header, "^{{μορφή ρήματος") then head = pos['μορφή ρήματος']['link']
	elseif mw.ustring.find(header, "^{{ρηματική φωνή") then head = pos['ρηματική φωνή']['link']
	elseif mw.ustring.find(header, "^{{μορφή σύνθετου όρου") then head = pos['μορφή σύνθετου όρου']['link']
	

-- LANGUAGE headings always Level 2 =={{-xxx-}}==	('^[a-z][%-0-9a-z]*[0-9a-z]$')
		-- {{-xx-}} This is iso for Language links From [[Module:Languages]] keyowrd: link
		-- language links like {{-xx-}} with require("Module:lang").langiso_to_langlink(iso)
		-- test {{-el-cyp-}}
	elseif mw.ustring.find(header, "{{-([%-a-z]*)-}}") 	
	then
		head = require("Module:lang").langiso_to_langlink(mw.ustring.sub(mw.ustring.match(header, "{{%-([%-a-z]*)%-}}"), 1, -1))

-- and in Appendices	=============


-- {{λ|ωωωω|<iso code>|altxxx}} there could be  xxx {{λ|xxx|iso|altxxx}} xxx
-- iso has latin small letters, and my have hyphen -
	elseif mw.ustring.find(header, "{{λ%|(.*[^{%|}])%|([%-a-z]*)%|(.*[^{%|}])}}")
		then lalthead1 = mw.ustring.gsub(header, "{{λ%|(.*[^{%|}])%|", "")
			lalthead2 = mw.ustring.gsub(lalthead1, "%|([%-a-z]*)%|", "")
			lalthead3 = mw.ustring.gsub(lalthead2, "}", "")
			head = mw.ustring.gsub(lalthead3, "[%|{}]", "")

-- {{λ|ωωωω|<iso code>}} there could be  xxx {{λ|xxx|iso}} xxx
-- iso has latin small letters, and my have hyphen -
	elseif mw.ustring.find(header, "{{λ%|(.*[^{%|}])%|([%-a-z]*)}}")
		then lhead1 = mw.ustring.gsub(header, "{{λ", "")
			lhead2 = mw.ustring.gsub(lhead1, "%|([%-a-z]*)}}", "")
			head = mw.ustring.gsub(lhead2, "[%|{}]", "")
		
-- there could be xxxx [[zzz|xxx]] xxx
-- [[zzz|xxx]]
	elseif mw.ustring.find(header, "%[%[(.+[^%[%|%]])%|(.+[^%[%|%]])%]%]")
		then althead1 = mw.ustring.gsub(header, "%[%[(.+[^%[%|%]])%|", "")
			head = mw.ustring.gsub(althead1, "[]]", "")

-- there could be xxxx [[xxx]]] xxx
-- [[xxx]]	
	elseif mw.ustring.find(header, "%[%[(.+[^%|%]])%]%]")
		then head = mw.ustring.gsub(header, "[%[%]]", "")

-- ?# TO DO: both the above links together
	-- ..............
	
-- xxx xxx xxx 
	else
		head = header
		
		
	end -- close elseifs for head
end -- close for
--[[--------------------------< E X P O R T E D   F U N C T I O N S >------------------------------------------
]]

end -- close  function param

return {param = param}