Module:title

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

Module:title >> Module:title/τεκμηρίωση
Διαμορφώνει το στυλ του τίτλου σελίδας.

Καλείται από το Πρότυπο:title {{title}} ή ελληνικά: {{τίτλος}}

Creates styles for the page's title. Called by template {{title}}


-- 2019.07.09. Καλεί το [[Πρότυπο:title]]  - It calls [[Template:title]]
-- vertical left to right (e.g. for Mongolian) or italics (e.g. for binominal taxonomic)
-- This Module is an altered version from various 'italics modules'
 
local p = {}
 
function p.main(frame)
    -- Process the arguments
    local args
    if frame == mw.getCurrentFrame() then
        args = frame:getParent().args
        for k, v in pairs(frame.args) do
            args = frame.args
            break
		end
    else
        args = frame
    end    

	-- Get the current page object
    local title = mw.title.getCurrentTitle()
    -- Find the parts before and after a parenthesis, if any.
    local prefix, parenthesis = mw.ustring.match(title.text, '^(.+) (%([^%(%)]+%))$')
    -- If parenthesis were found, alter only the part before it. Otherwise, the whole title
    local result
    local kind = args['1'] or ''
    
-- vertical left to right (default text-orientation:upright is top to bottom) e.g. for Mongolian ᠲᠡᠶᠢᠮᠦ
	    if kind == 'vertical-lr' or kind == 'κάθετος-αδ' then
		  	if prefix and parenthesis and args.all ~= 'yes' then
		      	result = '<span style="writing-mode:vertical-lr;">' .. prefix .. '</span> ' .. parenthesis
    			else
    		   	result = '<span style="writing-mode:vertical-lr;">' .. title.text .. '</span>'
			end
    -- Add the namespace if it exists
    		if title.nsText and title.nsText ~= "" then
    		    result = title.nsText .. ':' .. result
    		end
    -- Call displaytitle with the generated text
    	return mw.getCurrentFrame():callParserFunction( 'DISPLAYTITLE', result )

		else
-- italics e.g. for taxonomic binominals e.g. [[Alectoris graeca]]
		if kind  == 'italics' or kind == 'πλάγιος' then
    		if prefix and parenthesis and args.all ~= 'yes' then
    	    	result = "''" .. prefix .. "'' " .. parenthesis
    		else
    	    	result = "''" .. title.text .. "''"
    		end
    -- Add the namespace if it exists
    		if title.nsText and title.nsText ~= "" then
    		    result = title.nsText .. ':' .. result
    		end
    -- Call displaytitle with the generated text
    	return mw.getCurrentFrame():callParserFunction( 'DISPLAYTITLE', result )
		end
	end
end

return p