경고: 이 문서의 오래된 판을 편집하고 있습니다. 이것을 게시하면, 이 판 이후로 바뀐 모든 편집이 사라집니다. 귀하는 로그인되어 있지 않습니다. 이대로 편집하면 귀하의 IP 주소가 편집 기록에 남게 됩니다.스팸 방지 검사입니다. 이것을 입력하지 마세요!--[[========================================================================= Italicize a taxon name appropriately by invoking italicizeTaxonName. The algorithm used is: * If the name has italic markup at the start or the end, do nothing. * Else * Remove (internal) italic markup. * If the name is made up of four words and the third word is a botanical connecting term, de-italicize the connecting term and add italic markup to the outside of the name. * Else if the name is made up of three words and the second word is a botanical connecting term or a variant of "cf.", de-italicize the connecting term and add italic markup to the outside of the name. * Else just add italic markup to the outside of the name. =============================================================================]] local p = {} local cTerms3 = { subspecies = "subsp.", ["subsp."] = "subsp.", subsp = "subsp.", ["ssp."] = "subsp.", ssp = "subsp.", varietas = "var.", ["var."] = "var.", var = "var.", subvarietas = "subvar.", ["subvar."] = "subvar.", subvar = "subvar.", forma = "f.", ["f."] = "f.", f = "f.", subforma = "subf.", ["subf."] = "subf.", subf = "subf." } local cTerms2 = { subgenus = "subg.", ["subg."] = "subg.", subg = "subg.", section = "sect.", ["sect."] = "sect.", ["cf."] = "cf.", cf = "cf.", ["c.f."] = "cf." } --[[========================================================================= Italicize a taxon name appropriately. =============================================================================]] function p.main(frame) local name = frame.args[1] or '' local linked = frame.args['linked'] == 'yes' return p.italicizeTaxonName(name, linked) end function p.italicizeTaxonName(name, linked) local italMarker = "''" -- trim the name and replace any use of the HTML italic tags by Wikimedia markup name = string.gsub(string.gsub(mw.text.trim(name), "<i>", italMarker), "</i>", italMarker) local result = name if name ~= '' then if string.sub(name, 1, 2) == "''" or string.sub(name, -2) == "''" then -- do nothing if the name already has italic markers at the start or end else name = string.gsub(name, "''", "") -- first remove internal italics local words = mw.text.split(name, " ", true) local deitalicized = false if #words == 4 then -- test for the third word of a four word name being a connecting term if cTerms3[words[3]] then -- de-italicize the connecting term by adding internal italic markup result = words[1] .. " " .. words[2] .. italMarker .. " " .. cTerms3[words[3]] .. italMarker .. " " .. words[4] deitalicized = true end elseif #words == 3 then -- test for the second word of a three word name being a connecting term if cTerms2[words[2]] then -- de-italicize the connecting term by adding internal italic markup result = words[1] .. " " .. italMarker .. cTerms2[words[2]] .. italMarker .. " " .. words[3] deitalicized = true end else -- do nothing result = name end -- add outside markup if linked then if deitalicized then result = "[[" .. name .. "|" .. italMarker .. result .. italMarker .. "]]" else result = italMarker .. "[[" .. name .. "]]" .. italMarker end else result = italMarker .. result .. italMarker end end end return result end return p 편집 요약 가온 위키에서의 모든 기여는 크리에이티브 커먼즈 저작자표시-동일조건변경허락 라이선스로 배포된다는 점을 유의해 주세요(자세한 내용에 대해서는 가온 위키:저작권 문서를 읽어주세요). 만약 여기에 동의하지 않는다면 문서를 저장하지 말아 주세요. 또한, 직접 작성했거나 퍼블릭 도메인과 같은 자유 문서에서 가져왔다는 것을 보증해야 합니다. 저작권이 있는 내용을 허가 없이 저장하지 마세요! 취소 편집 도움말 (새 창에서 열림) 이 문서에서 사용한 틀: 모듈:TaxonItalics/설명문서 (편집)