모듈:인용/CS1
Module| 이 Lua 모듈은 약 5,580,000 페이지에서 사용됩니다. 큰 중단과 서버 로드를 방지하려면 모듈의 /sandbox 또는 /testcase 하위 페이지 또는 자체 모듈 샌드박스에서 변경 사항을 테스트해야 합니다.테스트된 변경 사항은 한 번의 편집으로 이 페이지에 추가할 수 있습니다.변경사항을 구현하기 전에 대화 페이지에서 변경사항에 대해 논의하는 것을 고려합니다. |
| 이 모듈은 TemplateStyle을 사용합니다. |
| 이 모듈은 페이지 보호 대상입니다.매우 많은 페이지에서 사용 중이거나 매우 자주 교체되는 가시성이 높은 모듈입니다.파괴 행위나 실수는 많은 페이지에 영향을 미치고 사소한 편집도 서버에 상당한 부하를 줄 수 있으므로 편집으로부터 보호됩니다. |
이 모듈 및 관련 하위 모듈은 인용 스타일 1 및 인용 스타일 2 인용 템플릿을 지원합니다.일반적으로 직접 호출하는 것이 아니라 핵심 CS1 및 CS2 템플릿 중 하나에서 호출됩니다.
다음 파일은 CS12 인용 템플릿에 대한 모듈 지원으로 구성됩니다.
| 살아 있는 | 샌드박스 | 차이가 있는 | 묘사 | ||
|---|---|---|---|---|---|
| 모듈: 인용/CS1 | 모듈: 인용문/CS1/샌드박스 | [편집] | 차이가 있는 | 렌더링 및 지원 기능 | |
| 모듈: 인용/CS1/구성 | 모듈: 인용문/CS1/구성/샌드박스 | [편집] | 차이가 있는 | 변환 테이블, 오류 및 식별자 처리기 | |
| 모듈: 인용문/CS1/화이트리스트 | 모듈: 인용문/CS1/화이트리스트/샌드박스 | [편집] | 차이가 있는 | 활성 및 사용되지 않는 CS12 매개 변수 목록 | |
| 모듈: 인용/CS1/날짜 확인 | 모듈: 인용/CS1/날짜 확인/샌드박스 | [편집] | 차이가 있는 | 날짜 형식 유효성 검사 기능 | |
| 모듈: 인용문/CS1/식별자 | 모듈: 인용문/CS1/식별자/샌드박스 | [편집] | 차이가 있는 | 명명된 식별자(ISBN, DOI, PMID 등)를 지원하는 함수 | |
| 모듈: 인용문/CS1/유틸리티 | 모듈: 인용문/CS1/유틸리티/샌드박스 | [편집] | diff | Common functions and tables | |
| Module:Citation/CS1/COinS | Module:Citation/CS1/COinS/sandbox | [edit] | diff | Functions that render a CS1 2 template's metadata | |
| Module:Citation/CS1/styles.css | Module:Citation/CS1/sandbox/styles.css | [edit] | diff | CSS styles applied to the CS1 2 templates | |
| Module:Citation/CS1/Suggestions | Module:Citation/CS1/Suggestions/sandbox | [edit] | diff | List that maps common erroneous parameter names to valid parameter names | |
Other documentation:
- Module talk:Citation/CS1/Feature requests
- Module talk:Citation/CS1/COinS
- Module:Cs1 documentation support – a set of functions (some experimental) that extract information from the module suite for the purpose of documenting CS1 2
- Module:Citation/CS1/doc/Category list – lists of category names taken directly from Module:Citation/CS1/Configuration and Module:Citation/CS1/Configuration/sandbox
testcases
- Module:Citation/CS1/testcases (run)
- Module:Citation/CS1/testcases/errors (run) – error and maintenance messaging
- Module:Citation/CS1/testcases/dates (run) – date validation
- Module:Citation/CS1/testcases/identifiers (run) – identifiers
- Module:Citation/CS1/testcases/anchor (run) – CITEREF anchors
require('strict'); --[[--------------------------< F O R W A R D D E C L A R A T I O N S >-------------------------------------- each of these counts against the Lua upvalue limit ]] local validation; -- functions in Module:Citation/CS1/Date_validation local utilities; -- functions in Module:Citation/CS1/Utilities local z = {}; -- table of tables in Module:Citation/CS1/Utilities local identifiers; -- functions and tables in Module:Citation/CS1/Identifiers local metadata; -- functions in Module:Citation/CS1/COinS local cfg = {}; -- table of configuration tables that are defined in Module:Citation/CS1/Configuration local whitelist = {}; -- table of tables listing valid template parameter names; defined in Module:Citation/CS1/Whitelist --[[------------------< P A G E S C O P E V A R I A B L E S >--------------- declare variables here that have page-wide scope that are not brought in from other modules; that are created here and used here ]] local added_deprecated_cat; -- Boolean flag so that the category is added only once local added_vanc_errs; -- Boolean flag so we only emit one Vancouver error / category local added_generic_name_errs; -- Boolean flag so we only emit one generic name error / category and stop testing names once an error is encountered local Frame; -- holds the module's frame table local is_preview_mode; -- true when article is in preview mode; false when using 'Preview page with this template' (previewing the module) local is_sandbox; -- true when using sandbox modules to render citation --[[--------------------------< F I R S T _ S E T >------------------------------------------------------------ Locates and returns the first set value in a table of values where the order established in the table, left-to-right (or top-to-bottom), is the order in which the values are evaluated. Returns nil if none are set. This version replaces the original 'for _, val in pairs do' and a similar version that used ipairs. With the pairs version the order of evaluation could not be guaranteed. With the ipairs version, a nil value would terminate the for-loop before it reached the actual end of the list. ]] local function first_set (list, count) local i = 1; while i <= count do -- loop through all items in list if utilities.is_set( list[i] ) then return list[i]; -- return the first set list member end i = i + 1; -- point to next end end --[[--------------------------< A D D _ V A N C _ E R R O R >---------------------------------------------------- Adds a single Vancouver system error message to the template's output regardless of how many error actually exist. To prevent duplication, added_vanc_errs is nil until an error message is emitted. added_vanc_errs is a Boolean declared in page scope variables above ]] local function add_vanc_error (source, position) if added_vanc_errs then return end added_vanc_errs = true; -- note that we've added this category utilities.set_message ('err_vancouver', {source, position}); end --[[--------------------------< I S _ S C H E M E >------------------------------------------------------------ does this thing that purports to be a URI scheme seem to be a valid scheme? The scheme is checked to see if it is in agreement with http://tools.ietf.org/html/std66#section-3.1 which says: Scheme names consist of a sequence of characters beginning with a letter and followed by any combination of letters, digits, plus ("+"), period ("."), or hyphen ("-"). returns true if it does, else false ]] local function is_scheme (scheme) return scheme and scheme:match ('^%a[%a%d%+%.%-]*:'); -- true if scheme is set and matches the pattern end --[=[-------------------------< I S _ D O M A I N _ N A M E >-------------------------------------------------- Does this thing that purports to be a domain name seem to be a valid domain name? Syntax defined here: http://tools.ietf.org/html/rfc1034#section-3.5 BNF defined here: https://tools.ietf.org/html/rfc4234 Single character names are generally reserved; see https://tools.ietf.org/html/draft-ietf-dnsind-iana-dns-01#page-15; see also [[Single-letter second-level domain]] list of TLDs: https://www.iana.org/domains/root/db RFC 952 (modified by RFC 1123) requires the first and last character of a hostname to be a letter or a digit. Between the first and last characters the name may use letters, digits, and the hyphen. Also allowed are IPv4 addresses. IPv6 not supported domain is expected to be stripped of any path so that the last character in the last character of the TLD. tld is two or more alpha characters. Any preceding '//' (from splitting a URL with a scheme) will be stripped here. Perhaps not necessary but retained in case it is necessary for IPv4 dot decimal. There are several tests: the first character of the whole domain name including subdomains must be a letter or a digit internationalized domain name (ASCII characters with .xn-- ASCII Compatible Encoding (ACE) prefix xn-- in the TLD) see https://tools.ietf.org/html/rfc3490 single-letter/digit second-level domains in the .org, .cash, and .today TLDs q, x, and z SL domains in the .com TLD i and q SL domains in the .net TLD single-letter SL domains in the ccTLDs (where the ccTLD is two letters) two-character SL domains in gTLDs (where the gTLD is two or more letters) three-plus-character SL domains in gTLDs (where the gTLD is two or more letters) IPv4 dot-decimal address format; TLD not allowed returns true if domain appears to be a proper name and TLD or IPv4 address, else false ]=] local function is_domain_name (domain) if not domain then return false; -- if not set, abandon end domain = domain:gsub ('^//', ''); -- strip '//' from domain name if present; done here so we only have to do it once if not domain:match ('^[%w]') then -- first character must be letter or digit return false; end if domain:match ('^%a+:') then -- hack to detect things that look like s:Page:Title where Page: is namespace at Wikisource return false; end local patterns = { -- patterns that look like URLs '%f[%w][%w][%w%-]+[%w]%.%a%a+