Module:also

Hello, you have come here looking for the meaning of the word Module:also. In DICTIOUS you will not only get to know all the dictionary meanings for the word Module:also, but we will also tell you about its etymology, its characteristics and you will know how to say Module:also in singular and plural. Everything you need to know about the word Module:also you have here. The definition of the word Module:also will help you to be more precise and correct when speaking or writing your texts. Knowing the definition ofModule:also, as well as those of other words, enriches your vocabulary and provides you with more and better linguistic resources.

This module implements the template {{also}}.


local m_debug = require("Module:debug")
local m_links = require("Module:links")
local m_params = require("Module:parameters")
local m_scripts = require("Module:scripts")
local m_str_utils = require("Module:string utilities")
local m_util = require("Module:utilities")

local codepoint = m_str_utils.codepoint
local ulen = m_str_utils.len
local yesno = require("Module:yesno")

local und = require("Module:languages").getByCode("und")

local export = {}

function export.main(frame)
	local params = {
		 = {required = true, list = true},
		 = {list = true, allow_holes = true},
		 = {list = true, allow_holes = true, separate_no_index = true},
		 = {type = "boolean"}
	}
	
	local args = m_params.process(frame:getParent().args or frame.args, params)
	
	if args.maxindex > 0 then
		-- ]
		m_debug.track("also/sc param")
	end
	
	local uni_default = yesno((args == "auto") or args) and "auto" or nil
	
	local title = mw.title.getCurrentTitle()
	local full_pagename = title.fullText
	
	-- Disables tagging outside of mainspace, where {{also}} more often links to
	-- pages that are not entries and don't need tagging. Tagging in Reconstruction
	-- would be more complicated and is often unnecessary, and there are very few
	-- entries in Appendix.
	local detect_sc = title.nsText == ""
		or args -- to test the script detection capabilities
	
	local items = {}
	local use_semicolon = false
	local arg_plaintext
		
	for i, arg in ipairs(args) do
		local uni = args or uni_default
		local sc = args and m_scripts.getByCode(args) or und:findBestScript(arg)
		
		if arg:find(",", 1, true) then
			use_semicolon = true
		end
		
		if not yesno(uni, uni) then
			uni = nil
		end
		
		-- Create the link.
		arg = m_links.plain_link{term = arg, lang = und, sc = sc}
		
		-- We use the link to determine if arg is the current page, so that it works on edge cases like unsupported titles.
		if not arg:match("<strong class=\"selflink\">") then
			arg = '<b class="' .. sc:getCode() .. '">' .. arg .. "</b>"
			
			local cp
			if uni then
				m_debug.track("also/uni")
				
				if uni == 'auto' then
					arg_plaintext = m_util.get_plaintext(arg)
					cp = (ulen(arg_plaintext) == 1) and codepoint(arg_plaintext, 1, 1)
				else
					cp = tonumber(uni)
					
					if ulen(arg) ~= 1 or cp ~= codepoint(arg, 1, 1) then
						m_debug.track("also/uni/noauto")
					else
						m_debug.track("also/uni/auto")
					end
				end
			end
			
			if cp then
				local m_unidata = require('Module:Unicode data')
				
				arg = arg .. (" <small></small>"):format(
					cp,
					m_unidata.lookup_name(cp):gsub("<", "&lt;")
				)
			end
			
			table.insert(items, arg)
		end
	end
	
	if #items == 0 then
		table.insert(items, "{{{1}}}")
	end
	
	-- Join with serial "and" and serial comma
	local function serial_comma_join(seq, conjunction)
		conjunction = conjunction or ","
		if #seq == 0 then
			return ""
		elseif #seq == 1 then
			return seq -- nothing to join
		elseif #seq == 2 then
			return seq .. " ''and'' " .. seq
		else
			return table.concat(seq, conjunction .. " ", 1, #seq - 1)
				.. "<span class='serial-comma'>" .. conjunction .. "</span>" ..
				"''<span class='serial-and'> and</span>'' " ..
				seq
		end
	end
	
	return ("<div class=\"disambig-see-also\">''See also:'' %s</div>"):format(
		serial_comma_join(items, use_semicolon and ";" or ",")
	)
end

return export