วิกิซอร์ซ
thwikisource
https://th.wikisource.org/wiki/%E0%B8%AB%E0%B8%99%E0%B9%89%E0%B8%B2%E0%B8%AB%E0%B8%A5%E0%B8%B1%E0%B8%81
MediaWiki 1.39.0-wmf.23
first-letter
สื่อ
พิเศษ
พูดคุย
ผู้ใช้
คุยกับผู้ใช้
วิกิซอร์ซ
คุยเรื่องวิกิซอร์ซ
ไฟล์
คุยเรื่องไฟล์
มีเดียวิกิ
คุยเรื่องมีเดียวิกิ
แม่แบบ
คุยเรื่องแม่แบบ
วิธีใช้
คุยเรื่องวิธีใช้
หมวดหมู่
คุยเรื่องหมวดหมู่
สถานีย่อย
คุยเรื่องสถานีย่อย
ผู้สร้างสรรค์
คุยเรื่องผู้สร้างสรรค์
งานแปล
คุยเรื่องงานแปล
หน้า
คุยเรื่องหน้า
ดัชนี
คุยเรื่องดัชนี
TimedText
TimedText talk
มอดูล
คุยเรื่องมอดูล
Gadget
Gadget talk
Gadget definition
Gadget definition talk
คาถาสมเด็จพระพุฒาจารย์ (โต พรหมรังสี)
0
184
189498
170300
2022-08-17T08:01:59Z
49.231.142.15
/* คาถาบูชาพระสมเด็จ */
wikitext
text/x-wiki
{{no source}}
{{no header}}
'''คาถาสมเด็จพระพุฒาจารย์ (โต พรหมรังสี)'''
===พุทธมังคลคาถา===
'''หรือเรียกว่า คำนมัสการบูชาพระอรหันต์แปดทิศ'''
สัมพุทโธ ทิปะทัง เสฏโฐ นิสินโน เจวะ มัชฌิเม
โกณฑัญโญ ปุพพะภาเค จะ อาคเณยเย จะ กัสสะโป
สารีปุตโต จะ ทักขิเณ หะระติเย อุปาลิ จะ
ปัจฉิมเมปิ จะ อานันโท พายัพเพ จะ คะวัมปะติ
โมคคัลลาโน จะ อุตตะเร อีสาเนปิ จะ ราหุโล
อิเม โข มังคะลา พุทธา สัพเพ อิธะ ปะติฏฐิตา
วันทิตา เต จะ อ้มเหหิ สักกาเรหิ จะ ปูชิตา
เอเตสัง อานุภาเวนะ สัพพะโสตถี ภะวันตุ โน
อิจเจวะมัจจันตะนะมัสสะเนยยัง
นะมัสสะมาโน ระตะนัตตะยัง ยัง
ปุญญาภิสันทัง วิปุลัง อะลัตถัง
ตัสสานุภาเวนะ หะตันตะราโยฯ
*หมายเหตุ: พุทธมังคลคาถานี้ หรือเรียกว่า คำนมัสการบูชาพระอรหันต์แปดทิศ
ล้วนแต่มีฤทธิ์ทุกองค์ เป็นมหาเถระผู้ยิ่งใหญ่ในทางพระพุทธศาสนา
เมื่อทำการสวดบูชาแล้ว ย่อมจะมีลาภผลเป็นมิ่งมงคล
และปราศจากอันตราย ถ้าจะสวดแบบธรรมดาก็ได้ โดยหัวหน้ากล่าวนำ
หันทะ มะยัง พุทธะมังคละคาถาโย ภะณามะเส
<ref><ref>อ</ref></ref>===คาถาบูชาพระสมเด็จ===
ปุตตะกาโม ลาเภ ปุตตัง
ธะนะ กาโม ลาเภ ธะนัง
อัตถิกาเย กายะ ญายะ
เทวานัง ปิยะตัง สุตะวา
===คาถาอารธนาพระสมเด็จ===
โตเสนโต วะระธัมเมนะ
โตสัฏฐาเน สิเว วะเร
โตสัง อะกาสิ ชันตูนัง
โตสะจิตตัง นะมามิหัง
อิติปิโสภะคะวา ยะมะราชาโน ท้าวเวสสุวัณโณ
มรณังสุขัง อะระหังสุคะโต นะโมพุทธายะ
===คาถาสืบสร้างทางสวรรค์และนิพพาน===
พุทธะ พุทธา พุทเธ พุทโธ พุทธัง อะระหัง พุทโธ อิติปิโส ภะคะวา นะโมพุทธายะ
===คาถาชินบัญชร===
พระคาถานี้เป็นคาถาศักดิ์สิทธิ์ตกทอดมาจากลังกา ท่านเจ้าประคุณสมเด็จฯค้นพบในคัมภีร์โบราณและได้ดัดแปลงแต่งเติมให้ดีขึ้นเป็นเอกลักษณ์พิเศษ ผู้ใดสวดภาวนาพระคาถานี้เป็นประจำสม่ำเสมอจะทำให้เกิดความสิริมงคลแก่ตนเอง ศัตรูไม่กล้ากล้ำกราย มีเมตตามหานิยม ขจัดภัยตลอดจนคุณไสยต่างๆ เพื่อให้เกิดอานุภาพยิ่งขึ้น ก่อนเจริญภาวนาให้ตั้งนะโม ๓ จบ แล้วระลึกถึงและตั้งคำอธิษฐานว่า
ปัตตะกาโม ลาภะ ปัตตัง ธะนะ กาเม ลาภะ ธะนัง อัตถิกาเย กายะ ญายะ เทวานัง ปิยะตัง สุตะวา
'''เริ่มบทพระคาถาชินบัญชร'''
:1. ชิยาสะรากะตา พุทธา เชตะวา มารัง สะวาหะนัง จะตุสัจจา สะภัง ระสัง เย ปิวิงสุ นะราสะภา.
:2. ตัณหังกะราทะโย พุทธา อัฏฐาวีสะติ นายะกา สัพเพ ปะติฏฐิตา มัยหัง มัตถะเก เต มุนิสสะรา.
:3. สีเส ปะติฏฐิโต มัยหัง พุทโธ ธัมโม ทะวิโล จะเน สังโฆ ปะติฏฐิโต มัยหัง อุเร สัพพะคุณากะโร.
:4. หะทะเย เม อุนุรุทโธ สารีปุตโต จะ ทักขิเณ โกณฑัญโญ ปิฏฐิภาคัสมิง โมคคัลลโน จะ วามะเก.
:5. ทักขิเณ สะวะเน มัยหัง อาสุง อานันทะราหุลา กัสสะโป จะ มะหานาโม อุภาสุง วะมะโสตัตเก.
:6. เกสันเต ปิฏฐิภาคัสมิง สุริโย วะ ปะภังกะโร นิสันโน สิริสัมปันโน โสภิโต มุนิปุงคะโว.
:7. กุมาระกัสสะโป เถโร มะเหสี จิตตะวาทะโก โส มัยหัง วะทะเน นิจจัง ปะติฏฐาสิ คุณากะโร.
:8. ปุณโณ อังคุลิมาโล จะ อุปาลี นันทะสีวะลี เถรา ปัญจะ อิเมชาตา นะลาเต ติละกา มะมะ.
:9. เสสาสีติ มะหาเถรา วิชิตา ชินะสาวะกา เอเตสีติ มะหาเถรา ชิตะวันโต ชิโนระสา
ชะลันตา สีละเต เชนะ อังคะมังเคสุ สัณฐิตา.
:10. ระตะนัง ปุระโต อาสิ ทักขิเณ เมตตะสุตกัง ธะชังคัง ปัจฉะโต อาสิ วาเม อังคุลิมาละกัง.
:11. ขันธะโมระปะริตตัญจะ อาฏานาฏิยะ สุตตะ กัง อากาเส ฉะทะนัง อาสิ เสสา ปาการะสัณฐิตา.
:12. ชินานานาพะละสังยุตตา สัตตะปาการะลังกะตา วาตะปิตตาทิสัญชาตา พาหิรัชฌัตตุปัททะวา.
:13. อะเสสา วินะยัง ยันตุ อะนันตะชินะเตชะสา วะเสโต เม สะกิจเจนะ สะทา สัมพุทธะปัญชะเร.
:14. ชินะปัญชะระมัชฌัมหิ วิหะรันตัง มะหีตะเล สะทา ปาเลนตุ มัง สัพเพ เต มะหาปุริสา สะภา อิจเจวะมันโต สุคุตโต สุรักโข ชินานุภาเวนะ
ชิตุปัททะโว ธัมมานุภาเวนะ ชิตาริสังโฆ สังฆานุภาเวนะ ชิตันตะวาโย สัทธัมมานุภาวะปาลิโต จะรามิชินะปัญชะเรติ.
9awzhtrmh5fet1w4wmzyytcl1kq3i4d
มหาวรรคภาค ๑ - อุโปสถขันธกะ - จะแสดงธรรมท่ามกลางสงฆ์ต้องได้รับอาราธนาก่อน เป็นต้น
0
927
189492
1093
2022-08-16T21:47:31Z
YURi
4431
แจ้งลบด้วย[[WS:iScript|สจห.]]: ท1 – ไม่มีเนื้อหา
wikitext
text/x-wiki
{{ลบ|ท1 – ไม่มีเนื้อหา}}
*[[จะแสดงธรรมท่ามกลางสงฆ์ต้องได้รับอาราธนาก่อน|จะแสดงธรรมท่ามกลางสงฆ์ต้องได้รับอาราธนาก่อน]]
*[[ถามพระวินัยท่ามกลางสงฆ์ต้องได้รับสมมติก่อน|ถามพระวินัยท่ามกลางสงฆ์ต้องได้รับสมมติก่อน]]
*[[อุโปสถขันธกะ - จะแสดงธรรมท่ามกลางสงฆ์ต้องได้รับอาราธนาก่อน เป็นต้น - วิธีสมมติเป็นผู้ถาม|วิธีสมมติเป็นผู้ถาม]]
*[[อุโปสถขันธกะ - จะแสดงธรรมท่ามกลางสงฆ์ต้องได้รับอาราธนาก่อน เป็นต้น - กรรมวาจาสมมติตน|กรรมวาจาสมมติตน]]
*[[อุโปสถขันธกะ - จะแสดงธรรมท่ามกลางสงฆ์ต้องได้รับอาราธนาก่อน เป็นต้น - กรรมวาจาสมมติผู้อื่น|กรรมวาจาสมมติผู้อื่น]]
*[[จะแสดงธรรมท่ามกลางสงฆ์ต้องได้รับอาราธนาก่อน เป็นต้น - ถามพระวินัยต้องตรวจดูบริษัทก่อน|ถามพระวินัยต้องตรวจดูบริษัทก่อน]]
*[[จะแสดงธรรมท่ามกลางสงฆ์ต้องได้รับอาราธนาก่อน เป็นต้น - วิธีสมมติเป็นผู้วิสัชนา|วิธีสมมติเป็นผู้วิสัชนา]]
*[[อุโปสถขันธกะ - จะแสดงธรรมท่ามกลางสงฆ์ต้องได้รับอาราธนาก่อน เป็นต้น - กรรมวาจาสมมติตน|กรรมวาจาสมมติตน]]
*[[อุโปสถขันธกะ - จะแสดงธรรมท่ามกลางสงฆ์ต้องได้รับอาราธนาก่อน เป็นต้น - กรรมวาจาสมมติผู้อื่น|กรรมวาจาสมมติผู้อื่น]]
*[[วิสัชนาพระวินัยต้องตรวจดูบริษัทก่อน|วิสัชนาพระวินัยต้องตรวจดูบริษัทก่อน]]
*[[จะแสดงธรรมท่ามกลางสงฆ์ต้องได้รับอาราธนาก่อน เป็นต้น - โจทก์ต้องขอโอกาสต่อจำเลย|โจทก์ต้องขอโอกาสต่อจำเลย]]
*[[จะแสดงธรรมท่ามกลางสงฆ์ต้องได้รับอาราธนาก่อน เป็นต้น - ก่อนโจทต้องพิจารณาดูบุคคล|ก่อนโจทต้องพิจารณาดูบุคคล]]
*[[จะแสดงธรรมท่ามกลางสงฆ์ต้องได้รับอาราธนาก่อน เป็นต้น - ก่อนขอโอกาสต้องพิจารณาดูบุคคล|ก่อนขอโอกาสต้องพิจารณาดูบุคคล]]
g2ryp4rn0sqg38kqf4k7if9smcme1un
มหากาพย์กิลกาเมช
0
15188
189491
33295
2022-08-16T21:44:58Z
YURi
4431
แจ้งลบด้วย[[WS:iScript|สจห.]]: 1=ท6 (มีคนแปลไว้ในพันทิป เผยแพร่ครั้งแรก 2546 > [http://topicstock.pantip.com/writer/topicstock/W2141232/W2141232.html ลิงก์])
wikitext
text/x-wiki
{{ลบ|1=ท6 (มีคนแปลไว้ในพันทิป เผยแพร่ครั้งแรก 2546 > [http://topicstock.pantip.com/writer/topicstock/W2141232/W2141232.html ลิงก์])}}
เนื้อหาต่อไปนี้เป็นบทแปลโดยสรุปของ '''มหากาพย์กิลกาเมช'''
== เรื่องย่อ ==
=== จารึกแท่งที่ 1 ===
<blockquote>
พระองค์ ผู้เห็นสรรพสิ่งทั้งปวง (ชา นักบา อิมุรุ) ข้าจักประกาศให้โลกรู้,</br>
พระองค์ ผู้รู้สรรพสิ่งทั้งปวง ที่ข้าจักเล่า</br>
…… (ข้อความขาดหาย)……</br>
ทรงเห็นความลี้ลับอันยิ่งใหญ่ ทรงรู้ในสิ่งที่ซ่อนเร้น:</br>
ทรงกู้ความรู้ในทุกกาลสมัยก่อนยุคน้ำท่วมโลก.</br>
ทรงเดินทางไปไกลโพ้นเกินแห่งหน, </br>
ทรงเดินทางไปโพ้นจากความเหน็ดเหนื่อย,</br>
และได้จำหลักเรื่องราวนี้บนศิลาไว้ </br></blockquote>
'''กิลกาเมช''' ผู้กล้าผู้ยิ่งใหญ่ ผู้มีสรรพความรู้ทั้งมวลนี้ (เนเมฆุ), ได้สร้างมหานครอุรุค; จารึกนี้ขอเชิญท่านมาแวะทัศนาความยิ่งใหญ่ กำแพงสูง งานช่าง ของนครแห่งนี้ และ ณ ที่นี้ ที่ฐานของประตูนคร อันเป็นรากฐานแห่งกำแพงนครนี้ มีรอยจารึกเรื่องราวแห่งคุณูปการของกิลกาเมช อันเป็นเรื่องที่ท่านกำลังจะได้ฟังนี้
เรื่องดังกล่าวมีอยู่ว่า กิลกาเมช ผู้เป็นเทพเจ้าสองในสามส่วน และเป็นมนุษย์หนึ่งในสามส่วน เป็นกษัตริย์ผู้ยิ่งใหญ่ที่สุดในโลก และเป็นอภิมนุษย์ผู้แข็งแรงที่สุดที่เคยมีอยู่ ทว่าพระองค์ยังเยาว์วัย และปกครองพสกนิกรอย่างโหดร้าย ผู้คนร้องเรียกอานุ เทพเจ้าแห่งท้องฟ้า เทพผู้เป็นใหญ่แห่งนครนี้ เพื่อให้ช่วยเหลือพวกคน อานุทรงยินดีช่วย โดยรังสรรค์คนป่าคนหนึ่ง คือ เอนคิดู ขึ้นมา โดยอยู่ในป่ารก ทุรกันดาร ดินแดนของกิลกาเมช
เอนคุดู คนป่าผู้ดุร้ายนี้ มีกำลังเทียมเท่าสัตว์ป่านับสิบๆ ตัว เขาจักทำหน้าที่เป็นอวมนุษย์ ผู้เป็นคู่แข่งของอภิมนุษย์ผู้มีนามว่ากิลกาเมช
ลูกชายนายพรานดักสัตว์คนหนึ่ง ขณะเข้าไปดูกักดักในป่า ก็เห็นเอนคิดูวิ่งเปลือยกายอยู่กับสัตว์ป่า ลูกนายพรานจึงวิ่งไปบอกข่าวนี้แก่บิดา ผู้เป็นบิดาบอกให้ลูกชายเข้าไปในเมือง แล้วพานางคณิกาในอาราม ที่ชื่อ ชัมฮัต กลับเข้ามาในป่าด้วยกัน ครั้นเมื่อนาง[เข้าป่า และ]เห็นเอนคิดู นางก็จะเสนอตัวร่วมสมสู่กับคนป่านั้น พรานบอกว่า หากเอนคิดูยอม ก็จะสูญเสียความแข็งแรงและหมดจากความป่าเถื่อน
นางชัมฮัตได้พบกับเอนคิดูที่ตาน้ำผุด ซึ่งมีสัตว์ป่าทั้งมวลมาชุมนุมกัน นางเสนอตัวจะร่วมสมสู่กับเอนคิดู และเขาก็ยอมตาม และทันใดก็สูญเสียความแข็งแรง และหมดจากความป่าเถื่อน แต่เขาก็ได้รับกำลังสมองและความรู้ (แทน) เอนคิดูเศร้าเสียใจที่ต้องสูญเสียสภาพเดิมของตน แต่นางคณิกาอาสาจะพาเขาเข้าไปในเมือง ซึ่งความสนุกทั้งปวงแห่งความเจริญฉายแสงอย่างเจิดจ้า นางอาสาจะพาเขาไปหากิลกาเมช บุรุษผู้เดียวที่ควรค่าจะเป็นมิตรกับเอนคิดู
ในเวลานั้นกิลกาเมชฝันถึงเรื่องสองเรื่องด้วยกัน เรื่องแรกคือ ฝันว่ามีอุกกาบาตตกมาบนโลก ซึ่งมีขนาดใหญ่มากจนกิลกาเมชไม่อาจยก หรือผลักกลิ้งได้ ผู้คนมาชุมนุม และฉลองกันรอบอุกกาบาตนั้น และกิลกาเมชก็โอบกอดก้อนอุกกาบาตไว้เยี่ยงภรรยา แต่มารดาของตน นั่นคือ เทพี ริมัต-นินสุน บังคับให้ตนเอาชนะอุกกาบาตก้อนนั้น เรื่องที่สอง กิลกาเมชฝันว่ามีขวานเล่มหนึ่งที่ประตู มีขนาดใหญ่มากจนตนไม่สามารถยกหรือผลักได้เลย ผู้คนมาชุมนุมและฉลองกันรอบขวานเล่มนั้น และกิลกาเมชก็โอบกอดขวานเล่มนั้นไว้เยี่ยงภรรยา แต่มารดาของตน ก็บังคับให้ตนเอาชนะขวานเล่มนั้นอีก กิลกาเมชขอให้มารดาช่วยแก้ฝันให้ นางบอกว่า จะมีบุรุษผู้มีกำลังมหาศาลมายังนครอุรุค กิลกาเมชจะโอบกอดเขาเยี่ยงภรรยา และบุรุษผู้นี้จะช่วยกิลกาเมชทำภารกิจอันยิ่งใหญ่
===จารึกแท่งที่ 2===
เอนคิดูค่อยๆ ได้รับความศิวิไลซ์ โดยการอาศัยอยู่ระยะหนึ่งกับกลุ่มคนเลี้ยงแกะ ซึ่งสอนให้เขาดูแลฝูงสัตว์ สอนการกิน การพูดให้เหมาะสม และการนุ่งห่ม จากนั้นเอนคิดูก็เข้านครอุรุคในช่วงการฉลองครั้งยิ่งใหญ่ กิลกาเมช ในฐานะกษัตริย์ ก็ประกาศสิทธิที่จะร่วมสมสู่ครั้งแรกกับเจ้าสาวใหม่ทุกคน ในวันที่นางเข้าพิธีสมรส ในเวลานั้นเอนคิดูเข้าไปในเมือง และกิลกาเมชกำลังจะประกาศสิทธิดังกล่าว
อินคิดูเคืองโกรธกับความชั่วช้านี้ จึงไปยืนที่หน้าประตูเรือนหอ และขวางทางกิลกาเมชเอาไว้ และทั้งสองก็ต่อสู้กันอย่างดุเดือด กระทั่งกิลกาเมชเอาชนะคู่ต่อสู้ได้ เพราะเอนคิดุบิดบังมิให้กิลกาเมชเห็นว่าตนเหนือกว่า และทั้งสองก็สวมกอดกัน สาบานเป็นสหายกัน
ทั้งเอนคิดู และกิลกาเมชค่อยๆ อ่อนแรง และใช้ชีวิตอย่างเกียจคร้านมากขึ้นอยู่ในนคร กิลกาเมชจึงเสนอที่จะออกผจญภัยครั้งยิ่งใหญ่ และทั้งสองจะเดินทางไปยังป่าซีดาร์อันไพศาล ในเขตอิหร่านตอนใต้ และโค่นต้นซีดาร์ทั้งหมดจนสิ้น ในการนี้ ทั้งสองจักต้องฆ่าองครักษ์แห่งป่านั้น นั่นคืออสูรร้าย นามว่าฮัมบาบาผู้น่าหวาดกลัว .. เอนคิดูรู้เรื่องเกี่ยวกับฮัมบาบาจากช่วงที่เคยอยู่ในป่าเยี่ยงคนป่า เขาพยายามจะเอาชนะกิลกาเมช มิให้ทำเรื่องโง่ๆ นี้ แต่ก็ไร้ผล
===จากรึกแท่งที่ 3===
(ข้อความส่วนใหญ่ของจารึกแท่งที่ 3 นี้ขาดหาย)
ปุโรหิตผู้อาวุโสแห่งนครนี้ทักท้วงความพยายามของกิลกาเมช แต่ในที่สุดก็เห็นพ้องด้วยอย่างไม่สู้เต็มใจนัก พวกเขาฝากชีวิตของกษัตริย์ไว้ในมือของเอนคิดู ซึ่งพวกเขายืนยันจะ… ในการรบกับฮัมบาบา มารดาของกิลกาเมชเศร้าเสียใจกับชะตากรรมของลูกชาย คอยสวดขอพร ชามาช เทพเจ้าแห่งตะวัน ถามว่าเหตุใดจึงให้หัวใจที่ไม่รู้หยุดนิ่งไว้ในทรงของลูกชายตน ชามาชสัญญาว่าจะคอยเฝ้ารักษาชีวิตของกิลกาเมชไว้ ส่วนนางรามัต-นินสุน ก็สั่งให้เอนคิดูคุ้มครองชีวิตของกษัตริย์องค์นี้ และคอยเป็นกองหน้าในการต่อสู้กับฮัมบาบา ท่ามกลางความหวั่นวิตกนั้น เอนคิดูพยายามจะโน้มน้าวให้กิลกาเมชล้มเลิกการเดินทางนี้ แต่กิลกาเมชก็ยังคงยึดมั่นว่าจะดำเนินการให้เป็นผลสำเร็จ
===จารึกแท่งที่ 4===
จารึกแท่งที่ 4 เล่าเรื่องการเดินทางไปยังป่าซีดาร์ แต่ละวันในช่วงการเดินทางทั้ง 6 วันนั้น กิลกาเมชขอพรจากเทพชามาช และพระองค์ก็มีเมตตา บันดาลให้กิลกาเมชได้ฝันอันเป็นนิมิตในตอนกลางคืน ความฝันเหล่านี้ล้วนเป็นลางร้าย
(ความฝันเรื่องแรกขาดหายไปจากจารึก)
ความฝันเรื่องที่สอง กิลกาเมชฝันว่าตนได้ปล้ำกับกระทิงใหญ่ ซึ่งเพียงหายใจออกมาแผ่นดินก็แยกออกได้ เอนคิดูแก้ฝันแก่กิลกาเมชว่า ฝันนี้หมายความว่า ชามาช ก็คือกระทิง จักปกป้องกิลกาเมชไว้
ความฝันเรื่องที่สามเป็นดังนี้ ท้องฟ้ากึกก้องกัมปนาทด้วยเสียงฟ้าร้อง และแผ่นดินสะเทือนเลื่อนลั่น ครั้นแล้วท้องฟ้าก็มืดมิด และทุกสิ่งสงบนิ่งราวกับความตาย สายฟ้าฟาดลงมาบนพื้น เกิดไฟเจิดจ้า โครงกระดูก ถั่งท่วมมาจากฟากฟ้า เมื่อความร้อนเหือดหาย และไฟดับมอด พื้นที่ราบแห่งนั้นก็กลายเป็นเถ้าธุลี
ในคราวนี้เอนคิดูทำนายฝันผิดไป แต่ก็คล้ายกับความฝันอื่นๆ คือเป็นนิมิตหมายว่า กิลกาเมชกำลังอยู่ในโอกาสที่ดี ฝันเรื่องที่สี่ขาดหายไป แต่เอนคิดูบอกกิลกาเมชว่า ความฝันนั้นนิมิตบอกความสำร็จในการต่อสู้ที่จะมาถึง ส่วนฝันเรื่องที่ห้าก็ขาดหายไปเช่นกัน
เมื่อถึงป่าทางเข้าป่าซีดาร์ กิลกาเมชก็ตัวสั่นด้วยความกลัว เขาสวดมนต์ต์ขอพระชามาช เตือนให้พระองค์ทราบว่า พระองค์สัญญากับนินสุนแล้ว ว่าตนจักปลอดภัย ชามาชร้องเรียกลงมาจากสวรรค์ สั่งให้กิลกาเมชเข้าไปในป่านั้น เพราะเวลานั้นฮัมบาบามิได้สวมเสื้อเกราะ ปกติอสูรฮัมบาบานั้นสวมเกราะ 7 ตัว แต่ตอนนี้สวมตัวเดียว เวลานี้มันจึงอ่อนแอเป็นพิเศษ เอนคิดูก็สูญความกล้า และหันหลังกลับ กิลกาเมชจึงทำร้ายเขา และทั้งสองต่อสู้อันอย่างรุนแรง เข้าไป ฝ่ายฮัมบาบาเมื่อได้ยินเสียงการต่อสู้ดังกล่าว ก็ก้าวออกมาจากป่าซีดาร์อย่างองอาจเพื่อท้าทายผู้บุกรุก ข้อความตอนนี้ในจารึกหายไปมาก ที่ด้านหนึ่งของจารึกยังมีข้อความปรากฏ กล่าวว่ากิลกาเมชเอาชนะเอนคิดูได้ และเสนอว่าทั้งสองควรจะยืนต้านอสูรร้ายพร้อมกัน
===จารึกแท่งที่ 5===
กิลกาเมชและเอนคิดูเข้าไปในป่าซีดาร์อันงดงามเฉิดฉาย และเริ่มโค่นต้นไม้ลง เมื่อได้ยินเสียงนี้ ฮัมบานาก็แผดคำรามมาหาคนทั้งสอง และเตือนให้ออกไป เอนคิดูตะโกนบอกฮัมบาบา ว่าตนทั้งสองแข็งแรงยิ่งกว่าอสูรฮัมบาบา ฮัมบาบา ซึ่งทราบว่ากิลกาเมชเป็นกษัตริย์ จึงเคืองโกรธกิลกาเมช เพราะฟังคำสั่งจากคนธรรมดาอย่างเอนคิดู มันเปลี่ยนหน้าไปสวมหน้ากากอันน่าเกลียด แล้วเริ่มคุกคามคนทั้งสอง กิลกาเมชจึงวิ่งหนีไปซ่อนตัว เอนคิดูตะโกนบอกกิลกาเมชให้มีกำลังใจ กิลกาเมชจึงปรากฏตัวออกจากที่ซ่อน และทั้งสองก็เริ่มการสู้รบเยี่ยงมหากาพย์ กับฮัมบาบา เวลานั้นชามาชก็บุกเข้ามาในป่า ช่วยคนทั้งสอง และฮัมบาบาก็พ่ายแพ้ มันคุกเข่า ขณะที่ดาบของกิลกาเมชจ่ออยู่ที่ลำคอ ฮัมบาบาร้องขอชีวิต และเสนอจะมอบต้นไม้ทั้งหมดในป่าแก่กิลกาเมช และจักขอเป็นทาสรับใช้ไปชั่วนิรันดร์ ขณะที่กิลกาเมชครุ่นคิดเรื่องนี้ เอนคิดูก็แทรกขึ้นมา บอกให้กิลกาเมชฆ่าฮัมบาบาเสียก่อนที่เทพเจ้าองค์ใดๆ จะมาถึง และจะห้ามมิให้ทำเช่นนั้น หากเขาฆ่าฮัมบาบา เขาก็จักได้เกียรติยศเกรียงไกรแผ่ไพศาลไปชั่วกาลนาน กิลกาเมชจึงฟันดาบของตนอย่างแรง ตัดศีรษะของฮัมบาบาหลุดจากบ่า แต่ก่อนจะตายนั้น ฮัมบาบาก็กรีดร้องสาปแช่งเอนคิดูว่า “เจ้าทั้งสอง เอนคิดูจงอย่ามีชีวิตยืนนาน เอนคิดูจงอย่าได้พบความสงบสุขในโลกนี้เลย”
กิลกาเมชและเอนคิดูช่วยกันตัดไม้ในป่าซีดาร์ โดยเฉพาะต้นที่สูงที่สุด เพื่อจะนำไปสร้างประตูซีดาร์อันโอฬารแห่งนครอุรุค ทั้งสองได้สร้างแพจากไม้ซีดาร์ (บรรทุกไม้ที่ตัด) และล่องมาตามแม่น้ำยูเฟรตีส จนถึงนครของตน
===จารึกแท่งที่ 6===
หลังจากเหตุการณ์ดังกล่าว กิลกาเมช ผู้มีชื่อเสียงขจรขจาย และมีเสน่ห์เรืองรองภายในอารมณ์อันหรู
ก็ลุ่มหลงเสน่หาเทพีเอชตาร์ ผู้มาตามหากิลกาเมช และเสนอตนจะเป็นคนรักของกิลกาเมช กิลกาเมชปฏิเสธคำร้องขอนี้ด้วยความขัดเคืองใจ โดยร่ายยาวถึงคนรักที่ตายแล้วทั้งปวงที่นางอิชตาร์เคยมี และยังชักเรื่องดวงชะตาที่ต้องถึงฆาต เมื่อพวกเขาทั้งหมดได้ประสบด้วยน้ำมือของนาง นางอิชตาร์เคืองแค้นยิ่งนัก รีบกลับสวรรค์ และขอให้บิดา คืออานุ เทพเจ้าแห่งท้องฟ้า ได้มอบโคสวรรค์แก่นาง เพื่อแก้แค้นทำลายกิลกาเมช และพระนครด้วย
<blockquote>
พระบิดา โปรดประทานโคสวรรค์แก่ข้า</br>
เพื่อสังหารกิลกาเมชและทำลายนครของมันด้วยเถิด </br>
เพราะหากท่านไม่ประทานโคสวรรค์แก่ข้าแล้ว </br>
ข้าจักรื้อประตูนรกเอง </br>
จักพังเสาและประตูให้ราบเรียบพนาสูร </br>
และข้าจักปล่อยปีศาจร้าย</br>
และปล่อยให้ปีศาจมาท่องในโลกมนุษย์</br>
และมันจักกินสรรพชีวิต</br>
ปีศาจร้ายจักคร่าชีวิตทั้งปวง</blockquote>
เทพอานุ จึงยอมตาม และส่งโคสวรรค์ลงมายังนครอุรุค
แต่ละครั้งที่โคนี้หายใจ ลมหายใจของมันมีพลังอย่างมหาศาล จนเหวลึกอันโอฬารพลันเปิดกว้างในปฐพี ผู้คนนับร้อยร่วงพรูสู่ความตาย กิลกาเมชและเอนคิดูหวนมาร่วมมือกันอีกครา ร่วมสังหารโคกล้าตัวนี้ อิชตาร์ยิ่งขัดเคืองใจนัก แต่เอนคิดูก็เริ่มพูดให้นางเคืองโกรธ โดยกล่าวว่านางจักเป็นเหยื่อรายถัดไป ว่าตนและกิลกาเมชจักประหารนางเป็นรายถัดไป และเอนคิดูก็เฉือนน่องโคออกมาข้างหนึ่ง แล้วขว้างลอยคว้างไปเบื้องหน้าของนาง
===จารึกแท่งที่ 7===
เอนคิดูล้มป่วยลงหลังจากฝันเป็นลางนิมิตอยู่หลายครั้ง เขาได้ทราบจากนักบวชว่า ตนจะถูกแยก [ออกจากกิลกาเมช] เพื่อแก้แค้นโดยพวกเทพเจ้า เทพเจ้าผู้ใหญ่ได้มาชุมนุมและตัดสินว่า จักต้องมีคนถูกลงโทษ เพราะไปฆ่าฮัมบาบา และฆ่าโคสวรรค์ นั่นก็คือผู้กล้าทั้งสอง เทพเหล่านั้นตัดสินใจว่าเอนคิดูควรจะได้รับการลงโทษนี้ เมื่อได้รับการตัดสินอย่างไม่ยุติธรรม เอนคิดูจึงแค้นใจนัก สาปแช่งประตูซีดาร์อันโอฬาร ที่สร้างจากไม้ในป่าซีดาร์ และสาปนางชัมฮัต คณิหาแห่งอาราม และนายพรานผู้นำพาตนมาสู่ความศิวิไลซ์ ชามฮัชเตือนเขาว่า แม้ชีวิตของเขาจะสั้น แต่เขาก็ได้ดื่มด่ำกับผลพวงแห่งความศิวิไลซ์ และรู้ถึงความสุขอันเป็นยอด เอนคิดูจึงให้พรแก่นางคณิกา และพรานผู้นั้น ในฝันครั้งหนึ่ง มีอสูรใหญ่มาจับตัวเอินคิดู และลากถูไปลงนรก เรือนแห่งสนธยากาล ที่คนตายทั้งปวงจบชีวิตลง ขณะกำลังจะตาย เขาบรรยายถึงนรกไว้ว่า
<blockquote>
เรือนที่คนตายได้พำนักในความมืดมิดสนิทนัก</br>
ที่พวกเขาได้ดื่มปฏิกูล และกินก้อนศิลา</br>
ที่พวกเขานุ่งห่มขนเยี่ยงนก</br>
ที่ไม่มีแสงรุกมาถึงความมืดชั่วนิรันดร์อีกต่อไป</br>
ที่ประตูและกุญแจนรกถูกเคลือบด้วยฝุ่นหนา</br>
ที่ข้าเข้าไปในเรือนแห่งฝุ่น</br>
ทุก ๆ ด้านมีมงกุฎกษัตริย์สุมรุมกอง</br>
ทุก ๆ ด้านมีเสียงเหล่ากษัตริย์ผู้สวมมงกุฎเหล่านั้น</br>
ผู้บัดนี้ได้เพียงถวายอาหารเทพอานุ และเอนลิล</br>
ขนมนมเนย เนื้อ และน้ำ รินจากหนัง</br>
ข้าเห็นนักบวชหนึ่งและทาสหนึ่งนั่งในเรือนแห่งฝุ่น</br>
ข้ายังเห็นนักบวชแห่งการขจัดมลทิน และนักบวชแห่งความสุขสันต์</br>
ข้าเห็นนักบวชทั้งปวงแห่งเทพเจ้าผู้ยิ่งใหญ่</br>
ที่นั่น เทพเอตานา และซุมุคัน ก็นั่งกัน</br>
ที่นั่น เอเรชคิกัล ราชินีแห่งนรกก็นั่งอยู่</br>
เบเลตเสรี อาลักษณ์แห่งนรก นั่งเบื้องหน้านาง</br>
เบเลตเสรี ถือจารึก อ่านถวายเอเรชคิกัล</br>
นางเงยพระพักตร์ช้า ๆ เมื่อเห็นข้า</br>
นางชี้มาที่ข้า ว่า</br>
“ใครส่งชายคนนี้มา”</blockquote>
เอนคิดูถวายตัวแก่กิลกาเมช(ก่อนตาย) และหลังจากทนทุกข์ทรมานอย่างแสนสาหัสอยู่ 12 วัน สุดท้ายก็ถึงแก่ความตาย
===จารึกแท่งที่ 8===
กิลกาเมชจำพรากจากสหายด้วยความตาย และร่ำร้องด้วยความอาลัยยิ่ง และสั่งผู้คนทั้งมวลอย่าได้หยุดนิ่ง ด้วยคร่ำครวญอาลัยถึงสหาย (ข้อความส่วนใหญ่ของจารึกแท่งนี้ขาดหายไป แต่ครึ่งหลังของจารึกดูเหมือนจะพรรณนาถึงอนุสาวรีย์ที่กิลกาเมชสร้างให้เอนคิดู)
===จารึกแท่งที่ 9===
กิลกาเมชปล่อยชีวิตไปวันๆ มิได้อาบน้ำ มิได้โกนหนวดเครา มิได้ดูแลตนเอง เศร้าโศกถึงมิตรมิได้สร่าง แต่เนื่องจากบัดนี้กิลกาเมชระลึกได้ ว่าตนจะต้องตายด้วยเช่นกัน และเมื่อคิดได้เช่นนี้ ก็ตื่นตระหนกเป็นยิ่งนัก ตัดสินใจว่าตนจะไม่มีชีวิตอยู่ได้ เว้นแต่จะมีชีวิตนิรันดร์ และจักไปเดินทางที่เสี่ยงอันตรายที่สุดยิ่งกว่าการเดินทางครั้งไหนๆ นั่นคือการเดินทางสู่อุตนาปิชติม พร้อมชายา ผู้เป็นมนุษย์ปุถุชนเพียงสองคน? ที่เทพเจ้าประทานชีวิตนิรันดร์ให้
อุตนาปิชตัมนั้นคือดินแดนแสนไกล อยู่ที่ปากของแม่น้ำทั้งมวล อยู่ที่ปลายสุดของโลก อุตนาปิชติม คือกษัตริย์ผู้ยิ่งใหญ่ในโลกนี้ ก่อนจะมีน้ำท่วมใหญ่ พระองค์และชายา เป็นปุถุชนเพียงสองคน ที่เทพเจ้าเฝ้าพิทักษ์รักษาในช่วงน้ำท่วมโลกครั้งนั้น หลังจากฝันเป็นลางนิมิตครั้งหนึ่ง กิลกาเมชก็ออกเดินทาง โดยไปถึงภูเขา มาชู ซึ่งเป็นหลักหมายของตะวันขึ้นและตะวันตกดิน และได้พบกับแมงป่องขนาดใหญ่สองตน ผู้พิทักษ์หนทางสู่ขุนเขามาชู ปกปัก แมงป่องเหล่านี้พยายามบอกให้กิลกาเมชเข้าใจว่าการเดินทางครั้งนี้เต็มไปด้วยอันตราย และไร้ผล แต่ก็ยอมให้กิลกาเมชผ่านไปได้
เมื่อผ่านขุนเขามาชู ก็ถึงดินแดนแห่งรัตติกาล ซึ่งไม่มีแสงสว่างปรากฏเลย กิลกาเมชเดินทางได้ 11 ลี้ ก็เริ่มมีแสงรำไร หลังจากผ่านไป 12 ลี้ ก็เข้าสู่ทิวาวาร กิลกาเมชเข้าไปในสวนอัญมณีอันเรืองรอง ไพรพฤกษ์ทั้งมวลล้วนแต่เพชรพลอยล้ำค่า
===จารึกแท่งที่ 10===
กิลกาเมชเดินทางมาถึงโรงเตี๊ยมเล็กๆ ริมฝั่งทะเล โรงเตี๊ยมแห่งนี้มีสิดุรี เป็นผู้ดูแล เขาตกใจเมื่อเป็นกิลกาเมชปรากฏตัวในสภาพมอมแมม สิดุรีปิดประตูลั่นดาล ไม่ยอมให้กิลกาเมชเข้าไป กิลกาเมชบอกให้ทราบว่าตนเป็นใคร และถามสิดูรีว่าจะไปหาอุตนาปิชติมได้อย่างไร นางก็บอกกิลกาเมช เช่นเดียวกับแมงป่องยักษ์ ว่าการเดินทางนั้นจะไร้ผล และหนทางเต็มไปด้วยอันตราย แต่นางก็แนะให้ไปหา อุร์ชานาบี คนแจวเรือ ซึ่งจะนำไปสู่อุตนาปิชติมได้
กิลกาเมชจึงไปหาอุร์ชานาบี แสดงท่าทางยะโส และก้าวร้าวรุนแรงนัก และขณะเดียวกันก็ได้ทำลาย ”เครื่องศิลา” ที่นับว่าสำคัญยิ่งยวดต่อการเดินทางสู่อุตนาปิชติม เมื่อกิลกาเมชบอกว่าจะไปอุตนาปิชติม คนแจวเรือก็บอกว่าเวลานี้ไปไม่ได้เสียแล้ว เพราะ “เครื่องศิลา” นั้นถูกทำลาย แต่เขาก็แนะนำกิลกาเมช ให้โค้นต้นไม้จำนวนมากลง เพื่อใช้เป็นใช้ถ่อเรือ สายน้ำที่พวกเขาจะข้ามไปนั้น เป็นสายน้ำแห่งความตาย หากปุถุชนคนใดสัมผัสน้ำนั้น ก็จะเสียชีวิตลงทันที กิลกาเมชใช้ไม้ถ่อ และถ่อเรือไปได้โดยไม่สัมผัสกับสายน้ำอันตรายนั้น
หลังจากผ่านการเดินทางที่อันตรายและยาวนานแล้ว กิลกาเมชก็มาถึงชายฝั่งแห่งหนึ่ง และเผชิญหน้ากับชายคนหนึ่ง กิลกาเมชบอกชายผู้นี่ว่า ตนกำลังเที่ยวหาอุตนาปิชติม และความลับของชีวิตชั่วนิรันดร์ ชายชราผู้นั้นแนะนำกิลกาเมชว่า ความตายนั้นเป็นสิ่งจำเป็น เนื่องจากเป็นเจตจำนงของเทพเจ้า ความพยายามของมนุษย์ทั้งปวงนั้นเป็นเพียงสิ่งชั่วครู่ ไม่ถาวร
===จารึกแท่งที่ 11===
มาถึงจุดนี้ กิลกาเมชรู้แจ้งว่าตนกำลังสนทนาอยู่กับ อุตนาปิชติม ผู้อยู่แสนไกล นั่นเอง เขามิได้คาดคิดว่ามนุษย์อมตะจะเหมือนคนธรรมดา และแก่ชราได้ กิลกาเมชจึงถามอุตนาปิชติมว่า ตนจะมีความเป็นอมตะได้อย่างไร อุตนาปิชติมจึงตอบว่า ความลับอันยิ่งใหญ่ที่ถูกซ่อนเร้นจากมนุษย์ ก็คือ
ในสมัยก่อนน้ำท่วมโลก ยังมีนครแห่งหนึ่ง ชื่อ ชุรุปปัค อยู่ริมฝั่งแม่น้ำยูเฟรตีส ณ ที่นั้น สภาแห่งเทพเจ้ากำลังชุมนุมอย่างเป็นความลับ โดยเทพทั้งปวงนั้นคิดแก้ปัญหา โดยการจะทำลายโลกให้เกิดน้ำท่วมใหญ่ขึ้น เทพเจ้าทั้งหลายล้วนสาบานว่าจักไม่แพ่งพรายความลับนี้แก่สรรพชีวิตใดๆ บนโลก แต่ เออา (เทพเจ้าองค์หนึ่ง ที่สร้างสรรค์มนุษยชาติ) ก็มาที่บ้านของอุตนาปิชติม และเล่าความลับนี้ให้แก่ผนังบ้านของอุตนาปิชติม จึงไม่เป็นการผิดคำสาบานที่ให้ไว้แก่เทพเจ้าทั้งหลาย เทพองค์นี้ได้แนะนำผนังบ้านของอุตนาปิชติมให้สร้างเรือขนาดใหญ่ มีความยาวเท่ากับความกว้าง และคลุมเรือนี้เสีย และนำสิ่งมีชีวิตทั้งปวงมาลงเรือไว้
อุตนาปิชติมลงมือทำงาน และสร้างเรือใหญ่ได้เสร็จในปีถัดมา จากนั้นก็ขนทองคำ เงิน และสิ่งมีชีวิตทั้งปวงบนโลกมาลงเรือ และนำเรือลงน้ำ เออาสั่งให้อุตนาปิชติมลงเรือ และสั่งให้ปิดประตูด้วย [ไม่นานนัก]เมฆดำทะมึนก็มาถึง พร้อมด้วยอาดาด เทพเจ้าแห่งสายฟ้าที่ร้องลั่นมาพร้อมกัน แผ่นดินแยกเหมือนกับหม้อดิน และแสงสว่างทั้งปวงก็กลายเป็นความมืดมิด น้ำท่วมใหญ่มาก จนแม้เทพเจ้าก็ยังพรั่นพรึง
<blockquote>
ทวยเทพสะท้านราวสุนัขสั่นระริก ซ่อนตัวอยู่ลับลิบในสวรรค์</br>
อิชตาร์กรีดร้องและครวญคร่ำ</br>
“วารวันเก่าแก่แปรเป็นศิลา</br>
เราตัดสินสิ่งชั่วแล้วในสภา</br>
เหตุใดเราตัดสินสิ่งชั่วนั้นในสภาเรา</br>
เหตุเราตัดสินทำลายคนของเรา</br>
เวลานี้เราเพิ่งสร้างมนุษย์อันเป็นที่รักของเรา</br>
บัดนี้เราทำลายพวกเขาในห้วงนที”</br>
เทพทั้งมวลล้วนครวญคร่ำ ร่ำไห้ไปพร้อมนาง</br>
เทพทั้งหลายนั่งสั่นหวีด กรีดน้ำตา </blockquote>
น้ำท่วมใหญ่คราวนั้นเกิดขึ้นนาน 7 วัน 7 คืน และสุดท้ายแสงสว่างก็คืนสู่โลก อุตนาปิชติมเปิดหน้าต่างออก และโลกทั้งมวลก็กลับกลายเป็นทะเลเรียบ มนุษย์ทั้งปวงกลายเป็นศิลา จากนั้นอุตนาปิชติม ก็ทรุดตัวลงคุกเข่า ร่ำไห้
เรือของอุตนาปิชติมลอยไปหยุดค้างบนยอดเขานีมุช เรือจอดอยู่อย่างมั่นคงบนยอดเขานั้น แต่ยังอยู่ใต้ผิวทะเล และคงติดอยู่ที่นั่นอีก 7 วัน และในวันที่ 7 …
<blockquote>
ข้า (อุตนาปิชติม) ปล่อยนกเขาตัวหนึ่งออกจากเรือ</br>
มันบินออกไป แต่บินวน และกลับมา</br>
เพราะมันไม่พบกิ่งไม้ที่จะเกาะ</br>
ข้าจึงปล่อยนกนางแอ่นออกจากเรือ </br>
มันบินออกไป แต่บินวน และกลับมา</br>
เพราะมันไม่พบกิ่งไม้ที่จะเกาะ</br>
ข้าจึงปล่อยอีกาออกจากเรือ</br>
มันบินออกไป และน้ำก็ซัดกลับ</br>
มันกิน มันข่วนพื้น แต่มันบินวน และไม่กลับมา</br>
ข้าจึงส่งสิ่งมีชีวิตทั้งมวลออกไปทุกทิศทุกทาง และบูชายัญแพะตวหนึ่งในจุดนั้นเอง</blockquote>
เทพเจ้าได้กลิ่นเครื่องสังเวยและบูชายัญ และเริ่มมาชุมนุมกับรอบๆ อุตนาปิชติม ฝ่ายเอนลิล ผู้ที่แต่เดิมเสนอให้ทำลายมนุษย์ทั้งปวงก็มาถึง เอนลิลเกรี้ยวกราดที่ยังมีมนุษย์คนหนึ่งรอดชีวิต เพราะทวยเทพต่างเห็นพ้องที่จะกวาดเอาชีวิตมนุษย์ทั้งมวล เอนลิลกล่าวโทษเออาที่ทรยศ แต่เออาขอให้เอนลิลโปรดเมตตา เอนลิลจึงจับตัวอุตนาปิชติมกะภรรยาไว้ และให้พร
<blockquote>
ครั้งหนึ่ง อุตนาปิชติมเป็นปุถุชน ผู้ไม่พ้นความตาย</br>
ครานี้ ขอให้เขาเป็นเทพ และอมตะ</br>
ขอให้เขามีชีวิตยืนยาว ณ แหล่งแม่น้ำทั้งปวง </blockquote>
เมื่อเล่าจบ อุตนาปติมก็ให้กิลกาเมชได้มีโอกาสเป็นอมตะบ้าง หากกิลกาเมชสามารถทนตื่นได้ 6 วัน 7 คืน โดยไม่หลับ เขาก็จักได้เป็นอมตะ กิลกาเมชรับเงื่อนไขทั้งหมดนี้ และนั่งลงริมฝั่งน้ำ ทันทีที่เขานั่งลง เขาก็ผลอยหลับไป อุตนาปิชติมจึงบอกภรรยาว่า ผู้ชายทุกคนเป็นคนหลอกลวง ซึ่งกิลกาเมชจะปฏิเสธว่าตนไม่ได้หลับ อุตนาปิชติมจึงขอให้ภรรยาปิ้งขนมปังทุกวัน และวางไว้ที่เท้าของกิลกาเมช
กิลกาเมชหลับโดยไม่ตื่นเลยเป็นเวลา 6 วัน 7 คืน แล้วอุตนาปิชตัมก็ปลุกให้เขาตื่น เมื่อสะดุ้งตื่น กิลกาเมชก็พูดว่า “ข้าเพียงแต่งีบไปชั่วเสี้ยววินาที ณ ที่นี้เอง” อุตนาปิชติมจึงชี้ไปที่ขนมปังเหล่านั้น บอกให้ทราบถึงสภาพการเสื่อมสลายจากขนมปังใหม่สุด จนถึงที่เก่าที่สุด และมีราขึ้น ซึ่งวางอยู่แทบเท้านับแต่วันแรก กิลกาเมชจึงกลัดกลุ้มใจยิ่งนัก
<blockquote>
โธ่เอ๋ย แล้วนี่ข้าจักทำอย่างไร บัดนี้ข้าจักไปแห่งหนใด </br>
ความตายกัดกินร่างกายข้า</br>
ความตายพำนักในกายข้า </br>
ข้าจะไปที่ใด ข้าจะเห็นที่ใด ก็มีแต่ความตาย</blockquote>
ภรรยาของอุตนาปิชติมขอร้องให้สามีได้เมตตากิลกาเมช อุตนาปิชติมจึงบอกสถานที่แห่งความอมตะแก่กิลกาเมช ซึ่งมีต้นไม้ลี้ลับต้นหนึ่ง ซึ่งจะทำให้กิลกาเมชเป็นหนุ่มขึ้นอีกครั้ง ต้นไม้นี้อยู่ที่ก้นทะเล รอบแผ่นดินแสนไกล กิลกาเมลมัดก้อนหินไว้กับเท้า แล้วจมลงไปที่ก้นทะเล แล้วถอนต้นไม้วิเศษ แต่ก็ไม่ได้ใช้ประโยชน์จากมัน เพราะไม่วางใจ แต่คิดจะนำกลับไปอุรุค และทดสอบกับชายชราก่อน เพื่อให้แน่ใจว่าได้ผลจริง
อุร์ชนาบีพากิลกาเมชข้ามสายน้ำแห่งความตาย แล้วเดินทางเข้าไปจากฝั่งหลายลี้ กิลกาเมชและอุร์ชานาบีหยุดรับประทานอาหารและนอนหลับ ขณะที่หลับไหลอยู่นั้น ก็มีงูเลื้อยขึ้นมา กินต้นไม้วิเศษนั้นเสีย แล้วเลื้อยจากไป เมื่อกิลกาเมชตื่นมา ก็พบว่าต้นไม้วิเศษหายไปแล้ว จึงเสียใจทรุดตัวลงคุกเข่า ร่ำไห้
<blockquote>
ข้าเหน็ดเหนื่อยแรงกายไปเพื่อใครเล่า</br>
ข้าเดินทางไกลก็เพื่อใครเล่า </br>
ข้าทนทุกข์เวทนามาเพื่อใคร</br>
ข้าได้แต่ความสูญเปล่าแก่ข้าเอง</br>
ข้าต้องเสียประโยชน์แก่อสรพิษ ผู้เปรียบสิงโตบนพื้นปฐพี</blockquote>
===จารึกแท่งที่ 12===
เล่าเกี่ยวกับวัตถุอย่างหนึ่งที่สูญหายไป เรียกว่า ปุคคุ และ มิคคุ (เข้าใจว่า หมายถึง กลอง และไม้ตีกลอง) ซึ่งเทพีอิชตาร์ได้เคยมอบไว้แก่กิลกาเมช และเล่าถึงวิญญาณของเอนคิดูกลับคืนมา สัญญาว่าจะหาของที่หายมาคืนให้ จากนั้นก็เล่าเรื่องอันโหดร้ายในปรโลก
เรื่องดังกล่าวจบลงที่กิลกาเมช เมื่อสิ้นสุดการเดินทาง ก็มายืนอยู่เบื้องหน้าประตูเมืองอุรุค เชื้อเชิญให้อุร์ชานาบีมองไปรอบๆ และชมความยิ่งใหญ่ของพระนคร กำแพงสูง งานฝีมืออันประณีต และ ณ ที่นี้เอง ที่ฐานของประตูเมือง อันเป็นฐานของกำแพงนคร ที่ประดิษฐานหินแก้วไพฑูรย์ ซึ่งสลักเรื่องราวการเดินทางของกิลกาเมชไว้เป็นตำนาน.
== แหล่งข้อมูลอื่น ==
* [http://www.wsu.edu/~dee/MESO/GILG.HTM คำแปลจารึกอย่างย่อ] {{en icon}}
* [http://www.piney-2.com/Gil01.html คำแปลจารึกทั้ง 12 แผ่นอย่างละเอียด] {{en icon}}
paalq7858e9ca98sqes51nubdtgiai2
นิทานแกล้มเหล้า
0
16225
189493
37559
2022-08-16T23:50:33Z
YURi
4431
แจ้งลบด้วย[[WS:iScript|สจห.]]: 1=ท6 - เทพ สุนทรสารทูล เป็นข้าราชการบำนาญที่ยังมีชีวิตอยู่ ตาม [http://thepsundarasardula.blogspot.com/2014/12/blog-post_19.html ลิงก์นี้]
wikitext
text/x-wiki
{{ลบ|1=ท6 - เทพ สุนทรสารทูล เป็นข้าราชการบำนาญที่ยังมีชีวิตอยู่ ตาม [http://thepsundarasardula.blogspot.com/2014/12/blog-post_19.html ลิงก์นี้]}}
<center>
นิทานแกล้มเหล้า ๘๓ เรื่อง
เทพ สุนทรสารทูล
นิทานแกล้มเหล้า
เป็นนิทานไทยแท้แต่โบราณ
แบบแผนการเล่านิทานแกล้มเหล้าเป็นทั้งศาสตร์และศิลป์
เป็นเครื่องสำแดงอารมณ์ขันของคนไทย
ใครได้อ่านแล้วจะติดใจ
ต้องอ่านซ้ำอีกสามหน
นักอ่านบางคนอาจวางไว้ข้างเตียงนอน
เพื่อเอาไว้อ่านเป็นเพื่อนนอนยามเหงาเศร้าโศก
เฒ่าธรรมาภิสมัยใจเหี่ยวแห้ง
อาจสดชื่นมีชีวิตชีวาขึ้นเมื่อได้อ่านนิทานแกล้มเหล้า
แต่สุภาพสตรีห้ามอ่าน
เป็นเรื่องลับเฉพาะสำหรับสุภาพบุรุษ
</center>
<center>คำประหน้าพากย์</center>
{|
|เล่านิทานลามกตลกเล่น||พอจี้เส้นคลายทุกข์เป็นสุขศรี
|-
|มีทั้งเรื่องหยาบคายร้ายและดี||เป็นวิธีเล่าขานนิทานไทย
|-
|มิใช่เรื่องหยาบคายร้ายแรงดอก||เป็นทางออกเรื่องเพศสังเกตได้
|-
|ฟังนิทานลามกอย่าตกใจ||ไม่มีใครชำเรากุเมารี
|-
|ประเพณีไทยแท้แต่โบราณ||เล่านิทานขำขันทุกวันวี่
|-
|คำพังเพยคำผวนคำยวนยี||มหามีหนีหอหัวร่อเอิ๊ก
|-
|เล่านิทานขำขันตะบันราด||บุรุษชาติเล่าขานกันเอิกเริก
|-
|หินกระทบดอกแหนแลชะเวิก||ไม่ยอมเลิกเล่าสนุกมีมุขใน
|-
|เล่านิทานลามกตลกหลวง||ยังเล่าลวงพระเจ้าแผ่นดินได้
|-
|เข้านวดฟั้นบาทาในคราใด||ต้องเล่าไขนิทานโบราณคิก
|-
|ไม่เชื่อเชิญถามชาติมหาดเล็ก||จำพวกเด็กตัวตลกพกไอขิก
|-
|เที่ยววิ่งหานิทานเก่าจนเท้าพลิก||หัวร่อริกไปเล่าเจ้าแผ่นดิน
|-
|อันนิทานแกล้มเหล้าเรื่องเก่าแก่||มีมาแต่ก่อนกรุงพระโกสินทร์
|-
|สำแดงอารมณ์ขันของศิลปิน||เคยได้ยินเล่าขานมานานนม
|-
|เกรงจะสูญเสียหายเสียดายนัก||จึงอนุรักษ์สืบเสาะมาสะสม
|-
|สำหรับนักอนุรักษ์นิยมชม||เรื่องโบรมโบราณนิทานไทย
|-
|สำหรับมวลนักเลงเก่งภาษา||พวกครูบาถ้วนทั่วหัวสมัย
|-
|จะได้รู้รากเหง้าต้นเถาไม้||เอามาไขปัญหาภาษาเรา
|-
|ราชบัณฑิตผู้เฒ่าชั้นเก่าก่อน||จะได้นอนตรวจตราภาษาเก่า
|-
|ไม่เดาสวดอวดรู้เที่ยวดูเบา||รู้รากเหง้าตำราที่ลึกลับ
|-
|ภาษาไทยใช้มาแต่ตาปู่||จะได้รู้ภาษาเราชั้นเก่ากึก
|-
|ไม่ใช่ตรรกวิทยาหลับตานึก||จะได้ศึกษาดูให้รู้จริง
|-
|มิใช่รู้เงาเงาแล้วเดาสวด||เพื่อจะอวดปัญญามหาหิงค์
|-
|นักปราดเปรียวเปรี้ยวปริดตะลิงปิง||กลายเป็นลิงหลอกเจ้ากินข้าวตัง ฯ
|}
fp7nxdzsvitllavimz6m5vwhc88kavr
วิกิซอร์ซ:งานแปล
4
16838
189467
180794
2022-08-16T16:22:23Z
Venise12mai1834
8884
wikitext
text/x-wiki
{{process header
| title = {{PAGENAME}}
| section =
| previous = [[วิกิซอร์ซ:นโยบายและแนวปฏิบัติ|นโยบายและแนวปฏิบัติ]]
| next =
| shortcut =
| notes =
}}
คำแปลงานภาษาต่างประเทศเป็นภาษาไทย โดยปรกติแล้ว สามารถนำมาลงที่วิกิซอร์ซภาษาไทยได้ ไม่ว่าจะเป็นคำแปลที่เผยแพร่ในแหล่งอื่นมาแล้ว หรือคำแปลที่ผู้ใช้วิกิซอร์ซจัดทำขึ้นเอง
==คำแปลที่เผยแพร่ในแหล่งอื่นมาแล้ว==
คำแปลที่เผยแพร่ในแหล่งอื่นมาแล้ว จะนำมาลงได้ ถ้าคำแปลนั้นเป็น[[วิกิซอร์ซ:วิกิซอร์ซมีอะไรได้บ้าง|งานประเภทที่วิกิซอร์ซรับไว้ได้]] และ[[วิกิซอร์ซ:นโยบายลิขสิทธิ์|ไม่มีปัญหาลิขสิทธิ์]]
ข้อควรตระหนัก คือ คำแปลไม่ได้มีสถานะทางลิขสิทธิ์เดียวกับงานต้นฉบับเสมอไป เช่น แม้งานต้นฉบับจะเป็นสาธารณสมบัติ ก็ไม่ได้หมายความว่า คำแปลของงานดังกล่าวจะเป็นสาธารณสมบัติตามไปด้วย สถานะทางลิขสิทธิ์ของคำแปล ให้พิจารณาที่ตัวคำแปล มิใช่ที่งานต้นฉบับ งานใดมีลิขสิทธิ์หรือไม่ โปรดอ่านรายละเอียดที่ [[วิกิซอร์ซ:นโยบายลิขสิทธิ์]]
ถ้างานหนึ่งมีคำแปลหลายสำนวน จะนำกี่สำนวนมาลงก็ได้ โปรดอ่านรายละเอียดที่ [[วิกิซอร์ซ:ฉบับ]]
คำแปลในกลุ่มนี้ ให้ลงไว้ในหน้าหลักเหมือนงานประเภทอื่น ๆ
==คำแปลที่ผู้ใช้วิกิซอร์ซจัดทำขึ้นเอง==
คำแปลที่ผู้ใช้วิกิซอร์ซจัดทำขึ้นเอง สามารถนำมาลงที่วิกิซอร์ซได้ ถ้า
# งานต้นฉบับเป็น[[วิกิซอร์ซ:วิกิซอร์ซมีอะไรได้บ้าง|งานประเภทที่วิกิซอร์ซรับไว้ได้]] และ[[วิกิซอร์ซ:นโยบายลิขสิทธิ์|ไม่มีปัญหาลิขสิทธิ์]]
# เป็นการแปลงานต้นฉบับทั้งฉบับ มิใช่เพียงส่วนหนึ่งส่วนใด
คำแปลที่ผู้ใช้วิกิซอร์ซจัดทำขึ้นเอง จะต้องระบุให้ชัดเจนว่า เป็นคำแปลของวิกิซอร์ซ และต้องลงไว้ในเนมสเปซ "งานแปล" (หน้าที่มีชื่อขึ้นต้นว่า "งานแปล:")
คำแปลฉบับวิกิซอร์ซนี้ ต่างจากกรณีก่อนหน้า ตรงที่ควรมีเพียงสำนวนเดียวต่องานต้นฉบับหนึ่งงาน ไม่พึงมีหน้าหนึ่งเป็นสำนวนของผู้ใช้คนหนึ่ง อีกหน้าหนึ่งเป็นสำนวนของผู้ใช้อีกคน เป็นต้น
แต่งานใดมี "คำแปลที่เผยแพร่ในแหล่งอื่นมาแล้ว" จะมี "คำแปลที่ผู้ใช้วิกิซอร์ซจัดทำขึ้นเอง" อีกก็ได้
สำหรับคำแปลฉบับวิกิซอร์ซ ผู้แปลมีสิทธิกำหนดสัญญาอนุญาตแบบใดก็ได้ที่[[วิกิซอร์ซ:นโยบายลิขสิทธิ์#การมีส่วนร่วมในวิกิซอร์ซ|เข้ากันได้กับวิกิซอร์ซ]] โดยใช้ {{tl|สัญญาอนุญาตงานแปล}}
===หน้าที่เกี่ยวข้อง===
* [[วิกิซอร์ซ:งานแปล/งานใหม่|รายชื่องานแปลที่เพิ่มเข้ามาใหม่]]
* [[:แม่แบบ:หัวเรื่องงานแปล]]
* [[:แม่แบบ:สัญญาอนุญาตงานแปล]]
* [[:แม่แบบ:ลิงก์ไปงานแปล]]
* [[:แม่แบบ:ลิงก์ไปงานแปลย่อย]]
[[หมวดหมู่:นโยบายวิกิซอร์ซ]]
[[หมวดหมู่:งานแปลของวิกิซอร์ซ| ]]
4rxkih6oyig66f9oj2opnp3eq217g7c
แม่แบบ:เริ่มอ้างอิง
10
17452
189450
42568
2022-08-16T15:48:26Z
Venise12mai1834
8884
wikitext
text/x-wiki
<includeonly><templatestyles src="Refbegin/styles.css" /><!--
--><div class="refbegin <!--
-->{{#if: {{{indent|}}} | refbegin-hanging-indents }} <!--
-->{{#if: {{{normalfont|}}} | refbegin-100 }} <!--
-->{{#if: {{{1|}}}
| refbegin-columns {{#iferror: {{#ifexpr: {{{1|1}}} > 1 }}
| references-column-width
| references-column-count references-column-count-{{#if:1|{{{1}}}}} }}
| {{#if: {{{colwidth|}}}
| references-column-width }} }}" style="<!--
-->{{#if: {{{1|}}}
| {{#iferror: {{#ifexpr: {{{1|1}}} > 1 }}
| column-width: {{#if:1|{{{1|30em}}}}}
| column-count: {{#if:1|{{{1}}}}}; }}
| {{#if: {{{colwidth|}}}
| column-width: {{{colwidth|30em}}} }} }}"><!--
-->{{#if: {{{normalfont|}}}
| [[Category:Pages using refbegin with normalfont parameter]]}}</includeonly><noinclude>
{{เอกสารกำกับแม่แบบ}}
[[หมวดหมู่:แม่แบบอ้างอิง]]
</noinclude>
4je9avfye8yzcgfhyjy0dt3dy8s4e05
189451
189450
2022-08-16T15:50:24Z
Venise12mai1834
8884
wikitext
text/x-wiki
<includeonly><templatestyles src="Refbegin/styles.css" /><!--
--><div class="refbegin <!--
-->{{#if: {{{indent|}}} | refbegin-hanging-indents }} <!--
-->{{#if: {{{normalfont|}}} | refbegin-100 }} <!--
-->{{#if: {{{1|}}}
| refbegin-columns {{#iferror: {{#ifexpr: {{{1|1}}} > 1 }}
| references-column-width
| references-column-count references-column-count-{{#if:1|{{{1}}}}} }}
| {{#if: {{{colwidth|}}}
| references-column-width }} }}" style="<!--
-->{{#if: {{{1|}}}
| {{#iferror: {{#ifexpr: {{{1|1}}} > 1 }}
| column-width: {{#if:1|{{{1|30em}}}}}
| column-count: {{#if:1|{{{1}}}}}; }}
| {{#if: {{{colwidth|}}}
| column-width: {{{colwidth|30em}}} }} }}"><!--
-->{{#if: {{{normalfont|}}}
| [[Category:Pages using refbegin with normalfont parameter]]}}</includeonly><noinclude>
{{เอกสารกำกับแม่แบบ}}
</noinclude>
gi1o5ryxt60qmcgufc546oz59ckxggl
189452
189451
2022-08-16T15:50:53Z
Venise12mai1834
8884
wikitext
text/x-wiki
<includeonly><templatestyles src="Refbegin/styles.css" /><!--
--><div class="refbegin <!--
-->{{#if: {{{indent|}}} | refbegin-hanging-indents }} <!--
-->{{#if: {{{normalfont|}}} | refbegin-100 }} <!--
-->{{#if: {{{1|}}}
| refbegin-columns {{#iferror: {{#ifexpr: {{{1|1}}} > 1 }}
| references-column-width
| references-column-count references-column-count-{{#if:1|{{{1}}}}} }}
| {{#if: {{{colwidth|}}}
| references-column-width }} }}" style="<!--
-->{{#if: {{{1|}}}
| {{#iferror: {{#ifexpr: {{{1|1}}} > 1 }}
| column-width: {{#if:1|{{{1|30em}}}}}
| column-count: {{#if:1|{{{1}}}}}; }}
| {{#if: {{{colwidth|}}}
| column-width: {{{colwidth|30em}}} }} }}"><!--
-->{{#if: {{{normalfont|}}}
| [[Category:Pages using refbegin with normalfont parameter]]}}</includeonly><noinclude>{{เอกสารกำกับแม่แบบ}}</noinclude>
9d98q3fmko5x37z8uaxuzmpb90b6nsc
189457
189452
2022-08-16T16:03:24Z
Venise12mai1834
8884
wikitext
text/x-wiki
<includeonly><templatestyles src="Refbegin/styles.css" /><!--
--><div class="refbegin <!--
-->{{#if: {{{indent|}}} | refbegin-hanging-indents }} <!--
-->{{#if: {{{1|}}}
| refbegin-columns {{#iferror: {{#ifexpr: {{{1|1}}} > 1 }}
| references-column-width
| references-column-count references-column-count-{{#if:1|{{{1}}}}} }}
| {{#if: {{{colwidth|}}}
| references-column-width }} }}" style="<!--
-->{{#if: {{{1|}}}
| {{#iferror: {{#ifexpr: {{{1|1}}} > 1 }}
| column-width: {{#if:1|{{{1|30em}}}}}
| column-count: {{#if:1|{{{1}}}}}; }}
| {{#if: {{{colwidth|}}}
| column-width: {{{colwidth|30em}}} }} }}"></includeonly><noinclude>
{{Documentation}}
</noinclude>
phti1gd1af94q1ec12mn1uqky2cbl6p
แม่แบบ:เริ่มอ้างอิง/doc
10
17453
189453
42569
2022-08-16T15:51:01Z
Venise12mai1834
8884
wikitext
text/x-wiki
แม่แบบนี้ใช้คู่กับแม่แบบ {{มบ|จบอ้างอิง}} และ {{มบ|รายการอ้างอิง}} ดังตัวอย่างนี้
<pre>
{{เริ่มอ้างอิง}}
* รายการ 1
* รายการ 2
* รายการ 3
{{จบอ้างอิง}}
</pre>
[[หมวดหมู่:แม่แบบอ้างอิง]]
drolhdkl1uzxdcee0xswain7z3obizs
189455
189453
2022-08-16T15:52:25Z
Venise12mai1834
8884
wikitext
text/x-wiki
แม่แบบ {{มบ|เริ่มอ้างอิง}} กับ {{มบ|จบอ้างอิง}} ใช้ควบคู่กัน เพื่อจัดความเรียบร้อยของรายการอ้างอิง ดังตัวอย่างนี้
<pre>
{{เริ่มอ้างอิง}}
* รายการ 1
* รายการ 2
* รายการ 3
{{จบอ้างอิง}}
</pre>
[[หมวดหมู่:แม่แบบอ้างอิง]]
pf7hry82r9x8qnqb5lolkgpcp00xe5e
แม่แบบ:จบอ้างอิง
10
17454
189454
42570
2022-08-16T15:51:52Z
Venise12mai1834
8884
wikitext
text/x-wiki
<includeonly></div></includeonly><noinclude>{{เริ่มอ้างอิง/doc}}</noinclude>
8odbgrw4h010qxnv7a8jxxny1vqpm1f
189456
189454
2022-08-16T16:01:26Z
Venise12mai1834
8884
wikitext
text/x-wiki
<includeonly></div></includeonly><noinclude>{{คู่มือการใช้งาน|แม่แบบ:เริ่มอ้างอิง/doc}}</noinclude>
b8buuvmtcqv5ionvvvdqnsvmouh7ovj
แม่แบบ:อ้างเว็บ
10
18663
189400
47204
2022-08-16T13:49:58Z
Venise12mai1834
8884
อัปเดต
wikitext
text/x-wiki
<includeonly>{{#invoke:citation/CS1|citation
|CitationClass=web
}}</includeonly><noinclude>
{{documentation}}
</noinclude>
rcgmbcxu7hvs583g1f3rzz4c4dkizda
แม่แบบ:อ้างเว็บ/doc
10
18665
189401
180667
2022-08-16T13:55:16Z
Venise12mai1834
8884
wikitext
text/x-wiki
==วิธีใช้==
ใช้โค้ดดังนี้
===โค้ดที่ใช้บ่อยที่สุด===
<pre>
{{อ้างเว็บ
| url =
| author =
| date =
| accessdate =
| title =
| website =
| publisher =
| location =
}}
</pre>
===โค้ดทั้งหมด===
<pre>
{{อ้างเว็บ
| url =
| url-access =
| title =
| last =
| first =
| author-link =
| last2 =
| first2 =
| author-link2 =
| date =
| year =
| orig-date =
| editor-last =
| editor-first =
| editor-link =
| editor2-last =
| editor2-first =
| editor2-link =
| department =
| website =
| series =
| publisher =
| agency =
| location =
| page =
| pages =
| at =
| language =
| script-title =
| trans-title =
| type =
| format =
| arxiv =
| asin =
| bibcode =
| doi =
| doi-broken-date =
| isbn =
| issn =
| jfm =
| jstor =
| lccn =
| mr =
| oclc =
| ol =
| osti =
| pmc =
| pmid =
| rfc =
| ssrn =
| zbl =
| id =
| access-date =
| url-status =
| archive-url =
| archive-date =
| via =
| quote =
| ref =
| postscript =
}}
</pre>
[[หมวดหมู่:แม่แบบอ้างอิง]]
0k1gdtmuwxu7qwjiommgioxsmsye7gv
189402
189401
2022-08-16T13:59:23Z
Venise12mai1834
8884
wikitext
text/x-wiki
==วิธีใช้==
ใช้โค้ดดังนี้
===โค้ดที่ใช้บ่อยที่สุด===
<pre>
{{อ้างเว็บ
| url =
| author =
| date =
| accessdate =
| title =
| website =
| publisher =
| location =
}}
</pre>
===โค้ดทั้งหมด===
<pre>
{{อ้างเว็บ
| url =
| url-access =
| title =
| last =
| first =
| author-link =
| last2 =
| first2 =
| author-link2 =
| date =
| year =
| orig-date =
| editor-last =
| editor-first =
| editor-link =
| editor2-last =
| editor2-first =
| editor2-link =
| department =
| website =
| series =
| publisher =
| agency =
| location =
| page =
| pages =
| at =
| language =
| script-title =
| trans-title =
| type =
| format =
| arxiv =
| asin =
| bibcode =
| doi =
| doi-broken-date =
| isbn =
| issn =
| jfm =
| jstor =
| lccn =
| mr =
| oclc =
| ol =
| osti =
| pmc =
| pmid =
| rfc =
| ssrn =
| zbl =
| id =
| access-date =
| url-status =
| archive-url =
| archive-date =
| via =
| quote =
| ref =
| postscript =
}}
</pre>
==ตัวอย่าง==
<pre>
* {{อ้างเว็บ
| first = Richa
| last = Naidu
| first2 = Ross
| last2 = Kerber
| title = Analysis: Ben & Jerry's Unilever fight shows risks of ceding control
| url = https://www.reuters.com/business/retail-consumer/ben-jerrys-unilever-fight-shows-risks-ceding-control-2022-08-16/
| date = 2022-08-16
| accessdate = 2022-08-16
| website = Reuters
| publisher = Reuters
| location = London
}}
</pre>
* {{อ้างเว็บ
| first = Richa
| last = Naidu
| first2 = Ross
| last2 = Kerber
| title = Analysis: Ben & Jerry's Unilever fight shows risks of ceding control
| url = https://www.reuters.com/business/retail-consumer/ben-jerrys-unilever-fight-shows-risks-ceding-control-2022-08-16/
| date = 2022-08-16
| accessdate = 2022-08-16
| website = Reuters
| publisher = Reuters
| location = London
}}
[[หมวดหมู่:แม่แบบอ้างอิง]]
gegg2umzxyn7mew0dwzgxcr3uo9n6jy
189422
189402
2022-08-16T14:50:29Z
Venise12mai1834
8884
wikitext
text/x-wiki
==วิธีใช้==
ใช้โค้ดดังนี้
===โค้ดที่ใช้บ่อยที่สุด===
<pre>
{{อ้างเว็บ
| url =
| author =
| date =
| accessdate =
| title =
| website =
| publisher =
| location =
| ref =
}}
</pre>
===โค้ดทั้งหมด===
<pre>
{{อ้างเว็บ
| url =
| url-access =
| title =
| last =
| first =
| author-link =
| last2 =
| first2 =
| author-link2 =
| date =
| year =
| orig-date =
| editor-last =
| editor-first =
| editor-link =
| editor2-last =
| editor2-first =
| editor2-link =
| department =
| website =
| series =
| publisher =
| agency =
| location =
| page =
| pages =
| at =
| language =
| script-title =
| trans-title =
| type =
| format =
| arxiv =
| asin =
| bibcode =
| doi =
| doi-broken-date =
| isbn =
| issn =
| jfm =
| jstor =
| lccn =
| mr =
| oclc =
| ol =
| osti =
| pmc =
| pmid =
| rfc =
| ssrn =
| zbl =
| id =
| access-date =
| url-status =
| archive-url =
| archive-date =
| via =
| quote =
| ref =
| postscript =
}}
</pre>
==ตัวอย่าง==
<pre>
* {{อ้างเว็บ
| first = Richa
| last = Naidu
| first2 = Ross
| last2 = Kerber
| title = Analysis: Ben & Jerry's Unilever fight shows risks of ceding control
| url = https://www.reuters.com/business/retail-consumer/ben-jerrys-unilever-fight-shows-risks-ceding-control-2022-08-16/
| date = 2022-08-16
| accessdate = 2022-08-16
| website = Reuters
| publisher = Reuters
| location = London
}}
</pre>
* {{อ้างเว็บ
| first = Richa
| last = Naidu
| first2 = Ross
| last2 = Kerber
| title = Analysis: Ben & Jerry's Unilever fight shows risks of ceding control
| url = https://www.reuters.com/business/retail-consumer/ben-jerrys-unilever-fight-shows-risks-ceding-control-2022-08-16/
| date = 2022-08-16
| accessdate = 2022-08-16
| website = Reuters
| publisher = Reuters
| location = London
}}
[[หมวดหมู่:แม่แบบอ้างอิง]]
4gqermrkbeid7o9z2z8sx6vk18pvp3f
189474
189422
2022-08-16T16:30:21Z
Venise12mai1834
8884
wikitext
text/x-wiki
{{เว็บย่อ|{{มบ|อว}}}}
==วิธีใช้==
ใช้โค้ดดังนี้
===โค้ดที่ใช้บ่อยที่สุด===
<pre>
{{อ้างเว็บ
| url =
| author =
| date =
| accessdate =
| title =
| website =
| publisher =
| location =
| ref =
}}
</pre>
===โค้ดทั้งหมด===
<pre>
{{อ้างเว็บ
| url =
| url-access =
| title =
| last =
| first =
| author-link =
| last2 =
| first2 =
| author-link2 =
| date =
| year =
| orig-date =
| editor-last =
| editor-first =
| editor-link =
| editor2-last =
| editor2-first =
| editor2-link =
| department =
| website =
| series =
| publisher =
| agency =
| location =
| page =
| pages =
| at =
| language =
| script-title =
| trans-title =
| type =
| format =
| arxiv =
| asin =
| bibcode =
| doi =
| doi-broken-date =
| isbn =
| issn =
| jfm =
| jstor =
| lccn =
| mr =
| oclc =
| ol =
| osti =
| pmc =
| pmid =
| rfc =
| ssrn =
| zbl =
| id =
| access-date =
| url-status =
| archive-url =
| archive-date =
| via =
| quote =
| ref =
| postscript =
}}
</pre>
==ตัวอย่าง==
<pre>
* {{อ้างเว็บ
| first = Richa
| last = Naidu
| first2 = Ross
| last2 = Kerber
| title = Analysis: Ben & Jerry's Unilever fight shows risks of ceding control
| url = https://www.reuters.com/business/retail-consumer/ben-jerrys-unilever-fight-shows-risks-ceding-control-2022-08-16/
| date = 2022-08-16
| accessdate = 2022-08-16
| website = Reuters
| publisher = Reuters
| location = London
}}
</pre>
* {{อ้างเว็บ
| first = Richa
| last = Naidu
| first2 = Ross
| last2 = Kerber
| title = Analysis: Ben & Jerry's Unilever fight shows risks of ceding control
| url = https://www.reuters.com/business/retail-consumer/ben-jerrys-unilever-fight-shows-risks-ceding-control-2022-08-16/
| date = 2022-08-16
| accessdate = 2022-08-16
| website = Reuters
| publisher = Reuters
| location = London
}}
[[หมวดหมู่:แม่แบบอ้างอิง]]
5k0ybtyi0nftn3yk0vdxam1c7b1lsvf
189486
189474
2022-08-16T16:51:28Z
Venise12mai1834
8884
wikitext
text/x-wiki
{{เว็บย่อ|{{มบ|อว}}}}
==วิธีใช้==
ใช้โค้ดดังนี้
===โค้ดที่ใช้บ่อย===
<pre>
{{อ้างเว็บ
| url =
| author =
| date =
| accessdate =
| title =
| website =
| publisher =
| location =
| ref =
}}
</pre>
===โค้ดทั้งหมด===
<pre>
{{อ้างเว็บ
| url =
| url-access =
| title =
| last =
| first =
| author-link =
| last2 =
| first2 =
| author-link2 =
| date =
| year =
| orig-date =
| editor-last =
| editor-first =
| editor-link =
| editor2-last =
| editor2-first =
| editor2-link =
| department =
| website =
| series =
| publisher =
| agency =
| location =
| page =
| pages =
| at =
| language =
| script-title =
| trans-title =
| type =
| format =
| arxiv =
| asin =
| bibcode =
| doi =
| doi-broken-date =
| isbn =
| issn =
| jfm =
| jstor =
| lccn =
| mr =
| oclc =
| ol =
| osti =
| pmc =
| pmid =
| rfc =
| ssrn =
| zbl =
| id =
| access-date =
| url-status =
| archive-url =
| archive-date =
| via =
| quote =
| ref =
| postscript =
}}
</pre>
==ตัวอย่าง==
<pre>
* {{อ้างเว็บ
| first = Richa
| last = Naidu
| first2 = Ross
| last2 = Kerber
| title = Analysis: Ben & Jerry's Unilever fight shows risks of ceding control
| url = https://www.reuters.com/business/retail-consumer/ben-jerrys-unilever-fight-shows-risks-ceding-control-2022-08-16/
| date = 2022-08-16
| accessdate = 2022-08-16
| website = Reuters
| publisher = Reuters
| location = London
}}
</pre>
* {{อ้างเว็บ
| first = Richa
| last = Naidu
| first2 = Ross
| last2 = Kerber
| title = Analysis: Ben & Jerry's Unilever fight shows risks of ceding control
| url = https://www.reuters.com/business/retail-consumer/ben-jerrys-unilever-fight-shows-risks-ceding-control-2022-08-16/
| date = 2022-08-16
| accessdate = 2022-08-16
| website = Reuters
| publisher = Reuters
| location = London
}}
[[หมวดหมู่:แม่แบบอ้างอิง]]
bp658fahm7rbomyjnhw4p1tireeoxmc
งานแปล:คำประกาศอิสรภาพสหรัฐ
114
19708
189468
168318
2022-08-16T16:24:51Z
Venise12mai1834
8884
wikitext
text/x-wiki
{{หัวเรื่องงานแปล
| ชื่อ = {{PAGENAME}}
| ปี = 2319
| ภาษา = en
| ต้นฉบับ =
| ผู้สร้างสรรค์ = สหรัฐ
| บรรณาธิการ =
| ส่วน =
| ผู้มีส่วนร่วม =
| ก่อนหน้า =
| ถัดไป =
| หมายเหตุ =
| สถานีย่อย = รัฐธรรมนูญสหรัฐ
}}
{{ตรคป
|{{กก|{{รมมจ|In {{พญ|Congress}}, July 4, 1776.
|{{พญ|A Declaration}}
|By the {{พญ|Representatives}} of the
|{{พญ|United States of America,}}
|In {{พญ|General Congress}} assembled.}}|center}}
|{{กก|{{รมมจ|ในรัฐสภา 4 กรกฎาคม 1776
|คำประกาศ
|ของผู้แทน
|สหรัฐอเมริกา
|ณ รัฐสภาซึ่งประชุมใหญ่}}|center}}
| ไม่ย่อหน้า =
}}
{{ตรคป
|{{ขจ|W}}{{พญ|hen}} in the course of human Events, it becomes necessary for one People to dissolve the Political Bands which have connected them with another, and to assume among the Powers of the Earth, the separate and equal Station to which the Laws of Nature and of Nature’s God entitle them, a decent Respect to the Opinions of Mankind requires that they should declare the causes which impel them to the Separation.
|{{ขจ|ใ}}นห้วงเหตุการณ์ของมนุษย์ เมื่อกลายเป็นความจำเป็นสำหรับชนกลุ่มหนึ่งที่จะต้องยุบเลิกคณะ<ref>บางฉบับเป็น "bond" (พันธะ ความผูกมัด ฯลฯ)</ref> ทางการเมืองซึ่งเรียงร้อยพวกตนเข้ากับกลุ่มอื่น และที่จะต้องรับเอาสถานะซึ่งแบ่งแยกไว้ต่างหากและโดยเท่าเทียมในท่ามกลางมหาอำนาจของโลกตามที่กฎธรรมชาติและกฎของพระผู้เป็นเจ้าในธรรมชาติมอบให้ไว้ การที่เขาเหล่านั้นพึงประกาศสาเหตุที่ผลักดันให้ตนแยกตัวออกมา ก็เป็นเรื่องต้องกระทำเพื่อสำแดงความนับถืออย่างเหมาะสมต่อความคิดเห็นของหมู่มนุษย์
| ไม่ย่อหน้า =
}}
{{ตรคป
|We hold these Truths to be self-evident, that all Men are created equal, that they are endowed by their Creator with certain unalienable Rights, that among these are Life, Liberty, and the pursuit of Happiness — That to secure these Rights, Governments are instituted among Men, deriving their just Powers from the Consent of the Governed, that whenever any Form of Government becomes destructive of these Ends, it is the Right of the People to alter or abolish it, and to institute a new Government, laying its Foundation on such Principles, and organizing its Powers in such Form, as to them shall seem most likely to effect their Safety and Happiness. Prudence, indeed, will dictate that Governments long established should not be changed for light and transient Causes; and accordingly all Experience hath shewn, that Mankind are more disposed to suffer, while Evils are sufferable, than to right themselves by abolishing the Forms to which they are accustomed. But when a long Train of Abuses and Usurpations, pursuing invariably the same Object, evinces a Design to reduce them under absolute Despotism, it is their Right, it is their Duty, to throw off such Government, and to provide new Guards for their future Security. Such has been the patient Sufferance of these Colonies; and such is now the Necessity which constrains them to alter their former Systems of Government. The History of the Present King of Great-Britain is a History of repeated Injuries and Usurpations, all having in direct Object the Establishment of an absolute Tyranny over these States. To prove this, let Facts be submitted to a candid World.
|ความสัตย์จริงดังต่อไปนี้ เราถือว่า ชัดแจ้งอยู่ในตัวแล้ว คือ ทุกคนได้รับการรังสรรค์มาให้เท่าเทียมกัน พระผู้สร้างเขาเหล่านั้นได้ประทานให้เขามีสิทธิบางประการอันถ่ายโอนแก่กันไม่ได้ ซึ่งเรื่องนี้รวมถึงชีวิต เสรีภาพ และการแสวงหาความสุข เพื่อประกันสิทธิเหล่านี้ จึงมีการจัดตั้งการปกครองขึ้นในท่ามกลางผู้คน โดยรับอำนาจอันชอบธรรมมาจากความยินยอมของผู้ใต้ปกครอง เมื่อใดที่การปกครองรูปแบบใด ๆ กลายเป็นเครื่องล้างผลาญจุดมุ่งหมายเหล่านี้ เมื่อนั้นก็เป็นสิทธิของประชาชนที่จะเปลี่ยนแปลงหรือล้มล้างการปกครองนั้น และจัดตั้งการปกครองใหม่ โดยสถาปนารากฐานไว้บนหลักการดังกล่าว และจัดระเบียบอำนาจไว้ในรูปแบบที่เขามองว่า น่าจะยังให้ความปลอดภัยและความสุขของพวกเขาสัมฤทธิ์ผลมากที่สุด การพิจารณาอย่างรอบคอบย่อมบอกได้อยู่แล้วว่า การปกครองที่ก่อตั้งมานานไม่พึงถูกเปลี่ยนเพียงเพราะสาเหตุเล็กน้อยหรือชั่วครั้งคราว และประสบการณ์ทั้งหลายก็ได้แสดงให้เห็นทำนองเดียวกันว่า ในยามที่ความเลวร้ายทั้งหลายยังทนรับได้ หมู่มนุษย์ย่อมยอมทนกับรูปแบบ[การปกครอง]ที่ตนคุ้นเคยมากกว่าจะเยียวยาตนด้วยการล้มล้างรูปแบบนั้นเสีย แต่เมื่อการข่มเหงและช่วงชิงอันยาวนานเพื่อบรรลุเป้าหมายเดิม ๆ ไม่รู้จบได้ส่อความมุ่งหมายที่จะบั่นทอนเขาทั้งหลายให้อยู่ภายใต้ระบอบเผด็จการเต็มขั้น ก็เป็นสิทธิของเขาเหล่านั้น เป็นหน้าที่ของพวกเขาเหล่านั้น ที่จะเหวี่ยงการปกครองอันนั้นทิ้งไป แล้วจัดให้มีสิ่งใหม่ไว้คุ้มกันความมั่นคงในอนาคตของพวกตน นั่นแหละที่อาณานิคมนี้ได้อดรนทนกันมา และนั่นแหละคือความจำเป็นที่บีบให้อาณานิคมต้องแปลงเปลี่ยนระบบการปกครองเดิมของตนเสียในบัดนี้ ประวัติศาสตร์ของพระเจ้ากรุงบริเตนใหญ่องค์ปัจจุบัน เป็นประวัติศาสตร์แห่งบาดแผลและการช่วงชิงซ้ำแล้วซ้ำเล่า ซึ่งล้วนแล้วแต่มีวัตถุประสงค์โดยตรงเป็นการก่อตั้งระบอบทรราชย์เต็มขั้นไว้เหนือรัฐเหล่านี้ เพื่อพิสูจน์เรื่องนี้ จึงขอนำเสนอข้อเท็จจริงต่อประชาคมโลกที่ไร้อคติ [ดังนี้]
}}
{{ตรคป
|He has refused his Assent to Laws, the most wholesome and necessary for the public Good.
|กษัตริย์องค์นั้นไม่ยอมอนุมัติกฎหมาย อันเป็นประโยชน์และจำเป็นต่อสวัสดิภาพสาธารณะอย่างถึงที่สุด
}}
{{ตรคป
|He has forbidden his Governors to pass Laws of immediate and pressing Importance, unless suspended in their Operation till his Assent should be obtained; and when so suspended, he has utterly neglected to attend to them.
|กษัตริย์องค์นั้นห้ามข้าหลวงของตัวอนุญาตกฎหมายที่มีความสำคัญอย่างรีบและด่วน แต่ให้รอการมีผลใช้บังคับไว้จนกว่าจะไดรับอนุมัติจากตัว และเมื่อรอไว้ฉะนั้น ตัวก็จะเพิกเฉยไม่เอาใจใส่เสียโดยสิ้นเชิง
}}
{{ตรคป
|He has refused to pass other Laws for the Accommodation of large Districts of People; unless those People would relinquish the Right of Representation in the Legislature, a Right inestimable to them, and formidable to Tyrants only.
|กษัตริย์องค์นั้นไม่ยอมอนุญาตกฎหมายฉบับอื่น ๆ เพื่อสวัสดิการชุมชนขนาดใหญ่ เว้นแต่ชนเหล่านั้นจะสละสิทธิมีผู้แทนในสภานิติบัญญัติ ซึ่งเป็นสิทธิอันหาค่ามิได้สำหรับชนเหล่านั้น และเป็นของแสลงสำหรับทรราชเท่านั้น
}}
{{ตรคป
|He has called together Legislative Bodies at Places unusual, uncomfortable, and distant from the Depository of their public Records, for the sole Purpose of fatiguing them into Compliance with his Measures.
|กษัตริย์องค์นั้นเรียกประชุมองค์กรนิติบัญญัติ ณ สถานที่อันผิดประหลาด ขัดข้อง และห่างไกลหอเก็บบันทึกสาธารณะขององค์กรเหล่านั้น เพียงเพื่อให้องค์กรนั้นอิดระอาจนยอมตามมาตรการของตัว
}}
{{ตรคป
|He has dissolved Representative Houses repeatedly, for opposing with manly Firmness his Invasions on the Rights of the People.
|กษัตริย์องค์นั้นยุบสภาผู้แทนหลายต่อหลายครั้ง เมื่อการที่ตัวเข้าก้าวก่ายสิทธิของประชาชนนั้นถูกคัดค้านอย่างเด็ดเดี่ยวสมชาย
}}
{{ตรคป
|He has refused for a long Time, after such Dissolutions, to cause others to be elected; whereby the Legislative Powers, incapable of Annihilation, have returned to the People at large for their exercise; the State remaining in the mean time exposed to all the Dangers of Invasion from without, and Convulsions within.
|กษัตริย์องค์นั้น เมื่อยุบสภาฉะนั้นแล้ว ก็ไม่ยอมให้ผู้อื่นได้รับเลือกตั้งเข้ามาเป็นเนิ่นนาน อันจะเป็นการคืนอำนาจนิติบัญญัติ — อำนาจอันทำลายมิได้ — กลับสู่ประชาชนโดยรวมเพื่อให้ประชาชนได้ใช้ ขณะเดียวกัน ก็ทำให้รัฐค้างคาอยู่ในความเสี่ยงที่จะเกิดการรุกรานจากภายนอกและความอลหม่านจากภายใน
}}
{{ตรคป
|He has endeavoured to prevent the Population of these States; for that Purpose obstructing the Laws for Naturalization of Foreigners; refusing to pass others to encourage their Migrations hither, and raising the Conditions of new Appropriations of Lands.
|กษัตริย์องค์นั้นเพียรมิให้มีการตั้งถิ่นฐานในรัฐนี้ และเพื่อความมุ่งประสงค์นั้น จึงขัดขวางกฎหมายว่าด้วยการแปลงสัญชาติให้คนต่างด้าว ไม่ยอมอนุญาตกฎหมายฉบับอื่นที่ส่งเสริมให้คนต่างด้าวย้ายถิ่นฐานเข้ามา และเพิ่มเงื่อนไขในการถือครอง<ref>"Appropriation" แปลว่า การถือครอง ยึดครอง จัดสรร ฯลฯ ก็ได้</ref> ที่ดินรายใหม่
}}
{{ตรคป
|He has obstructed the Administration of Justice, by refusing his Assent to Laws for establishing Judiciary Powers.
|กษัตริย์องค์นั้นขัดขวางการบริหารงานยุติธรรม โดยไม่ยอมอนุมัติกฎหมายก่อตั้งอำนาจตุลาการ
}}
{{ตรคป
|He has made Judges dependent on his Will alone, for the Tenure of their Offices, and the Amount and Payment of their Salaries.
|กษัตริย์องค์นั้นกระทำให้ตุลาการตกอยู่ใต้อัธยาศัยของตัวแต่ผู้เดียว ในด้านระยะเวลาดำรงตำแหน่ง กับทั้งจำนวนและการจ่ายเงินตอบแทน<ref>"Salary" มักแปลว่า เงินเดือน แต่ที่จริงหมายถึง ค่าจ้างที่จ่ายเป็นงวด ๆ จะเป็นเดือน เป็นปี หรืออย่างอื่นก็ได้ ในที่นี้จึงแปลว่า เงินตอบแทน</ref>
}}
{{ตรคป
|He has erected a Multitude of new Offices, and sent hither Swarms of Officers to harass our People, and eat out their Substance.
|กษัตริย์องค์นั้นสรรค์สร้างตำแหน่งใหม่ขึ้นอีกโข แล้วส่งขุนนางของตัวเป็นโขยงไปดำรงตำแหน่งนั้นเพื่อรังควานประชาชนของพวกเรา และบ่อนฟอนสมบัติพัสถานของพวกเขา
}}
{{ตรคป
|He has kept among us, in Times of Peace, Standing Armies, without the consent of our Legislatures.
|ในยามสงบ กษัตริย์องค์นั้นวางกำลังทหารประจำการไว้ในหมู่เรา โดยหาได้รับความยินยอมจากสภานิติบัญญัติของเราไม่
}}
{{ตรคป
|He has affected to render the Military independent of and superior to the Civil Power.
|กษัตริย์องค์นั้นพอใจจะให้ทหารเป็นอิสระจากและอยู่เหนือกว่าอำนาจพลเรือน
}}
{{ตรคป
|He has combined with others to subject us to a Jurisdiction foreign to our Constitution, and unacknowledged by our Laws; giving his Assent to their Acts of pretended Legislation:
|กษัตริย์องค์นั้นได้สมรู้กับผู้อื่นในการกดเราไว้ใต้อำนาจซึ่งรัฐธรรมนูญเราไม่รับรู้และกฎหมายเราไม่รับรอง โดยอนุมัติการกระทำของเขาเหล่านั้นในการแอบอ้างออกกฎหมาย
}}
{{ตรคป
|For quartering large Bodies of Armed Troops among us:
|เพื่อเอาทหารพร้อมอาวุธกองใหญ่มาไว้ในท่ามกลางเรา
}}
{{ตรคป
|For protecting them, by a mock Trial, from Punishment for any Murders which they should commit on the Inhabitants of these States:
|เพื่อกันมิให้เขาถูกลงโทษฐานฆาตกรรมซึ่งเขาอาจกระทำต่อผู้อยู่อาศัยในรัฐนี้ โดยจัดให้มีการพิจารณาคดีจอมปลอม
}}
{{ตรคป
|For cutting off our Trade with all Parts of the World:
|เพื่อตัดเราขาดจากการค้าขายกับส่วนอื่น ๆ ของโลก
}}
{{ตรคป
|For imposing taxes on us without our Consent:
|เพื่อกำหนดภาษีให้เราโดยเรามิได้ยินยอมด้วย
}}
{{ตรคป
|For depriving us, in many Cases, of the Benefits of Trial by Jury:
|เพื่อกีดกันเราจากประโยชน์ในการมีลูกขุนพิจารณา ดังมีมาในหลาย ๆ คดี
}}
{{ตรคป
|For transporting us beyond Seas to be tried for pretended Offences:
|เพื่อขนส่งเราข้ามน้ำข้ามทะเลไปเป็นจำเลยในความผิดจอมปลอม
}}
{{ตรคป
|For abolishing the free System of English Laws in a neighbouring Province, establishing therein an arbitrary Government, and enlarging its Boundaries, so as to render it at once an Example and fit Instrument for introducing the same absolute Rule in these Colonies:
|เพื่อล้มเลิกระบบเสรีตามกฎหมายอังกฤษในมณฑลข้างเคียง แล้วก่อตั้งการปกครองตามอำเภอใจ กับขยายขอบข่ายการปกครองนั้น เพื่อให้เป็นตัวอย่างและเครื่องมืออันเหมาะเจาะในการนำระบอบเบ็ดเสร็จอย่างเดียวกันมาใช้ในอาณานิคมนี้ทีเดียว
}}
{{ตรคป
|For taking away our Charters, abolishing our most valuable Laws, and altering fundamentally the Forms of our Governments:
|เพื่อพรากไปเสียซึ่งกฎบัตรของเรา แล้วเอากฎหมายอันเปี่ยมค่าของเราไปล้มเลิก กับทั้งเพิกถอนแปรเปลี่ยนรูปแบบการปกครองของเราจนถึงรากฐาน
}}
{{ตรคป
|For suspending our own Legislatures, and declaring themselves invested with Power to legislate for us in all Cases whatsoever:
|เพื่อระงับสภานิติบัญญัติของเราเอง และประกาศตัวว่า มีอำนาจออกกฎหมายให้เราทุกกรณีไม่ว่าจะมีประการใด
}}
{{ตรคป
|He has abdicated Government here, by declaring us out of his Protection and waging War against us.
|กษัตริย์องค์นั้นทิ้งเสียซึ่งการปกครองในที่แห่งนี่ โดยมีประกาศให้เราพ้นจากความคุ้มครองของตัว แล้วเปิดสงครามกับเรา
}}
{{ตรคป
|He has plundered our Seas, ravaged our Coasts, burnt our Towns, and destroyed the Lives of our People.
|กษัตริย์องค์นั้นปล้นน่านน้ำเรา ผลาญชายฝั่งเรา เผาบ้านเมืองเรา และทำลายชีวิตประชาชนของเรา
}}
{{ตรคป
|He is, at this Time, transporting large Armies of foreign Mercenaries to compleat the Works of Death, Desolation, and Tyranny, already begun with circumstances of Cruelty and Perfidy, scarcely paralleled in the most barbarous Ages, and totally unworthy the Head of a civilized Nation.
|ยามนี้ กษัตริย์องค์นั้นกำลังขนส่งทหารรับจ้างต่างชาติกองใหญ่มาจัดการเข่นฆ่า กวาดต้อน และกดขี่ให้เสร็จสิ้น ซึ่งได้เกิดขึ้นแล้วด้วยพฤติการณ์อันทารุณและกลิ้งกลอกชนิดที่ยุคป่าเถื่อนส่วนใหญ่ยังแทบจะเทียบไม่ติด และไม่คู่ควรแก่การเป็นประมุขของอารยประเทศแม้แต่น้อย
}}
{{ตรคป
|He has constrained our fellow Citizens taken Captive on the high Seas to bear Arms against their Country, to become the Executioners of their Friends and Brethren, or to fall themselves by their Hands.
|กษัตริย์องค์นั้นบีบให้เพื่อนร่วมชาติเราซึ่งถูกจับเป็นเชลยกลางทะเลหลวงต้องคว้าอาวุธขึ้นสู้กับประเทศของตน จนกลายเป็นผู้ประหัตประหารเพื่อนพ้องน้องพี่ของตน หรือไม่ก็ตกอยู่ในเงื้อมมือของเขาเหล่านั้นแทน
}}
{{ตรคป
|He has excited domestic Insurrections amongst us, and has endeavoured to bring on the Inhabitants of our Frontiers, the merciless Indian Savages, whose known Rule of Warfare, is an undistinguished Destruction, of all Ages, Sexes and Conditions.
|กษัตริย์องค์นั้นยั่วยุให้เกิดความปั่นป่วนในบ้านเมืองท่ามกลางพวกเรา และเพียรจะชักพาผู้อยู่ตามพรมแดนเราเข้ามา ซึ่งก็คือ เหล่าอินเดียนคนป่าไร้เมตตา ซึ่งเป็นที่รับรู้กันว่า มีกฎแห่งการรบ คือ ทำลายล้างไม่เลือกหน้า ไม่ว่าอายุ เพศ หรือสภาพใด
}}
{{ตรคป
|In every stage of these Oppressions we have Petitioned for Redress in the most humble Terms: Our repeated Petitions have been answered only by repeated Injury. A Prince, whose Character is thus marked by every act which may define a Tyrant, is unfit to be the Ruler of a free People.
|ทุก ๆ ช่วงที่ถูกเบียดเบียนเช่นนี้ เราได้ฎีกาขอบรรเทาทุกข์ด้วยถ้อยคำสุดนอบน้อม การตอบรับอย่างเดียวที่มีต่อฎีกาเราซ้ำ ๆ คือ การประทุษร้ายเราซ้ำ ๆ ฉะนี้แล้ว เจ้าชายผู้ที่พระสันดานสำแดงออกด้วยการกระทำทุกประเภทที่อาจเป็นคำนิยามของทรราช ก็ไม่ควรคู่จะเป็นผู้ปกครองของเสรีชนเลย
}}
{{ตรคป
|Nor have we been wanting in Attentions to our British Brethren. We have warned them from Time to Time of Attempts by their Legislature to extend an unwarrantable Jurisdiction over us. We have reminded them of the Circumstances of our Emigration and Settlement here. We have appealed to their native Justice and Magnanimity, and we have conjured them by the Ties of common Kindred to disavow these Usurpations, which, would inevitably interrupt our Connections and Correspondence. They too have been deaf to the Voice of Justice and of Consanguinity. We must, therefore, acquiesce in the Necessity, which denounces our Separation, and hold them, as we hold the rest of Mankind, Enemies in War, in Peace, Friends.
|ใช่ว่าเรากระหายความสนใจจากพี่น้องชาวบริเตนของเรา เราได้ตักเตือนเขาเป็นระยะถึงการที่สภานิติบัญญัติของเขาพยายามทวีเขตอำนาจเหนือเราโดยไร้เหตุ เราได้ย้ำเตือนเขาถึงพฤติการณ์ที่เราโยกย้ายถิ่นฐานมาตั้งรกรากกันที่นี่ เราได้วอนขอให้เขามีความเป็นธรรมและเห็นใจกันตามสัญชาตญาณบ้าง เราได้ยกเยื่อใยของการมีบรรพบุรุษร่วมกันมาโน้มน้าวให้เขาออกมาต่อต้านการช่วงชิงเหล่านี้ ซึ่งจะมีผลให้ความเกี่ยวพันและลงรอยกันของเราต้องสะดุด แต่พวกเขาก็ดุจเดียวกัน ทำหูหนวกตาบอดต่อเสียงกู่ร้องของความยุติธรรมและความสัมพันธ์ทางสายเลือด เหตุฉะนี้ เราจึงจำต้องยอมรับว่า มีความจำเป็นต้องแถลงถึงการแยกตัวออกมา และถือว่า เขาเหล่านั้นเป็นศัตรูในยามรบ เป็นเพื่อนคบในยามสันติ เฉกเช่นที่เราถือต่อมวลมนุษย์ที่เหลือ
}}
{{ตรคป
|We, therefore, the Representatives of the {{พญ|United States of America}}, in General Congress, Assembled, appealing to the Supreme Judge of the World for the Rectitude of our Intentions, do, in the Name, and by Authority of the good People of these Colonies, solemnly Publish and Declare, That these United Colonies are, and of Right ought to be, Free and Independent States; that they are absolved from all Allegiance to the British Crown, and that all political Connection between them and the State of Great-Britain, is and ought to be totally dissolved; and that as Free and Independent States, they have full Power to levy War, conclude Peace, contract Alliances, establish Commerce, and to do all other Acts and Things which Independent States may of right do. And for the support of this Declaration, with a firm Reliance on the Protection of the divine Providence, we mutually pledge to each other our Lives, our Fortunes, and our sacred Honor.
|ดังนั้น เรา เหล่าผู้แทนสหรัฐอเมริกา ในรัฐสภาซึ่งประชุมใหญ่ ได้วอนขอต่อองค์ตุลาการสูงสุดในพิภพให้ตัดสินความถูกต้องของเจตนาแห่งเรา จึงเผยแพร่และประกาศอย่างเป็นพิธีการ ในนามและด้วยอำนาจของผองสุจริตชนแห่งอาณานิคมนี้ ว่า อาณานิคมร่วมเหล่านี้เป็น และโดยสิทธิแล้วก็พึงเป็น รัฐซึ่งเป็นไทและเป็นอิสระ พ้นจากความสวามิภักดิ์ต่อราชาธิปไตยบริเตนในทุกสถาน และความเกี่ยวพันทางการเมืองทุกประการในระหว่างอาณานิคมกับรัฐบริเตนใหญ่เป็นอันและพึงเป็นอันยุติลงทั้งสิ้น และอาณานิคมนี้ ในฐานะรัฐซึ่งเป็นไทและเป็นอิสระ มีอำนาจบริบูรณ์ที่จะก่อสงคราม ตกลงสันติภาพ ทำสัญญาพันธมิตร ก่อตั้งการค้า กับทั้งกระทำการและกิจอื่น ๆ ทั้งปวงซึ่งรัฐอิสระอาจกระทำได้ตามสิทธิ และเพื่อสนับสนุนคำประกาศนี้ เราจึงพร้อมใจกันฝากชีวิต ชะตากรรม<ref>"Fortune" หมายถึง (1) โชคชะตา ชะตากรรม หรือ (2) ทรัพย์สิน ทรัพย์สมบัติ ก็ได้ นอกเหนือไปจากความหมายอื่น ๆ แต่ในที่นี้ใช้รูปพหูพจน์ ("fortunes") ซึ่งหมายถึง ชะตากรรม จึงแปลว่า ชะตากรรม</ref> และเกียรติยศอันศักดิ์สิทธิ์ ไว้ในกันและกัน โดยตั้งมั่นอยู่ในความคุ้มครองของพระเทวลิขิต
}}
{{ตรคป
|{{กก|{{รมมจ|''Signed by'' {{พญล|Order}} ''and in'' {{พญล|Behalf}} ''of the'' {{พญล|Congress}},
|{{พญ|John Hancock}}, {{พญล|President}}.}}|center}}
|{{กก|{{รมมจ|ลงชื่อตามคำสั่งและในนามของรัฐสภา
|จอห์น แฮนค็อก ประธาน}}|center}}
| ไม่ย่อหน้า =
}}
{{ตรคป
|{{รมมจ|{{พญล|Attest.}}
|CHARLES THOMSON, Secretary.}}
|{{รมมจ|พยาน
|ชาลส์ ทอมสัน เลขานุการ}}
| ไม่ย่อหน้า =
}}
{{ตรคป
|{{ก|{{พญล|Philadelphia: Printed by John Dunlap.}}|บ=font-size:90%}}
|{{ก|ฟิลาเดลเฟีย จอห์น ดันแลป ผู้พิมพ์|บ=font-size:90%}}
| ไม่ย่อหน้า =
}}
==เชิงอรรถ==
{{รกออ}}
==อ้างอิง==
{{เริ่มอ้างอิง}}
* {{อ้างเว็บ|author=United States|date=1776-07-04|url=https://collections.library.yale.edu/catalog/2003775|title=In congress, July 4, 1776. A Declaration by the representatives of the United States of America, In General Congress assembled … signed by order and in behalf of the Congress, John Hancock, President. Attest. Charles Thomson, Secretary|publisher=Yale University Library|location=New Haven, CT|website=Yale University Library Digital Collections (1977 Folio 13)}}
{{จบอ้างอิง}}
{{สัญญาอนุญาตงานแปล
| {{PD-old}}
| {{สาธารณสมบัติ-เอง}}
}}
[[หมวดหมู่:ประกาศ]]
[[หมวดหมู่:รัฐธรรมนูญสหรัฐ]]
affn3jqr7kjo7r96nkmn8vm3tnsyz0f
มอดูล:Citation/CS1
828
33552
189398
89005
2022-08-16T13:47:28Z
Venise12mai1834
8884
อัปเดต
Scribunto
text/plain
require ('Module:No globals');
--[[--------------------------< 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+$', -- three or more character hostname.hostname or hostname.tld
'%f[%w][%w][%w%-]+[%w]%.xn%-%-[%w]+$', -- internationalized domain name with ACE prefix
'%f[%a][qxz]%.com$', -- assigned one character .com hostname (x.com times out 2015-12-10)
'%f[%a][iq]%.net$', -- assigned one character .net hostname (q.net registered but not active 2015-12-10)
'%f[%w][%w]%.%a%a$', -- one character hostname and ccTLD (2 chars)
'%f[%w][%w][%w]%.%a%a+$', -- two character hostname and TLD
'^%d%d?%d?%.%d%d?%d?%.%d%d?%d?%.%d%d?%d?', -- IPv4 address
}
for _, pattern in ipairs (patterns) do -- loop through the patterns list
if domain:match (pattern) then
return true; -- if a match then we think that this thing that purports to be a URL is a URL
end
end
for _, d in ipairs ({'cash', 'company', 'today', 'org'}) do -- look for single letter second level domain names for these top level domains
if domain:match ('%f[%w][%w]%.' .. d) then
return true
end
end
return false; -- no matches, we don't know what this thing is
end
--[[--------------------------< I S _ U R L >------------------------------------------------------------------
returns true if the scheme and domain parts of a URL appear to be a valid URL; else false.
This function is the last step in the validation process. This function is separate because there are cases that
are not covered by split_url(), for example is_parameter_ext_wikilink() which is looking for bracketted external
wikilinks.
]]
local function is_url (scheme, domain)
if utilities.is_set (scheme) then -- if scheme is set check it and domain
return is_scheme (scheme) and is_domain_name (domain);
else
return is_domain_name (domain); -- scheme not set when URL is protocol-relative
end
end
--[[--------------------------< S P L I T _ U R L >------------------------------------------------------------
Split a URL into a scheme, authority indicator, and domain.
First remove Fully Qualified Domain Name terminator (a dot following TLD) (if any) and any path(/), query(?) or fragment(#).
If protocol-relative URL, return nil scheme and domain else return nil for both scheme and domain.
When not protocol-relative, get scheme, authority indicator, and domain. If there is an authority indicator (one
or more '/' characters immediately following the scheme's colon), make sure that there are only 2.
Any URL that does not have news: scheme must have authority indicator (//). TODO: are there other common schemes
like news: that don't use authority indicator?
Strip off any port and path;
]]
local function split_url (url_str)
local scheme, authority, domain;
url_str = url_str:gsub ('([%a%d])%.?[/%?#].*$', '%1'); -- strip FQDN terminator and path(/), query(?), fragment (#) (the capture prevents false replacement of '//')
if url_str:match ('^//%S*') then -- if there is what appears to be a protocol-relative URL
domain = url_str:match ('^//(%S*)')
elseif url_str:match ('%S-:/*%S+') then -- if there is what appears to be a scheme, optional authority indicator, and domain name
scheme, authority, domain = url_str:match ('(%S-:)(/*)(%S+)'); -- extract the scheme, authority indicator, and domain portions
if utilities.is_set (authority) then
authority = authority:gsub ('//', '', 1); -- replace place 1 pair of '/' with nothing;
if utilities.is_set(authority) then -- if anything left (1 or 3+ '/' where authority should be) then
return scheme; -- return scheme only making domain nil which will cause an error message
end
else
if not scheme:match ('^news:') then -- except for news:..., MediaWiki won't link URLs that do not have authority indicator; TODO: a better way to do this test?
return scheme; -- return scheme only making domain nil which will cause an error message
end
end
domain = domain:gsub ('(%a):%d+', '%1'); -- strip port number if present
end
return scheme, domain;
end
--[[--------------------------< L I N K _ P A R A M _ O K >---------------------------------------------------
checks the content of |title-link=, |series-link=, |author-link=, etc. for properly formatted content: no wikilinks, no URLs
Link parameters are to hold the title of a Wikipedia article, so none of the WP:TITLESPECIALCHARACTERS are allowed:
# < > [ ] | { } _
except the underscore which is used as a space in wiki URLs and # which is used for section links
returns false when the value contains any of these characters.
When there are no illegal characters, this function returns TRUE if value DOES NOT appear to be a valid URL (the
|<param>-link= parameter is ok); else false when value appears to be a valid URL (the |<param>-link= parameter is NOT ok).
]]
local function link_param_ok (value)
local scheme, domain;
if value:find ('[<>%[%]|{}]') then -- if any prohibited characters
return false;
end
scheme, domain = split_url (value); -- get scheme or nil and domain or nil from URL;
return not is_url (scheme, domain); -- return true if value DOES NOT appear to be a valid URL
end
--[[--------------------------< L I N K _ T I T L E _ O K >---------------------------------------------------
Use link_param_ok() to validate |<param>-link= value and its matching |<title>= value.
|<title>= may be wiki-linked but not when |<param>-link= has a value. This function emits an error message when
that condition exists
check <link> for inter-language interwiki-link prefix. prefix must be a MediaWiki-recognized language
code and must begin with a colon.
]]
local function link_title_ok (link, lorig, title, torig)
local orig;
if utilities.is_set (link) then -- don't bother if <param>-link doesn't have a value
if not link_param_ok (link) then -- check |<param>-link= markup
orig = lorig; -- identify the failing link parameter
elseif title:find ('%[%[') then -- check |title= for wikilink markup
orig = torig; -- identify the failing |title= parameter
elseif link:match ('^%a+:') then -- if the link is what looks like an interwiki
local prefix = link:match ('^(%a+):'):lower(); -- get the interwiki prefix
if cfg.inter_wiki_map[prefix] then -- if prefix is in the map, must have preceding colon
orig = lorig; -- flag as error
end
end
end
if utilities.is_set (orig) then
link = ''; -- unset
utilities.set_message ('err_bad_paramlink', orig); -- URL or wikilink in |title= with |title-link=;
end
return link; -- link if ok, empty string else
end
--[[--------------------------< C H E C K _ U R L >------------------------------------------------------------
Determines whether a URL string appears to be valid.
First we test for space characters. If any are found, return false. Then split the URL into scheme and domain
portions, or for protocol-relative (//example.com) URLs, just the domain. Use is_url() to validate the two
portions of the URL. If both are valid, or for protocol-relative if domain is valid, return true, else false.
Because it is different from a standard URL, and because this module used external_link() to make external links
that work for standard and news: links, we validate newsgroup names here. The specification for a newsgroup name
is at https://tools.ietf.org/html/rfc5536#section-3.1.4
]]
local function check_url( url_str )
if nil == url_str:match ("^%S+$") then -- if there are any spaces in |url=value it can't be a proper URL
return false;
end
local scheme, domain;
scheme, domain = split_url (url_str); -- get scheme or nil and domain or nil from URL;
if 'news:' == scheme then -- special case for newsgroups
return domain:match('^[%a%d%+%-_]+%.[%a%d%+%-_%.]*[%a%d%+%-_]$');
end
return is_url (scheme, domain); -- return true if value appears to be a valid URL
end
--[=[-------------------------< I S _ P A R A M E T E R _ E X T _ W I K I L I N K >----------------------------
Return true if a parameter value has a string that begins and ends with square brackets [ and ] and the first
non-space characters following the opening bracket appear to be a URL. The test will also find external wikilinks
that use protocol-relative URLs. Also finds bare URLs.
The frontier pattern prevents a match on interwiki-links which are similar to scheme:path URLs. The tests that
find bracketed URLs are required because the parameters that call this test (currently |title=, |chapter=, |work=,
and |publisher=) may have wikilinks and there are articles or redirects like '//Hus' so, while uncommon, |title=[[//Hus]]
is possible as might be [[en://Hus]].
]=]
local function is_parameter_ext_wikilink (value)
local scheme, domain;
if value:match ('%f[%[]%[%a%S*:%S+.*%]') then -- if ext. wikilink with scheme and domain: [xxxx://yyyyy.zzz]
scheme, domain = split_url (value:match ('%f[%[]%[(%a%S*:%S+).*%]'));
elseif value:match ('%f[%[]%[//%S+.*%]') then -- if protocol-relative ext. wikilink: [//yyyyy.zzz]
scheme, domain = split_url (value:match ('%f[%[]%[(//%S+).*%]'));
elseif value:match ('%a%S*:%S+') then -- if bare URL with scheme; may have leading or trailing plain text
scheme, domain = split_url (value:match ('(%a%S*:%S+)'));
elseif value:match ('//%S+') then -- if protocol-relative bare URL: //yyyyy.zzz; may have leading or trailing plain text
scheme, domain = split_url (value:match ('(//%S+)')); -- what is left should be the domain
else
return false; -- didn't find anything that is obviously a URL
end
return is_url (scheme, domain); -- return true if value appears to be a valid URL
end
--[[-------------------------< C H E C K _ F O R _ U R L >-----------------------------------------------------
loop through a list of parameters and their values. Look at the value and if it has an external link, emit an error message.
]]
local function check_for_url (parameter_list, error_list)
for k, v in pairs (parameter_list) do -- for each parameter in the list
if is_parameter_ext_wikilink (v) then -- look at the value; if there is a URL add an error message
table.insert (error_list, utilities.wrap_style ('parameter', k));
end
end
end
--[[--------------------------< S A F E _ F O R _ U R L >------------------------------------------------------
Escape sequences for content that will be used for URL descriptions
]]
local function safe_for_url( str )
if str:match( "%[%[.-%]%]" ) ~= nil then
utilities.set_message ('err_wikilink_in_url', {});
end
return str:gsub( '[%[%]\n]', {
['['] = '[',
[']'] = ']',
['\n'] = ' ' } );
end
--[[--------------------------< E X T E R N A L _ L I N K >----------------------------------------------------
Format an external link with error checking
]]
local function external_link (URL, label, source, access)
local err_msg = '';
local domain;
local path;
local base_url;
if not utilities.is_set (label) then
label = URL;
if utilities.is_set (source) then
utilities.set_message ('err_bare_url_missing_title', {utilities.wrap_style ('parameter', source)});
else
error (cfg.messages["bare_url_no_origin"]);
end
end
if not check_url (URL) then
utilities.set_message ('err_bad_url', {utilities.wrap_style ('parameter', source)});
end
domain, path = URL:match ('^([/%.%-%+:%a%d]+)([/%?#].*)$'); -- split the URL into scheme plus domain and path
if path then -- if there is a path portion
path = path:gsub ('[%[%]]', {['['] = '%5b', [']'] = '%5d'}); -- replace '[' and ']' with their percent-encoded values
URL = table.concat ({domain, path}); -- and reassemble
end
base_url = table.concat ({ "[", URL, " ", safe_for_url (label), "]" }); -- assemble a wiki-markup URL
if utilities.is_set (access) then -- access level (subscription, registration, limited)
base_url = utilities.substitute (cfg.presentation['ext-link-access-signal'], {cfg.presentation[access].class, cfg.presentation[access].title, base_url}); -- add the appropriate icon
end
return base_url;
end
--[[--------------------------< D E P R E C A T E D _ P A R A M E T E R >--------------------------------------
Categorize and emit an error message when the citation contains one or more deprecated parameters. The function includes the
offending parameter name to the error message. Only one error message is emitted regardless of the number of deprecated
parameters in the citation.
added_deprecated_cat is a Boolean declared in page scope variables above
]]
local function deprecated_parameter(name)
if not added_deprecated_cat then
added_deprecated_cat = true; -- note that we've added this category
utilities.set_message ('err_deprecated_params', {name}); -- add error message
end
end
--[=[-------------------------< K E R N _ Q U O T E S >--------------------------------------------------------
Apply kerning to open the space between the quote mark provided by the module and a leading or trailing quote
mark contained in a |title= or |chapter= parameter's value.
This function will positive kern either single or double quotes:
"'Unkerned title with leading and trailing single quote marks'"
" 'Kerned title with leading and trailing single quote marks' " (in real life the kerning isn't as wide as this example)
Double single quotes (italic or bold wiki-markup) are not kerned.
Replaces Unicode quote marks in plain text or in the label portion of a [[L|D]] style wikilink with typewriter
quote marks regardless of the need for kerning. Unicode quote marks are not replaced in simple [[D]] wikilinks.
Call this function for chapter titles, for website titles, etc.; not for book titles.
]=]
local function kern_quotes (str)
local cap = '';
local wl_type, label, link;
wl_type, label, link = utilities.is_wikilink (str); -- wl_type is: 0, no wl (text in label variable); 1, [[D]]; 2, [[L|D]]
if 1 == wl_type then -- [[D]] simple wikilink with or without quote marks
if mw.ustring.match (str, '%[%[[\"“”\'‘’].+[\"“”\'‘’]%]%]') then -- leading and trailing quote marks
str = utilities.substitute (cfg.presentation['kern-left'], str);
str = utilities.substitute (cfg.presentation['kern-right'], str);
elseif mw.ustring.match (str, '%[%[[\"“”\'‘’].+%]%]') then -- leading quote marks
str = utilities.substitute (cfg.presentation['kern-left'], str);
elseif mw.ustring.match (str, '%[%[.+[\"“”\'‘’]%]%]') then -- trailing quote marks
str = utilities.substitute (cfg.presentation['kern-right'], str);
end
else -- plain text or [[L|D]]; text in label variable
label = mw.ustring.gsub (label, '[“”]', '\"'); -- replace “” (U+201C & U+201D) with " (typewriter double quote mark)
label = mw.ustring.gsub (label, '[‘’]', '\''); -- replace ‘’ (U+2018 & U+2019) with ' (typewriter single quote mark)
cap = mw.ustring.match (label, "^([\"\'][^\'].+)"); -- match leading double or single quote but not doubled single quotes (italic markup)
if utilities.is_set (cap) then
label = utilities.substitute (cfg.presentation['kern-left'], cap);
end
cap = mw.ustring.match (label, "^(.+[^\'][\"\'])$") -- match trailing double or single quote but not doubled single quotes (italic markup)
if utilities.is_set (cap) then
label = utilities.substitute (cfg.presentation['kern-right'], cap);
end
if 2 == wl_type then
str = utilities.make_wikilink (link, label); -- reassemble the wikilink
else
str = label;
end
end
return str;
end
--[[--------------------------< F O R M A T _ S C R I P T _ V A L U E >----------------------------------------
|script-title= holds title parameters that are not written in Latin-based scripts: Chinese, Japanese, Arabic, Hebrew, etc. These scripts should
not be italicized and may be written right-to-left. The value supplied by |script-title= is concatenated onto Title after Title has been wrapped
in italic markup.
Regardless of language, all values provided by |script-title= are wrapped in <bdi>...</bdi> tags to isolate RTL languages from the English left to right.
|script-title= provides a unique feature. The value in |script-title= may be prefixed with a two-character ISO 639-1 language code and a colon:
|script-title=ja:*** *** (where * represents a Japanese character)
Spaces between the two-character code and the colon and the colon and the first script character are allowed:
|script-title=ja : *** ***
|script-title=ja: *** ***
|script-title=ja :*** ***
Spaces preceding the prefix are allowed: |script-title = ja:*** ***
The prefix is checked for validity. If it is a valid ISO 639-1 language code, the lang attribute (lang="ja") is added to the <bdi> tag so that browsers can
know the language the tag contains. This may help the browser render the script more correctly. If the prefix is invalid, the lang attribute
is not added. At this time there is no error message for this condition.
Supports |script-title=, |script-chapter=, |script-<periodical>=
]]
local function format_script_value (script_value, script_param)
local lang=''; -- initialize to empty string
local name;
if script_value:match('^%l%l%l?%s*:') then -- if first 3 or 4 non-space characters are script language prefix
lang = script_value:match('^(%l%l%l?)%s*:%s*%S.*'); -- get the language prefix or nil if there is no script
if not utilities.is_set (lang) then
utilities.set_message ('err_script_parameter', {script_param, cfg.err_msg_supl['missing title part']}); -- prefix without 'title'; add error message
return ''; -- script_value was just the prefix so return empty string
end
-- if we get this far we have prefix and script
name = cfg.lang_code_remap[lang] or mw.language.fetchLanguageName( lang, cfg.this_wiki_code ); -- get language name so that we can use it to categorize
if utilities.is_set (name) then -- is prefix a proper ISO 639-1 language code?
script_value = script_value:gsub ('^%l+%s*:%s*', ''); -- strip prefix from script
-- is prefix one of these language codes?
if utilities.in_array (lang, cfg.script_lang_codes) then
utilities.add_prop_cat ('script', {name, lang})
else
utilities.set_message ('err_script_parameter', {script_param, cfg.err_msg_supl['unknown language code']}); -- unknown script-language; add error message
end
lang = ' lang="' .. lang .. '" '; -- convert prefix into a lang attribute
else
utilities.set_message ('err_script_parameter', {script_param, cfg.err_msg_supl['invalid language code']}); -- invalid language code; add error message
lang = ''; -- invalid so set lang to empty string
end
else
utilities.set_message ('err_script_parameter', {script_param, cfg.err_msg_supl['missing prefix']}); -- no language code prefix; add error message
end
script_value = utilities.substitute (cfg.presentation['bdi'], {lang, script_value}); -- isolate in case script is RTL
return script_value;
end
--[[--------------------------< S C R I P T _ C O N C A T E N A T E >------------------------------------------
Initially for |title= and |script-title=, this function concatenates those two parameter values after the script
value has been wrapped in <bdi> tags.
]]
local function script_concatenate (title, script, script_param)
if utilities.is_set (script) then
script = format_script_value (script, script_param); -- <bdi> tags, lang attribute, categorization, etc.; returns empty string on error
if utilities.is_set (script) then
title = title .. ' ' .. script; -- concatenate title and script title
end
end
return title;
end
--[[--------------------------< W R A P _ M S G >--------------------------------------------------------------
Applies additional message text to various parameter values. Supplied string is wrapped using a message_list
configuration taking one argument. Supports lower case text for {{citation}} templates. Additional text taken
from citation_config.messages - the reason this function is similar to but separate from wrap_style().
]]
local function wrap_msg (key, str, lower)
if not utilities.is_set ( str ) then
return "";
end
if true == lower then
local msg;
msg = cfg.messages[key]:lower(); -- set the message to lower case before
return utilities.substitute ( msg, str ); -- including template text
else
return utilities.substitute ( cfg.messages[key], str );
end
end
--[[----------------< W I K I S O U R C E _ U R L _ M A K E >-------------------
Makes a Wikisource URL from Wikisource interwiki-link. Returns the URL and appropriate
label; nil else.
str is the value assigned to |chapter= (or aliases) or |title= or |title-link=
]]
local function wikisource_url_make (str)
local wl_type, D, L;
local ws_url, ws_label;
local wikisource_prefix = table.concat ({'https://', cfg.this_wiki_code, '.wikisource.org/wiki/'});
wl_type, D, L = utilities.is_wikilink (str); -- wl_type is 0 (not a wikilink), 1 (simple wikilink), 2 (complex wikilink)
if 0 == wl_type then -- not a wikilink; might be from |title-link=
str = D:match ('^[Ww]ikisource:(.+)') or D:match ('^[Ss]:(.+)'); -- article title from interwiki link with long-form or short-form namespace
if utilities.is_set (str) then
ws_url = table.concat ({ -- build a Wikisource URL
wikisource_prefix, -- prefix
str, -- article title
});
ws_label = str; -- label for the URL
end
elseif 1 == wl_type then -- simple wikilink: [[Wikisource:ws article]]
str = D:match ('^[Ww]ikisource:(.+)') or D:match ('^[Ss]:(.+)'); -- article title from interwiki link with long-form or short-form namespace
if utilities.is_set (str) then
ws_url = table.concat ({ -- build a Wikisource URL
wikisource_prefix, -- prefix
str, -- article title
});
ws_label = str; -- label for the URL
end
elseif 2 == wl_type then -- non-so-simple wikilink: [[Wikisource:ws article|displayed text]] ([[L|D]])
str = L:match ('^[Ww]ikisource:(.+)') or L:match ('^[Ss]:(.+)'); -- article title from interwiki link with long-form or short-form namespace
if utilities.is_set (str) then
ws_label = D; -- get ws article name from display portion of interwiki link
ws_url = table.concat ({ -- build a Wikisource URL
wikisource_prefix, -- prefix
str, -- article title without namespace from link portion of wikilink
});
end
end
if ws_url then
ws_url = mw.uri.encode (ws_url, 'WIKI'); -- make a usable URL
ws_url = ws_url:gsub ('%%23', '#'); -- undo percent-encoding of fragment marker
end
return ws_url, ws_label, L or D; -- return proper URL or nil and a label or nil
end
--[[----------------< F O R M A T _ P E R I O D I C A L >-----------------------
Format the three periodical parameters: |script-<periodical>=, |<periodical>=,
and |trans-<periodical>= into a single Periodical meta-parameter.
]]
local function format_periodical (script_periodical, script_periodical_source, periodical, trans_periodical)
if not utilities.is_set (periodical) then
periodical = ''; -- to be safe for concatenation
else
periodical = utilities.wrap_style ('italic-title', periodical); -- style
end
periodical = script_concatenate (periodical, script_periodical, script_periodical_source); -- <bdi> tags, lang attribute, categorization, etc.; must be done after title is wrapped
if utilities.is_set (trans_periodical) then
trans_periodical = utilities.wrap_style ('trans-italic-title', trans_periodical);
if utilities.is_set (periodical) then
periodical = periodical .. ' ' .. trans_periodical;
else -- here when trans-periodical without periodical or script-periodical
periodical = trans_periodical;
utilities.set_message ('err_trans_missing_title', {'periodical'});
end
end
return periodical;
end
--[[------------------< F O R M A T _ C H A P T E R _ T I T L E >---------------
Format the four chapter parameters: |script-chapter=, |chapter=, |trans-chapter=,
and |chapter-url= into a single chapter meta- parameter (chapter_url_source used
for error messages).
]]
local function format_chapter_title (script_chapter, script_chapter_source, chapter, chapter_source, trans_chapter, trans_chapter_source, chapter_url, chapter_url_source, no_quotes, access)
local ws_url, ws_label, L = wikisource_url_make (chapter); -- make a wikisource URL and label from a wikisource interwiki link
if ws_url then
ws_label = ws_label:gsub ('_', ' '); -- replace underscore separators with space characters
chapter = ws_label;
end
if not utilities.is_set (chapter) then
chapter = ''; -- to be safe for concatenation
else
if false == no_quotes then
chapter = kern_quotes (chapter); -- if necessary, separate chapter title's leading and trailing quote marks from module provided quote marks
chapter = utilities.wrap_style ('quoted-title', chapter);
end
end
chapter = script_concatenate (chapter, script_chapter, script_chapter_source); -- <bdi> tags, lang attribute, categorization, etc.; must be done after title is wrapped
if utilities.is_set (chapter_url) then
chapter = external_link (chapter_url, chapter, chapter_url_source, access); -- adds bare_url_missing_title error if appropriate
elseif ws_url then
chapter = external_link (ws_url, chapter .. ' ', 'ws link in chapter'); -- adds bare_url_missing_title error if appropriate; space char to move icon away from chap text; TODO: better way to do this?
chapter = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, chapter});
end
if utilities.is_set (trans_chapter) then
trans_chapter = utilities.wrap_style ('trans-quoted-title', trans_chapter);
if utilities.is_set (chapter) then
chapter = chapter .. ' ' .. trans_chapter;
else -- here when trans_chapter without chapter or script-chapter
chapter = trans_chapter;
chapter_source = trans_chapter_source:match ('trans%-?(.+)'); -- when no chapter, get matching name from trans-<param>
utilities.set_message ('err_trans_missing_title', {chapter_source});
end
end
return chapter;
end
--[[----------------< H A S _ I N V I S I B L E _ C H A R S >-------------------
This function searches a parameter's value for non-printable or invisible characters.
The search stops at the first match.
This function will detect the visible replacement character when it is part of the Wikisource.
Detects but ignores nowiki and math stripmarkers. Also detects other named stripmarkers
(gallery, math, pre, ref) and identifies them with a slightly different error message.
See also coins_cleanup().
Output of this function is an error message that identifies the character or the
Unicode group, or the stripmarker that was detected along with its position (or,
for multi-byte characters, the position of its first byte) in the parameter value.
]]
local function has_invisible_chars (param, v)
local position = ''; -- position of invisible char or starting position of stripmarker
local capture; -- used by stripmarker detection to hold name of the stripmarker
local stripmarker; -- boolean set true when a stripmarker is found
capture = string.match (v, '[%w%p ]*'); -- test for values that are simple ASCII text and bypass other tests if true
if capture == v then -- if same there are no Unicode characters
return;
end
for _, invisible_char in ipairs (cfg.invisible_chars) do
local char_name = invisible_char[1]; -- the character or group name
local pattern = invisible_char[2]; -- the pattern used to find it
position, _, capture = mw.ustring.find (v, pattern); -- see if the parameter value contains characters that match the pattern
if position and (cfg.invisible_defs.zwj == capture) then -- if we found a zero-width joiner character
if mw.ustring.find (v, cfg.indic_script) then -- it's ok if one of the Indic scripts
position = nil; -- unset position
elseif cfg.emoji[mw.ustring.codepoint (v, position+1)] then -- is zwj followed by a character listed in emoji{}?
position = nil; -- unset position
end
end
if position then
if 'nowiki' == capture or 'math' == capture or -- nowiki and math stripmarkers (not an error condition)
('templatestyles' == capture and utilities.in_array (param, {'id', 'quote'})) then -- templatestyles stripmarker allowed in these parameters
stripmarker = true; -- set a flag
elseif true == stripmarker and cfg.invisible_defs.del == capture then -- because stripmakers begin and end with the delete char, assume that we've found one end of a stripmarker
position = nil; -- unset
else
local err_msg;
if capture and not (cfg.invisible_defs.del == capture or cfg.invisible_defs.zwj == capture) then
err_msg = capture .. ' ' .. char_name;
else
err_msg = char_name .. ' ' .. 'character';
end
utilities.set_message ('err_invisible_char', {err_msg, utilities.wrap_style ('parameter', param), position}); -- add error message
return; -- and done with this parameter
end
end
end
end
--[[-------------------< A R G U M E N T _ W R A P P E R >----------------------
Argument wrapper. This function provides support for argument mapping defined
in the configuration file so that multiple names can be transparently aliased to
single internal variable.
]]
local function argument_wrapper ( args )
local origin = {};
return setmetatable({
ORIGIN = function ( self, k )
local dummy = self[k]; -- force the variable to be loaded.
return origin[k];
end
},
{
__index = function ( tbl, k )
if origin[k] ~= nil then
return nil;
end
local args, list, v = args, cfg.aliases[k];
if type( list ) == 'table' then
v, origin[k] = utilities.select_one ( args, list, 'err_redundant_parameters' );
if origin[k] == nil then
origin[k] = ''; -- Empty string, not nil
end
elseif list ~= nil then
v, origin[k] = args[list], list;
else
-- maybe let through instead of raising an error?
-- v, origin[k] = args[k], k;
error( cfg.messages['unknown_argument_map'] .. ': ' .. k);
end
-- Empty strings, not nil;
if v == nil then
v = '';
origin[k] = '';
end
tbl = rawset( tbl, k, v );
return v;
end,
});
end
--[[--------------------------< N O W R A P _ D A T E >-------------------------
When date is YYYY-MM-DD format wrap in nowrap span: <span ...>YYYY-MM-DD</span>.
When date is DD MMMM YYYY or is MMMM DD, YYYY then wrap in nowrap span:
<span ...>DD MMMM</span> YYYY or <span ...>MMMM DD,</span> YYYY
DOES NOT yet support MMMM YYYY or any of the date ranges.
]]
local function nowrap_date (date)
local cap = '';
local cap2 = '';
if date:match("^%d%d%d%d%-%d%d%-%d%d$") then
date = utilities.substitute (cfg.presentation['nowrap1'], date);
elseif date:match("^%a+%s*%d%d?,%s+%d%d%d%d$") or date:match ("^%d%d?%s*%a+%s+%d%d%d%d$") then
cap, cap2 = string.match (date, "^(.*)%s+(%d%d%d%d)$");
date = utilities.substitute (cfg.presentation['nowrap2'], {cap, cap2});
end
return date;
end
--[[--------------------------< S E T _ T I T L E T Y P E >---------------------
This function sets default title types (equivalent to the citation including
|type=<default value>) for those templates that have defaults. Also handles the
special case where it is desirable to omit the title type from the rendered citation
(|type=none).
]]
local function set_titletype (cite_class, title_type)
if utilities.is_set (title_type) then
if 'none' == cfg.keywords_xlate[title_type] then
title_type = ''; -- if |type=none then type parameter not displayed
end
return title_type; -- if |type= has been set to any other value use that value
end
return cfg.title_types [cite_class] or ''; -- set template's default title type; else empty string for concatenation
end
--[[--------------------------< S A F E _ J O I N >-----------------------------
Joins a sequence of strings together while checking for duplicate separation characters.
]]
local function safe_join( tbl, duplicate_char )
local f = {}; -- create a function table appropriate to type of 'duplicate character'
if 1 == #duplicate_char then -- for single byte ASCII characters use the string library functions
f.gsub = string.gsub
f.match = string.match
f.sub = string.sub
else -- for multi-byte characters use the ustring library functions
f.gsub = mw.ustring.gsub
f.match = mw.ustring.match
f.sub = mw.ustring.sub
end
local str = ''; -- the output string
local comp = ''; -- what does 'comp' mean?
local end_chr = '';
local trim;
for _, value in ipairs( tbl ) do
if value == nil then value = ''; end
if str == '' then -- if output string is empty
str = value; -- assign value to it (first time through the loop)
elseif value ~= '' then
if value:sub(1, 1) == '<' then -- special case of values enclosed in spans and other markup.
comp = value:gsub( "%b<>", "" ); -- remove HTML markup (<span>string</span> -> string)
else
comp = value;
end
-- typically duplicate_char is sepc
if f.sub(comp, 1, 1) == duplicate_char then -- is first character same as duplicate_char? why test first character?
-- Because individual string segments often (always?) begin with terminal punct for the
-- preceding segment: 'First element' .. 'sepc next element' .. etc.?
trim = false;
end_chr = f.sub(str, -1, -1); -- get the last character of the output string
-- str = str .. "<HERE(enchr=" .. end_chr .. ")" -- debug stuff?
if end_chr == duplicate_char then -- if same as separator
str = f.sub(str, 1, -2); -- remove it
elseif end_chr == "'" then -- if it might be wiki-markup
if f.sub(str, -3, -1) == duplicate_char .. "''" then -- if last three chars of str are sepc''
str = f.sub(str, 1, -4) .. "''"; -- remove them and add back ''
elseif f.sub(str, -5, -1) == duplicate_char .. "]]''" then -- if last five chars of str are sepc]]''
trim = true; -- why? why do this and next differently from previous?
elseif f.sub(str, -4, -1) == duplicate_char .. "]''" then -- if last four chars of str are sepc]''
trim = true; -- same question
end
elseif end_chr == "]" then -- if it might be wiki-markup
if f.sub(str, -3, -1) == duplicate_char .. "]]" then -- if last three chars of str are sepc]] wikilink
trim = true;
elseif f.sub(str, -3, -1) == duplicate_char .. '"]' then -- if last three chars of str are sepc"] quoted external link
trim = true;
elseif f.sub(str, -2, -1) == duplicate_char .. "]" then -- if last two chars of str are sepc] external link
trim = true;
elseif f.sub(str, -4, -1) == duplicate_char .. "'']" then -- normal case when |url=something & |title=Title.
trim = true;
end
elseif end_chr == " " then -- if last char of output string is a space
if f.sub(str, -2, -1) == duplicate_char .. " " then -- if last two chars of str are <sepc><space>
str = f.sub(str, 1, -3); -- remove them both
end
end
if trim then
if value ~= comp then -- value does not equal comp when value contains HTML markup
local dup2 = duplicate_char;
if f.match(dup2, "%A" ) then dup2 = "%" .. dup2; end -- if duplicate_char not a letter then escape it
value = f.gsub(value, "(%b<>)" .. dup2, "%1", 1 ) -- remove duplicate_char if it follows HTML markup
else
value = f.sub(value, 2, -1 ); -- remove duplicate_char when it is first character
end
end
end
str = str .. value; -- add it to the output string
end
end
return str;
end
--[[--------------------------< I S _ S U F F I X >-----------------------------
returns true if suffix is properly formed Jr, Sr, or ordinal in the range 1–9.
Puncutation not allowed.
]]
local function is_suffix (suffix)
if utilities.in_array (suffix, {'Jr', 'Sr', 'Jnr', 'Snr', '1st', '2nd', '3rd'}) or suffix:match ('^%dth$') then
return true;
end
return false;
end
--[[--------------------< I S _ G O O D _ V A N C _ N A M E >-------------------
For Vancouver style, author/editor names are supposed to be rendered in Latin
(read ASCII) characters. When a name uses characters that contain diacritical
marks, those characters are to be converted to the corresponding Latin
character. When a name is written using a non-Latin alphabet or logogram, that
name is to be transliterated into Latin characters. The module doesn't do this
so editors may/must.
This test allows |first= and |last= names to contain any of the letters defined
in the four Unicode Latin character sets
[http://www.unicode.org/charts/PDF/U0000.pdf C0 Controls and Basic Latin] 0041–005A, 0061–007A
[http://www.unicode.org/charts/PDF/U0080.pdf C1 Controls and Latin-1 Supplement] 00C0–00D6, 00D8–00F6, 00F8–00FF
[http://www.unicode.org/charts/PDF/U0100.pdf Latin Extended-A] 0100–017F
[http://www.unicode.org/charts/PDF/U0180.pdf Latin Extended-B] 0180–01BF, 01C4–024F
|lastn= also allowed to contain hyphens, spaces, and apostrophes.
(http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
|firstn= also allowed to contain hyphens, spaces, apostrophes, and periods
This original test:
if nil == mw.ustring.find (last, "^[A-Za-zÀ-ÖØ-öø-ƿDŽ-ɏ%-%s%']*$")
or nil == mw.ustring.find (first, "^[A-Za-zÀ-ÖØ-öø-ƿDŽ-ɏ%-%s%'%.]+[2-6%a]*$") then
was written outside of the code editor and pasted here because the code editor
gets confused between character insertion point and cursor position. The test has
been rewritten to use decimal character escape sequence for the individual bytes
of the Unicode characters so that it is not necessary to use an external editor
to maintain this code.
\195\128-\195\150 – À-Ö (U+00C0–U+00D6 – C0 controls)
\195\152-\195\182 – Ø-ö (U+00D8-U+00F6 – C0 controls)
\195\184-\198\191 – ø-ƿ (U+00F8-U+01BF – C0 controls, Latin extended A & B)
\199\132-\201\143 – DŽ-ɏ (U+01C4-U+024F – Latin extended B)
]]
local function is_good_vanc_name (last, first, suffix, position)
if not suffix then
if first:find ('[,%s]') then -- when there is a space or comma, might be first name/initials + generational suffix
first = first:match ('(.-)[,%s]+'); -- get name/initials
suffix = first:match ('[,%s]+(.+)$'); -- get generational suffix
end
end
if utilities.is_set (suffix) then
if not is_suffix (suffix) then
add_vanc_error (cfg.err_msg_supl.suffix, position);
return false; -- not a name with an appropriate suffix
end
end
if nil == mw.ustring.find (last, "^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%']*$") or
nil == mw.ustring.find (first, "^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%'%.]*$") then
add_vanc_error (cfg.err_msg_supl['non-Latin char'], position);
return false; -- not a string of Latin characters; Vancouver requires Romanization
end;
return true;
end
--[[--------------------------< R E D U C E _ T O _ I N I T I A L S >------------------------------------------
Attempts to convert names to initials in support of |name-list-style=vanc.
Names in |firstn= may be separated by spaces or hyphens, or for initials, a period.
See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35062/.
Vancouver style requires family rank designations (Jr, II, III, etc.) to be rendered
as Jr, 2nd, 3rd, etc. See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35085/.
This code only accepts and understands generational suffix in the Vancouver format
because Roman numerals look like, and can be mistaken for, initials.
This function uses ustring functions because firstname initials may be any of the
Unicode Latin characters accepted by is_good_vanc_name ().
]]
local function reduce_to_initials(first, position)
local name, suffix = mw.ustring.match(first, "^(%u+) ([%dJS][%drndth]+)$");
if not name then -- if not initials and a suffix
name = mw.ustring.match(first, "^(%u+)$"); -- is it just initials?
end
if name then -- if first is initials with or without suffix
if 3 > mw.ustring.len (name) then -- if one or two initials
if suffix then -- if there is a suffix
if is_suffix (suffix) then -- is it legitimate?
return first; -- one or two initials and a valid suffix so nothing to do
else
add_vanc_error (cfg.err_msg_supl.suffix, position); -- one or two initials with invalid suffix so error message
return first; -- and return first unmolested
end
else
return first; -- one or two initials without suffix; nothing to do
end
end
end -- if here then name has 3 or more uppercase letters so treat them as a word
local initials, names = {}, {}; -- tables to hold name parts and initials
local i = 1; -- counter for number of initials
names = mw.text.split (first, '[%s,]+'); -- split into a table of names and possible suffix
while names[i] do -- loop through the table
if 1 < i and names[i]:match ('[%dJS][%drndth]+%.?$') then -- if not the first name, and looks like a suffix (may have trailing dot)
names[i] = names[i]:gsub ('%.', ''); -- remove terminal dot if present
if is_suffix (names[i]) then -- if a legitimate suffix
table.insert (initials, ' ' .. names[i]); -- add a separator space, insert at end of initials table
break; -- and done because suffix must fall at the end of a name
end -- no error message if not a suffix; possibly because of Romanization
end
if 3 > i then
table.insert (initials, mw.ustring.sub(names[i], 1, 1)); -- insert the initial at end of initials table
end
i = i + 1; -- bump the counter
end
return table.concat(initials) -- Vancouver format does not include spaces.
end
--[[--------------------------< L I S T _ P E O P L E >--------------------------
Formats a list of people (authors, contributors, editors, interviewers, translators)
names in the list will be linked when
|<name>-link= has a value
|<name>-mask- does NOT have a value; masked names are presumed to have been
rendered previously so should have been linked there
when |<name>-mask=0, the associated name is not rendered
]]
local function list_people (control, people, etal)
local sep;
local namesep;
local format = control.format;
local maximum = control.maximum;
local name_list = {};
if 'vanc' == format then -- Vancouver-like name styling?
sep = cfg.presentation['sep_nl_vanc']; -- name-list separator between names is a comma
namesep = cfg.presentation['sep_name_vanc']; -- last/first separator is a space
else
sep = cfg.presentation['sep_nl']; -- name-list separator between names is a semicolon
namesep = cfg.presentation['sep_name']; -- last/first separator is <comma><space>
end
if sep:sub (-1, -1) ~= " " then sep = sep .. " " end
if utilities.is_set (maximum) and maximum < 1 then return "", 0; end -- returned 0 is for EditorCount; not used for other names
for i, person in ipairs (people) do
if utilities.is_set (person.last) then
local mask = person.mask;
local one;
local sep_one = sep;
if utilities.is_set (maximum) and i > maximum then
etal = true;
break;
end
if mask then
local n = tonumber (mask); -- convert to a number if it can be converted; nil else
if n then
one = 0 ~= n and string.rep("—", n) or nil; -- make a string of (n > 0) mdashes, nil else, to replace name
person.link = nil; -- don't create link to name if name is replaces with mdash string or has been set nil
else
one = mask; -- replace name with mask text (must include name-list separator)
sep_one = " "; -- modify name-list separator
end
else
one = person.last; -- get surname
local first = person.first -- get given name
if utilities.is_set (first) then
if ("vanc" == format) then -- if Vancouver format
one = one:gsub ('%.', ''); -- remove periods from surnames (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
if not person.corporate and is_good_vanc_name (one, first, nil, i) then -- and name is all Latin characters; corporate authors not tested
first = reduce_to_initials (first, i); -- attempt to convert first name(s) to initials
end
end
one = one .. namesep .. first;
end
end
if utilities.is_set (person.link) then
one = utilities.make_wikilink (person.link, one); -- link author/editor
end
if one then -- if <one> has a value (name, mdash replacement, or mask text replacement)
table.insert (name_list, one); -- add it to the list of names
table.insert (name_list, sep_one); -- add the proper name-list separator
end
end
end
local count = #name_list / 2; -- (number of names + number of separators) divided by 2
if 0 < count then
if 1 < count and not etal then
if 'amp' == format then
name_list[#name_list-2] = " & "; -- replace last separator with ampersand text
elseif 'and' == format then
if 2 == count then
name_list[#name_list-2] = cfg.presentation.sep_nl_and; -- replace last separator with 'and' text
else
name_list[#name_list-2] = cfg.presentation.sep_nl_end; -- replace last separator with '(sep) and' text
end
end
end
name_list[#name_list] = nil; -- erase the last separator
end
local result = table.concat (name_list); -- construct list
if etal and utilities.is_set (result) then -- etal may be set by |display-authors=etal but we might not have a last-first list
result = result .. sep .. ' ' .. cfg.messages['et al']; -- we've got a last-first list and etal so add et al.
end
return result, count; -- return name-list string and count of number of names (count used for editor names only)
end
--[[--------------------< M A K E _ C I T E R E F _ I D >-----------------------
Generates a CITEREF anchor ID if we have at least one name or a date. Otherwise
returns an empty string.
namelist is one of the contributor-, author-, or editor-name lists chosen in that
order. year is Year or anchor_year.
]]
local function make_citeref_id (namelist, year)
local names={}; -- a table for the one to four names and year
for i,v in ipairs (namelist) do -- loop through the list and take up to the first four last names
names[i] = v.last
if i == 4 then break end -- if four then done
end
table.insert (names, year); -- add the year at the end
local id = table.concat(names); -- concatenate names and year for CITEREF id
if utilities.is_set (id) then -- if concatenation is not an empty string
return "CITEREF" .. id; -- add the CITEREF portion
else
return ''; -- return an empty string; no reason to include CITEREF id in this citation
end
end
--[[--------------------------< C I T E _ C L A S S _A T T R I B U T E _M A K E >------------------------------
construct <cite> tag class attribute for this citation.
<cite_class> – config.CitationClass from calling template
<mode> – value from |mode= parameter
]]
local function cite_class_attribute_make (cite_class, mode)
local class_t = {};
table.insert (class_t, 'citation'); -- required for blue highlight
if 'citation' ~= cite_class then
table.insert (class_t, cite_class); -- identify this template for user css
table.insert (class_t, utilities.is_set (mode) and mode or 'cs1'); -- identify the citation style for user css or javascript
else
table.insert (class_t, utilities.is_set (mode) and mode or 'cs2'); -- identify the citation style for user css or javascript
end
for _, prop_key in ipairs (z.prop_keys_t) do
table.insert (class_t, prop_key); -- identify various properties for user css or javascript
end
return table.concat (class_t, ' '); -- make a big string and done
end
--[[---------------------< N A M E _ H A S _ E T A L >--------------------------
Evaluates the content of name parameters (author, editor, etc.) for variations on
the theme of et al. If found, the et al. is removed, a flag is set to true and
the function returns the modified name and the flag.
This function never sets the flag to false but returns its previous state because
it may have been set by previous passes through this function or by the associated
|display-<names>=etal parameter
]]
local function name_has_etal (name, etal, nocat, param)
if utilities.is_set (name) then -- name can be nil in which case just return
local patterns = cfg.et_al_patterns; -- get patterns from configuration
for _, pattern in ipairs (patterns) do -- loop through all of the patterns
if name:match (pattern) then -- if this 'et al' pattern is found in name
name = name:gsub (pattern, ''); -- remove the offending text
etal = true; -- set flag (may have been set previously here or by |display-<names>=etal)
if not nocat then -- no categorization for |vauthors=
utilities.set_message ('err_etal', {param}); -- and set an error if not added
end
end
end
end
return name, etal;
end
--[[---------------------< N A M E _ I S _ N U M E R I C >----------------------
Add maint cat when name parameter value does not contain letters. Does not catch
mixed alphanumeric names so |last=A. Green (1922-1987) does not get caught in the
current version of this test but |first=(1888) is caught.
returns nothing
]]
local function name_is_numeric (name, list_name)
if utilities.is_set (name) then
if mw.ustring.match (name, '^[%A]+$') then -- when name does not contain any letters
utilities.set_message ('maint_numeric_names', cfg.special_case_translation [list_name]); -- add a maint cat for this template
end
end
end
--[[-----------------< N A M E _ H A S _ M U L T _ N A M E S >------------------
Evaluates the content of last/surname (authors etc.) parameters for multiple names.
Multiple names are indicated if there is more than one comma or any "unescaped"
semicolons. Escaped semicolons are ones used as part of selected HTML entities.
If the condition is met, the function adds the multiple name maintenance category.
returns nothing
]]
local function name_has_mult_names (name, list_name)
local _, commas, semicolons, nbsps;
if utilities.is_set (name) then
_, commas = name:gsub (',', ''); -- count the number of commas
_, semicolons = name:gsub (';', ''); -- count the number of semicolons
-- nbsps probably should be its own separate count rather than merged in
-- some way with semicolons because Lua patterns do not support the
-- grouping operator that regex does, which means there is no way to add
-- more entities to escape except by adding more counts with the new
-- entities
_, nbsps = name:gsub (' ',''); -- count nbsps
-- There is exactly 1 semicolon per entity, so subtract nbsps
-- from semicolons to 'escape' them. If additional entities are added,
-- they also can be subtracted.
if 1 < commas or 0 < (semicolons - nbsps) then
utilities.set_message ('maint_mult_names', cfg.special_case_translation [list_name]); -- add a maint message
end
end
end
--[=[-------------------------< I S _ G E N E R I C >----------------------------------------------------------
Compares values assigned to various parameters according to the string provided as <item> in the function call.
<item> can have on of two values:
'generic_names' – for name-holding parameters: |last=, |first=, |editor-last=, etc
'generic_titles' – for |title=
There are two types of generic tests. The 'accept' tests look for a pattern that should not be rejected by the
'reject' test. For example,
|author=[[John Smith (author)|Smith, John]]
would be rejected by the 'author' reject test. But piped wikilinks with 'author' disambiguation should not be
rejected so the 'accept' test prevents that from happening. Accept tests are always performed before reject
tests.
Each of the 'accept' and 'reject' sequence tables hold tables for en.wiki (['en']) and local.wiki (['local'])
that each can hold a test sequence table The sequence table holds, at index [1], a test pattern, and, at index
[2], a boolean control value. The control value tells string.find() or mw.ustring.find() to do plain-text search (true)
or a pattern search (false). The intent of all this complexity is to make these searches as fast as possible so
that we don't run out of processing time on very large articles.
Returns
true when a reject test finds the pattern or string
false when an accept test finds the pattern or string
nil else
]=]
local function is_generic (item, value, wiki)
local test_val;
local str_lower = { -- use string.lower() for en.wiki (['en']) and use mw.ustring.lower() or local.wiki (['local'])
['en'] = string.lower,
['local'] = mw.ustring.lower,
}
local str_find = { -- use string.find() for en.wiki (['en']) and use mw.ustring.find() or local.wiki (['local'])
['en'] = string.find,
['local'] = mw.ustring.find,
}
local function test (val, test_t, wiki) -- local function to do the testing; <wiki> selects lower() and find() functions
val = test_t[2] and str_lower[wiki](value) or val; -- when <test_t[2]> set to 'true', plaintext search using lowercase value
return str_find[wiki] (val, test_t[1], 1, test_t[2]); -- return nil when not found or matched
end
local test_types_t = {'accept', 'reject'}; -- test accept patterns first, then reject patterns
local wikis_t = {'en', 'local'}; -- do tests for each of these keys; en.wiki first, local.wiki second
for _, test_type in ipairs (test_types_t) do -- for each test type
for _, generic_value in pairs (cfg.special_case_translation[item][test_type]) do -- spin through the list of generic value fragments to accept or reject
for _, wiki in ipairs (wikis_t) do
if generic_value[wiki] then
if test (value, generic_value[wiki], wiki) then -- go do the test
return ('reject' == test_type); -- param value rejected, return true; false else
end
end
end
end
end
end
--[[--------------------------< N A M E _ I S _ G E N E R I C >------------------------------------------------
calls is_generic() to determine if <name> is a 'generic name' listed in cfg.generic_names; <name_alias> is the
parameter name used in error messaging
]]
local function name_is_generic (name, name_alias)
if not added_generic_name_errs and is_generic ('generic_names', name) then
utilities.set_message ('err_generic_name', name_alias); -- set an error message
added_generic_name_errs = true;
end
end
--[[--------------------------< N A M E _ C H E C K S >--------------------------------------------------------
This function calls various name checking functions used to validate the content of the various name-holding parameters.
]]
local function name_checks (last, first, list_name, last_alias, first_alias)
local accept_name;
if utilities.is_set (last) then
last, accept_name = utilities.has_accept_as_written (last); -- remove accept-this-as-written markup when it wraps all of <last>
if not accept_name then -- <last> not wrapped in accept-as-written markup
name_has_mult_names (last, list_name); -- check for multiple names in the parameter (last only)
name_is_numeric (last, list_name); -- check for names that are composed of digits and punctuation
name_is_generic (last, last_alias); -- check for names found in the generic names list
end
end
if utilities.is_set (first) then
first, accept_name = utilities.has_accept_as_written (first); -- remove accept-this-as-written markup when it wraps all of <first>
if not accept_name then -- <first> not wrapped in accept-as-written markup
name_is_numeric (first, list_name); -- check for names that are composed of digits and punctuation
name_is_generic (first, first_alias); -- check for names found in the generic names list
end
local wl_type, D = utilities.is_wikilink (first);
if 0 ~= wl_type then
first = D;
utilities.set_message ('err_bad_paramlink', first_alias);
end
end
return last, first; -- done
end
--[[----------------------< E X T R A C T _ N A M E S >-------------------------
Gets name list from the input arguments
Searches through args in sequential order to find |lastn= and |firstn= parameters
(or their aliases), and their matching link and mask parameters. Stops searching
when both |lastn= and |firstn= are not found in args after two sequential attempts:
found |last1=, |last2=, and |last3= but doesn't find |last4= and |last5= then the
search is done.
This function emits an error message when there is a |firstn= without a matching
|lastn=. When there are 'holes' in the list of last names, |last1= and |last3=
are present but |last2= is missing, an error message is emitted. |lastn= is not
required to have a matching |firstn=.
When an author or editor parameter contains some form of 'et al.', the 'et al.'
is stripped from the parameter and a flag (etal) returned that will cause list_people()
to add the static 'et al.' text from Module:Citation/CS1/Configuration. This keeps
'et al.' out of the template's metadata. When this occurs, an error is emitted.
]]
local function extract_names(args, list_name)
local names = {}; -- table of names
local last; -- individual name components
local first;
local link;
local mask;
local i = 1; -- loop counter/indexer
local n = 1; -- output table indexer
local count = 0; -- used to count the number of times we haven't found a |last= (or alias for authors, |editor-last or alias for editors)
local etal = false; -- return value set to true when we find some form of et al. in an author parameter
local last_alias, first_alias, link_alias; -- selected parameter aliases used in error messaging
while true do
last, last_alias = utilities.select_one ( args, cfg.aliases[list_name .. '-Last'], 'err_redundant_parameters', i ); -- search through args for name components beginning at 1
first, first_alias = utilities.select_one ( args, cfg.aliases[list_name .. '-First'], 'err_redundant_parameters', i );
link, link_alias = utilities.select_one ( args, cfg.aliases[list_name .. '-Link'], 'err_redundant_parameters', i );
mask = utilities.select_one ( args, cfg.aliases[list_name .. '-Mask'], 'err_redundant_parameters', i );
last, etal = name_has_etal (last, etal, false, last_alias); -- find and remove variations on et al.
first, etal = name_has_etal (first, etal, false, first_alias); -- find and remove variations on et al.
last, first = name_checks (last, first, list_name, last_alias, first_alias); -- multiple names, extraneous annotation, etc. checks
if first and not last then -- if there is a firstn without a matching lastn
local alias = first_alias:find ('given', 1, true) and 'given' or 'first'; -- get first or given form of the alias
utilities.set_message ('err_first_missing_last', {
first_alias, -- param name of alias missing its mate
first_alias:gsub (alias, {['first'] = 'last', ['given'] = 'surname'}), -- make param name appropriate to the alias form
}); -- add this error message
elseif not first and not last then -- if both firstn and lastn aren't found, are we done?
count = count + 1; -- number of times we haven't found last and first
if 2 <= count then -- two missing names and we give up
break; -- normal exit or there is a two-name hole in the list; can't tell which
end
else -- we have last with or without a first
local result;
link = link_title_ok (link, link_alias, last, last_alias); -- check for improper wiki-markup
if first then
link = link_title_ok (link, link_alias, first, first_alias); -- check for improper wiki-markup
end
names[n] = {last = last, first = first, link = link, mask = mask, corporate = false}; -- add this name to our names list (corporate for |vauthors= only)
n = n + 1; -- point to next location in the names table
if 1 == count then -- if the previous name was missing
utilities.set_message ('err_missing_name', {list_name:match ("(%w+)List"):lower(), i - 1}); -- add this error message
end
count = 0; -- reset the counter, we're looking for two consecutive missing names
end
i = i + 1; -- point to next args location
end
return names, etal; -- all done, return our list of names and the etal flag
end
--[[--------------------------< N A M E _ T A G _ G E T >------------------------------------------------------
attempt to decode |language=<lang_param> and return language name and matching tag; nil else.
This function looks for:
<lang_param> as a tag in cfg.lang_code_remap{}
<lang_param> as a name in cfg.lang_name_remap{}
<lang_param> as a name in cfg.mw_languages_by_name_t
<lang_param> as a tag in cfg.mw_languages_by_tag_t
when those fail, presume that <lang_param> is an IETF-like tag that MediaWiki does not recognize. Strip all
script, region, variant, whatever subtags from <lang_param> to leave just a two or three character language tag
and look for the new <lang_param> in cfg.mw_languages_by_tag_t{}
on success, returns name (in properly capitalized form) and matching tag (in lowercase); on failure returns nil
]]
local function name_tag_get (lang_param)
local lang_param_lc = mw.ustring.lower (lang_param); -- use lowercase as an index into the various tables
local name;
local tag;
name = cfg.lang_code_remap[lang_param_lc]; -- assume <lang_param_lc> is a tag; attempt to get remapped language name
if name then -- when <name>, <lang_param> is a tag for a remapped language name
return name, lang_param_lc; -- so return <name> from remap and <lang_param_lc>
end
tag = lang_param_lc:match ('^(%a%a%a?)%-.*'); -- still assuming that <lang_param_lc> is a tag; strip script, region, variant subtags
name = cfg.lang_code_remap[tag]; -- attempt to get remapped language name with language subtag only
if name then -- when <name>, <tag> is a tag for a remapped language name
return name, tag; -- so return <name> from remap and <tag>
end
if cfg.lang_name_remap[lang_param_lc] then -- not a tag, assume <lang_param_lc> is a name; attempt to get remapped language tag
return cfg.lang_name_remap[lang_param_lc][1], cfg.lang_name_remap[lang_param_lc][2]; -- for this <lang_param_lc>, return a (possibly) new name and appropriate tag
end
tag = cfg.mw_languages_by_name_t[lang_param_lc]; -- assume that <lang_param_lc> is a language name; attempt to get its matching tag
if tag then
return cfg.mw_languages_by_tag_t[tag], tag; -- <lang_param_lc> is a name so return the name from the table and <tag>
end
name = cfg.mw_languages_by_tag_t[lang_param_lc]; -- assume that <lang_param_lc> is a tag; attempt to get its matching language name
if name then
return name, lang_param_lc; -- <lang_param_lc> is a tag so return it and <name>
end
tag = lang_param_lc:match ('^(%a%a%a?)%-.*'); -- is <lang_param_lc> an IETF-like tag that MediaWiki doesn't recognize? <tag> gets the language subtag; nil else
if tag then
name = cfg.mw_languages_by_tag_t[tag]; -- attempt to get a language name using the shortened <tag>
if name then
return name, tag; -- <lang_param_lc> is an unrecognized IETF-like tag so return <name> and language subtag
end
end
end
--[[-------------------< L A N G U A G E _ P A R A M E T E R >------------------
Gets language name from a provided two- or three-character ISO 639 code. If a code
is recognized by MediaWiki, use the returned name; if not, then use the value that
was provided with the language parameter.
When |language= contains a recognized language (either code or name), the page is
assigned to the category for that code: Category:Norwegian-language sources (no).
For valid three-character code languages, the page is assigned to the single category
for '639-2' codes: Category:CS1 ISO 639-2 language sources.
Languages that are the same as the local wiki are not categorized. MediaWiki does
not recognize three-character equivalents of two-character codes: code 'ar' is
recognized but code 'ara' is not.
This function supports multiple languages in the form |language=nb, French, th
where the language names or codes are separated from each other by commas with
optional space characters.
]]
local function language_parameter (lang)
local tag; -- some form of IETF-like language tag; language subtag with optional region, sript, vatiant, etc subtags
local lang_subtag; -- ve populates |language= with mostly unecessary region subtags the MediaWiki does not recognize; this is the base language subtag
local name; -- the language name
local language_list = {}; -- table of language names to be rendered
local names_t = {}; -- table made from the value assigned to |language=
local this_wiki_name = mw.language.fetchLanguageName (cfg.this_wiki_code, cfg.this_wiki_code); -- get this wiki's language name
names_t = mw.text.split (lang, '%s*,%s*'); -- names should be a comma separated list
for _, lang in ipairs (names_t) do -- reuse lang here because we don't yet know if lang is a language name or a language tag
name, tag = name_tag_get (lang); -- attempt to get name/tag pair for <lang>; <name> has proper capitalization; <tag> is lowercase
if utilities.is_set (tag) then
lang_subtag = tag:gsub ('^(%a%a%a?)%-.*', '%1'); -- for categorization, strip any IETF-like tags from language tag
if cfg.this_wiki_code ~= lang_subtag then -- when the language is not the same as this wiki's language
if 2 == lang_subtag:len() then -- and is a two-character tag
-- utilities.add_prop_cat ('foreign-lang-source', {name, lang_subtag}, lang_subtag); -- categorize it; tag appended to allow for multiple language categorization
utilities.add_prop_cat ('foreign-lang-source', {name, tag}, lang_subtag); -- categorize it; tag appended to allow for multiple language categorization
else -- or is a recognized language (but has a three-character tag)
utilities.add_prop_cat ('foreign-lang-source-2', {lang_subtag}, lang_subtag); -- categorize it differently TODO: support multiple three-character tag categories per cs1|2 template?
end
elseif cfg.local_lang_cat_enable then -- when the language and this wiki's language are the same and categorization is enabled
utilities.add_prop_cat ('local-lang-source', {name, lang_subtag}); -- categorize it
end
else
name = lang; -- return whatever <lang> has so that we show something
utilities.set_message ('maint_unknown_lang'); -- add maint category if not already added
end
table.insert (language_list, name);
name = ''; -- so we can reuse it
end
name = utilities.make_sep_list (#language_list, language_list);
if (1 == #language_list) and (lang_subtag == cfg.this_wiki_code) then -- when only one language, find lang name in this wiki lang name; for |language=en-us, 'English' in 'American English'
return ''; -- if one language and that language is this wiki's return an empty string (no annotation)
end
return (" " .. wrap_msg ('language', name)); -- otherwise wrap with '(in ...)'
--[[ TODO: should only return blank or name rather than full list
so we can clean up the bunched parenthetical elements Language, Type, Format
]]
end
--[[-----------------------< S E T _ C S _ S T Y L E >--------------------------
Gets the default CS style configuration for the given mode.
Returns default separator and either postscript as passed in or the default.
In CS1, the default postscript and separator are '.'.
In CS2, the default postscript is the empty string and the default separator is ','.
]]
local function set_cs_style (postscript, mode)
if utilities.is_set(postscript) then
-- emit a maintenance message if user postscript is the default cs1 postscript
-- we catch the opposite case for cs2 in set_style
if mode == 'cs1' and postscript == cfg.presentation['ps_' .. mode] then
utilities.set_message ('maint_postscript');
end
else
postscript = cfg.presentation['ps_' .. mode];
end
return cfg.presentation['sep_' .. mode], postscript;
end
--[[--------------------------< S E T _ S T Y L E >-----------------------------
Sets the separator and postscript styles. Checks the |mode= first and the
#invoke CitationClass second. Removes the postscript if postscript == none.
]]
local function set_style (mode, postscript, cite_class)
local sep;
if 'cs2' == mode then
sep, postscript = set_cs_style (postscript, 'cs2');
elseif 'cs1' == mode then
sep, postscript = set_cs_style (postscript, 'cs1');
elseif 'citation' == cite_class then
sep, postscript = set_cs_style (postscript, 'cs2');
else
sep, postscript = set_cs_style (postscript, 'cs1');
end
if cfg.keywords_xlate[postscript:lower()] == 'none' then
-- emit a maintenance message if user postscript is the default cs2 postscript
-- we catch the opposite case for cs1 in set_cs_style
if 'cs2' == mode or 'citation' == cite_class then
utilities.set_message ('maint_postscript');
end
postscript = '';
end
return sep, postscript
end
--[=[-------------------------< I S _ P D F >-----------------------------------
Determines if a URL has the file extension that is one of the PDF file extensions
used by [[MediaWiki:Common.css]] when applying the PDF icon to external links.
returns true if file extension is one of the recognized extensions, else false
]=]
local function is_pdf (url)
return url:match ('%.pdf$') or url:match ('%.PDF$') or
url:match ('%.pdf[%?#]') or url:match ('%.PDF[%?#]') or
url:match ('%.PDF#') or url:match ('%.pdf#');
end
--[[--------------------------< S T Y L E _ F O R M A T >-----------------------
Applies CSS style to |format=, |chapter-format=, etc. Also emits an error message
if the format parameter does not have a matching URL parameter. If the format parameter
is not set and the URL contains a file extension that is recognized as a PDF document
by MediaWiki's commons.css, this code will set the format parameter to (PDF) with
the appropriate styling.
]]
local function style_format (format, url, fmt_param, url_param)
if utilities.is_set (format) then
format = utilities.wrap_style ('format', format); -- add leading space, parentheses, resize
if not utilities.is_set (url) then
utilities.set_message ('err_format_missing_url', {fmt_param, url_param}); -- add an error message
end
elseif is_pdf (url) then -- format is not set so if URL is a PDF file then
format = utilities.wrap_style ('format', 'PDF'); -- set format to PDF
else
format = ''; -- empty string for concatenation
end
return format;
end
--[[---------------------< G E T _ D I S P L A Y _ N A M E S >------------------
Returns a number that defines the number of names displayed for author and editor
name lists and a Boolean flag to indicate when et al. should be appended to the name list.
When the value assigned to |display-xxxxors= is a number greater than or equal to zero,
return the number and the previous state of the 'etal' flag (false by default
but may have been set to true if the name list contains some variant of the text 'et al.').
When the value assigned to |display-xxxxors= is the keyword 'etal', return a number
that is one greater than the number of authors in the list and set the 'etal' flag true.
This will cause the list_people() to display all of the names in the name list followed by 'et al.'
In all other cases, returns nil and the previous state of the 'etal' flag.
inputs:
max: A['DisplayAuthors'] or A['DisplayEditors']; a number or some flavor of etal
count: #a or #e
list_name: 'authors' or 'editors'
etal: author_etal or editor_etal
]]
local function get_display_names (max, count, list_name, etal, param)
if utilities.is_set (max) then
if 'etal' == max:lower():gsub("[ '%.]", '') then -- the :gsub() portion makes 'etal' from a variety of 'et al.' spellings and stylings
max = count + 1; -- number of authors + 1 so display all author name plus et al.
etal = true; -- overrides value set by extract_names()
elseif max:match ('^%d+$') then -- if is a string of numbers
max = tonumber (max); -- make it a number
if max >= count then -- if |display-xxxxors= value greater than or equal to number of authors/editors
utilities.set_message ('err_disp_name', {param, max}); -- add error message
max = nil;
end
else -- not a valid keyword or number
utilities.set_message ('err_disp_name', {param, max}); -- add error message
max = nil; -- unset; as if |display-xxxxors= had not been set
end
end
return max, etal;
end
--[[----------< E X T R A _ T E X T _ I N _ P A G E _ C H E C K >---------------
Adds error if |page=, |pages=, |quote-page=, |quote-pages= has what appears to be
some form of p. or pp. abbreviation in the first characters of the parameter content.
check page for extraneous p, p., pp, pp., pg, pg. at start of parameter value:
good pattern: '^P[^%.P%l]' matches when page begins PX or P# but not Px
where x and X are letters and # is a digit
bad pattern: '^[Pp][PpGg]' matches when page begins pp, pP, Pp, PP, pg, pG, Pg, PG
]]
local function extra_text_in_page_check (val, name)
if not val:match (cfg.vol_iss_pg_patterns.good_ppattern) then
for _, pattern in ipairs (cfg.vol_iss_pg_patterns.bad_ppatterns) do -- spin through the selected sequence table of patterns
if val:match (pattern) then -- when a match, error so
utilities.set_message ('err_extra_text_pages', name); -- add error message
return; -- and done
end
end
end
end
--[[--------------------------< E X T R A _ T E X T _ I N _ V O L _ I S S _ C H E C K >------------------------
Adds error if |volume= or |issue= has what appears to be some form of redundant 'type' indicator.
For |volume=:
'V.', or 'Vol.' (with or without the dot) abbreviations or 'Volume' in the first characters of the parameter
content (all case insensitive). 'V' and 'v' (without the dot) are presumed to be roman numerals so
are allowed.
For |issue=:
'No.', 'I.', 'Iss.' (with or without the dot) abbreviations, or 'Issue' in the first characters of the
parameter content (all case insensitive).
Single character values ('v', 'i', 'n') allowed when not followed by separator character ('.', ':', '=', or
whitespace character) – param values are trimmed of whitespace by MediaWiki before delivered to the module.
<val> is |volume= or |issue= parameter value
<name> is |volume= or |issue= parameter name for error message
<selector> is 'v' for |volume=, 'i' for |issue=
sets error message on failure; returns nothing
]]
local function extra_text_in_vol_iss_check (val, name, selector)
if not utilities.is_set (val) then
return;
end
local patterns = 'v' == selector and cfg.vol_iss_pg_patterns.vpatterns or cfg.vol_iss_pg_patterns.ipatterns;
local handler = 'v' == selector and 'err_extra_text_volume' or 'err_extra_text_issue';
val = val:lower(); -- force parameter value to lower case
for _, pattern in ipairs (patterns) do -- spin through the selected sequence table of patterns
if val:match (pattern) then -- when a match, error so
utilities.set_message (handler, name); -- add error message
return; -- and done
end
end
end
--[=[-------------------------< G E T _ V _ N A M E _ T A B L E >----------------------------------------------
split apart a |vauthors= or |veditors= parameter. This function allows for corporate names, wrapped in doubled
parentheses to also have commas; in the old version of the code, the doubled parentheses were included in the
rendered citation and in the metadata. Individual author names may be wikilinked
|vauthors=Jones AB, [[E. B. White|White EB]], ((Black, Brown, and Co.))
]=]
local function get_v_name_table (vparam, output_table, output_link_table)
local name_table = mw.text.split(vparam, "%s*,%s*"); -- names are separated by commas
local wl_type, label, link; -- wl_type not used here; just a placeholder
local i = 1;
while name_table[i] do
if name_table[i]:match ('^%(%(.*[^%)][^%)]$') then -- first segment of corporate with one or more commas; this segment has the opening doubled parentheses
local name = name_table[i];
i = i + 1; -- bump indexer to next segment
while name_table[i] do
name = name .. ', ' .. name_table[i]; -- concatenate with previous segments
if name_table[i]:match ('^.*%)%)$') then -- if this table member has the closing doubled parentheses
break; -- and done reassembling so
end
i = i + 1; -- bump indexer
end
table.insert (output_table, name); -- and add corporate name to the output table
table.insert (output_link_table, ''); -- no wikilink
else
wl_type, label, link = utilities.is_wikilink (name_table[i]); -- wl_type is: 0, no wl (text in label variable); 1, [[D]]; 2, [[L|D]]
table.insert (output_table, label); -- add this name
if 1 == wl_type then
table.insert (output_link_table, label); -- simple wikilink [[D]]
else
table.insert (output_link_table, link); -- no wikilink or [[L|D]]; add this link if there is one, else empty string
end
end
i = i + 1;
end
return output_table;
end
--[[--------------------------< P A R S E _ V A U T H O R S _ V E D I T O R S >--------------------------------
This function extracts author / editor names from |vauthors= or |veditors= and finds matching |xxxxor-maskn= and
|xxxxor-linkn= in args. It then returns a table of assembled names just as extract_names() does.
Author / editor names in |vauthors= or |veditors= must be in Vancouver system style. Corporate or institutional names
may sometimes be required and because such names will often fail the is_good_vanc_name() and other format compliance
tests, are wrapped in doubled parentheses ((corporate name)) to suppress the format tests.
Supports generational suffixes Jr, 2nd, 3rd, 4th–6th.
This function sets the Vancouver error when a required comma is missing and when there is a space between an author's initials.
]]
local function parse_vauthors_veditors (args, vparam, list_name)
local names = {}; -- table of names assembled from |vauthors=, |author-maskn=, |author-linkn=
local v_name_table = {};
local v_link_table = {}; -- when name is wikilinked, targets go in this table
local etal = false; -- return value set to true when we find some form of et al. vauthors parameter
local last, first, link, mask, suffix;
local corporate = false;
vparam, etal = name_has_etal (vparam, etal, true); -- find and remove variations on et al. do not categorize (do it here because et al. might have a period)
v_name_table = get_v_name_table (vparam, v_name_table, v_link_table); -- names are separated by commas
for i, v_name in ipairs(v_name_table) do
first = ''; -- set to empty string for concatenation and because it may have been set for previous author/editor
local accept_name;
v_name, accept_name = utilities.has_accept_as_written (v_name); -- remove accept-this-as-written markup when it wraps all of <v_name>
if accept_name then
last = v_name;
corporate = true; -- flag used in list_people()
elseif string.find(v_name, "%s") then
if v_name:find('[;%.]') then -- look for commonly occurring punctuation characters;
add_vanc_error (cfg.err_msg_supl.punctuation, i);
end
local lastfirstTable = {}
lastfirstTable = mw.text.split(v_name, "%s+")
first = table.remove(lastfirstTable); -- removes and returns value of last element in table which should be initials or generational suffix
if not mw.ustring.match (first, '^%u+$') then -- mw.ustring here so that later we will catch non-Latin characters
suffix = first; -- not initials so assume that whatever we got is a generational suffix
first = table.remove(lastfirstTable); -- get what should be the initials from the table
end
last = table.concat(lastfirstTable, ' ') -- returns a string that is the concatenation of all other names that are not initials and generational suffix
if not utilities.is_set (last) then
first = ''; -- unset
last = v_name; -- last empty because something wrong with first
add_vanc_error (cfg.err_msg_supl.name, i);
end
if mw.ustring.match (last, '%a+%s+%u+%s+%a+') then
add_vanc_error (cfg.err_msg_supl['missing comma'], i); -- matches last II last; the case when a comma is missing
end
if mw.ustring.match (v_name, ' %u %u$') then -- this test is in the wrong place TODO: move or replace with a more appropriate test
add_vanc_error (cfg.err_msg_supl.initials, i); -- matches a space between two initials
end
else
last = v_name; -- last name or single corporate name? Doesn't support multiword corporate names? do we need this?
end
if utilities.is_set (first) then
if not mw.ustring.match (first, "^%u?%u$") then -- first shall contain one or two upper-case letters, nothing else
add_vanc_error (cfg.err_msg_supl.initials, i); -- too many initials; mixed case initials (which may be ok Romanization); hyphenated initials
end
is_good_vanc_name (last, first, suffix, i); -- check first and last before restoring the suffix which may have a non-Latin digit
if utilities.is_set (suffix) then
first = first .. ' ' .. suffix; -- if there was a suffix concatenate with the initials
suffix = ''; -- unset so we don't add this suffix to all subsequent names
end
else
if not corporate then
is_good_vanc_name (last, '', nil, i);
end
end
link = utilities.select_one ( args, cfg.aliases[list_name .. '-Link'], 'err_redundant_parameters', i ) or v_link_table[i];
mask = utilities.select_one ( args, cfg.aliases[list_name .. '-Mask'], 'err_redundant_parameters', i );
names[i] = {last = last, first = first, link = link, mask = mask, corporate = corporate}; -- add this assembled name to our names list
end
return names, etal; -- all done, return our list of names
end
--[[--------------------------< S E L E C T _ A U T H O R _ E D I T O R _ S O U R C E >------------------------
Select one of |authors=, |authorn= / |lastn / firstn=, or |vauthors= as the source of the author name list or
select one of |editorn= / editor-lastn= / |editor-firstn= or |veditors= as the source of the editor name list.
Only one of these appropriate three will be used. The hierarchy is: |authorn= (and aliases) highest and |authors= lowest;
|editorn= (and aliases) highest and |veditors= lowest (support for |editors= withdrawn)
When looking for |authorn= / |editorn= parameters, test |xxxxor1= and |xxxxor2= (and all of their aliases); stops after the second
test which mimicks the test used in extract_names() when looking for a hole in the author name list. There may be a better
way to do this, I just haven't discovered what that way is.
Emits an error message when more than one xxxxor name source is provided.
In this function, vxxxxors = vauthors or veditors; xxxxors = authors as appropriate.
]]
local function select_author_editor_source (vxxxxors, xxxxors, args, list_name)
local lastfirst = false;
if utilities.select_one ( args, cfg.aliases[list_name .. '-Last'], 'none', 1 ) or -- do this twice in case we have a |first1= without a |last1=; this ...
utilities.select_one ( args, cfg.aliases[list_name .. '-First'], 'none', 1 ) or -- ... also catches the case where |first= is used with |vauthors=
utilities.select_one ( args, cfg.aliases[list_name .. '-Last'], 'none', 2 ) or
utilities.select_one ( args, cfg.aliases[list_name .. '-First'], 'none', 2 ) then
lastfirst = true;
end
if (utilities.is_set (vxxxxors) and true == lastfirst) or -- these are the three error conditions
(utilities.is_set (vxxxxors) and utilities.is_set (xxxxors)) or
(true == lastfirst and utilities.is_set (xxxxors)) then
local err_name;
if 'AuthorList' == list_name then -- figure out which name should be used in error message
err_name = 'author';
else
err_name = 'editor';
end
utilities.set_message ('err_redundant_parameters', err_name .. '-name-list parameters'); -- add error message
end
if true == lastfirst then return 1 end; -- return a number indicating which author name source to use
if utilities.is_set (vxxxxors) then return 2 end;
if utilities.is_set (xxxxors) then return 3 end;
return 1; -- no authors so return 1; this allows missing author name test to run in case there is a first without last
end
--[[--------------------------< I S _ V A L I D _ P A R A M E T E R _ V A L U E >------------------------------
This function is used to validate a parameter's assigned value for those parameters that have only a limited number
of allowable values (yes, y, true, live, dead, etc.). When the parameter value has not been assigned a value (missing
or empty in the source template) the function returns the value specified by ret_val. If the parameter value is one
of the list of allowed values returns the translated value; else, emits an error message and returns the value
specified by ret_val.
TODO: explain <invert>
]]
local function is_valid_parameter_value (value, name, possible, ret_val, invert)
if not utilities.is_set (value) then
return ret_val; -- an empty parameter is ok
end
if (not invert and utilities.in_array (value, possible)) then -- normal; <value> is in <possible> table
return cfg.keywords_xlate[value]; -- return translation of parameter keyword
elseif invert and not utilities.in_array (value, possible) then -- invert; <value> is not in <possible> table
return value; -- return <value> as it is
else
utilities.set_message ('err_invalid_param_val', {name, value}); -- not an allowed value so add error message
return ret_val;
end
end
--[[--------------------------< T E R M I N A T E _ N A M E _ L I S T >----------------------------------------
This function terminates a name list (author, contributor, editor) with a separator character (sepc) and a space
when the last character is not a sepc character or when the last three characters are not sepc followed by two
closing square brackets (close of a wikilink). When either of these is true, the name_list is terminated with a
single space character.
]]
local function terminate_name_list (name_list, sepc)
if (string.sub (name_list, -3, -1) == sepc .. '. ') then -- if already properly terminated
return name_list; -- just return the name list
elseif (string.sub (name_list, -1, -1) == sepc) or (string.sub (name_list, -3, -1) == sepc .. ']]') then -- if last name in list ends with sepc char
return name_list .. " "; -- don't add another
else
return name_list .. sepc .. ' '; -- otherwise terminate the name list
end
end
--[[-------------------------< F O R M A T _ V O L U M E _ I S S U E >----------------------------------------
returns the concatenation of the formatted volume and issue parameters as a single string; or formatted volume
or formatted issue, or an empty string if neither are set.
]]
local function format_volume_issue (volume, issue, cite_class, origin, sepc, lower)
if not utilities.is_set (volume) and not utilities.is_set (issue) then
return '';
end
-- same condition as in format_pages_sheets()
local is_journal = 'journal' == cite_class or (utilities.in_array (cite_class, {'citation', 'map', 'interview'}) and 'journal' == origin);
local is_numeric_vol = volume and (volume:match ('^[MDCLXVI]+$') or volume:match ('^%d+$')); -- is only uppercase roman numerals or only digits?
local is_long_vol = volume and (4 < mw.ustring.len(volume)); -- is |volume= value longer than 4 characters?
if volume and (not is_numeric_vol and is_long_vol) then -- when not all digits or Roman numerals, is |volume= longer than 4 characters?
utilities.add_prop_cat ('long-vol'); -- yes, add properties cat
end
if is_journal then -- journal-style formatting
local vol = '';
if utilities.is_set (volume) then
if is_numeric_vol then -- |volume= value all digits or all uppercase Roman numerals?
vol = utilities.substitute (cfg.presentation['vol-bold'], {sepc, volume}); -- render in bold face
elseif is_long_vol then -- not all digits or Roman numerals; longer than 4 characters?
vol = utilities.substitute (cfg.messages['j-vol'], {sepc, utilities.hyphen_to_dash (volume)}); -- not bold
else -- four or fewer characters
vol = utilities.substitute (cfg.presentation['vol-bold'], {sepc, utilities.hyphen_to_dash (volume)}); -- bold
end
end
if utilities.is_set (issue) then
return vol .. utilities.substitute (cfg.messages['j-issue'], issue);
end
return vol;
end
if 'podcast' == cite_class and utilities.is_set (issue) then
return wrap_msg ('issue', {sepc, issue}, lower);
end
-- all other types of citation
if utilities.is_set (volume) and utilities.is_set (issue) then
return wrap_msg ('vol-no', {sepc, utilities.hyphen_to_dash (volume), issue}, lower);
elseif utilities.is_set (volume) then
return wrap_msg ('vol', {sepc, utilities.hyphen_to_dash (volume)}, lower);
else
return wrap_msg ('issue', {sepc, issue}, lower);
end
end
--[[-------------------------< F O R M A T _ P A G E S _ S H E E T S >-----------------------------------------
adds static text to one of |page(s)= or |sheet(s)= values and returns it with all of the others set to empty strings.
The return order is:
page, pages, sheet, sheets
Singular has priority over plural when both are provided.
]]
local function format_pages_sheets (page, pages, sheet, sheets, cite_class, origin, sepc, nopp, lower)
if 'map' == cite_class then -- only cite map supports sheet(s) as in-source locators
if utilities.is_set (sheet) then
if 'journal' == origin then
return '', '', wrap_msg ('j-sheet', sheet, lower), '';
else
return '', '', wrap_msg ('sheet', {sepc, sheet}, lower), '';
end
elseif utilities.is_set (sheets) then
if 'journal' == origin then
return '', '', '', wrap_msg ('j-sheets', sheets, lower);
else
return '', '', '', wrap_msg ('sheets', {sepc, sheets}, lower);
end
end
end
local is_journal = 'journal' == cite_class or (utilities.in_array (cite_class, {'citation', 'map', 'interview'}) and 'journal' == origin);
if utilities.is_set (page) then
if is_journal then
return utilities.substitute (cfg.messages['j-page(s)'], page), '', '', '';
elseif not nopp then
return utilities.substitute (cfg.messages['p-prefix'], {sepc, page}), '', '', '';
else
return utilities.substitute (cfg.messages['nopp'], {sepc, page}), '', '', '';
end
elseif utilities.is_set (pages) then
if is_journal then
return utilities.substitute (cfg.messages['j-page(s)'], pages), '', '', '';
elseif tonumber(pages) ~= nil and not nopp then -- if pages is only digits, assume a single page number
return '', utilities.substitute (cfg.messages['p-prefix'], {sepc, pages}), '', '';
elseif not nopp then
return '', utilities.substitute (cfg.messages['pp-prefix'], {sepc, pages}), '', '';
else
return '', utilities.substitute (cfg.messages['nopp'], {sepc, pages}), '', '';
end
end
return '', '', '', ''; -- return empty strings
end
--[[--------------------------< I N S O U R C E _ L O C _ G E T >----------------------------------------------
returns one of the in-source locators: page, pages, or at.
If any of these are interwiki links to Wikisource, returns the label portion of the interwiki-link as plain text
for use in COinS. This COinS thing is done because here we convert an interwiki-link to an external link and
add an icon span around that; get_coins_pages() doesn't know about the span. TODO: should it?
TODO: add support for sheet and sheets?; streamline;
TODO: make it so that this function returns only one of the three as the single in-source (the return value assigned
to a new name)?
]]
local function insource_loc_get (page, page_orig, pages, pages_orig, at)
local ws_url, ws_label, coins_pages, L; -- for Wikisource interwiki-links; TODO: this corrupts page metadata (span remains in place after cleanup; fix there?)
if utilities.is_set (page) then
if utilities.is_set (pages) or utilities.is_set (at) then
pages = ''; -- unset the others
at = '';
end
extra_text_in_page_check (page, page_orig); -- emit error message when |page= value begins with what looks like p., pp., etc.
ws_url, ws_label, L = wikisource_url_make (page); -- make ws URL from |page= interwiki link; link portion L becomes tooltip label
if ws_url then
page = external_link (ws_url, ws_label .. ' ', 'ws link in page'); -- space char after label to move icon away from in-source text; TODO: a better way to do this?
page = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, page});
coins_pages = ws_label;
end
elseif utilities.is_set (pages) then
if utilities.is_set (at) then
at = ''; -- unset
end
extra_text_in_page_check (pages, pages_orig); -- emit error message when |page= value begins with what looks like p., pp., etc.
ws_url, ws_label, L = wikisource_url_make (pages); -- make ws URL from |pages= interwiki link; link portion L becomes tooltip label
if ws_url then
pages = external_link (ws_url, ws_label .. ' ', 'ws link in pages'); -- space char after label to move icon away from in-source text; TODO: a better way to do this?
pages = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, pages});
coins_pages = ws_label;
end
elseif utilities.is_set (at) then
ws_url, ws_label, L = wikisource_url_make (at); -- make ws URL from |at= interwiki link; link portion L becomes tooltip label
if ws_url then
at = external_link (ws_url, ws_label .. ' ', 'ws link in at'); -- space char after label to move icon away from in-source text; TODO: a better way to do this?
at = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, at});
coins_pages = ws_label;
end
end
return page, pages, at, coins_pages;
end
--[[--------------------------< I S _ U N I Q U E _ A R C H I V E _ U R L >------------------------------------
add error message when |archive-url= value is same as |url= or chapter-url= (or alias...) value
]]
local function is_unique_archive_url (archive, url, c_url, source, date)
if utilities.is_set (archive) then
if archive == url or archive == c_url then
utilities.set_message ('err_bad_url', {utilities.wrap_style ('parameter', source)}); -- add error message
return '', ''; -- unset |archive-url= and |archive-date= because same as |url= or |chapter-url=
end
end
return archive, date;
end
--[=[-------------------------< A R C H I V E _ U R L _ C H E C K >--------------------------------------------
Check archive.org URLs to make sure they at least look like they are pointing at valid archives and not to the
save snapshot URL or to calendar pages. When the archive URL is 'https://web.archive.org/save/' (or http://...)
archive.org saves a snapshot of the target page in the URL. That is something that Wikipedia should not allow
unwitting readers to do.
When the archive.org URL does not have a complete timestamp, archive.org chooses a snapshot according to its own
algorithm or provides a calendar 'search' result. [[WP:ELNO]] discourages links to search results.
This function looks at the value assigned to |archive-url= and returns empty strings for |archive-url= and
|archive-date= and an error message when:
|archive-url= holds an archive.org save command URL
|archive-url= is an archive.org URL that does not have a complete timestamp (YYYYMMDDhhmmss 14 digits) in the
correct place
otherwise returns |archive-url= and |archive-date=
There are two mostly compatible archive.org URLs:
//web.archive.org/<timestamp>... -- the old form
//web.archive.org/web/<timestamp>... -- the new form
The old form does not support or map to the new form when it contains a display flag. There are four identified flags
('id_', 'js_', 'cs_', 'im_') but since archive.org ignores others following the same form (two letters and an underscore)
we don't check for these specific flags but we do check the form.
This function supports a preview mode. When the article is rendered in preview mode, this function may return a modified
archive URL:
for save command errors, return undated wildcard (/*/)
for timestamp errors when the timestamp has a wildcard, return the URL unmodified
for timestamp errors when the timestamp does not have a wildcard, return with timestamp limited to six digits plus wildcard (/yyyymm*/)
]=]
local function archive_url_check (url, date)
local err_msg = ''; -- start with the error message empty
local path, timestamp, flag; -- portions of the archive.org URL
if (not url:match('//web%.archive%.org/')) and (not url:match('//liveweb%.archive%.org/')) then -- also deprecated liveweb Wayback machine URL
return url, date; -- not an archive.org archive, return ArchiveURL and ArchiveDate
end
if url:match('//web%.archive%.org/save/') then -- if a save command URL, we don't want to allow saving of the target page
err_msg = cfg.err_msg_supl.save;
url = url:gsub ('(//web%.archive%.org)/save/', '%1/*/', 1); -- for preview mode: modify ArchiveURL
elseif url:match('//liveweb%.archive%.org/') then
err_msg = cfg.err_msg_supl.liveweb;
else
path, timestamp, flag = url:match('//web%.archive%.org/([^%d]*)(%d+)([^/]*)/'); -- split out some of the URL parts for evaluation
if not path then -- malformed in some way; pattern did not match
err_msg = cfg.err_msg_supl.timestamp;
elseif 14 ~= timestamp:len() then -- path and flag optional, must have 14-digit timestamp here
err_msg = cfg.err_msg_supl.timestamp;
if '*' ~= flag then
local replacement = timestamp:match ('^%d%d%d%d%d%d') or timestamp:match ('^%d%d%d%d'); -- get the first 6 (YYYYMM) or first 4 digits (YYYY)
if replacement then -- nil if there aren't at least 4 digits (year)
replacement = replacement .. string.rep ('0', 14 - replacement:len()); -- year or yearmo (4 or 6 digits) zero-fill to make 14-digit timestamp
url=url:gsub ('(//web%.archive%.org/[^%d]*)%d[^/]*', '%1' .. replacement .. '*', 1) -- for preview, modify ts to 14 digits plus splat for calendar display
end
end
elseif utilities.is_set (path) and 'web/' ~= path then -- older archive URLs do not have the extra 'web/' path element
err_msg = cfg.err_msg_supl.path;
elseif utilities.is_set (flag) and not utilities.is_set (path) then -- flag not allowed with the old form URL (without the 'web/' path element)
err_msg = cfg.err_msg_supl.flag;
elseif utilities.is_set (flag) and not flag:match ('%a%a_') then -- flag if present must be two alpha characters and underscore (requires 'web/' path element)
err_msg = cfg.err_msg_supl.flag;
else
return url, date; -- return ArchiveURL and ArchiveDate
end
end
-- if here, something not right so
utilities.set_message ('err_archive_url', {err_msg}); -- add error message and
if is_preview_mode then
return url, date; -- preview mode so return ArchiveURL and ArchiveDate
else
return '', ''; -- return empty strings for ArchiveURL and ArchiveDate
end
end
--[[--------------------------< P L A C E _ C H E C K >--------------------------------------------------------
check |place=, |publication-place=, |location= to see if these params include digits. This function added because
many editors misuse location to specify the in-source location (|page(s)= and |at= are supposed to do that)
returns the original parameter value without modification; added maint cat when parameter value contains digits
]]
local function place_check (param_val)
if not utilities.is_set (param_val) then -- parameter empty or omitted
return param_val; -- return that empty state
end
if mw.ustring.find (param_val, '%d') then -- not empty, are there digits in the parameter value
utilities.set_message ('maint_location'); -- yep, add maint cat
end
return param_val; -- and done
end
--[[--------------------------< I S _ A R C H I V E D _ C O P Y >----------------------------------------------
compares |title= to 'Archived copy' (placeholder added by bots that can't find proper title); if matches, return true; nil else
]]
local function is_archived_copy (title)
title = mw.ustring.lower(title); -- switch title to lower case
if title:find (cfg.special_case_translation.archived_copy.en) then -- if title is 'Archived copy'
return true;
elseif cfg.special_case_translation.archived_copy['local'] then
if mw.ustring.find (title, cfg.special_case_translation.archived_copy['local']) then -- mw.ustring() because might not be Latin script
return true;
end
end
end
--[[--------------------------< C I T A T I O N 0 >------------------------------------------------------------
This is the main function doing the majority of the citation formatting.
]]
local function citation0( config, args )
--[[
Load Input Parameters
The argument_wrapper facilitates the mapping of multiple aliases to single internal variable.
]]
local A = argument_wrapper ( args );
local i
-- Pick out the relevant fields from the arguments. Different citation templates
-- define different field names for the same underlying things.
local author_etal;
local a = {}; -- authors list from |lastn= / |firstn= pairs or |vauthors=
local Authors;
local NameListStyle = is_valid_parameter_value (A['NameListStyle'], A:ORIGIN('NameListStyle'), cfg.keywords_lists['name-list-style'], '');
local Collaboration = A['Collaboration'];
do -- to limit scope of selected
local selected = select_author_editor_source (A['Vauthors'], A['Authors'], args, 'AuthorList');
if 1 == selected then
a, author_etal = extract_names (args, 'AuthorList'); -- fetch author list from |authorn= / |lastn= / |firstn=, |author-linkn=, and |author-maskn=
elseif 2 == selected then
NameListStyle = 'vanc'; -- override whatever |name-list-style= might be
a, author_etal = parse_vauthors_veditors (args, args.vauthors, 'AuthorList'); -- fetch author list from |vauthors=, |author-linkn=, and |author-maskn=
elseif 3 == selected then
Authors = A['Authors']; -- use content of |authors=
if 'authors' == A:ORIGIN('Authors') then -- but add a maint cat if the parameter is |authors=
utilities.set_message ('maint_authors'); -- because use of this parameter is discouraged; what to do about the aliases is a TODO:
end
end
if utilities.is_set (Collaboration) then
author_etal = true; -- so that |display-authors=etal not required
end
end
local editor_etal;
local e = {}; -- editors list from |editor-lastn= / |editor-firstn= pairs or |veditors=
do -- to limit scope of selected
local selected = select_author_editor_source (A['Veditors'], nil, args, 'EditorList'); -- support for |editors= withdrawn
if 1 == selected then
e, editor_etal = extract_names (args, 'EditorList'); -- fetch editor list from |editorn= / |editor-lastn= / |editor-firstn=, |editor-linkn=, and |editor-maskn=
elseif 2 == selected then
NameListStyle = 'vanc'; -- override whatever |name-list-style= might be
e, editor_etal = parse_vauthors_veditors (args, args.veditors, 'EditorList'); -- fetch editor list from |veditors=, |editor-linkn=, and |editor-maskn=
end
end
local Chapter = A['Chapter']; -- done here so that we have access to |contribution= from |chapter= aliases
local Chapter_origin = A:ORIGIN ('Chapter');
local Contribution; -- because contribution is required for contributor(s)
if 'contribution' == Chapter_origin then
Contribution = Chapter; -- get the name of the contribution
end
local c = {}; -- contributors list from |contributor-lastn= / contributor-firstn= pairs
if utilities.in_array (config.CitationClass, {"book", "citation"}) and not utilities.is_set (A['Periodical']) then -- |contributor= and |contribution= only supported in book cites
c = extract_names (args, 'ContributorList'); -- fetch contributor list from |contributorn= / |contributor-lastn=, -firstn=, -linkn=, -maskn=
if 0 < #c then
if not utilities.is_set (Contribution) then -- |contributor= requires |contribution=
utilities.set_message ('err_contributor_missing_required_param', 'contribution'); -- add missing contribution error message
c = {}; -- blank the contributors' table; it is used as a flag later
end
if 0 == #a then -- |contributor= requires |author=
utilities.set_message ('err_contributor_missing_required_param', 'author'); -- add missing author error message
c = {}; -- blank the contributors' table; it is used as a flag later
end
end
else -- if not a book cite
if utilities.select_one (args, cfg.aliases['ContributorList-Last'], 'err_redundant_parameters', 1 ) then -- are there contributor name list parameters?
utilities.set_message ('err_contributor_ignored'); -- add contributor ignored error message
end
Contribution = nil; -- unset
end
local Title = A['Title'];
local TitleLink = A['TitleLink'];
local auto_select = ''; -- default is auto
local accept_link;
TitleLink, accept_link = utilities.has_accept_as_written (TitleLink, true); -- test for accept-this-as-written markup
if (not accept_link) and utilities.in_array (TitleLink, {'none', 'pmc', 'doi'}) then -- check for special keywords
auto_select = TitleLink; -- remember selection for later
TitleLink = ''; -- treat as if |title-link= would have been empty
end
TitleLink = link_title_ok (TitleLink, A:ORIGIN ('TitleLink'), Title, 'title'); -- check for wiki-markup in |title-link= or wiki-markup in |title= when |title-link= is set
local Section = ''; -- {{cite map}} only; preset to empty string for concatenation if not used
if 'map' == config.CitationClass and 'section' == Chapter_origin then
Section = A['Chapter']; -- get |section= from |chapter= alias list; |chapter= and the other aliases not supported in {{cite map}}
Chapter = ''; -- unset for now; will be reset later from |map= if present
end
local Periodical = A['Periodical'];
local Periodical_origin = '';
if utilities.is_set (Periodical) then
Periodical_origin = A:ORIGIN('Periodical'); -- get the name of the periodical parameter
local i;
Periodical, i = utilities.strip_apostrophe_markup (Periodical); -- strip apostrophe markup so that metadata isn't contaminated
if i then -- non-zero when markup was stripped so emit an error message
utilities.set_message ('err_apostrophe_markup', {Periodical_origin});
end
end
if 'mailinglist' == config.CitationClass then -- special case for {{cite mailing list}}
if utilities.is_set (Periodical) and utilities.is_set (A ['MailingList']) then -- both set emit an error TODO: make a function for this and similar?
utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', Periodical_origin) .. ' และ ' .. utilities.wrap_style ('parameter', 'mailinglist')});
end
Periodical = A ['MailingList']; -- error or no, set Periodical to |mailinglist= value because this template is {{cite mailing list}}
Periodical_origin = A:ORIGIN('MailingList');
end
local ScriptPeriodical = A['ScriptPeriodical'];
-- web and news not tested for now because of
-- Wikipedia:Administrators%27_noticeboard#Is_there_a_semi-automated_tool_that_could_fix_these_annoying_"Cite_Web"_errors?
if not (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) then -- 'periodical' templates require periodical parameter
-- local p = {['journal'] = 'journal', ['magazine'] = 'magazine', ['news'] = 'newspaper', ['web'] = 'website'}; -- for error message
local p = {['journal'] = 'journal', ['magazine'] = 'magazine'}; -- for error message
if p[config.CitationClass] then
utilities.set_message ('err_missing_periodical', {config.CitationClass, p[config.CitationClass]});
end
end
local Volume;
local ScriptPeriodical_origin = A:ORIGIN('ScriptPeriodical');
if 'citation' == config.CitationClass then
if utilities.is_set (Periodical) then
if not utilities.in_array (Periodical_origin, cfg.citation_no_volume_t) then -- {{citation}} does not render |volume= when these parameters are used
Volume = A['Volume']; -- but does for all other 'periodicals'
end
elseif utilities.is_set (ScriptPeriodical) then
if 'script-website' ~= ScriptPeriodical_origin then -- {{citation}} does not render volume for |script-website=
Volume = A['Volume']; -- but does for all other 'periodicals'
end
else
Volume = A['Volume']; -- and does for non-'periodical' cites
end
elseif utilities.in_array (config.CitationClass, cfg.templates_using_volume) then -- render |volume= for cs1 according to the configuration settings
Volume = A['Volume'];
end
extra_text_in_vol_iss_check (Volume, A:ORIGIN ('Volume'), 'v');
local Issue;
if 'citation' == config.CitationClass then
if utilities.is_set (Periodical) and utilities.in_array (Periodical_origin, cfg.citation_issue_t) then -- {{citation}} may render |issue= when these parameters are used
Issue = utilities.hyphen_to_dash (A['Issue']);
end
elseif utilities.in_array (config.CitationClass, cfg.templates_using_issue) then -- conference & map books do not support issue; {{citation}} listed here because included in settings table
if not (utilities.in_array (config.CitationClass, {'conference', 'map', 'citation'}) and not (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical))) then
Issue = utilities.hyphen_to_dash (A['Issue']);
end
end
extra_text_in_vol_iss_check (Issue, A:ORIGIN ('Issue'), 'i');
local Page;
local Pages;
local At;
if not utilities.in_array (config.CitationClass, cfg.templates_not_using_page) then
Page = A['Page'];
Pages = utilities.hyphen_to_dash (A['Pages']);
At = A['At'];
end
local Edition = A['Edition'];
local PublicationPlace = place_check (A['PublicationPlace'], A:ORIGIN('PublicationPlace'));
local Place = place_check (A['Place'], A:ORIGIN('Place'));
local PublisherName = A['PublisherName'];
local PublisherName_origin = A:ORIGIN('PublisherName');
if utilities.is_set (PublisherName) then
local i = 0;
PublisherName, i = utilities.strip_apostrophe_markup (PublisherName); -- strip apostrophe markup so that metadata isn't contaminated; publisher is never italicized
if i then -- non-zero when markup was stripped so emit an error message
utilities.set_message ('err_apostrophe_markup', {PublisherName_origin});
end
end
local Newsgroup = A['Newsgroup']; -- TODO: strip apostrophe markup?
local Newsgroup_origin = A:ORIGIN('Newsgroup');
if 'newsgroup' == config.CitationClass then
if utilities.is_set (PublisherName) then -- general use parameter |publisher= not allowed in cite newsgroup
utilities.set_message ('err_parameter_ignored', {PublisherName_origin});
end
PublisherName = nil; -- ensure that this parameter is unset for the time being; will be used again after COinS
end
local URL = A['URL']; -- TODO: better way to do this for URL, ChapterURL, and MapURL?
local UrlAccess = is_valid_parameter_value (A['UrlAccess'], A:ORIGIN('UrlAccess'), cfg.keywords_lists['url-access'], nil);
if not utilities.is_set (URL) and utilities.is_set (UrlAccess) then
UrlAccess = nil;
utilities.set_message ('err_param_access_requires_param', 'url');
end
local ChapterURL = A['ChapterURL'];
local ChapterUrlAccess = is_valid_parameter_value (A['ChapterUrlAccess'], A:ORIGIN('ChapterUrlAccess'), cfg.keywords_lists['url-access'], nil);
if not utilities.is_set (ChapterURL) and utilities.is_set (ChapterUrlAccess) then
ChapterUrlAccess = nil;
utilities.set_message ('err_param_access_requires_param', {A:ORIGIN('ChapterUrlAccess'):gsub ('%-access', '')});
end
local MapUrlAccess = is_valid_parameter_value (A['MapUrlAccess'], A:ORIGIN('MapUrlAccess'), cfg.keywords_lists['url-access'], nil);
if not utilities.is_set (A['MapURL']) and utilities.is_set (MapUrlAccess) then
MapUrlAccess = nil;
utilities.set_message ('err_param_access_requires_param', {'map-url'});
end
local this_page = mw.title.getCurrentTitle(); -- also used for COinS and for language
local no_tracking_cats = is_valid_parameter_value (A['NoTracking'], A:ORIGIN('NoTracking'), cfg.keywords_lists['yes_true_y'], nil);
-- check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories
if not utilities.is_set (no_tracking_cats) then -- ignore if we are already not going to categorize this page
if utilities.in_array (this_page.nsText, cfg.uncategorized_namespaces) then
no_tracking_cats = "true"; -- set no_tracking_cats
end
for _, v in ipairs (cfg.uncategorized_subpages) do -- cycle through page name patterns
if this_page.text:match (v) then -- test page name against each pattern
no_tracking_cats = "true"; -- set no_tracking_cats
break; -- bail out if one is found
end
end
end
-- check for extra |page=, |pages= or |at= parameters. (also sheet and sheets while we're at it)
utilities.select_one (args, {'page', 'p', 'pp', 'pages', 'at', 'sheet', 'sheets'}, 'err_redundant_parameters'); -- this is a dummy call simply to get the error message and category
local coins_pages;
Page, Pages, At, coins_pages = insource_loc_get (Page, A:ORIGIN('Page'), Pages, A:ORIGIN('Pages'), At);
local NoPP = is_valid_parameter_value (A['NoPP'], A:ORIGIN('NoPP'), cfg.keywords_lists['yes_true_y'], nil);
if utilities.is_set (PublicationPlace) and utilities.is_set (Place) then -- both |publication-place= and |place= (|location=) allowed if different
utilities.add_prop_cat ('location-test'); -- add property cat to evaluate how often PublicationPlace and Place are used together
if PublicationPlace == Place then
Place = ''; -- unset; don't need both if they are the same
end
elseif not utilities.is_set (PublicationPlace) and utilities.is_set (Place) then -- when only |place= (|location=) is set ...
PublicationPlace = Place; -- promote |place= (|location=) to |publication-place
end
if PublicationPlace == Place then Place = ''; end -- don't need both if they are the same
local URL_origin = A:ORIGIN('URL'); -- get name of parameter that holds URL
local ChapterURL_origin = A:ORIGIN('ChapterURL'); -- get name of parameter that holds ChapterURL
local ScriptChapter = A['ScriptChapter'];
local ScriptChapter_origin = A:ORIGIN ('ScriptChapter');
local Format = A['Format'];
local ChapterFormat = A['ChapterFormat'];
local TransChapter = A['TransChapter'];
local TransChapter_origin = A:ORIGIN ('TransChapter');
local TransTitle = A['TransTitle'];
local ScriptTitle = A['ScriptTitle'];
--[[
Parameter remapping for cite encyclopedia:
When the citation has these parameters:
|encyclopedia= and |title= then map |title= to |article= and |encyclopedia= to |title=
|encyclopedia= and |article= then map |encyclopedia= to |title=
|trans-title= maps to |trans-chapter= when |title= is re-mapped
|url= maps to |chapter-url= when |title= is remapped
All other combinations of |encyclopedia=, |title=, and |article= are not modified
]]
local Encyclopedia = A['Encyclopedia']; -- used as a flag by this module and by ~/COinS
if utilities.is_set (Encyclopedia) then -- emit error message when Encyclopedia set but template is other than {{cite encyclopedia}} or {{citation}}
if 'encyclopaedia' ~= config.CitationClass and 'citation' ~= config.CitationClass then
utilities.set_message ('err_parameter_ignored', {A:ORIGIN ('Encyclopedia')});
Encyclopedia = nil; -- unset because not supported by this template
end
end
if ('encyclopaedia' == config.CitationClass) or ('citation' == config.CitationClass and utilities.is_set (Encyclopedia)) then
if utilities.is_set (Periodical) and utilities.is_set (Encyclopedia) then -- when both set emit an error TODO: make a function for this and similar?
utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', A:ORIGIN ('Encyclopedia')) .. ' และ ' .. utilities.wrap_style ('parameter', Periodical_origin)});
end
if utilities.is_set (Encyclopedia) then
Periodical = Encyclopedia; -- error or no, set Periodical to Encyclopedia; allow periodical without encyclopedia
Periodical_origin = A:ORIGIN ('Encyclopedia');
end
if utilities.is_set (Periodical) then -- Periodical is set when |encyclopedia= is set
if utilities.is_set (Title) or utilities.is_set (ScriptTitle) then
if not utilities.is_set (Chapter) then
Chapter = Title; -- |encyclopedia= and |title= are set so map |title= to |article= and |encyclopedia= to |title=
ScriptChapter = ScriptTitle;
ScriptChapter_origin = A:ORIGIN('ScriptTitle')
TransChapter = TransTitle;
ChapterURL = URL;
ChapterURL_origin = URL_origin;
ChapterUrlAccess = UrlAccess;
if not utilities.is_set (ChapterURL) and utilities.is_set (TitleLink) then
Chapter = utilities.make_wikilink (TitleLink, Chapter);
end
Title = Periodical;
ChapterFormat = Format;
Periodical = ''; -- redundant so unset
TransTitle = '';
URL = '';
Format = '';
TitleLink = '';
ScriptTitle = '';
end
elseif utilities.is_set (Chapter) or utilities.is_set (ScriptChapter) then -- |title= not set
Title = Periodical; -- |encyclopedia= set and |article= set so map |encyclopedia= to |title=
Periodical = ''; -- redundant so unset
end
end
end
-- special case for cite techreport.
local ID = A['ID'];
if (config.CitationClass == "techreport") then -- special case for cite techreport
if utilities.is_set (A['Number']) then -- cite techreport uses 'number', which other citations alias to 'issue'
if not utilities.is_set (ID) then -- can we use ID for the "number"?
ID = A['Number']; -- yes, use it
else -- ID has a value so emit error message
utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', 'id') .. ' และ ' .. utilities.wrap_style ('parameter', 'number')});
end
end
end
-- Account for the oddity that is {{cite conference}}, before generation of COinS data.
local ChapterLink -- = A['ChapterLink']; -- deprecated as a parameter but still used internally by cite episode
local Conference = A['Conference'];
local BookTitle = A['BookTitle'];
local TransTitle_origin = A:ORIGIN ('TransTitle');
if 'conference' == config.CitationClass then
if utilities.is_set (BookTitle) then
Chapter = Title;
Chapter_origin = 'title';
-- ChapterLink = TitleLink; -- |chapter-link= is deprecated
ChapterURL = URL;
ChapterUrlAccess = UrlAccess;
ChapterURL_origin = URL_origin;
URL_origin = '';
ChapterFormat = Format;
TransChapter = TransTitle;
TransChapter_origin = TransTitle_origin;
Title = BookTitle;
Format = '';
-- TitleLink = '';
TransTitle = '';
URL = '';
end
elseif 'speech' ~= config.CitationClass then
Conference = ''; -- not cite conference or cite speech so make sure this is empty string
end
-- CS1/2 mode
local Mode = is_valid_parameter_value (A['Mode'], A:ORIGIN('Mode'), cfg.keywords_lists['mode'], '');
-- separator character and postscript
local sepc, PostScript = set_style (Mode:lower(), A['PostScript'], config.CitationClass);
-- controls capitalization of certain static text
local use_lowercase = ( sepc == ',' );
-- cite map oddities
local Cartography = "";
local Scale = "";
local Sheet = A['Sheet'] or '';
local Sheets = A['Sheets'] or '';
if config.CitationClass == "map" then
if utilities.is_set (Chapter) then --TODO: make a function for this and similar?
utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', 'map') .. ' และ ' .. utilities.wrap_style ('parameter', Chapter_origin)}); -- add error message
end
Chapter = A['Map'];
Chapter_origin = A:ORIGIN('Map');
ChapterURL = A['MapURL'];
ChapterURL_origin = A:ORIGIN('MapURL');
TransChapter = A['TransMap'];
ScriptChapter = A['ScriptMap']
ScriptChapter_origin = A:ORIGIN('ScriptMap')
ChapterUrlAccess = MapUrlAccess;
ChapterFormat = A['MapFormat'];
Cartography = A['Cartography'];
if utilities.is_set ( Cartography ) then
Cartography = sepc .. " " .. wrap_msg ('cartography', Cartography, use_lowercase);
end
Scale = A['Scale'];
if utilities.is_set ( Scale ) then
Scale = sepc .. " " .. Scale;
end
end
-- Account for the oddities that are {{cite episode}} and {{cite serial}}, before generation of COinS data.
local Series = A['Series'];
if 'episode' == config.CitationClass or 'serial' == config.CitationClass then
local SeriesLink = A['SeriesLink'];
SeriesLink = link_title_ok (SeriesLink, A:ORIGIN ('SeriesLink'), Series, 'series'); -- check for wiki-markup in |series-link= or wiki-markup in |series= when |series-link= is set
local Network = A['Network'];
local Station = A['Station'];
local s, n = {}, {};
-- do common parameters first
if utilities.is_set (Network) then table.insert(n, Network); end
if utilities.is_set (Station) then table.insert(n, Station); end
ID = table.concat(n, sepc .. ' ');
if 'episode' == config.CitationClass then -- handle the oddities that are strictly {{cite episode}}
local Season = A['Season'];
local SeriesNumber = A['SeriesNumber'];
if utilities.is_set (Season) and utilities.is_set (SeriesNumber) then -- these are mutually exclusive so if both are set TODO: make a function for this and similar?
utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', 'season') .. ' และ ' .. utilities.wrap_style ('parameter', 'seriesno')}); -- add error message
SeriesNumber = ''; -- unset; prefer |season= over |seriesno=
end
-- assemble a table of parts concatenated later into Series
if utilities.is_set (Season) then table.insert(s, wrap_msg ('season', Season, use_lowercase)); end
if utilities.is_set (SeriesNumber) then table.insert(s, wrap_msg ('seriesnum', SeriesNumber, use_lowercase)); end
if utilities.is_set (Issue) then table.insert(s, wrap_msg ('episode', Issue, use_lowercase)); end
Issue = ''; -- unset because this is not a unique parameter
Chapter = Title; -- promote title parameters to chapter
ScriptChapter = ScriptTitle;
ScriptChapter_origin = A:ORIGIN('ScriptTitle');
ChapterLink = TitleLink; -- alias |episode-link=
TransChapter = TransTitle;
ChapterURL = URL;
ChapterUrlAccess = UrlAccess;
ChapterURL_origin = URL_origin;
ChapterFormat = Format;
Title = Series; -- promote series to title
TitleLink = SeriesLink;
Series = table.concat(s, sepc .. ' '); -- this is concatenation of season, seriesno, episode number
if utilities.is_set (ChapterLink) and not utilities.is_set (ChapterURL) then -- link but not URL
Chapter = utilities.make_wikilink (ChapterLink, Chapter);
elseif utilities.is_set (ChapterLink) and utilities.is_set (ChapterURL) then -- if both are set, URL links episode;
Series = utilities.make_wikilink (ChapterLink, Series);
end
URL = ''; -- unset
TransTitle = '';
ScriptTitle = '';
Format = '';
else -- now oddities that are cite serial
Issue = ''; -- unset because this parameter no longer supported by the citation/core version of cite serial
Chapter = A['Episode']; -- TODO: make |episode= available to cite episode someday?
if utilities.is_set (Series) and utilities.is_set (SeriesLink) then
Series = utilities.make_wikilink (SeriesLink, Series);
end
Series = utilities.wrap_style ('italic-title', Series); -- series is italicized
end
end
-- end of {{cite episode}} stuff
-- handle type parameter for those CS1 citations that have default values
local TitleType = A['TitleType'];
local Degree = A['Degree'];
if utilities.in_array (config.CitationClass, {'AV-media-notes', 'interview', 'mailinglist', 'map', 'podcast', 'pressrelease', 'report', 'speech', 'techreport', 'thesis'}) then
TitleType = set_titletype (config.CitationClass, TitleType);
if utilities.is_set (Degree) and "Thesis" == TitleType then -- special case for cite thesis
TitleType = Degree .. ' ' .. cfg.title_types ['thesis']:lower();
end
end
if utilities.is_set (TitleType) then -- if type parameter is specified
TitleType = utilities.substitute ( cfg.messages['type'], TitleType); -- display it in parentheses
-- TODO: Hack on TitleType to fix bunched parentheses problem
end
-- legacy: promote PublicationDate to Date if neither Date nor Year are set.
local Date = A['Date'];
local Date_origin; -- to hold the name of parameter promoted to Date; required for date error messaging
local PublicationDate = A['PublicationDate'];
local Year = A['Year'];
if not utilities.is_set (Date) then
Date = Year; -- promote Year to Date
Year = nil; -- make nil so Year as empty string isn't used for CITEREF
if not utilities.is_set (Date) and utilities.is_set (PublicationDate) then -- use PublicationDate when |date= and |year= are not set
Date = PublicationDate; -- promote PublicationDate to Date
PublicationDate = ''; -- unset, no longer needed
Date_origin = A:ORIGIN('PublicationDate'); -- save the name of the promoted parameter
else
Date_origin = A:ORIGIN('Year'); -- save the name of the promoted parameter
end
else
Date_origin = A:ORIGIN('Date'); -- not a promotion; name required for error messaging
end
if PublicationDate == Date then PublicationDate = ''; end -- if PublicationDate is same as Date, don't display in rendered citation
--[[
Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates. This must be done before we do COinS because here is where
we get the date used in the metadata.
Date validation supporting code is in Module:Citation/CS1/Date_validation
]]
local DF = is_valid_parameter_value (A['DF'], A:ORIGIN('DF'), cfg.keywords_lists['df'], '');
if not utilities.is_set (DF) then
DF = cfg.global_df; -- local |df= if present overrides global df set by {{use xxx date}} template
end
local ArchiveURL;
local ArchiveDate;
local ArchiveFormat = A['ArchiveFormat'];
ArchiveURL, ArchiveDate = archive_url_check (A['ArchiveURL'], A['ArchiveDate'])
ArchiveFormat = style_format (ArchiveFormat, ArchiveURL, 'archive-format', 'archive-url');
ArchiveURL, ArchiveDate = is_unique_archive_url (ArchiveURL, URL, ChapterURL, A:ORIGIN('ArchiveURL'), ArchiveDate); -- add error message when URL or ChapterURL == ArchiveURL
local AccessDate = A['AccessDate'];
local LayDate = A['LayDate'];
local COinS_date = {}; -- holds date info extracted from |date= for the COinS metadata by Module:Date verification
local DoiBroken = A['DoiBroken'];
local Embargo = A['Embargo'];
local anchor_year; -- used in the CITEREF identifier
do -- create defined block to contain local variables error_message, date_parameters_list, mismatch
local error_message = '';
-- AirDate has been promoted to Date so not necessary to check it
local date_parameters_list = {
['access-date'] = {val = AccessDate, name = A:ORIGIN ('AccessDate')},
['archive-date'] = {val = ArchiveDate, name = A:ORIGIN ('ArchiveDate')},
['date'] = {val = Date, name = Date_origin},
['doi-broken-date'] = {val = DoiBroken, name = A:ORIGIN ('DoiBroken')},
['pmc-embargo-date'] = {val = Embargo, name = A:ORIGIN ('Embargo')},
['lay-date'] = {val = LayDate, name = A:ORIGIN ('LayDate')},
['publication-date'] = {val = PublicationDate, name = A:ORIGIN ('PublicationDate')},
['year'] = {val = Year, name = A:ORIGIN ('Year')},
};
local error_list = {};
anchor_year, Embargo = validation.dates(date_parameters_list, COinS_date, error_list);
-- start temporary Julian / Gregorian calendar uncertainty categorization
if COinS_date.inter_cal_cat then
utilities.add_prop_cat ('jul-greg-uncertainty');
end
-- end temporary Julian / Gregorian calendar uncertainty categorization
if utilities.is_set (Year) and utilities.is_set (Date) then -- both |date= and |year= not normally needed;
validation.year_date_check (Year, A:ORIGIN ('Year'), Date, A:ORIGIN ('Date'), error_list);
end
if 0 == #error_list then -- error free dates only; 0 when error_list is empty
local modified = false; -- flag
if utilities.is_set (DF) then -- if we need to reformat dates
modified = validation.reformat_dates (date_parameters_list, DF); -- reformat to DF format, use long month names if appropriate
end
if true == validation.date_hyphen_to_dash (date_parameters_list) then -- convert hyphens to dashes where appropriate
modified = true;
utilities.set_message ('maint_date_format'); -- hyphens were converted so add maint category
end
-- for those wikis that can and want to have English date names translated to the local language; not supported at en.wiki
if cfg.date_name_auto_xlate_enable and validation.date_name_xlate (date_parameters_list, cfg.date_digit_auto_xlate_enable ) then
utilities.set_message ('maint_date_auto_xlated'); -- add maint cat
modified = true;
end
if modified then -- if the date_parameters_list values were modified
AccessDate = date_parameters_list['access-date'].val; -- overwrite date holding parameters with modified values
ArchiveDate = date_parameters_list['archive-date'].val;
Date = date_parameters_list['date'].val;
DoiBroken = date_parameters_list['doi-broken-date'].val;
LayDate = date_parameters_list['lay-date'].val;
PublicationDate = date_parameters_list['publication-date'].val;
end
else
utilities.set_message ('err_bad_date', {utilities.make_sep_list (#error_list, error_list)}); -- add this error message
end
end -- end of do
local ID_list = {}; -- sequence table of rendered identifiers
local ID_list_coins = {}; -- table of identifiers and their values from args; key is same as cfg.id_handlers's key
local Class = A['Class']; -- arxiv class identifier
local ID_support = {
{A['ASINTLD'], 'ASIN', 'err_asintld_missing_asin', A:ORIGIN ('ASINTLD')},
{DoiBroken, 'DOI', 'err_doibroken_missing_doi', A:ORIGIN ('DoiBroken')},
{Embargo, 'PMC', 'err_embargo_missing_pmc', A:ORIGIN ('Embargo')},
}
ID_list, ID_list_coins = identifiers.identifier_lists_get (args, {DoiBroken = DoiBroken, ASINTLD = A['ASINTLD'], Embargo = Embargo, Class = Class}, ID_support);
-- Account for the oddities that are {{cite arxiv}}, {{cite biorxiv}}, {{cite citeseerx}}, {{cite ssrn}}, before generation of COinS data.
if utilities.in_array (config.CitationClass, whitelist.preprint_template_list) then
if not utilities.is_set (ID_list_coins[config.CitationClass:upper()]) then -- |arxiv= or |eprint= required for cite arxiv; |biorxiv= & |citeseerx= required for their templates
utilities.set_message ('err_' .. config.CitationClass .. '_missing'); -- add error message
end
Periodical = ({['arxiv'] = 'arXiv', ['biorxiv'] = 'bioRxiv', ['citeseerx'] = 'CiteSeerX', ['ssrn'] = 'Social Science Research Network'})[config.CitationClass];
end
-- Link the title of the work if no |url= was provided, but we have a |pmc= or a |doi= with |doi-access=free
if config.CitationClass == "journal" and not utilities.is_set (URL) and not utilities.is_set (TitleLink) and not utilities.in_array (cfg.keywords_xlate[Title], {'off', 'none'}) then -- TODO: remove 'none' once existing citations have been switched to 'off', so 'none' can be used as token for "no title" instead
if 'none' ~= cfg.keywords_xlate[auto_select] then -- if auto-linking not disabled
if identifiers.auto_link_urls[auto_select] then -- manual selection
URL = identifiers.auto_link_urls[auto_select]; -- set URL to be the same as identifier's external link
URL_origin = cfg.id_handlers[auto_select:upper()].parameters[1]; -- set URL_origin to parameter name for use in error message if citation is missing a |title=
elseif identifiers.auto_link_urls['pmc'] then -- auto-select PMC
URL = identifiers.auto_link_urls['pmc']; -- set URL to be the same as the PMC external link if not embargoed
URL_origin = cfg.id_handlers['PMC'].parameters[1]; -- set URL_origin to parameter name for use in error message if citation is missing a |title=
elseif identifiers.auto_link_urls['doi'] then -- auto-select DOI
URL = identifiers.auto_link_urls['doi'];
URL_origin = cfg.id_handlers['DOI'].parameters[1];
end
end
if utilities.is_set (URL) then -- set when using an identifier-created URL
if utilities.is_set (AccessDate) then -- |access-date= requires |url=; identifier-created URL is not |url=
utilities.set_message ('err_accessdate_missing_url'); -- add an error message
AccessDate = ''; -- unset
end
if utilities.is_set (ArchiveURL) then -- |archive-url= requires |url=; identifier-created URL is not |url=
utilities.set_message ('err_archive_missing_url'); -- add an error message
ArchiveURL = ''; -- unset
end
end
end
-- At this point fields may be nil if they weren't specified in the template use. We can use that fact.
-- Test if citation has no title
if not utilities.is_set (Title) and not utilities.is_set (TransTitle) and not utilities.is_set (ScriptTitle) then -- has special case for cite episode
utilities.set_message ('err_citation_missing_title', {'episode' == config.CitationClass and 'series' or 'title'});
end
if utilities.in_array (cfg.keywords_xlate[Title], {'off', 'none'}) and
utilities.in_array (config.CitationClass, {'journal', 'citation'}) and
(utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and
('journal' == Periodical_origin or 'script-journal' == ScriptPeriodical_origin) then -- special case for journal cites
Title = ''; -- set title to empty string
utilities.set_message ('maint_untitled'); -- add maint cat
end
-- COinS metadata (see <http://ocoins.info/>) for automated parsing of citation information.
-- handle the oddity that is cite encyclopedia and {{citation |encyclopedia=something}}. Here we presume that
-- when Periodical, Title, and Chapter are all set, then Periodical is the book (encyclopedia) title, Title
-- is the article title, and Chapter is a section within the article. So, we remap
local coins_chapter = Chapter; -- default assuming that remapping not required
local coins_title = Title; -- et tu
if 'encyclopaedia' == config.CitationClass or ('citation' == config.CitationClass and utilities.is_set (Encyclopedia)) then
if utilities.is_set (Chapter) and utilities.is_set (Title) and utilities.is_set (Periodical) then -- if all are used then
coins_chapter = Title; -- remap
coins_title = Periodical;
end
end
local coins_author = a; -- default for coins rft.au
if 0 < #c then -- but if contributor list
coins_author = c; -- use that instead
end
local QuotePage = A['QuotePage'];
local QuotePages = utilities.hyphen_to_dash (A['QuotePages']);
-- this is the function call to COinS()
local OCinSoutput = metadata.COinS({
['Periodical'] = utilities.strip_apostrophe_markup (Periodical), -- no markup in the metadata
['Encyclopedia'] = Encyclopedia, -- just a flag; content ignored by ~/COinS
['Chapter'] = metadata.make_coins_title (coins_chapter, ScriptChapter), -- Chapter and ScriptChapter stripped of bold / italic / accept-as-written markup
['Degree'] = Degree; -- cite thesis only
['Title'] = metadata.make_coins_title (coins_title, ScriptTitle), -- Title and ScriptTitle stripped of bold / italic / accept-as-written markup
['PublicationPlace'] = PublicationPlace,
['Date'] = COinS_date.rftdate, -- COinS_date has correctly formatted date if Date is valid;
['Season'] = COinS_date.rftssn,
['Quarter'] = COinS_date.rftquarter,
['Chron'] = COinS_date.rftchron or (not COinS_date.rftdate and Date) or '', -- chron but if not set and invalid date format use Date; keep this last bit?
['Series'] = Series,
['Volume'] = Volume,
['Issue'] = Issue,
['Pages'] = coins_pages or metadata.get_coins_pages (first_set ({Sheet, Sheets, Page, Pages, At, QuotePage, QuotePages}, 7)), -- pages stripped of external links
['Edition'] = Edition,
['PublisherName'] = PublisherName or Newsgroup, -- any apostrophe markup already removed from PublisherName
['URL'] = first_set ({ChapterURL, URL}, 2),
['Authors'] = coins_author,
['ID_list'] = ID_list_coins,
['RawPage'] = this_page.prefixedText,
}, config.CitationClass);
-- Account for the oddities that are {{cite arxiv}}, {{cite biorxiv}}, {{cite citeseerx}}, and {{cite ssrn}} AFTER generation of COinS data.
if utilities.in_array (config.CitationClass, whitelist.preprint_template_list) then -- we have set rft.jtitle in COinS to arXiv, bioRxiv, CiteSeerX, or ssrn now unset so it isn't displayed
Periodical = ''; -- periodical not allowed in these templates; if article has been published, use cite journal
end
-- special case for cite newsgroup. Do this after COinS because we are modifying Publishername to include some static text
if 'newsgroup' == config.CitationClass and utilities.is_set (Newsgroup) then
PublisherName = utilities.substitute (cfg.messages['newsgroup'], external_link( 'news:' .. Newsgroup, Newsgroup, Newsgroup_origin, nil ));
end
local Editors;
local EditorCount; -- used only for choosing {ed.) or (eds.) annotation at end of editor name-list
local Contributors; -- assembled contributors name list
local contributor_etal;
local Translators; -- assembled translators name list
local translator_etal;
local t = {}; -- translators list from |translator-lastn= / translator-firstn= pairs
t = extract_names (args, 'TranslatorList'); -- fetch translator list from |translatorn= / |translator-lastn=, -firstn=, -linkn=, -maskn=
local Interviewers;
local interviewers_list = {};
interviewers_list = extract_names (args, 'InterviewerList'); -- process preferred interviewers parameters
local interviewer_etal;
-- Now perform various field substitutions.
-- We also add leading spaces and surrounding markup and punctuation to the
-- various parts of the citation, but only when they are non-nil.
do
local last_first_list;
local control = {
format = NameListStyle, -- empty string or 'vanc'
maximum = nil, -- as if display-authors or display-editors not set
mode = Mode
};
do -- do editor name list first because the now unsupported coauthors used to modify control table
control.maximum , editor_etal = get_display_names (A['DisplayEditors'], #e, 'editors', editor_etal, A:ORIGIN ('DisplayEditors'));
Editors, EditorCount = list_people (control, e, editor_etal);
if 1 == EditorCount and (true == editor_etal or 1 < #e) then -- only one editor displayed but includes etal then
EditorCount = 2; -- spoof to display (eds.) annotation
end
end
do -- now do interviewers
control.maximum, interviewer_etal = get_display_names (A['DisplayInterviewers'], #interviewers_list, 'interviewers', interviewer_etal, A:ORIGIN ('DisplayInterviewers'));
Interviewers = list_people (control, interviewers_list, interviewer_etal);
end
do -- now do translators
control.maximum, translator_etal = get_display_names (A['DisplayTranslators'], #t, 'translators', translator_etal, A:ORIGIN ('DisplayTranslators'));
Translators = list_people (control, t, translator_etal);
end
do -- now do contributors
control.maximum, contributor_etal = get_display_names (A['DisplayContributors'], #c, 'contributors', contributor_etal, A:ORIGIN ('DisplayContributors'));
Contributors = list_people (control, c, contributor_etal);
end
do -- now do authors
control.maximum, author_etal = get_display_names (A['DisplayAuthors'], #a, 'authors', author_etal, A:ORIGIN ('DisplayAuthors'));
last_first_list = list_people (control, a, author_etal);
if utilities.is_set (Authors) then
Authors, author_etal = name_has_etal (Authors, author_etal, false, 'authors'); -- find and remove variations on et al.
if author_etal then
Authors = Authors .. ' ' .. cfg.messages['et al']; -- add et al. to authors parameter
end
else
Authors = last_first_list; -- either an author name list or an empty string
end
end -- end of do
if utilities.is_set (Authors) and utilities.is_set (Collaboration) then
Authors = Authors .. ' (' .. Collaboration .. ')'; -- add collaboration after et al.
end
end
local ConferenceFormat = A['ConferenceFormat'];
local ConferenceURL = A['ConferenceURL'];
ConferenceFormat = style_format (ConferenceFormat, ConferenceURL, 'conference-format', 'conference-url');
Format = style_format (Format, URL, 'format', 'url');
-- special case for chapter format so no error message or cat when chapter not supported
if not (utilities.in_array (config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) or
('citation' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and not utilities.is_set (Encyclopedia))) then
ChapterFormat = style_format (ChapterFormat, ChapterURL, 'chapter-format', 'chapter-url');
end
if not utilities.is_set (URL) then
if utilities.in_array (config.CitationClass, {"web", "podcast", "mailinglist"}) or -- |url= required for cite web, cite podcast, and cite mailinglist
('citation' == config.CitationClass and ('website' == Periodical_origin or 'script-website' == ScriptPeriodical_origin)) then -- and required for {{citation}} with |website= or |script-website=
utilities.set_message ('err_cite_web_url');
end
-- do we have |accessdate= without either |url= or |chapter-url=?
if utilities.is_set (AccessDate) and not utilities.is_set (ChapterURL) then -- ChapterURL may be set when URL is not set;
utilities.set_message ('err_accessdate_missing_url');
AccessDate = '';
end
end
local UrlStatus = is_valid_parameter_value (A['UrlStatus'], A:ORIGIN('UrlStatus'), cfg.keywords_lists['url-status'], '');
local OriginalURL
local OriginalURL_origin
local OriginalFormat
local OriginalAccess;
UrlStatus = UrlStatus:lower(); -- used later when assembling archived text
if utilities.is_set ( ArchiveURL ) then
if utilities.is_set (ChapterURL) then -- if chapter-url= is set apply archive url to it
OriginalURL = ChapterURL; -- save copy of source chapter's url for archive text
OriginalURL_origin = ChapterURL_origin; -- name of |chapter-url= parameter for error messages
OriginalFormat = ChapterFormat; -- and original |chapter-format=
if 'live' ~= UrlStatus then
ChapterURL = ArchiveURL -- swap-in the archive's URL
ChapterURL_origin = A:ORIGIN('ArchiveURL') -- name of |archive-url= parameter for error messages
ChapterFormat = ArchiveFormat or ''; -- swap in archive's format
ChapterUrlAccess = nil; -- restricted access levels do not make sense for archived URLs
end
elseif utilities.is_set (URL) then
OriginalURL = URL; -- save copy of original source URL
OriginalURL_origin = URL_origin; -- name of URL parameter for error messages
OriginalFormat = Format; -- and original |format=
OriginalAccess = UrlAccess;
if 'live' ~= UrlStatus then -- if URL set then |archive-url= applies to it
URL = ArchiveURL -- swap-in the archive's URL
URL_origin = A:ORIGIN('ArchiveURL') -- name of archive URL parameter for error messages
Format = ArchiveFormat or ''; -- swap in archive's format
UrlAccess = nil; -- restricted access levels do not make sense for archived URLs
end
end
elseif utilities.is_set (UrlStatus) then -- if |url-status= is set when |archive-url= is not set
utilities.set_message ('maint_url_status'); -- add maint cat
end
if utilities.in_array (config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) or -- if any of the 'periodical' cites except encyclopedia
('citation' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and not utilities.is_set (Encyclopedia)) then
local chap_param;
if utilities.is_set (Chapter) then -- get a parameter name from one of these chapter related meta-parameters
chap_param = A:ORIGIN ('Chapter')
elseif utilities.is_set (TransChapter) then
chap_param = A:ORIGIN ('TransChapter')
elseif utilities.is_set (ChapterURL) then
chap_param = A:ORIGIN ('ChapterURL')
elseif utilities.is_set (ScriptChapter) then
chap_param = ScriptChapter_origin;
else utilities.is_set (ChapterFormat)
chap_param = A:ORIGIN ('ChapterFormat')
end
if utilities.is_set (chap_param) then -- if we found one
utilities.set_message ('err_chapter_ignored', {chap_param}); -- add error message
Chapter = ''; -- and set them to empty string to be safe with concatenation
TransChapter = '';
ChapterURL = '';
ScriptChapter = '';
ChapterFormat = '';
end
else -- otherwise, format chapter / article title
local no_quotes = false; -- default assume that we will be quoting the chapter parameter value
if utilities.is_set (Contribution) and 0 < #c then -- if this is a contribution with contributor(s)
if utilities.in_array (Contribution:lower(), cfg.keywords_lists.contribution) then -- and a generic contribution title
no_quotes = true; -- then render it unquoted
end
end
Chapter = format_chapter_title (ScriptChapter, ScriptChapter_origin, Chapter, Chapter_origin, TransChapter, TransChapter_origin, ChapterURL, ChapterURL_origin, no_quotes, ChapterUrlAccess); -- Contribution is also in Chapter
if utilities.is_set (Chapter) then
Chapter = Chapter .. ChapterFormat ;
if 'map' == config.CitationClass and utilities.is_set (TitleType) then
Chapter = Chapter .. ' ' .. TitleType; -- map annotation here; not after title
end
Chapter = Chapter .. sepc .. ' ';
elseif utilities.is_set (ChapterFormat) then -- |chapter= not set but |chapter-format= is so ...
Chapter = ChapterFormat .. sepc .. ' '; -- ... ChapterFormat has error message, we want to see it
end
end
-- Format main title
local plain_title = false;
local accept_title;
Title, accept_title = utilities.has_accept_as_written (Title, true); -- remove accept-this-as-written markup when it wraps all of <Title>
if accept_title and ('' == Title) then -- only support forced empty for now "(())"
Title = cfg.messages['notitle']; -- replace by predefined "No title" message
-- TODO: utilities.set_message ( 'err_redundant_parameters', ...); -- issue proper error message instead of muting
ScriptTitle = ''; -- just mute for now
TransTitle = ''; -- just mute for now
plain_title = true; -- suppress text decoration for descriptive title
utilities.set_message ('maint_untitled'); -- add maint cat
end
if not accept_title then -- <Title> not wrapped in accept-as-written markup
if '...' == Title:sub (-3) then -- if ellipsis is the last three characters of |title=
Title = Title:gsub ('(%.%.%.)%.+$', '%1'); -- limit the number of dots to three
elseif not mw.ustring.find (Title, '%.%s*%a%.$') and -- end of title is not a 'dot-(optional space-)letter-dot' initialism ...
not mw.ustring.find (Title, '%s+%a%.$') then -- ...and not a 'space-letter-dot' initial (''Allium canadense'' L.)
Title = mw.ustring.gsub(Title, '%' .. sepc .. '$', ''); -- remove any trailing separator character; sepc and ms.ustring() here for languages that use multibyte separator characters
end
if utilities.is_set (ArchiveURL) and is_archived_copy (Title) then
utilities.set_message ('maint_archived_copy'); -- add maintenance category before we modify the content of Title
end
if is_generic ('generic_titles', Title) then
utilities.set_message ('err_generic_title'); -- set an error message
end
end
if (not plain_title) and (utilities.in_array (config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'mailinglist', 'interview', 'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) or
('citation' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and not utilities.is_set (Encyclopedia)) or
('map' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)))) then -- special case for cite map when the map is in a periodical treat as an article
Title = kern_quotes (Title); -- if necessary, separate title's leading and trailing quote marks from module provided quote marks
Title = utilities.wrap_style ('quoted-title', Title);
Title = script_concatenate (Title, ScriptTitle, 'script-title'); -- <bdi> tags, lang attribute, categorization, etc.; must be done after title is wrapped
TransTitle = utilities.wrap_style ('trans-quoted-title', TransTitle );
elseif plain_title or ('report' == config.CitationClass) then -- no styling for cite report and descriptive titles (otherwise same as above)
Title = script_concatenate (Title, ScriptTitle, 'script-title'); -- <bdi> tags, lang attribute, categorization, etc.; must be done after title is wrapped
TransTitle = utilities.wrap_style ('trans-quoted-title', TransTitle ); -- for cite report, use this form for trans-title
else
Title = utilities.wrap_style ('italic-title', Title);
Title = script_concatenate (Title, ScriptTitle, 'script-title'); -- <bdi> tags, lang attribute, categorization, etc.; must be done after title is wrapped
TransTitle = utilities.wrap_style ('trans-italic-title', TransTitle);
end
if utilities.is_set (TransTitle) then
if utilities.is_set (Title) then
TransTitle = " " .. TransTitle;
else
utilities.set_message ('err_trans_missing_title', {'title'});
end
end
if utilities.is_set (Title) then -- TODO: is this the right place to be making Wikisource URLs?
if utilities.is_set (TitleLink) and utilities.is_set (URL) then
utilities.set_message ('err_wikilink_in_url'); -- set an error message because we can't have both
TitleLink = ''; -- unset
end
if not utilities.is_set (TitleLink) and utilities.is_set (URL) then
Title = external_link (URL, Title, URL_origin, UrlAccess) .. TransTitle .. Format;
URL = ''; -- unset these because no longer needed
Format = "";
elseif utilities.is_set (TitleLink) and not utilities.is_set (URL) then
local ws_url;
ws_url = wikisource_url_make (TitleLink); -- ignore ws_label return; not used here
if ws_url then
Title = external_link (ws_url, Title .. ' ', 'ws link in title-link'); -- space char after Title to move icon away from italic text; TODO: a better way to do this?
Title = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], TitleLink, Title});
Title = Title .. TransTitle;
else
Title = utilities.make_wikilink (TitleLink, Title) .. TransTitle;
end
else
local ws_url, ws_label, L; -- Title has italic or quote markup by the time we get here which causes is_wikilink() to return 0 (not a wikilink)
ws_url, ws_label, L = wikisource_url_make (Title:gsub('^[\'"]*(.-)[\'"]*$', '%1')); -- make ws URL from |title= interwiki link (strip italic or quote markup); link portion L becomes tooltip label
if ws_url then
Title = Title:gsub ('%b[]', ws_label); -- replace interwiki link with ws_label to retain markup
Title = external_link (ws_url, Title .. ' ', 'ws link in title'); -- space char after Title to move icon away from italic text; TODO: a better way to do this?
Title = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, Title});
Title = Title .. TransTitle;
else
Title = Title .. TransTitle;
end
end
else
Title = TransTitle;
end
if utilities.is_set (Place) then
Place = " " .. wrap_msg ('written', Place, use_lowercase) .. sepc .. " ";
end
local ConferenceURL_origin = A:ORIGIN('ConferenceURL'); -- get name of parameter that holds ConferenceURL
if utilities.is_set (Conference) then
if utilities.is_set (ConferenceURL) then
Conference = external_link( ConferenceURL, Conference, ConferenceURL_origin, nil );
end
Conference = sepc .. " " .. Conference .. ConferenceFormat;
elseif utilities.is_set (ConferenceURL) then
Conference = sepc .. " " .. external_link( ConferenceURL, nil, ConferenceURL_origin, nil );
end
local Position = '';
if not utilities.is_set (Position) then
local Minutes = A['Minutes'];
local Time = A['Time'];
if utilities.is_set (Minutes) then
if utilities.is_set (Time) then --TODO: make a function for this and similar?
utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', 'minutes') .. ' และ ' .. utilities.wrap_style ('parameter', 'time')});
end
Position = " " .. Minutes .. " " .. cfg.messages['minutes'];
else
if utilities.is_set (Time) then
local TimeCaption = A['TimeCaption']
if not utilities.is_set (TimeCaption) then
TimeCaption = cfg.messages['event'];
if sepc ~= '.' then
TimeCaption = TimeCaption:lower();
end
end
Position = " " .. TimeCaption .. " " .. Time;
end
end
else
Position = " " .. Position;
At = '';
end
Page, Pages, Sheet, Sheets = format_pages_sheets (Page, Pages, Sheet, Sheets, config.CitationClass, Periodical_origin, sepc, NoPP, use_lowercase);
At = utilities.is_set (At) and (sepc .. " " .. At) or "";
Position = utilities.is_set (Position) and (sepc .. " " .. Position) or "";
if config.CitationClass == 'map' then
local Sections = A['Sections']; -- Section (singular) is an alias of Chapter so set earlier
local Inset = A['Inset'];
if utilities.is_set ( Inset ) then
Inset = sepc .. " " .. wrap_msg ('inset', Inset, use_lowercase);
end
if utilities.is_set ( Sections ) then
Section = sepc .. " " .. wrap_msg ('sections', Sections, use_lowercase);
elseif utilities.is_set ( Section ) then
Section = sepc .. " " .. wrap_msg ('section', Section, use_lowercase);
end
At = At .. Inset .. Section;
end
local Others = A['Others'];
if utilities.is_set (Others) and 0 == #a and 0 == #e then -- add maint cat when |others= has value and used without |author=, |editor=
if config.CitationClass == "AV-media-notes"
or config.CitationClass == "audio-visual" then -- special maint for AV/M which has a lot of 'false' positives right now
utilities.set_message ('maint_others_avm')
else
utilities.set_message ('maint_others');
end
end
Others = utilities.is_set (Others) and (sepc .. " " .. Others) or "";
if utilities.is_set (Translators) then
Others = safe_join ({sepc .. ' ', wrap_msg ('translated', Translators, use_lowercase), Others}, sepc);
end
if utilities.is_set (Interviewers) then
Others = safe_join ({sepc .. ' ', wrap_msg ('interview', Interviewers, use_lowercase), Others}, sepc);
end
local TitleNote = A['TitleNote'];
TitleNote = utilities.is_set (TitleNote) and (sepc .. " " .. TitleNote) or "";
if utilities.is_set (Edition) then
if Edition:match ('%f[%a][Ee]d%n?%.?$') or Edition:match ('%f[%a][Ee]dition$') then -- Ed, ed, Ed., ed., Edn, edn, Edn., edn.
utilities.set_message ('err_extra_text_edition'); -- add error message
end
Edition = " " .. wrap_msg ('edition', Edition);
else
Edition = '';
end
Series = utilities.is_set (Series) and wrap_msg ('series', {sepc, Series}) or ""; -- not the same as SeriesNum
local Agency = A['Agency'];
Agency = utilities.is_set (Agency) and wrap_msg ('agency', {sepc, Agency}) or "";
Volume = format_volume_issue (Volume, Issue, config.CitationClass, Periodical_origin, sepc, use_lowercase);
if utilities.is_set (AccessDate) then
local retrv_text = " " .. cfg.messages['retrieved']
AccessDate = nowrap_date (AccessDate); -- wrap in nowrap span if date in appropriate format
if (sepc ~= ".") then retrv_text = retrv_text:lower() end -- if mode is cs2, lower case
AccessDate = utilities.substitute (retrv_text, AccessDate); -- add retrieved text
AccessDate = utilities.substitute (cfg.presentation['accessdate'], {sepc, AccessDate}); -- allow editors to hide accessdates
end
if utilities.is_set (ID) then ID = sepc .. " " .. ID; end
local Docket = A['Docket'];
if "thesis" == config.CitationClass and utilities.is_set (Docket) then
ID = sepc .. " Docket " .. Docket .. ID;
end
if "report" == config.CitationClass and utilities.is_set (Docket) then -- for cite report when |docket= is set
ID = sepc .. ' ' .. Docket; -- overwrite ID even if |id= is set
end
if utilities.is_set (URL) then
URL = " " .. external_link( URL, nil, URL_origin, UrlAccess );
end
local Quote = A['Quote'];
local TransQuote = A['TransQuote'];
local ScriptQuote = A['ScriptQuote'];
if utilities.is_set (Quote) or utilities.is_set (TransQuote) or utilities.is_set (ScriptQuote) then
if utilities.is_set (Quote) then
if Quote:sub(1, 1) == '"' and Quote:sub(-1, -1) == '"' then -- if first and last characters of quote are quote marks
Quote = Quote:sub(2, -2); -- strip them off
end
end
Quote = utilities.wrap_style ('quoted-text', Quote ); -- wrap in <q>...</q> tags
if utilities.is_set (ScriptQuote) then
Quote = script_concatenate (Quote, ScriptQuote, 'script-quote'); -- <bdi> tags, lang attribute, categorization, etc.; must be done after quote is wrapped
end
if utilities.is_set (TransQuote) then
if TransQuote:sub(1, 1) == '"' and TransQuote:sub(-1, -1) == '"' then -- if first and last characters of |trans-quote are quote marks
TransQuote = TransQuote:sub(2, -2); -- strip them off
end
Quote = Quote .. " " .. utilities.wrap_style ('trans-quoted-title', TransQuote );
end
if utilities.is_set (QuotePage) or utilities.is_set (QuotePages) then -- add page prefix
local quote_prefix = '';
if utilities.is_set (QuotePage) then
extra_text_in_page_check (QuotePage, 'quote-page'); -- add to maint cat if |quote-page= value begins with what looks like p., pp., etc.
if not NoPP then
quote_prefix = utilities.substitute (cfg.messages['p-prefix'], {sepc, QuotePage}), '', '', '';
else
quote_prefix = utilities.substitute (cfg.messages['nopp'], {sepc, QuotePage}), '', '', '';
end
elseif utilities.is_set (QuotePages) then
extra_text_in_page_check (QuotePages, 'quote-pages'); -- add to maint cat if |quote-pages= value begins with what looks like p., pp., etc.
if tonumber(QuotePages) ~= nil and not NoPP then -- if only digits, assume single page
quote_prefix = utilities.substitute (cfg.messages['p-prefix'], {sepc, QuotePages}), '', '';
elseif not NoPP then
quote_prefix = utilities.substitute (cfg.messages['pp-prefix'], {sepc, QuotePages}), '', '';
else
quote_prefix = utilities.substitute (cfg.messages['nopp'], {sepc, QuotePages}), '', '';
end
end
Quote = quote_prefix .. ": " .. Quote;
else
Quote = sepc .. " " .. Quote;
end
PostScript = ""; -- cs1|2 does not supply terminal punctuation when |quote= is set
end
-- We check length of PostScript here because it will have been nuked by
-- the quote parameters. We'd otherwise emit a message even if there wasn't
-- a displayed postscript.
-- TODO: Should the max size (1) be configurable?
-- TODO: Should we check a specific pattern?
if utilities.is_set(PostScript) and mw.ustring.len(PostScript) > 1 then
utilities.set_message ('maint_postscript')
end
local Archived;
if utilities.is_set (ArchiveURL) then
local arch_text;
if not utilities.is_set (ArchiveDate) then
utilities.set_message ('err_archive_missing_date');
ArchiveDate = ''; -- empty string for concatenation
end
if "live" == UrlStatus then
arch_text = cfg.messages['archived'];
if sepc ~= "." then arch_text = arch_text:lower() end
if utilities.is_set (ArchiveDate) then
Archived = sepc .. ' ' .. utilities.substitute ( cfg.messages['archived-live'],
{external_link( ArchiveURL, arch_text, A:ORIGIN('ArchiveURL'), nil) .. ArchiveFormat, ArchiveDate } );
else
Archived = '';
end
if not utilities.is_set (OriginalURL) then
utilities.set_message ('err_archive_missing_url');
Archived = ''; -- empty string for concatenation
end
elseif utilities.is_set (OriginalURL) then -- UrlStatus is empty, 'dead', 'unfit', 'usurped', 'bot: unknown'
if utilities.in_array (UrlStatus, {'unfit', 'usurped', 'bot: unknown'}) then
arch_text = cfg.messages['archived-unfit'];
if sepc ~= "." then arch_text = arch_text:lower() end
Archived = sepc .. ' ' .. arch_text .. ArchiveDate; -- format already styled
if 'bot: unknown' == UrlStatus then
utilities.set_message ('maint_bot_unknown'); -- and add a category if not already added
else
utilities.set_message ('maint_unfit'); -- and add a category if not already added
end
else -- UrlStatus is empty, 'dead'
arch_text = cfg.messages['archived-dead'];
if sepc ~= "." then arch_text = arch_text:lower() end
if utilities.is_set (ArchiveDate) then
Archived = sepc .. " " .. utilities.substitute ( arch_text,
{ external_link( OriginalURL, cfg.messages['original'], OriginalURL_origin, OriginalAccess ) .. OriginalFormat, ArchiveDate } ); -- format already styled
else
Archived = ''; -- unset for concatenation
end
end
else -- OriginalUrl not set
arch_text = cfg.messages['archived-missing'];
if sepc ~= "." then arch_text = arch_text:lower() end
utilities.set_message ('err_archive_missing_url');
Archived = ''; -- empty string for concatenation
end
elseif utilities.is_set (ArchiveFormat) then
Archived = ArchiveFormat; -- if set and ArchiveURL not set ArchiveFormat has error message
else
Archived = '';
end
local Lay = '';
local LaySource = A['LaySource'];
local LayURL = A['LayURL'];
local LayFormat = A['LayFormat'];
LayFormat = style_format (LayFormat, LayURL, 'lay-format', 'lay-url');
if utilities.is_set (LayURL) then
if utilities.is_set (LayDate) then LayDate = " (" .. LayDate .. ")" end
if utilities.is_set (LaySource) then
LaySource = " – ''" .. utilities.safe_for_italics (LaySource) .. "''";
else
LaySource = "";
end
if sepc == '.' then
Lay = sepc .. " " .. external_link( LayURL, cfg.messages['lay summary'], A:ORIGIN('LayURL'), nil ) .. LayFormat .. LaySource .. LayDate
else
Lay = sepc .. " " .. external_link( LayURL, cfg.messages['lay summary']:lower(), A:ORIGIN('LayURL'), nil ) .. LayFormat .. LaySource .. LayDate
end
elseif utilities.is_set (LayFormat) then -- Test if |lay-format= is given without giving a |lay-url=
Lay = sepc .. LayFormat; -- if set and LayURL not set, then LayFormat has error message
end
local TranscriptURL = A['TranscriptURL']
local TranscriptFormat = A['TranscriptFormat'];
TranscriptFormat = style_format (TranscriptFormat, TranscriptURL, 'transcript-format', 'transcripturl');
local Transcript = A['Transcript'];
local TranscriptURL_origin = A:ORIGIN('TranscriptURL'); -- get name of parameter that holds TranscriptURL
if utilities.is_set (Transcript) then
if utilities.is_set (TranscriptURL) then
Transcript = external_link( TranscriptURL, Transcript, TranscriptURL_origin, nil );
end
Transcript = sepc .. ' ' .. Transcript .. TranscriptFormat;
elseif utilities.is_set (TranscriptURL) then
Transcript = external_link( TranscriptURL, nil, TranscriptURL_origin, nil );
end
local Publisher;
if utilities.is_set (PublicationDate) then
PublicationDate = wrap_msg ('published', PublicationDate);
end
if utilities.is_set (PublisherName) then
if utilities.is_set (PublicationPlace) then
Publisher = sepc .. " " .. PublicationPlace .. ": " .. PublisherName .. PublicationDate;
else
Publisher = sepc .. " " .. PublisherName .. PublicationDate;
end
elseif utilities.is_set (PublicationPlace) then
Publisher= sepc .. " " .. PublicationPlace .. PublicationDate;
else
Publisher = PublicationDate;
end
local TransPeriodical = A['TransPeriodical'];
local TransPeriodical_origin = A:ORIGIN ('TransPeriodical');
-- Several of the above rely upon detecting this as nil, so do it last.
if (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical) or utilities.is_set (TransPeriodical)) then
if utilities.is_set (Title) or utilities.is_set (TitleNote) then
Periodical = sepc .. " " .. format_periodical (ScriptPeriodical, ScriptPeriodical_origin, Periodical, TransPeriodical, TransPeriodical_origin);
else
Periodical = format_periodical (ScriptPeriodical, ScriptPeriodical_origin, Periodical, TransPeriodical, TransPeriodical_origin);
end
end
local Language = A['Language'];
if utilities.is_set (Language) then
Language = language_parameter (Language); -- format, categories, name from ISO639-1, etc.
else
Language=''; -- language not specified so make sure this is an empty string;
--[[ TODO: need to extract the wrap_msg from language_parameter
so that we can solve parentheses bunching problem with Format/Language/TitleType
]]
end
--[[
Handle the oddity that is cite speech. This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be " (Speech)" so that
the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
]]
if "speech" == config.CitationClass then -- cite speech only
TitleNote = TitleType; -- move TitleType to TitleNote so that it renders ahead of |event=
TitleType = ''; -- and unset
if utilities.is_set (Periodical) then -- if Periodical, perhaps because of an included |website= or |journal= parameter
if utilities.is_set (Conference) then -- and if |event= is set
Conference = Conference .. sepc .. " "; -- then add appropriate punctuation to the end of the Conference variable before rendering
end
end
end
-- Piece all bits together at last. Here, all should be non-nil.
-- We build things this way because it is more efficient in LUA
-- not to keep reassigning to the same string variable over and over.
local tcommon;
local tcommon2; -- used for book cite when |contributor= is set
if utilities.in_array (config.CitationClass, {"journal", "citation"}) and utilities.is_set (Periodical) then
if utilities.is_set (Others) then Others = safe_join ({Others, sepc .. " "}, sepc) end -- add terminal punctuation & space; check for dup sepc; TODO why do we need to do this here?
tcommon = safe_join( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Edition, Publisher, Agency, Volume}, sepc );
elseif utilities.in_array (config.CitationClass, {"book", "citation"}) and not utilities.is_set (Periodical) then -- special cases for book cites
if utilities.is_set (Contributors) then -- when we are citing foreword, preface, introduction, etc.
tcommon = safe_join( {Title, TitleNote}, sepc ); -- author and other stuff will come after this and before tcommon2
tcommon2 = safe_join( {Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
else
tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
end
elseif 'map' == config.CitationClass then -- special cases for cite map
if utilities.is_set (Chapter) then -- map in a book; TitleType is part of Chapter
tcommon = safe_join( {Title, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
elseif utilities.is_set (Periodical) then -- map in a periodical
tcommon = safe_join( {Title, TitleType, Format, Periodical, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
else -- a sheet or stand-alone map
tcommon = safe_join( {Title, TitleType, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher}, sepc );
end
elseif 'episode' == config.CitationClass then -- special case for cite episode
tcommon = safe_join( {Title, TitleNote, TitleType, Series, Language, Edition, Publisher}, sepc );
else -- all other CS1 templates
tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language,
Volume, Others, Edition, Publisher, Agency}, sepc );
end
if #ID_list > 0 then
ID_list = safe_join( { sepc .. " ", table.concat( ID_list, sepc .. " " ), ID }, sepc );
else
ID_list = ID;
end
local Via = A['Via'];
Via = utilities.is_set (Via) and wrap_msg ('via', Via) or '';
local idcommon;
if 'audio-visual' == config.CitationClass or 'episode' == config.CitationClass then -- special case for cite AV media & cite episode position transcript
idcommon = safe_join( { ID_list, URL, Archived, Transcript, AccessDate, Via, Lay, Quote }, sepc );
else
idcommon = safe_join( { ID_list, URL, Archived, AccessDate, Via, Lay, Quote }, sepc );
end
local text;
local pgtext = Position .. Sheet .. Sheets .. Page .. Pages .. At;
local OrigDate = A['OrigDate'];
OrigDate = utilities.is_set (OrigDate) and wrap_msg ('origdate', OrigDate) or '';
if utilities.is_set (Date) then
if utilities.is_set (Authors) or utilities.is_set (Editors) then -- date follows authors or editors when authors not set
Date = " (" .. Date .. ")" .. OrigDate .. sepc .. " "; -- in parentheses
else -- neither of authors and editors set
if (string.sub(tcommon, -1, -1) == sepc) then -- if the last character of tcommon is sepc
Date = " " .. Date .. OrigDate; -- Date does not begin with sepc
else
Date = sepc .. " " .. Date .. OrigDate; -- Date begins with sepc
end
end
end
if utilities.is_set (Authors) then
if (not utilities.is_set (Date)) then -- when date is set it's in parentheses; no Authors termination
Authors = terminate_name_list (Authors, sepc); -- when no date, terminate with 0 or 1 sepc and a space
end
if utilities.is_set (Editors) then
local in_text = " ";
local post_text = "";
if utilities.is_set (Chapter) and 0 == #c then
in_text = in_text .. cfg.messages['in'] .. " "
if (sepc ~= '.') then
in_text = in_text:lower() -- lowercase for cs2
end
end
if EditorCount <= 1 then
post_text = " (" .. cfg.messages['editor'] .. ")"; -- be consistent with no-author, no-date case
else
post_text = " (" .. cfg.messages['editors'] .. ")";
end
Editors = terminate_name_list (in_text .. Editors .. post_text, sepc); -- terminate with 0 or 1 sepc and a space
end
if utilities.is_set (Contributors) then -- book cite and we're citing the intro, preface, etc.
local by_text = sepc .. ' ' .. cfg.messages['by'] .. ' ';
if (sepc ~= '.') then by_text = by_text:lower() end -- lowercase for cs2
Authors = by_text .. Authors; -- author follows title so tweak it here
if utilities.is_set (Editors) and utilities.is_set (Date) then -- when Editors make sure that Authors gets terminated
Authors = terminate_name_list (Authors, sepc); -- terminate with 0 or 1 sepc and a space
end
if (not utilities.is_set (Date)) then -- when date is set it's in parentheses; no Contributors termination
Contributors = terminate_name_list (Contributors, sepc); -- terminate with 0 or 1 sepc and a space
end
text = safe_join( {Contributors, Date, Chapter, tcommon, Authors, Place, Editors, tcommon2, pgtext, idcommon }, sepc );
else
text = safe_join( {Authors, Date, Chapter, Place, Editors, tcommon, pgtext, idcommon }, sepc );
end
elseif utilities.is_set (Editors) then
if utilities.is_set (Date) then
if EditorCount <= 1 then
Editors = Editors .. ", " .. cfg.messages['editor'];
else
Editors = Editors .. ", " .. cfg.messages['editors'];
end
else
if EditorCount <= 1 then
Editors = Editors .. " (" .. cfg.messages['editor'] .. ")" .. sepc .. " "
else
Editors = Editors .. " (" .. cfg.messages['editors'] .. ")" .. sepc .. " "
end
end
text = safe_join( {Editors, Date, Chapter, Place, tcommon, pgtext, idcommon}, sepc );
else
if utilities.in_array (config.CitationClass, {"journal", "citation"}) and utilities.is_set (Periodical) then
text = safe_join( {Chapter, Place, tcommon, pgtext, Date, idcommon}, sepc );
else
text = safe_join( {Chapter, Place, tcommon, Date, pgtext, idcommon}, sepc );
end
end
if utilities.is_set (PostScript) and PostScript ~= sepc then
text = safe_join( {text, sepc}, sepc ); -- Deals with italics, spaces, etc.
text = text:sub(1, -sepc:len() - 1);
end
text = safe_join( {text, PostScript}, sepc );
-- Now enclose the whole thing in a <cite> element
local options_t = {};
options_t.class = cite_class_attribute_make (config.CitationClass, Mode);
local Ref = is_valid_parameter_value (A['Ref'], A:ORIGIN('Ref'), cfg.keywords_lists['ref'], nil, true); -- nil when |ref=harv; A['Ref'] else
if 'none' ~= cfg.keywords_xlate[(Ref and Ref:lower()) or ''] then
local namelist_t = {}; -- holds selected contributor, author, editor name list
local year = first_set ({Year, anchor_year}, 2); -- Year first for legacy citations and for YMD dates that require disambiguation
if #c > 0 then -- if there is a contributor list
namelist_t = c; -- select it
elseif #a > 0 then -- or an author list
namelist_t = a;
elseif #e > 0 then -- or an editor list
namelist_t = e;
end
local citeref_id;
if #namelist_t > 0 then -- if there are names in namelist_t
citeref_id = make_citeref_id (namelist_t, year); -- go make the CITEREF anchor
if mw.uri.anchorEncode (citeref_id) == ((Ref and mw.uri.anchorEncode (Ref)) or '') then -- Ref may already be encoded (by {{sfnref}}) so citeref_id must be encoded before comparison
utilities.set_message ('maint_ref_duplicates_default');
end
else
citeref_id = ''; -- unset
end
options_t.id = Ref or citeref_id;
end
if string.len (text:gsub('%b<>', '')) <= 2 then -- remove html and html-like tags; then get length of what remains;
z.error_cats_t = {}; -- blank the categories list
z.error_msgs_t = {}; -- blank the error messages list
OCinSoutput = nil; -- blank the metadata string
text = ''; -- blank the the citation
utilities.set_message ('err_empty_citation'); -- set empty citation message and category
end
local render_t = {}; -- here we collect the final bits for concatenation into the rendered citation
if utilities.is_set (options_t.id) then -- here we wrap the rendered citation in <cite ...>...</cite> tags
table.insert (render_t, utilities.substitute (cfg.presentation['cite-id'], {mw.uri.anchorEncode(options_t.id), mw.text.nowiki(options_t.class), text})); -- when |ref= is set or when there is a namelist
else
table.insert (render_t, utilities.substitute (cfg.presentation['cite'], {mw.text.nowiki(options_t.class), text})); -- when |ref=none or when namelist_t empty and |ref= is missing or is empty
end
if OCinSoutput then -- blanked when citation is 'empty' so don't bother to add boilerplate metadata span
table.insert (render_t, utilities.substitute (cfg.presentation['ocins'], OCinSoutput)); -- format and append metadata to the citation
end
local template_name = ('citation' == config.CitationClass) and 'citation' or 'cite ' .. (cfg.citation_class_map_t[config.CitationClass] or config.CitationClass);
local template_link = '[[Template:' .. template_name .. '|' .. template_name .. ']]';
local msg_prefix = '<code class="cs1-code">{{' .. template_link .. '}}</code>: ';
if 0 ~= #z.error_msgs_t then
mw.addWarning (utilities.substitute (cfg.messages.warning_msg_e, template_link));
table.insert (render_t, ' '); -- insert a space between citation and its error messages
table.sort (z.error_msgs_t); -- sort the error messages list; sorting includes wrapping <span> and <code> tags; hidden-error sorts ahead of visible-error
local hidden = true; -- presume that the only error messages emited by this template are hidden
for _, v in ipairs (z.error_msgs_t) do -- spin through the list of error messages
if v:find ('cs1-visible-error', 1, true) then -- look for the visible error class name
hidden = false; -- found one; so don't hide the error message prefix
break; -- and done because no need to look further
end
end
z.error_msgs_t[1] = table.concat ({utilities.error_comment (msg_prefix, hidden), z.error_msgs_t[1]}); -- add error message prefix to first error message to prevent extraneous punctuation
table.insert (render_t, table.concat (z.error_msgs_t, '; ')); -- make a big string of error messages and add it to the rendering
end
if 0 ~= #z.maint_cats_t then
mw.addWarning (utilities.substitute (cfg.messages.warning_msg_m, template_link));
table.sort (z.maint_cats_t); -- sort the maintenance messages list
local maint_msgs_t = {}; -- here we collect all of the maint messages
if 0 == #z.error_msgs_t then -- if no error messages
table.insert (maint_msgs_t, msg_prefix); -- insert message prefix in maint message livery
end
for _, v in ipairs( z.maint_cats_t ) do -- append maintenance categories
table.insert (maint_msgs_t, -- assemble new maint message and add it to the maint_msgs_t table
table.concat ({v, ' (', utilities.substitute (cfg.messages[':cat wikilink'], v), ')'})
);
end
table.insert (render_t, utilities.substitute (cfg.presentation['hidden-maint'], table.concat (maint_msgs_t, ' '))); -- wrap the group of maint messages with proper presentation and save
end
if not no_tracking_cats then
for _, v in ipairs (z.error_cats_t) do -- append error categories
table.insert (render_t, utilities.substitute (cfg.messages['cat wikilink'], v));
end
for _, v in ipairs (z.maint_cats_t) do -- append maintenance categories
table.insert (render_t, utilities.substitute (cfg.messages['cat wikilink'], v));
end
for _, v in ipairs (z.prop_cats_t) do -- append properties categories
table.insert (render_t, utilities.substitute (cfg.messages['cat wikilink'], v));
end
end
return table.concat (render_t); -- make a big string and done
end
--[[--------------------------< V A L I D A T E >--------------------------------------------------------------
Looks for a parameter's name in one of several whitelists.
Parameters in the whitelist can have three values:
true - active, supported parameters
false - deprecated, supported parameters
nil - unsupported parameters
]]
local function validate (name, cite_class, empty)
local name = tostring (name);
local enum_name; -- for enumerated parameters, is name with enumerator replaced with '#'
local state;
local function state_test (state, name) -- local function to do testing of state values
if true == state then return true; end -- valid actively supported parameter
if false == state then
if empty then return nil; end -- empty deprecated parameters are treated as unknowns
deprecated_parameter (name); -- parameter is deprecated but still supported
return true;
end
if 'tracked' == state then
local base_name = name:gsub ('%d', ''); -- strip enumerators from parameter names that have them to get the base name
utilities.add_prop_cat ('tracked-param', {base_name}, base_name); -- add a properties category; <base_name> modifies <key>
return true;
end
return nil;
end
if name:find ('#') then -- # is a cs1|2 reserved character so parameters with # not permitted
return nil;
end
if utilities.in_array (cite_class, whitelist.preprint_template_list ) then -- limited parameter sets allowed for these templates
state = whitelist.limited_basic_arguments[name];
if true == state_test (state, name) then return true; end
state = whitelist.preprint_arguments[cite_class][name]; -- look in the parameter-list for the template identified by cite_class
if true == state_test (state, name) then return true; end
-- limited enumerated parameters list
enum_name = name:gsub("%d+", "#" ); -- replace digit(s) with # (last25 becomes last#) (mw.ustring because non-Western 'local' digits)
state = whitelist.limited_numbered_arguments[enum_name];
if true == state_test (state, name) then return true; end
return false; -- not supported because not found or name is set to nil
end -- end limited parameter-set templates
if utilities.in_array (cite_class, whitelist.unique_param_template_list) then -- experiment for template-specific parameters for templates that accept parameters from the basic argument list
state = whitelist.unique_arguments[cite_class][name]; -- look in the template-specific parameter-lists for the template identified by cite_class
if true == state_test (state, name) then return true; end
end -- if here, fall into general validation
state = whitelist.basic_arguments[name]; -- all other templates; all normal parameters allowed
if true == state_test (state, name) then return true; end
-- all enumerated parameters allowed
enum_name = name:gsub("%d+", "#" ); -- replace digit(s) with # (last25 becomes last#) (mw.ustring because non-Western 'local' digits)
state = whitelist.numbered_arguments[enum_name];
if true == state_test (state, name) then return true; end
return false; -- not supported because not found or name is set to nil
end
--[=[-------------------------< I N T E R _ W I K I _ C H E C K >----------------------------------------------
check <value> for inter-language interwiki-link markup. <prefix> must be a MediaWiki-recognized language
code. when these values have the form (without leading colon):
[[<prefix>:link|label]] return label as plain-text
[[<prefix>:link]] return <prefix>:link as plain-text
return value as is else
]=]
local function inter_wiki_check (parameter, value)
local prefix = value:match ('%[%[(%a+):'); -- get an interwiki prefix if one exists
local _;
if prefix and cfg.inter_wiki_map[prefix:lower()] then -- if prefix is in the map, needs preceding colon so
utilities.set_message ('err_bad_paramlink', parameter); -- emit an error message
_, value, _ = utilities.is_wikilink (value); -- extract label portion from wikilink
end
return value;
end
--[[--------------------------< M I S S I N G _ P I P E _ C H E C K >------------------------------------------
Look at the contents of a parameter. If the content has a string of characters and digits followed by an equal
sign, compare the alphanumeric string to the list of cs1|2 parameters. If found, then the string is possibly a
parameter that is missing its pipe. There are two tests made:
{{cite ... |title=Title access-date=2016-03-17}} -- the first parameter has a value and whitespace separates that value from the missing pipe parameter name
{{cite ... |title=access-date=2016-03-17}} -- the first parameter has no value (whitespace after the first = is trimmed by MediaWiki)
cs1|2 shares some parameter names with XML/HTML attributes: class=, title=, etc. To prevent false positives XML/HTML
tags are removed before the search.
If a missing pipe is detected, this function adds the missing pipe maintenance category.
]]
local function missing_pipe_check (parameter, value)
local capture;
value = value:gsub ('%b<>', ''); -- remove XML/HTML tags because attributes: class=, title=, etc.
capture = value:match ('%s+(%a[%w%-]+)%s*=') or value:match ('^(%a[%w%-]+)%s*='); -- find and categorize parameters with possible missing pipes
if capture and validate (capture) then -- if the capture is a valid parameter name
utilities.set_message ('err_missing_pipe', parameter);
end
end
--[[--------------------------< H A S _ E X T R A N E O U S _ P U N C T >--------------------------------------
look for extraneous terminal punctuation in most parameter values; parameters listed in skip table are not checked
]]
local function has_extraneous_punc (param, value)
if 'number' == type (param) then
return;
end
param = param:gsub ('%d+', '#'); -- enumerated name-list mask params allow terminal punct; normalize
if cfg.punct_skip[param] then
return; -- parameter name found in the skip table so done
end
if value:match ('[,;:]$') then
utilities.set_message ('maint_extra_punct'); -- has extraneous punctuation; add maint cat
end
if value:match ('^=') then -- sometimes an extraneous '=' character appears ...
utilities.set_message ('maint_extra_punct'); -- has extraneous punctuation; add maint cat
end
end
--[[--------------------------< H A S _ E X T R A N E O U S _ U R L >------------------------------------------
look for extraneous url parameter values; parameters listed in skip table are not checked
]]
local function has_extraneous_url (url_param_t)
local url_error_t = {};
check_for_url (url_param_t, url_error_t); -- extraneous url check
if 0 ~= #url_error_t then -- non-zero when there are errors
table.sort (url_error_t);
utilities.set_message ('err_param_has_ext_link', {utilities.make_sep_list (#url_error_t, url_error_t)}); -- add this error message
end
end
--[[--------------------------< C I T A T I O N >--------------------------------------------------------------
This is used by templates such as {{cite book}} to create the actual citation text.
]]
local function citation(frame)
Frame = frame; -- save a copy in case we need to display an error message in preview mode
local sandbox = '/sandbox' -- i18n: replace this rvalue with the name that your wiki uses to identify sandbox subpages
is_sandbox = nil ~= string.find (frame:getTitle(), sandbox, 1, true); -- is this invoke the sandbox module?
sandbox = is_sandbox and sandbox or ''; -- use i18n sandbox to load sandbox modules when this module is the sandox; live modules else
local pframe = frame:getParent()
local styles;
cfg = mw.loadData ('Module:Citation/CS1/Configuration' .. sandbox); -- load sandbox versions of support modules when {{#invoke:Citation/CS1/sandbox|...}}; live modules else
whitelist = mw.loadData ('Module:Citation/CS1/Whitelist' .. sandbox);
utilities = require ('Module:Citation/CS1/Utilities' .. sandbox);
validation = require ('Module:Citation/CS1/Date_validation' .. sandbox);
identifiers = require ('Module:Citation/CS1/Identifiers' .. sandbox);
metadata = require ('Module:Citation/CS1/COinS' .. sandbox);
styles = 'Module:Citation/CS1' .. sandbox .. '/styles.css';
utilities.set_selected_modules (cfg); -- so that functions in Utilities can see the selected cfg tables
identifiers.set_selected_modules (cfg, utilities); -- so that functions in Identifiers can see the selected cfg tables and selected Utilities module
validation.set_selected_modules (cfg, utilities); -- so that functions in Date validataion can see selected cfg tables and the selected Utilities module
metadata.set_selected_modules (cfg, utilities); -- so that functions in COinS can see the selected cfg tables and selected Utilities module
z = utilities.z; -- table of error and category tables in Module:Citation/CS1/Utilities
is_preview_mode = not utilities.is_set (frame:preprocess ('{{REVISIONID}}'));
local args = {}; -- table where we store all of the template's arguments
local suggestions = {}; -- table where we store suggestions if we need to loadData them
local error_text; -- used as a flag
local config = {}; -- table to store parameters from the module {{#invoke:}}
for k, v in pairs( frame.args ) do -- get parameters from the {{#invoke}} frame
config[k] = v;
-- args[k] = v; -- crude debug support that allows us to render a citation from module {{#invoke:}}; skips parameter validation; TODO: keep?
end
local capture; -- the single supported capture when matching unknown parameters using patterns
local empty_unknowns = {}; -- sequence table to hold empty unknown params for error message listing
for k, v in pairs( pframe.args ) do -- get parameters from the parent (template) frame
v = mw.ustring.gsub (v, '^%s*(.-)%s*$', '%1'); -- trim leading/trailing whitespace; when v is only whitespace, becomes empty string
if v ~= '' then
if ('string' == type (k)) then
k = mw.ustring.gsub (k, '%d', cfg.date_names.local_digits); -- for enumerated parameters, translate 'local' digits to Western 0-9
end
if not validate( k, config.CitationClass ) then
if type (k) ~= 'string' then -- exclude empty numbered parameters
if v:match("%S+") ~= nil then
error_text = utilities.set_message ('err_text_ignored', {v});
end
elseif validate (k:lower(), config.CitationClass) then
error_text = utilities.set_message ('err_parameter_ignored_suggest', {k, k:lower()}); -- suggest the lowercase version of the parameter
else
if nil == suggestions.suggestions then -- if this table is nil then we need to load it
if is_sandbox then -- did the {{#invoke:}} use sandbox version?
suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions/sandbox' ); -- use the sandbox version
else
suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' ); -- use the live version
end
end
for pattern, param in pairs (suggestions.patterns) do -- loop through the patterns to see if we can suggest a proper parameter
capture = k:match (pattern); -- the whole match if no capture in pattern else the capture if a match
if capture then -- if the pattern matches
param = utilities.substitute (param, capture); -- add the capture to the suggested parameter (typically the enumerator)
if validate (param, config.CitationClass) then -- validate the suggestion to make sure that the suggestion is supported by this template (necessary for limited parameter lists)
error_text = utilities.set_message ('err_parameter_ignored_suggest', {k, param}); -- set the suggestion error message
else
error_text = utilities.set_message ('err_parameter_ignored', {k}); -- suggested param not supported by this template
v = ''; -- unset
end
end
end
if not utilities.is_set (error_text) then -- couldn't match with a pattern, is there an explicit suggestion?
if (suggestions.suggestions[ k:lower() ] ~= nil) and validate (suggestions.suggestions[ k:lower() ], config.CitationClass) then
utilities.set_message ('err_parameter_ignored_suggest', {k, suggestions.suggestions[ k:lower() ]});
else
utilities.set_message ('err_parameter_ignored', {k});
v = ''; -- unset value assigned to unrecognized parameters (this for the limited parameter lists)
end
end
end
end
args[k] = v; -- save this parameter and its value
elseif not utilities.is_set (v) then -- for empty parameters
if not validate (k, config.CitationClass, true) then -- is this empty parameter a valid parameter
k = ('' == k) and '(empty string)' or k; -- when k is empty string (or was space(s) trimmed to empty string), replace with descriptive text
table.insert (empty_unknowns, utilities.wrap_style ('parameter', k)); -- format for error message and add to the list
end
-- crude debug support that allows us to render a citation from module {{#invoke:}} TODO: keep?
-- elseif args[k] ~= nil or (k == 'postscript') then -- when args[k] has a value from {{#invoke}} frame (we don't normally do that)
-- args[k] = v; -- overwrite args[k] with empty string from pframe.args[k] (template frame); v is empty string here
end -- not sure about the postscript bit; that gets handled in parameter validation; historical artifact?
end
if 0 ~= #empty_unknowns then -- create empty unknown error message
utilities.set_message ('err_param_unknown_empty', {
1 == #empty_unknowns and '' or 's',
utilities.make_sep_list (#empty_unknowns, empty_unknowns)
});
end
local url_param_t = {};
for k, v in pairs( args ) do
if 'string' == type (k) then -- don't evaluate positional parameters
has_invisible_chars (k, v); -- look for invisible characters
end
has_extraneous_punc (k, v); -- look for extraneous terminal punctuation in parameter values
missing_pipe_check (k, v); -- do we think that there is a parameter that is missing a pipe?
args[k] = inter_wiki_check (k, v); -- when language interwiki-linked parameter missing leading colon replace with wiki-link label
if 'string' == type (k) and not cfg.url_skip[k] then -- when parameter k is not positional and not in url skip table
url_param_t[k] = v; -- make a parameter/value list for extraneous url check
end
end
has_extraneous_url (url_param_t); -- look for url in parameter values where a url does not belong
return table.concat ({
frame:extensionTag ('templatestyles', '', {src=styles}),
citation0( config, args)
});
end
--[[--------------------------< E X P O R T E D F U N C T I O N S >------------------------------------------
]]
return {citation = citation};
arh7r1j5jl1nszhz5ygxnrmqbbziy3g
189404
189398
2022-08-16T14:05:30Z
Venise12mai1834
8884
ย้อนกลับไปรุ่นที่ 89005 โดย [[Special:Contributions/Geonuch|Geonuch]] ([[User talk:Geonuch|พูดคุย]]) ด้วย[[WS:iScript|สจห.]]: ลองรุ่นเดิม
Scribunto
text/plain
local z = {
error_categories = {}; -- for categorizing citations that contain errors
error_ids = {};
message_tail = {};
maintenance_cats = {}; -- for categorizing citations that aren't erroneous per se, but could use a little work
properties_cats = {}; -- for categorizing citations based on certain properties, language of source for instance
}
-- Whether variable is set or not
function is_set( var )
return not (var == nil or var == '');
end
-- First set variable or nil if none
function first_set(...)
local list = {...};
for _, var in pairs(list) do
if is_set( var ) then
return var;
end
end
end
-- Whether needle is in haystack
function inArray( needle, haystack )
if needle == nil then
return false;
end
for n,v in ipairs( haystack ) do
if v == needle then
return n;
end
end
return false;
end
--[[
Categorize and emit an error message when the citation contains one or more deprecated parameters. Because deprecated parameters (currently |month=,
|coauthor=, and |coauthors=) aren't related to each other and because these parameters may be concatenated into the variables used by |date= and |author#= (and aliases)
details of which parameter caused the error message are not provided. Only one error message is emitted regardless of the number of deprecated parameters in the citation.
]]
function deprecated_parameter(name)
if true ~= Page_in_deprecated_cat then -- if we haven't been here before then set a
Page_in_deprecated_cat=true; -- sticky flag so that if there are more than one deprecated parameter the category is added only once
table.insert( z.message_tail, { seterror( 'deprecated_params', {name}, true ) } ); -- add error message
end
end
-- Populates numbered arguments in a message string using an argument table.
function substitute( msg, args )
return args and mw.message.newRawMessage( msg, args ):plain() or msg;
end
--[[--------------------------< K E R N _ Q U O T E S >--------------------------------------------------------
Apply kerning to open the space between the quote mark provided by the Module and a leading or trailing quote mark contained in a |title= or |chapter= parameter's value.
This function will positive kern either single or double quotes:
"'Unkerned title with leading and trailing single quote marks'"
" 'Kerned title with leading and trailing single quote marks' " (in real life the kerning isn't as wide as this example)
Double single quotes (italic or bold wikimarkup) are not kerned.
Call this function for chapter titles, for website titles, etc; not for book titles.
]]
function kern_quotes (str)
local cap='';
local cap2='';
cap, cap2 = str:match ("^([\"\'])([^\'].+)"); -- match leading double or single quote but not double single quotes
if is_set (cap) then
str = substitute (cfg.presentation['kern-left'], {cap, cap2});
end
cap, cap2 = str:match ("^(.+[^\'])([\"\'])$")
if is_set (cap) then
str = substitute (cfg.presentation['kern-right'], {cap, cap2});
end
return str;
end
--[[--------------------------< F O R M A T _ S C R I P T _ V A L U E >----------------------------------------
|script-title= holds title parameters that are not written in Latin based scripts: Chinese, Japanese, Arabic, Hebrew, etc. These scripts should
not be italicized and may be written right-to-left. The value supplied by |script-title= is concatenated onto Title after Title has been wrapped
in italic markup.
Regardless of language, all values provided by |script-title= are wrapped in <bdi>...</bdi> tags to isolate rtl languages from the English left to right.
|script-title= provides a unique feature. The value in |script-title= may be prefixed with a two-character ISO639-1 language code and a colon:
|script-title=ja:*** *** (where * represents a Japanese character)
Spaces between the two-character code and the colon and the colon and the first script character are allowed:
|script-title=ja : *** ***
|script-title=ja: *** ***
|script-title=ja :*** ***
Spaces preceding the prefix are allowed: |script-title = ja:*** ***
The prefix is checked for validity. If it is a valid ISO639-1 language code, the lang attribute (lang="ja") is added to the <bdi> tag so that browsers can
know the language the tag contains. This may help the browser render the script more correctly. If the prefix is invalid, the lang attribute
is not added. At this time there is no error message for this condition.
At this writing, only |script-title= is supported. It is anticipated that additional parameters will be created to use this function.
TODO: error messages when prefix is invalid ISO639-1 code; when script_value has prefix but no script;
]]
function format_script_value (script_value)
local lang=''; -- initialize to empty string
local name;
if script_value:match('^%l%l%s*:') then -- if first 3 non-space characters are script language prefix
lang = script_value:match('^(%l%l)%s*:%s*%S.*'); -- get the language prefix or nil if there is no script
if not is_set (lang) then
return ''; -- script_value was just the prefix so return empty string
end
-- if we get this far we have prefix and script
name = mw.language.fetchLanguageName( lang, "en" ); -- get language name so that we can use it to categorize
if is_set (name) then -- is prefix a proper ISO 639-1 language code?
script_value = script_value:gsub ('^%l%l%s*:%s*', ''); -- strip prefix from script
-- is prefix one of these language codes?
if inArray (lang, {'ar', 'bs', 'dv', 'el', 'fa', 'hy', 'ja', 'ko', 'ku', 'he', 'ps', 'ru', 'sd', 'sr', 'th', 'uk', 'ug', 'yi', 'zh'}) then
table.insert( z.properties_cats, 'CS1 uses ' .. name .. '-language script ('..lang..')'); -- categorize in language-specific categories
else
table.insert( z.properties_cats, 'CS1 uses foreign language script'); -- use this category as a catchall until language-specific category is available
end
lang = ' lang="' .. lang .. '" '; -- convert prefix into a lang attribute
else
lang = ''; -- invalid so set lang to empty string
end
end
script_value = substitute (cfg.presentation['bdi'], {lang, script_value}); -- isolate in case script is rtl
return script_value;
end
--[[--------------------------< S C R I P T _ C O N C A T E N A T E >------------------------------------------
Initially for |title= and |script-title=, this function concatenates those two parameter values after the script value has been
wrapped in <bdi> tags.
]]
function script_concatenate (title, script)
if is_set (script) then
script = format_script_value (script); -- <bdi> tags, lang atribute, categorization, etc; returns empty string on error
if is_set (script) then
title = title .. ' ' .. script; -- concatenate title and script title
end
end
return title;
end
--[[--------------------------< W R A P _ S T Y L E >----------------------------------------------------------
Applies styling to various parameters. Supplied string is wrapped using a message_list configuration taking one
argument; protects italic styled parameters. Additional text taken from citation_config.presentation - the reason
this function is similar to but separate from wrap_msg().
]]
function wrap_style (key, str)
if not is_set( str ) then
return "";
elseif inArray( key, { 'italic-title', 'trans-italic-title' } ) then
str = safeforitalics( str );
end
return substitute( cfg.presentation[key], {str} );
end
--[[--------------------------< W R A P _ M S G >--------------------------------------------------------------
Applies additional message text to various parameter values. Supplied string is wrapped using a message_list
configuration taking one argument. Supports lower case text for {{citation}} templates. Additional text taken
from citation_config.messages - the reason this function is similar to but separate from wrap_style().
]]
function wrap_msg (key, str, lower)
if not is_set( str ) then
return "";
end
if true == lower then
local msg;
msg = cfg.messages[key]:lower(); -- set the message to lower case before
str = substitute( msg, {str} ); -- including template text
return str;
else
return substitute( cfg.messages[key], {str} );
end
end
--[[--------------------------< F O R M A T _ C H A P T E R _ T I T L E >--------------------------------------
Format the three chapter parameters: |chapter=, |trans-chapter=, and |chapter-url= into a single Chapter meta-
parameter (chapter_url_source used for error messages).
]]
function format_chapter_title (chapter, transchapter, chapterurl, chapter_url_source)
local chapter_error = '';
if not is_set (chapter) then
chapter = ''; -- just to be safe for concatenation
if is_set (transchapter) then
chapter = wrap_style ('trans-quoted-title', transchapter);
chapter_error = " " .. seterror ('trans_missing_chapter');
end
if is_set (chapterurl) then
chapter = externallink (chapterurl, chapter, chapter_url_source); -- adds bare_url_missing_title error if appropriate
end
return chapter .. chapter_error;
else -- here when chapter is set
chapter = kern_quotes (chapter); -- if necessary, separate chapter title's leading and trailing quote marks from Module provided quote marks
chapter = wrap_style ('quoted-title', chapter);
if is_set (transchapter) then
transchapter = wrap_style ('trans-quoted-title', transchapter);
chapter = chapter .. ' ' .. transchapter;
end
if is_set (chapterurl) then
chapter = externallink (chapterurl, chapter); -- adds bare_url_missing_title error if appropriate
end
end
return chapter;
end
--[[
Argument wrapper. This function provides support for argument
mapping defined in the configuration file so that multiple names
can be transparently aliased to single internal variable.
]]
function argument_wrapper( args )
local origin = {};
return setmetatable({
ORIGIN = function( self, k )
local dummy = self[k]; --force the variable to be loaded.
return origin[k];
end
},
{
__index = function ( tbl, k )
if origin[k] ~= nil then
return nil;
end
local args, list, v = args, cfg.aliases[k];
if type( list ) == 'table' then
v, origin[k] = selectone( args, list, 'redundant_parameters' );
if origin[k] == nil then
origin[k] = ''; -- Empty string, not nil
end
elseif list ~= nil then
v, origin[k] = args[list], list;
else
-- maybe let through instead of raising an error?
-- v, origin[k] = args[k], k;
error( cfg.messages['unknown_argument_map'] );
end
-- Empty strings, not nil;
if v == nil then
v = cfg.defaults[k] or '';
origin[k] = '';
end
tbl = rawset( tbl, k, v );
return v;
end,
});
end
--[[
Looks for a parameter's name in the whitelist.
Parameters in the whitelist can have three values:
true - active, supported parameters
false - deprecated, supported parameters
nil - unsupported parameters
]]
function validate( name )
local name = tostring( name );
local state = whitelist.basic_arguments[ name ];
-- Normal arguments
if true == state then return true; end -- valid actively supported parameter
if false == state then
deprecated_parameter (name); -- parameter is deprecated but still supported
return true;
end
-- Arguments with numbers in them
name = name:gsub( "%d+", "#" ); -- replace digit(s) with # (last25 becomes last#
state = whitelist.numbered_arguments[ name ];
if true == state then return true; end -- valid actively supported parameter
if false == state then
deprecated_parameter (name); -- parameter is deprecated but still supported
return true;
end
return false; -- Not supported because not found or name is set to nil
end
--[[--------------------------< E R R O R C O M M E N T >------------------------------------------------------
Wraps error messages with css markup according to the state of hidden.
]]
function errorcomment( content, hidden )
return substitute( hidden and cfg.presentation['hidden-error'] or cfg.presentation['visible-error'], content );
end
--[[
Sets an error condition and returns the appropriate error message. The actual placement
of the error message in the output is the responsibility of the calling function.
]]
function seterror( error_id, arguments, raw, prefix, suffix )
local error_state = cfg.error_conditions[ error_id ];
prefix = prefix or "";
suffix = suffix or "";
if error_state == nil then
error( cfg.messages['undefined_error'] );
elseif is_set( error_state.category ) then
table.insert( z.error_categories, error_state.category );
end
local message = substitute( error_state.message, arguments );
message = message .. " ([[" .. cfg.messages['help page link'] ..
"#" .. error_state.anchor .. "|" ..
cfg.messages['help page label'] .. "]])";
z.error_ids[ error_id ] = true;
if inArray( error_id, { 'bare_url_missing_title', 'trans_missing_title' } )
and z.error_ids['citation_missing_title'] then
return '', false;
end
message = table.concat({ prefix, message, suffix });
if raw == true then
return message, error_state.hidden;
end
return errorcomment( message, error_state.hidden );
end
-- Formats a wiki style external link
function externallinkid(options)
local url_string = options.id;
if options.encode == true or options.encode == nil then
url_string = mw.uri.encode( url_string );
end
return mw.ustring.format( '[[%s|%s]]%s[%s%s%s %s]',
options.link, options.label, options.separator or " ",
options.prefix, url_string, options.suffix or "",
mw.text.nowiki(options.id)
);
end
-- Formats a wiki style internal link
function internallinkid(options)
return mw.ustring.format( '[[%s|%s]]%s[[%s%s%s|%s]]',
options.link, options.label, options.separator or " ",
options.prefix, options.id, options.suffix or "",
mw.text.nowiki(options.id)
);
end
-- Format an external link with error checking
function externallink( URL, label, source )
local error_str = "";
if not is_set( label ) then
label = URL;
if is_set( source ) then
error_str = seterror( 'bare_url_missing_title', { wrap_style ('parameter', source) }, false, " " );
else
error( cfg.messages["bare_url_no_origin"] );
end
end
if not checkurl( URL ) then
error_str = seterror( 'bad_url', {}, false, " " ) .. error_str;
end
return table.concat({ "[", URL, " ", safeforurl( label ), "]", error_str });
end
--[[--------------------------< N O W R A P _ D A T E >--------------------------------------------------------
When date is YYYY-MM-DD format wrap in nowrap span: <span ...>YYYY-MM-DD</span>. When date is DD MMMM YYYY or is
MMMM DD, YYYY then wrap in nowrap span: <span ...>DD MMMM</span> YYYY or <span ...>MMMM DD,</span> YYYY
DOES NOT yet support MMMM YYYY or any of the date ranges.
]]
function nowrap_date (date)
local cap='';
local cap2='';
if date:match("^%d%d%d%d%-%d%d%-%d%d$") then
date = substitute (cfg.presentation['nowrap1'], date);
elseif date:match("%a+%s*%d%d?,%s*%d%d%d%d") or date:match ("%d%d?%s*%a+%s*%d%d%d%d") then
cap, cap2 = string.match (date, "^(.*)%s+(%d%d%d%d)$");
date = substitute (cfg.presentation['nowrap2'], {cap, cap2});
end
return date;
end
--[[--------------------------< A M A Z O N >------------------------------------------------------------------
Formats a link to Amazon. Do simple error checking: asin must be mix of 10 numeric or uppercase alpha
characters. If a mix, first character must be uppercase alpha; if all numeric, asins must be 10-digit
isbn. If 10-digit isbn, add a maintenance category so a bot or awb script can replace |asin= with |isbn=.
Error message if not 10 characters, if not isbn10, if mixed and first character is a digit.
]]
function amazon(id, domain)
local err_cat = ""
if not id:match("^[%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u]$") then
err_cat = ' ' .. seterror ('bad_asin'); -- asin is not a mix of 10 uppercase alpha and numeric characters
else
if id:match("^%d%d%d%d%d%d%d%d%d[%dX]$") then -- if 10-digit numeric (or 9 digits with terminal X)
if checkisbn( id ) then -- see if asin value is isbn10
table.insert( z.maintenance_cats, "CS1 maint: ASIN uses ISBN"); -- add to maint category
elseif not is_set (err_cat) then
err_cat = ' ' .. seterror ('bad_asin'); -- asin is not isbn10
end
elseif not id:match("^%u[%d%u]+$") then
err_cat = ' ' .. seterror ('bad_asin'); -- asin doesn't begin with uppercase alpha
end
end
if not is_set(domain) then
domain = "com";
elseif inArray (domain, {'jp', 'uk'}) then -- Japan, United Kingdom
domain = "co." .. domain;
elseif inArray (domain, {'au', 'br', 'mx'}) then -- Australia, Brazil, Mexico
domain = "com." .. domain;
end
local handler = cfg.id_handlers['ASIN'];
return externallinkid({link = handler.link,
label=handler.label , prefix="//www.amazon."..domain.."/dp/",id=id,
encode=handler.encode, separator = handler.separator}) .. err_cat;
end
--[[--------------------------< A R X I V >--------------------------------------------------------------------
See: http://arxiv.org/help/arxiv_identifier
format and error check arXiv identifier. There are three valid forms of the identifier:
the first form, valid only between date codes 9108 and 0703 is:
arXiv:<archive>.<class>/<date code><number><version>
where:
<archive> is a string of alpha characters - may be hyphenated; no other punctuation
<class> is a string of alpha characters - may be hyphenated; no other punctuation
<date code> is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
first digit of YY for this form can only 9 and 0
<number> is a three-digit number
<version> is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
the second form, valid from April 2007 through December 2014 is:
arXiv:<date code>.<number><version>
where:
<date code> is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
<number> is a four-digit number
<version> is a 1 or more digit number preceded with a lowercase v; no spaces
the third form, valid from January 2015 is:
arXiv:<date code>.<number><version>
where:
<date code> and <version> are as defined for 0704-1412
<number> is a five-digit number
]]
function arxiv (id)
local handler = cfg.id_handlers['ARXIV'];
local year, month, version;
local err_cat = ""
if id:match("^%a[%a%.%-]+/[90]%d[01]%d%d%d%d$") or id:match("^%a[%a%.%-]+/[90]%d[01]%d%d%d%dv%d+$") then -- test for the 9108-0703 format w/ & w/o version
year, month = id:match("^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d[v%d]*$");
year = tonumber(year);
month = tonumber(month);
if ((not (90 < year or 8 > year)) or (1 > month or 12 < month)) or -- if invalid year or invalid month
((91 == year and 7 > month) or (7 == year and 3 < month)) then -- if years ok, are starting and ending months ok?
err_cat = ' ' .. seterror( 'bad_arxiv' ); -- set error message
end
elseif id:match("^%d%d[01]%d%.%d%d%d%d$") or id:match("^%d%d[01]%d%.%d%d%d%dv%d+$") then -- test for the 0704-1412 w/ & w/o version
year, month = id:match("^(%d%d)([01]%d)%.%d%d%d%d[v%d]*$");
year = tonumber(year);
month = tonumber(month);
if ((7 > year) or (14 < year) or (1 > month or 12 < month)) or -- is year invalid or is month invalid? (doesn't test for future years)
((7 == year) and (4 > month)) then --or -- when year is 07, is month invalid (before April)?
err_cat = ' ' .. seterror( 'bad_arxiv' ); -- set error message
end
elseif id:match("^%d%d[01]%d%.%d%d%d%d%d$") or id:match("^%d%d[01]%d%.%d%d%d%d%dv%d+$") then -- test for the 1501- format w/ & w/o version
year, month = id:match("^(%d%d)([01]%d)%.%d%d%d%d%d[v%d]*$");
year = tonumber(year);
month = tonumber(month);
if ((15 > year) or (1 > month or 12 < month)) then -- is year invalid or is month invalid? (doesn't test for future years)
err_cat = ' ' .. seterror( 'bad_arxiv' ); -- set error message
end
else
err_cat = ' ' .. seterror( 'bad_arxiv' ); -- arXiv id doesn't match any format
end
return externallinkid({link = handler.link, label = handler.label,
prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end
--[[
lccn normalization (http://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
a. Remove it.
b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
1. All these characters should be digits, and there should be six or less. (not done in this function)
2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.
Returns a normalized lccn for lccn() to validate. There is no error checking (step 3.b.1) performed in this function.
]]
function normalize_lccn (lccn)
lccn = lccn:gsub ("%s", ""); -- 1. strip whitespace
if nil ~= string.find (lccn,'/') then
lccn = lccn:match ("(.-)/"); -- 2. remove forward slash and all character to the right of it
end
local prefix
local suffix
prefix, suffix = lccn:match ("(.+)%-(.+)"); -- 3.a remove hyphen by splitting the string into prefix and suffix
if nil ~= suffix then -- if there was a hyphen
suffix=string.rep("0", 6-string.len (suffix)) .. suffix; -- 3.b.2 left fill the suffix with 0s if suffix length less than 6
lccn=prefix..suffix; -- reassemble the lccn
end
return lccn;
end
--[[
Format LCCN link and do simple error checking. LCCN is a character string 8-12 characters long. The length of the LCCN dictates the character type of the first 1-3 characters; the
rightmost eight are always digits. http://info-uri.info/registry/OAIHandler?verb=GetRecord&metadataPrefix=reg&identifier=info:lccn/
length = 8 then all digits
length = 9 then lccn[1] is lower case alpha
length = 10 then lccn[1] and lccn[2] are both lower case alpha or both digits
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lower case alpha or both digits
length = 12 then lccn[1] and lccn[2] are both lower case alpha
]]
function lccn(lccn)
local handler = cfg.id_handlers['LCCN'];
local err_cat = ''; -- presume that LCCN is valid
local id = lccn; -- local copy of the lccn
id = normalize_lccn (id); -- get canonical form (no whitespace, hyphens, forward slashes)
local len = id:len(); -- get the length of the lccn
if 8 == len then
if id:match("[^%d]") then -- if LCCN has anything but digits (nil if only digits)
err_cat = ' ' .. seterror( 'bad_lccn' ); -- set an error message
end
elseif 9 == len then -- LCCN should be adddddddd
if nil == id:match("%l%d%d%d%d%d%d%d%d") then -- does it match our pattern?
err_cat = ' ' .. seterror( 'bad_lccn' ); -- set an error message
end
elseif 10 == len then -- LCCN should be aadddddddd or dddddddddd
if id:match("[^%d]") then -- if LCCN has anything but digits (nil if only digits) ...
if nil == id:match("^%l%l%d%d%d%d%d%d%d%d") then -- ... see if it matches our pattern
err_cat = ' ' .. seterror( 'bad_lccn' ); -- no match, set an error message
end
end
elseif 11 == len then -- LCCN should be aaadddddddd or adddddddddd
if not (id:match("^%l%l%l%d%d%d%d%d%d%d%d") or id:match("^%l%d%d%d%d%d%d%d%d%d%d")) then -- see if it matches one of our patterns
err_cat = ' ' .. seterror( 'bad_lccn' ); -- no match, set an error message
end
elseif 12 == len then -- LCCN should be aadddddddddd
if not id:match("^%l%l%d%d%d%d%d%d%d%d%d%d") then -- see if it matches our pattern
err_cat = ' ' .. seterror( 'bad_lccn' ); -- no match, set an error message
end
else
err_cat = ' ' .. seterror( 'bad_lccn' ); -- wrong length, set an error message
end
if not is_set (err_cat) and nil ~= lccn:find ('%s') then
err_cat = ' ' .. seterror( 'bad_lccn' ); -- lccn contains a space, set an error message
end
return externallinkid({link = handler.link, label = handler.label,
prefix=handler.prefix,id=lccn,separator=handler.separator, encode=handler.encode}) .. err_cat;
end
--[[
Format PMID and do simple error checking. PMIDs are sequential numbers beginning at 1 and counting up. This code checks the PMID to see that it
contains only digits and is less than test_limit; the value in local variable test_limit will need to be updated periodically as more PMIDs are issued.
]]
function pmid(id)
local test_limit = 30000000; -- update this value as PMIDs approach
local handler = cfg.id_handlers['PMID'];
local err_cat = ''; -- presume that PMID is valid
if id:match("[^%d]") then -- if PMID has anything but digits
err_cat = ' ' .. seterror( 'bad_pmid' ); -- set an error message
else -- PMID is only digits
local id_num = tonumber(id); -- convert id to a number for range testing
if 1 > id_num or test_limit < id_num then -- if PMID is outside test limit boundaries
err_cat = ' ' .. seterror( 'bad_pmid' ); -- set an error message
end
end
return externallinkid({link = handler.link, label = handler.label,
prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end
--[[
Determines if a PMC identifier's online version is embargoed. Compares the date in |embargo= against today's date. If embargo date is
in the future, returns true; otherwise, returns false because the embargo has expired or |embargo= not set in this cite.
]]
function is_embargoed(embargo)
if is_set(embargo) then
local lang = mw.getContentLanguage();
local good1, embargo_date, good2, todays_date;
good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
good2, todays_date = pcall( lang.formatDate, lang, 'U' );
if good1 and good2 and tonumber( embargo_date ) >= tonumber( todays_date ) then --is embargo date is in the future?
return true; -- still embargoed
end
end
return false; -- embargo expired or |embargo= not set
end
--[[
Format a PMC, do simple error checking, and check for embargoed articles.
The embargo parameter takes a date for a value. If the embargo date is in the future
the PMC identifier will not be linked to the article. If the embargo specifies a date in the past, or if it is empty or omitted, then
the PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.
PMCs are sequential numbers beginning at 1 and counting up. This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.
]]
function pmc(id, embargo)
local test_limit = 5000000; -- update this value as PMCs approach
local handler = cfg.id_handlers['PMC'];
local err_cat = ''; -- presume that PMC is valid
local text;
if id:match("[^%d]") then -- if PMC has anything but digits
err_cat = ' ' .. seterror( 'bad_pmc' ); -- set an error message
else -- PMC is only digits
local id_num = tonumber(id); -- convert id to a number for range testing
if 1 > id_num or test_limit < id_num then -- if PMC is outside test limit boundaries
err_cat = ' ' .. seterror( 'bad_pmc' ); -- set an error message
end
end
if is_embargoed(embargo) then
text="[[" .. handler.link .. "|" .. handler.label .. "]]:" .. handler.separator .. id .. err_cat; --still embargoed so no external link
else
text = externallinkid({link = handler.link, label = handler.label, --no embargo date, ok to link to article
prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end
return text;
end
-- Formats a DOI and checks for DOI errors.
-- DOI names contain two parts: prefix and suffix separated by a forward slash.
-- Prefix: directory indicator '10.' followed by a registrant code
-- Suffix: character string of any length chosen by the registrant
-- This function checks a DOI name for: prefix/suffix. If the doi name contains spaces or endashes,
-- or, if it ends with a period or a comma, this function will emit a bad_doi error message.
-- DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
-- and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely if ever used in doi names.
function doi(id, inactive)
local cat = ""
local handler = cfg.id_handlers['DOI'];
local text;
if is_set(inactive) then
local inactive_year = inactive:match("%d%d%d%d") or ''; -- try to get the year portion from the inactive date
text = "[[" .. handler.link .. "|" .. handler.label .. "]]:" .. id;
if is_set(inactive_year) then
table.insert( z.error_categories, "Pages with DOIs inactive since " .. inactive_year );
else
table.insert( z.error_categories, "Pages with inactive DOIs" ); -- when inactive doesn't contain a recognizable year
end
inactive = " (" .. cfg.messages['inactive'] .. " " .. inactive .. ")"
else
text = externallinkid({link = handler.link, label = handler.label,
prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
inactive = ""
end
if nil == id:match("^10%.[^%s–]-/[^%s–]-[^%.,]$") then -- doi must begin with '10.', must contain a fwd slash, must not contain spaces or endashes, and must not end with period or comma
cat = ' ' .. seterror( 'bad_doi' );
end
return text .. inactive .. cat
end
-- Formats an OpenLibrary link, and checks for associated errors.
function openlibrary(id)
local code = id:match("^%d+([AMW])$"); -- only digits followed by 'A', 'M', or 'W'
local handler = cfg.id_handlers['OL'];
if ( code == "A" ) then
return externallinkid({link=handler.link, label=handler.label,
prefix="http://openlibrary.org/authors/OL",id=id, separator=handler.separator,
encode = handler.encode})
elseif ( code == "M" ) then
return externallinkid({link=handler.link, label=handler.label,
prefix="http://openlibrary.org/books/OL",id=id, separator=handler.separator,
encode = handler.encode})
elseif ( code == "W" ) then
return externallinkid({link=handler.link, label=handler.label,
prefix= "http://openlibrary.org/works/OL",id=id, separator=handler.separator,
encode = handler.encode})
else
return externallinkid({link=handler.link, label=handler.label,
prefix= "http://openlibrary.org/OL",id=id, separator=handler.separator,
encode = handler.encode}) ..
' ' .. seterror( 'bad_ol' );
end
end
--[[
Validate and format an issn. This code fixes the case where an editor has included an ISSN in the citation but has separated the two groups of four
digits with a space. When that condition occurred, the resulting link looked like this:
|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327] -- can't have spaces in an external link
This code now prevents that by inserting a hyphen at the issn midpoint. It also validates the issn for length and makes sure that the checkdigit agrees
with the calculated value. Incorrect length (8 digits), characters other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn
error message. The issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.
]]
function issn(id)
local issn_copy = id; -- save a copy of unadulterated issn; use this version for display if issn does not validate
local handler = cfg.id_handlers['ISSN'];
local text;
local valid_issn = true;
id=id:gsub( "[%s-–]", "" ); -- strip spaces, hyphens, and endashes from the issn
if 8 ~= id:len() or nil == id:match( "^%d*X?$" ) then -- validate the issn: 8 digits long, containing only 0-9 or X in the last position
valid_issn=false; -- wrong length or improper character
else
valid_issn=is_valid_isxn(id, 8); -- validate issn
end
if true == valid_issn then
id = string.sub( id, 1, 4 ) .. "-" .. string.sub( id, 5 ); -- if valid, display correctly formatted version
else
id = issn_copy; -- if not valid, use the show the invalid issn with error message
end
text = externallinkid({link = handler.link, label = handler.label,
prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
if false == valid_issn then
text = text .. ' ' .. seterror( 'bad_issn' ) -- add an error message if the issn is invalid
end
return text
end
--[[--------------------------< M E S S A G E _ I D >----------------------------------------------------------
Validate and format a usenet message id. Simple error checking, looks for 'id-left@id-right' not enclosed in
'<' and/or '>' angle brackets.
]]
function message_id (id)
local handler = cfg.id_handlers['USENETID'];
text = externallinkid({link = handler.link, label = handler.label,
prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
if not id:match('^.+@.+$') or not id:match('^[^<].*[^>]$')then -- doesn't have '@' or has one or first or last character is '< or '>'
text = text .. ' ' .. seterror( 'bad_message_id' ) -- add an error message if the message id is invalid
end
return text
end
--[[--------------------------< S E T _ T I T L E T Y P E >----------------------------------------------------
This function sets default title types (equivalent to the citation including |type=<default value>) for those citations that have defaults.
Also handles the special case where it is desirable to omit the title type from the rendered citation (|type=none).
]]
function set_titletype(cite_class, title_type)
if is_set(title_type) then
if "none" == title_type then
title_type = ""; -- if |type=none then type parameter not displayed
end
return title_type; -- if |type= has been set to any other value use that value
end
if "AV-media-notes" == cite_class or "DVD-notes" == cite_class then -- if this citation is cite AV media notes or cite DVD notes
return "Media notes"; -- display AV media notes / DVD media notes annotation
elseif "mailinglist" == cite_class then -- if this citation is cite mailing list
return "Mailing list"; -- display mailing list annotation
elseif "podcast" == cite_class then -- if this citation is cite podcast
return "Podcast"; -- display podcast annotation
elseif "pressrelease" == cite_class then -- if this citation is cite press release
return "Press release"; -- display press release annotation
elseif "report" == cite_class then -- if this citation is cite report
return "Report"; -- display report annotation
elseif "techreport" == cite_class then -- if this citation is cite techreport
return "Technical report"; -- display techreport annotation
elseif "thesis" == cite_class then -- if this citation is cite thesis (degree option handled after this function returns)
return "Thesis"; -- display simple thesis annotation (without |degree= modification)
end
end
--[[
Determines whether a URL string is valid
At present the only check is whether the string appears to
be prefixed with a URI scheme. It is not determined whether
the URI scheme is valid or whether the URL is otherwise well
formed.
]]
function checkurl( url_str )
-- Protocol-relative or URL scheme
return url_str:sub(1,2) == "//" or url_str:match( "^[^/]*:" ) ~= nil;
end
-- Removes irrelevant text and dashes from ISBN number
-- Similar to that used for Special:BookSources
function cleanisbn( isbn_str )
return isbn_str:gsub( "[^-0-9X]", "" );
end
--[[--------------------------< E S C A P E _ L U A _ M A G I C _ C H A R S >----------------------------------
Returns a string where all of lua's magic characters have been escaped. This is important because functions like
string.gsub() treat their pattern and replace strings as patterns, not literal strings.
]]
function escape_lua_magic_chars (argument)
argument = argument:gsub("%%", "%%%%"); -- replace % with %%
argument = argument:gsub("([%^%$%(%)%.%[%]%*%+%-%?])", "%%%1"); -- replace all other lua magic pattern characters
return argument;
end
--[[--------------------------< S T R I P _ A P O S T R O P H E _ M A R K U P >--------------------------------
Strip wiki italic and bold markup from argument so that it doesn't contaminate COinS metadata.
This function strips common patterns of apostrophe markup. We presume that editors who have taken the time to
markup a title have, as a result, provided valid markup. When they don't, some single apostrophes are left behind.
]]
function strip_apostrophe_markup (argument)
if not is_set (argument) then return argument; end
while true do
if argument:match ("%'%'%'%'%'") then -- bold italic (5)
argument=argument:gsub("%'%'%'%'%'", ""); -- remove all instances of it
elseif argument:match ("%'%'%'%'") then -- italic start and end without content (4)
argument=argument:gsub("%'%'%'%'", "");
elseif argument:match ("%'%'%'") then -- bold (3)
argument=argument:gsub("%'%'%'", "");
elseif argument:match ("%'%'") then -- italic (2)
argument=argument:gsub("%'%'", "");
else
break;
end
end
return argument; -- done
end
--[[--------------------------< M A K E _ C O I N S _ T I T L E >----------------------------------------------
Makes a title for COinS from Title and / or ScriptTitle (or any other name-script pairs)
Apostrophe markup (bold, italics) is stripped from each value so that the COinS metadata isn't correupted with strings
of %27%27...
]]
function make_coins_title (title, script)
if is_set (title) then
title = strip_apostrophe_markup (title); -- strip any apostrophe markup
else
title=''; -- if not set, make sure title is an empty string
end
if is_set (script) then
script = script:gsub ('^%l%l%s*:%s*', ''); -- remove language prefix if present (script value may now be empty string)
script = strip_apostrophe_markup (script); -- strip any apostrophe markup
else
script=''; -- if not set, make sure script is an empty string
end
if is_set (title) and is_set (script) then
script = ' ' .. script; -- add a space before we concatenate
end
return title .. script; -- return the concatenation
end
--[[--------------------------< G E T _ C O I N S _ P A G E S >------------------------------------------------
Extract page numbers from external wikilinks in any of the |page=, |pages=, or |at= parameters for use in COinS.
]]
function get_coins_pages (pages)
local pattern;
if not is_set (pages) then return pages; end -- if no page numbers then we're done
while true do
pattern = pages:match("%[(%w*:?//[^ ]+%s+)[%w%d].*%]"); -- pattern is the opening bracket, the url and following space(s): "[url "
if nil == pattern then break; end -- no more urls
pattern = escape_lua_magic_chars (pattern); -- pattern is not a literal string; escape lua's magic pattern characters
pages = pages:gsub(pattern, ""); -- remove as many instances of pattern as possible
end
pages = pages:gsub("[%[%]]", ""); -- remove the brackets
pages = pages:gsub("–", "-" ); -- replace endashes with hyphens
pages = pages:gsub("&%w+;", "-" ); -- and replace html entities (– etc.) with hyphens; do we need to replace numerical entities like   and the like?
return pages;
end
--[[
ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit. ISBN-13 is checked in checkisbn().
If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length and stripped of dashes,
spaces and other non-isxn characters.
]]
function is_valid_isxn (isxn_str, len)
local temp = 0;
isxn_str = { isxn_str:byte(1, len) }; -- make a table of bytes
len = len+1; -- adjust to be a loop counter
for i, v in ipairs( isxn_str ) do -- loop through all of the bytes and calculate the checksum
if v == string.byte( "X" ) then -- if checkdigit is X
temp = temp + 10*( len - i ); -- it represents 10 decimal
else
temp = temp + tonumber( string.char(v) )*(len-i);
end
end
return temp % 11 == 0; -- returns true if calculation result is zero
end
-- Determines whether an ISBN string is valid
function checkisbn( isbn_str )
if nil ~= isbn_str:match("[^%s-0-9X]") then return false; end -- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
isbn_str = isbn_str:gsub( "-", "" ):gsub( " ", "" ); -- remove hyphens and spaces
local len = isbn_str:len();
if len ~= 10 and len ~= 13 then
return false;
end
if len == 10 then
if isbn_str:match( "^%d*X?$" ) == nil then return false; end
return is_valid_isxn(isbn_str, 10);
else
local temp = 0;
if isbn_str:match( "^97[89]%d*$" ) == nil then return false; end -- isbn13 begins with 978 or 979
isbn_str = { isbn_str:byte(1, len) };
for i, v in ipairs( isbn_str ) do
temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );
end
return temp % 10 == 0;
end
end
-- Gets the display text for a wikilink like [[A|B]] or [[B]] gives B
function removewikilink( str )
return (str:gsub( "%[%[([^%[%]]*)%]%]", function(l)
return l:gsub( "^[^|]*|(.*)$", "%1" ):gsub("^%s*(.-)%s*$", "%1");
end));
end
-- Escape sequences for content that will be used for URL descriptions
function safeforurl( str )
if str:match( "%[%[.-%]%]" ) ~= nil then
table.insert( z.message_tail, { seterror( 'wikilink_in_url', {}, true ) } );
end
return str:gsub( '[%[%]\n]', {
['['] = '[',
[']'] = ']',
['\n'] = ' ' } );
end
-- Converts a hyphen to a dash
function hyphentodash( str )
if not is_set(str) or str:match( "[%[%]{}<>]" ) ~= nil then
return str;
end
return str:gsub( '-', '–' );
end
-- Protects a string that will be wrapped in wiki italic markup '' ... ''
function safeforitalics( str )
--[[ Note: We cannot use <i> for italics, as the expected behavior for
italics specified by ''...'' in the title is that they will be inverted
(i.e. unitalicized) in the resulting references. In addition, <i> and ''
tend to interact poorly under Mediawiki's HTML tidy. ]]
if not is_set(str) then
return str;
else
if str:sub(1,1) == "'" then str = "<span></span>" .. str; end
if str:sub(-1,-1) == "'" then str = str .. "<span></span>"; end
-- Remove newlines as they break italics.
return str:gsub( '\n', ' ' );
end
end
--[[--------------------------< S A F E J O I N >--------------------------------------------------------------
Joins a sequence of strings together while checking for duplicate separation characters.
]]
function safejoin( tbl, duplicate_char )
--[[
Note: we use string functions here, rather than ustring functions.
This has considerably faster performance and should work correctly as
long as the duplicate_char is strict ASCII. The strings
in tbl may be ASCII or UTF8.
]]
local str = ''; -- the output string
local comp = ''; -- what does 'comp' mean?
local end_chr = '';
local trim;
for _, value in ipairs( tbl ) do
if value == nil then value = ''; end
if str == '' then -- if output string is empty
str = value; -- assign value to it (first time through the loop)
elseif value ~= '' then
if value:sub(1,1) == '<' then -- Special case of values enclosed in spans and other markup.
comp = value:gsub( "%b<>", "" ); -- remove html markup (<span>string</span> -> string)
else
comp = value;
end
-- typically duplicate_char is sepc
if comp:sub(1,1) == duplicate_char then -- is first charactier same as duplicate_char? why test first character?
-- Because individual string segments often (always?) begin with terminal punct for th
-- preceding segment: 'First element' .. 'sepc next element' .. etc?
trim = false;
end_chr = str:sub(-1,-1); -- get the last character of the output string
-- str = str .. "<HERE(enchr=" .. end_chr.. ")" -- debug stuff?
if end_chr == duplicate_char then -- if same as separator
str = str:sub(1,-2); -- remove it
elseif end_chr == "'" then -- if it might be wikimarkup
if str:sub(-3,-1) == duplicate_char .. "''" then -- if last three chars of str are sepc''
str = str:sub(1, -4) .. "''"; -- remove them and add back ''
elseif str:sub(-5,-1) == duplicate_char .. "]]''" then -- if last five chars of str are sepc]]''
trim = true; -- why? why do this and next differently from previous?
elseif str:sub(-4,-1) == duplicate_char .. "]''" then -- if last four chars of str are sepc]''
trim = true; -- same question
end
elseif end_chr == "]" then -- if it might be wikimarkup
if str:sub(-3,-1) == duplicate_char .. "]]" then -- if last three chars of str are sepc]] wikilink
trim = true;
elseif str:sub(-2,-1) == duplicate_char .. "]" then -- if last two chars of str are sepc] external link
trim = true;
elseif str:sub(-4,-1) == duplicate_char .. "'']" then -- normal case when |url=something & |title=Title.
trim = true;
end
elseif end_chr == " " then -- if last char of output string is a space
if str:sub(-2,-1) == duplicate_char .. " " then -- if last two chars of str are <sepc><space>
str = str:sub(1,-3); -- remove them both
end
end
if trim then
if value ~= comp then -- value does not equal comp when value contains html markup
local dup2 = duplicate_char;
if dup2:match( "%A" ) then dup2 = "%" .. dup2; end -- if duplicate_char not a letter then escape it
value = value:gsub( "(%b<>)" .. dup2, "%1", 1 ) -- remove duplicate_char if it follows html markup
else
value = value:sub( 2, -1 ); -- remove duplicate_char when it is first character
end
end
end
str = str .. value; --add it to the output string
end
end
return str;
end
-- Attempts to convert names to initials.
function reducetoinitials(first)
local initials = {}
local i = 0; -- counter for number of initials
for word in string.gmatch(first, "%S+") do
table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
i = i + 1; -- bump the counter
if 2 <= i then break; end -- only two initials allowed in Vancouver system; if 2, quit
end
return table.concat(initials) -- Vancouver format does not include spaces.
end
-- Formats a list of people (e.g. authors / editors)
function listpeople(control, people)
local sep;
local namesep;
local format = control.format
local maximum = control.maximum
local lastauthoramp = control.lastauthoramp;
local text = {}
local etal = false;
if 'vanc' == format then -- Vancouver-like author/editor name styling?
sep = ','; -- name-list separator between authors is a comma
namesep = ' '; -- last/first separator is a space
else
sep = ';' -- name-list separator between authors is a semicolon
namesep = ', ' -- last/first separator is <comma><space>
end
if sep:sub(-1,-1) ~= " " then sep = sep .. " " end
if maximum ~= nil and maximum < 1 then return "", 0; end
for i,person in ipairs(people) do
if is_set(person.last) then
local mask = person.mask
local one
local sep_one = sep;
if maximum ~= nil and i > maximum then
etal = true;
break;
elseif (mask ~= nil) then
local n = tonumber(mask)
if (n ~= nil) then
one = string.rep("—",n)
else
one = mask;
sep_one = " ";
end
else
one = person.last
local first = person.first
if is_set(first) then
if ( "vanc" == format ) then first = reducetoinitials(first) end
one = one .. namesep .. first
end
if is_set(person.link) and person.link ~= control.page_name then
one = "[[" .. person.link .. "|" .. one .. "]]" -- link author/editor if this page is not the author's/editor's page
end
if is_set(person.link) and ((nil ~= person.link:find("//")) or (nil ~= person.link:find("[%[%]]"))) then
one = one .. " " .. seterror( 'bad_authorlink' ) end -- url or wikilink in author link;
end
table.insert( text, one )
table.insert( text, sep_one )
end
end
local count = #text / 2;
if count > 0 then
if count > 1 and is_set(lastauthoramp) and not etal then
text[#text-2] = " & ";
end
text[#text] = nil;
end
local result = table.concat(text) -- construct list
if etal then
local etal_text = cfg.messages['et al'];
result = result .. " " .. etal_text;
end
return result, count
end
--[[--------------------------< A N C H O R I D >--------------------------------------------------------------
Generates a CITEREF anchor ID if we have at least one name or a date. Otherwise returns an empty string.
]]
function anchorid( options )
local id = table.concat( options ); -- concatenate names and year for CITEREF id
if is_set (id) then -- if concatenation is not an empty string
return "CITEREF" .. id; -- add the CITEREF portion
else
return ''; -- return an empty string; no reason to include CITEREF id in this citation
end
end
--[[
Gets name list from the input arguments
Searches through args in sequential order to find |lastn= and |firstn= parameters (or their aliases), and their matching link and mask parameters.
Stops searching when both |lastn= and |firstn= are not found in args after two sequential attempts: found |last1=, |last2=, and |last3= but doesn't
find |last4= and |last5= then the search is done.
This function emits an error message when there is a |firstn= without a matching |lastn=. When there are 'holes' in the list of last names, |last1= and |last3=
are present but |last2= is missing, an error message is emitted. |lastn= is not required to have a matching |firstn=.
]]
function extractnames(args, list_name)
local names = {}; -- table of names
local last; -- individual name components
local first;
local link;
local mask;
local i = 1; -- loop counter/indexer
local n = 1; -- output table indexer
local count = 0; -- used to count the number of times we haven't found a |last= (or alias for authors, |editor-last or alias for editors)
local err_msg_list_name = list_name:match ("(%w+)List") .. 's list'; -- modify AuthorList or EditorList for use in error messages if necessary
while true do
last = selectone( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', i ); -- search through args for name components beginning at 1
first = selectone( args, cfg.aliases[list_name .. '-First'], 'redundant_parameters', i );
link = selectone( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i );
mask = selectone( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );
if first and not last then -- if there is a firstn without a matching lastn
table.insert( z.message_tail, { seterror( 'first_missing_last', {err_msg_list_name, i}, true ) } ); -- add this error message
elseif not first and not last then -- if both firstn and lastn aren't found, are we done?
count = count + 1; -- number of times we haven't found last and first
if 2 == count then -- two missing names and we give up
break; -- normal exit or there is a two-name hole in the list; can't tell which
end
else -- we have last with or without a first
names[n] = {last = last, first = first, link = link, mask = mask}; -- add this name to our names list
n = n + 1; -- point to next location in the names table
if 1 == count then -- if the previous name was missing
table.insert( z.message_tail, { seterror( 'missing_name', {err_msg_list_name, i-1}, true ) } ); -- add this error message
end
count = 0; -- reset the counter, we're looking for two consecutive missing names
end
i = i + 1; -- point to next args location
end
return names; -- all done, return our list of names
end
-- Populates ID table from arguments using configuration settings
function extractids( args )
local id_list = {};
for k, v in pairs( cfg.id_handlers ) do
v = selectone( args, v.parameters, 'redundant_parameters' );
if is_set(v) then id_list[k] = v; end
end
return id_list;
end
--[[--------------------------< B U I L D I D L I S T >--------------------------------------------------------
Takes a table of IDs and turns it into a table of formatted ID outputs.
]]
function buildidlist( id_list, options )
local new_list, handler = {};
function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
for k, v in pairs( id_list ) do
-- fallback to read-only cfg
handler = setmetatable( { ['id'] = v }, fallback(k) );
if handler.mode == 'external' then
table.insert( new_list, {handler.label, externallinkid( handler ) } );
elseif handler.mode == 'internal' then
table.insert( new_list, {handler.label, internallinkid( handler ) } );
elseif handler.mode ~= 'manual' then
error( cfg.messages['unknown_ID_mode'] );
elseif k == 'DOI' then
table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
elseif k == 'ARXIV' then
table.insert( new_list, {handler.label, arxiv( v ) } );
elseif k == 'ASIN' then
table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } );
elseif k == 'LCCN' then
table.insert( new_list, {handler.label, lccn( v ) } );
elseif k == 'OL' then
table.insert( new_list, {handler.label, openlibrary( v ) } );
elseif k == 'PMC' then
table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
elseif k == 'PMID' then
table.insert( new_list, {handler.label, pmid( v ) } );
elseif k == 'ISSN' then
table.insert( new_list, {handler.label, issn( v ) } );
elseif k == 'ISBN' then
local ISBN = internallinkid( handler );
if not checkisbn( v ) and not is_set(options.IgnoreISBN) then
ISBN = ISBN .. seterror( 'bad_isbn', {}, false, " ", "" );
end
table.insert( new_list, {handler.label, ISBN } );
elseif k == 'USENETID' then
table.insert( new_list, {handler.label, message_id( v ) } );
else
error( cfg.messages['unknown_manual_ID'] );
end
end
function comp( a, b ) -- used in following table.sort()
return a[1] < b[1];
end
table.sort( new_list, comp );
for k, v in ipairs( new_list ) do
new_list[k] = v[2];
end
return new_list;
end
-- Chooses one matching parameter from a list of parameters to consider
-- Generates an error if more than one match is present.
function selectone( args, possible, error_condition, index )
local value = nil;
local selected = '';
local error_list = {};
if index ~= nil then index = tostring(index); end
-- Handle special case of "#" replaced by empty string
if index == '1' then
for _, v in ipairs( possible ) do
v = v:gsub( "#", "" );
if is_set(args[v]) then
if value ~= nil and selected ~= v then
table.insert( error_list, v );
else
value = args[v];
selected = v;
end
end
end
end
for _, v in ipairs( possible ) do
if index ~= nil then
v = v:gsub( "#", index );
end
if is_set(args[v]) then
if value ~= nil and selected ~= v then
table.insert( error_list, v );
else
value = args[v];
selected = v;
end
end
end
if #error_list > 0 then
local error_str = "";
for _, k in ipairs( error_list ) do
if error_str ~= "" then error_str = error_str .. cfg.messages['parameter-separator'] end
error_str = error_str .. wrap_style ('parameter', k);
end
if #error_list > 1 then
error_str = error_str .. cfg.messages['parameter-final-separator'];
else
error_str = error_str .. cfg.messages['parameter-pair-separator'];
end
error_str = error_str .. wrap_style ('parameter', selected);
table.insert( z.message_tail, { seterror( error_condition, {error_str}, true ) } );
end
return value, selected;
end
-- COinS metadata (see <http://ocoins.info/>) allows automated tools to parse
-- the citation information.
function COinS(data)
if 'table' ~= type(data) or nil == next(data) then
return '';
end
local ctx_ver = "Z39.88-2004";
-- treat table strictly as an array with only set values.
local OCinSoutput = setmetatable( {}, {
__newindex = function(self, key, value)
if is_set(value) then
rawset( self, #self+1, table.concat{ key, '=', mw.uri.encode( removewikilink( value ) ) } );
end
end
});
if is_set(data.Chapter) then
OCinSoutput.rft_val_fmt = "info:ofi/fmt:kev:mtx:book";
OCinSoutput["rft.genre"] = "bookitem";
OCinSoutput["rft.atitle"] = data.Chapter;
OCinSoutput["rft.btitle"] = data.Title;
elseif is_set(data.Periodical) then
OCinSoutput.rft_val_fmt = "info:ofi/fmt:kev:mtx:journal";
OCinSoutput["rft.genre"] = "article";
OCinSoutput["rft.jtitle"] = data.Periodical;
OCinSoutput["rft.atitle"] = data.Title;
else
OCinSoutput.rft_val_fmt = "info:ofi/fmt:kev:mtx:book";
OCinSoutput["rft.genre"] = "book"
OCinSoutput["rft.btitle"] = data.Title;
end
OCinSoutput["rft.place"] = data.PublicationPlace;
OCinSoutput["rft.date"] = data.Date;
OCinSoutput["rft.series"] = data.Series;
OCinSoutput["rft.volume"] = data.Volume;
OCinSoutput["rft.issue"] = data.Issue;
OCinSoutput["rft.pages"] = data.Pages;
OCinSoutput["rft.edition"] = data.Edition;
OCinSoutput["rft.pub"] = data.PublisherName;
for k, v in pairs( data.ID_list ) do
local id, value = cfg.id_handlers[k].COinS;
if k == 'ISBN' then value = cleanisbn( v ); else value = v; end
if string.sub( id or "", 1, 4 ) == 'info' then
OCinSoutput["rft_id"] = table.concat{ id, "/", v };
else
OCinSoutput[ id ] = value;
end
end
local last, first;
for k, v in ipairs( data.Authors ) do
last, first = v.last, v.first;
if k == 1 then
if is_set(last) then
OCinSoutput["rft.aulast"] = last;
end
if is_set(first) then
OCinSoutput["rft.aufirst"] = first;
end
end
if is_set(last) and is_set(first) then
OCinSoutput["rft.au"] = table.concat{ last, ", ", first };
elseif is_set(last) then
OCinSoutput["rft.au"] = last;
end
end
OCinSoutput.rft_id = data.URL;
OCinSoutput.rfr_id = table.concat{ "info:sid/", mw.site.server:match( "[^/]*$" ), ":", data.RawPage };
OCinSoutput = setmetatable( OCinSoutput, nil );
-- sort with version string always first, and combine.
table.sort( OCinSoutput );
table.insert( OCinSoutput, 1, "ctx_ver=" .. ctx_ver ); -- such as "Z39.88-2004"
return table.concat(OCinSoutput, "&");
end
--[[--------------------------< G E T _ I S O 6 3 9 _ C O D E >------------------------------------------------
Validates language names provided in |language= parameter if not an ISO639-1 code. Handles the special case that is Norwegian where
ISO639-1 code 'no' is mapped to language name 'Norwegian Bokmål' by Extention:CLDR.
Returns the language name and associated ISO639-1 code. Because case of the source may be incorrect or different from the case that Wikimedia
uses, the name comparisons are done in lower case and when a match is found, the Wikimedia version (assumed to be correct) is returned along
with the code. When there is no match, we return the original language name string.
mw.language.fetchLanguageNames() will return a list of languages that aren't part of ISO639-1. Names that aren't ISO639-1 but that are included
in the list will be found if that name is provided in the |language= parameter. For example, if |language=Samaritan Aramaic, that name will be
found with the associated code 'sam', not an ISO639-1 code. When names are found and the associated code is not two characters, this function
returns only the Wikimedia language name.
Adapted from code taken from Module:Check ISO 639-1.
]]
function get_iso639_code (lang)
if 'norwegian' == lang:lower() then -- special case related to Wikimedia remap of code 'no' at Extension:CLDR
return 'Norwegian', 'no'; -- Make sure rendered version is properly capitalized
end
local languages = mw.language.fetchLanguageNames('en', 'all') -- get a list of language names known to Wikimedia
-- ('all' is required for North Ndebele, South Ndebele, and Ojibwa)
local langlc = mw.ustring.lower(lang); -- lower case version for comparisons
for code, name in pairs(languages) do -- scan the list to see if we can find our language
if langlc == mw.ustring.lower(name) then
if 2 ~= code:len() then -- ISO639-1 codes only
return name; -- so return the name but not the code
end
return name, code; -- found it, return name to ensure proper capitalization and the ISO639-1 code
end
end
return lang; -- not valid language; return language in original case and nil for ISO639-1 code
end
--[[--------------------------< L A N G U A G E _ P A R A M E T E R >------------------------------------------
Get language name from ISO639-1 code value provided. If a code is valid use the returned name; if not, then use the value that was provided with the language parameter.
There is an exception. There are three ISO639-1 codes for Norewegian language variants. There are two official variants: Norwegian Bokmål (code 'nb') and
Norwegian Nynorsk (code 'nn'). The third, code 'no', is defined by ISO639-1 as 'Norwegian' though in Norway this is pretty much meaningless. However, it appears
that on enwiki, editors are for the most part unaware of the nb and nn variants (compare page counts for these variants at Category:Articles with non-English-language external links.
Because Norwegian Bokmål is the most common language variant, Media wiki has been modified to return Norwegian Bokmål for ISO639-1 code 'no'. Here we undo that and
return 'Norwegian' when editors use |language=no. We presume that editors don't know about the variants or can't descriminate between them.
See Help talk:Citation Style_1#An ISO 639-1 language name test
When |language= contains a valid ISO639-1 code, the page is assigned to the category for that code: Category:Norwegian-language sources (no) if
the page is a mainspace page and the ISO639-1 code is not 'en'. Similarly, if the parameter is |language=Norwegian, it will be categorized in the same way.
]]
function language_parameter (lang, namespace)
local code; -- the ISO639-1 two character code
local name; -- the language name
local test='';
if 0 == namespace and (('en' == lang:lower()) or ('english' == lang:lower())) then
table.insert (z.maintenance_cats, 'CS1 maint: English language specified'); -- add maintenance category if |language=English or |language=en in article space
end
if 2 == lang:len() then -- ISO639-1 language code are 2 characters (fetchLanguageName also supports 3 character codes)
name = mw.language.fetchLanguageName( lang:lower(), "en" ); -- get ISO 639-1 language name if Language is a proper code
end
if is_set (name) then -- if Language specified a valid ISO639-1 code
code = lang:lower(); -- save it
else
name, code = get_iso639_code (lang); -- attempt to get code from name (assign name here so that we are sure of proper capitalization)
end
if is_set (code) then
if 'no' == code then name = 'Norwegian' end; -- override wikimedia when code is 'no'
if 0 == namespace and 'en' ~= code then -- is this page main / article space and English not the language?
table.insert( z.properties_cats, 'CS1 ' .. name .. '-language sources (' .. code .. ')'); -- in main space and not English: categorize
end
else
table.insert (z.maintenance_cats, 'CS1 maint: Unrecognized language'); -- add maintenance category when |language= does not appear to be ISO 639-1 language
end
return (" " .. wrap_msg ('language', name)); -- wrap with '(in ...)'
end
--[[--------------------------< G E T _ S E T T I N G S _ F R O M _ C I T E _ C L A S S >----------------------
When |mode= is not set or when its value is invalid, use config.CitationClass and parameter values to establish
rendered style.
]]
function get_settings_from_cite_class (ps, ref, cite_class)
local sep;
if (cite_class == "citation") then -- for citation templates (CS2)
sep = ','; -- set citation separator to its default (comma)
if not is_set (ps) then -- if |postscript= has not been set, set cs2 default
ps = ''; -- make sure it isn't nil
end
if not is_set (ref) then -- if |ref= is not set
ref = "harv"; -- set default |ref=harv
end
else -- not a citation template so CS1
sep = '.'; -- set cite xxx separator to its default (period)
if not is_set (ps) then -- if |postscript= has not been set
ps = '.'; -- set cs1 default
end
end
return sep, ps, ref -- return them all
end
--[[--------------------------< S E T _ S T Y L E >------------------------------------------------------------
Establish basic style settings to be used when rendering the citation. Uses |mode= if set and valid or uses
config.CitationClass from the template's #invoke: to establish style.
]]
function set_style (mode, ps, ref, cite_class)
local sep;
if is_set (mode) then
if 'cs2' == mode then -- if this template is to be rendered in CS2 (citation) style
sep = ','; -- separate elements with a comma
if not is_set (ps) then -- unless explicitely set to something
ps = ''; -- make sure it isn't nil
end
if not is_set (ref) then -- unless explicitely set to something
ref = 'harv'; -- set so this template renders with CITEREF anchor id
end
elseif 'cs1' == mode then -- if this template is to be rendered in CS1 (cite xxx) style
sep = '.'; -- separate elements with a period
if not is_set (ps) then -- unless explicitely set to something
ps = '.'; -- terminate the rendered citation with a period
end
else -- anything but cs1 or cs2
table.insert( z.message_tail, { seterror( 'invalid_param_val', {'mode', mode}, true ) } ); -- add error message
sep, ps, ref = get_settings_from_cite_class (ps, ref, cite_class); -- get settings based on the template's CitationClass
end
else -- when |mode= empty or omitted
sep, ps, ref = get_settings_from_cite_class (ps, ref, cite_class); -- get settings based on the template's CitationClass
end
if 'none' == ps:lower() then -- if assigned value is 'none' then
ps = ''; -- set to empty string
end
return sep, ps, ref
end
--[[--------------------------< C I T A T I O N 0 >------------------------------------------------------------
This is the main function doing the majority of the citation
formatting.
]]
function citation0( config, args)
--[[
Load Input Parameters
The argument_wrapper facilitates the mapping of multiple
aliases to single internal variable.
]]
local A = argument_wrapper( args );
local i
local PPrefix = A['PPrefix']
local PPPrefix = A['PPPrefix']
if is_set( A['NoPP'] ) then PPPrefix = "" PPrefix = "" end
-- Pick out the relevant fields from the arguments. Different citation templates
-- define different field names for the same underlying things.
local Authors = A['Authors'];
local a = extractnames( args, 'AuthorList' );
local Coauthors = A['Coauthors'];
local Others = A['Others'];
local Editors = A['Editors'];
local e = extractnames( args, 'EditorList' );
local NameListFormat = A['NameListFormat']; -- replaces |author-format= and |editor-format=
if is_set (NameListFormat) and ('vanc' ~= NameListFormat) then -- only accepted value for this parameter is 'vanc'
table.insert( z.message_tail, { seterror( 'invalid_param_val', {'name-list-format', NameListFormat}, true ) } ); -- not vanc so add error message
NameListFormat = ''; -- set to empty string
end
local Year = A['Year'];
local PublicationDate = A['PublicationDate'];
local OrigYear = A['OrigYear'];
local Date = A['Date'];
local LayDate = A['LayDate'];
------------------------------------------------- Get title data
local Title = A['Title'];
local ScriptTitle = A['ScriptTitle'];
local BookTitle = A['BookTitle'];
local Conference = A['Conference'];
local TransTitle = A['TransTitle'];
local TitleNote = A['TitleNote'];
local TitleLink = A['TitleLink'];
local Chapter = A['Chapter'];
local ChapterLink = A['ChapterLink']; -- deprecated
local TransChapter = A['TransChapter'];
local TitleType = A['TitleType'];
local Degree = A['Degree'];
local Docket = A['Docket'];
local ArchiveURL = A['ArchiveURL'];
local URL = A['URL']
local URLorigin = A:ORIGIN('URL'); -- get name of parameter that holds URL
local ChapterURL = A['ChapterURL'];
local ChapterURLorigin = A:ORIGIN('ChapterURL'); -- get name of parameter that holds ChapterURL
local ConferenceURL = A['ConferenceURL'];
local ConferenceURLorigin = A:ORIGIN('ConferenceURL'); -- get name of parameter that holds ConferenceURL
local Periodical = A['Periodical'];
local Series = A['Series'];
local Volume = A['Volume'];
local Issue = A['Issue'];
local Position = '';
local Page = A['Page'];
local Pages = hyphentodash( A['Pages'] );
local At = A['At'];
local Edition = A['Edition'];
local PublicationPlace = A['PublicationPlace']
local Place = A['Place'];
local PublisherName = A['PublisherName'];
local RegistrationRequired = A['RegistrationRequired'];
local SubscriptionRequired = A['SubscriptionRequired'];
local Via = A['Via'];
local AccessDate = A['AccessDate'];
local ArchiveDate = A['ArchiveDate'];
local Agency = A['Agency'];
local DeadURL = A['DeadURL']
local Language = A['Language'];
local Format = A['Format'];
local ChapterFormat = A['ChapterFormat'];
local DoiBroken = A['DoiBroken'];
local ID = A['ID'];
local ASINTLD = A['ASINTLD'];
local IgnoreISBN = A['IgnoreISBN'];
local Embargo = A['Embargo'];
local ID_list = extractids( args );
local Quote = A['Quote'];
local LayURL = A['LayURL'];
local LaySource = A['LaySource'];
local Transcript = A['Transcript'];
local TranscriptURL = A['TranscriptURL']
local TranscriptURLorigin = A:ORIGIN('TranscriptURL'); -- get name of parameter that holds TranscriptURL
local LastAuthorAmp = A['LastAuthorAmp'];
local no_tracking_cats = A['NoTracking'];
--these are used by cite interview
local Callsign = A['Callsign'];
local City = A['City'];
local Program = A['Program'];
--local variables that are not cs1 parameters
local use_lowercase; -- controls capitalization of certain static text
local this_page = mw.title.getCurrentTitle(); -- also used for COinS and for language
local anchor_year; -- used in the CITEREF identifier
local COinS_date; -- used in the COinS metadata
-- set default parameter values defined by |mode= parameter. If |mode= is empty or omitted, use CitationClass to set these values
local sepc; -- separator between citation elements for CS1 a period, for CS2, a comma
local PostScript;
local Ref;
sepc, PostScript, Ref = set_style (A['Mode']:lower(), A['PostScript'], A['Ref'], config.CitationClass);
use_lowercase = ( sepc == ',' ); -- used to control capitalization for certain static text
--check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories.
if not is_set(no_tracking_cats) then -- ignore if we are already not going to categorize this page
if inArray (this_page.nsText, cfg.uncategorized_namespaces) then
no_tracking_cats = "true"; -- set no_tracking_cats
end
end
-- check for extra |page=, |pages= or |at= parameters.
if is_set(Page) then
if is_set(Pages) or is_set(At) then
Page = Page .. " " .. seterror('extra_pages'); -- add error message
Pages = ''; -- unset the others
At = '';
end
elseif is_set(Pages) then
if is_set(At) then
Pages = Pages .. " " .. seterror('extra_pages'); -- add error messages
At = ''; -- unset
end
end
-- both |publication-place= and |place= (|location=) allowed if different
if not is_set(PublicationPlace) and is_set(Place) then
PublicationPlace = Place; -- promote |place= (|location=) to |publication-place
end
if PublicationPlace == Place then Place = ''; end -- don't need both if they are the same
--[[
Parameter remapping for cite encyclopedia:
When the citation has these parameters:
|encyclopedia and |title then map |title to |article and |encyclopedia to |title
|encyclopedia and |article then map |encyclopedia to |title
|encyclopedia then map |encyclopedia to |title
|trans_title maps to |trans_chapter when |title is re-mapped
|url maps to |chapterurl when |title is remapped
All other combinations of |encyclopedia, |title, and |article are not modified
TODO: script-title to script-chapter if and when we support script-chapter
]]
local Encyclopedia = A['Encyclopedia'];
if ( config.CitationClass == "encyclopaedia" ) or ( config.CitationClass == "citation" and is_set (Encyclopedia)) then -- test code for citation
if is_set(Periodical) then -- Periodical is set when |encyclopedia is set
if is_set(Title) then
if not is_set(Chapter) then
Chapter = Title; -- |encyclopedia and |title are set so map |title to |article and |encyclopedia to |title
TransChapter = TransTitle;
ChapterURL = URL;
Title = Periodical;
ChapterFormat = Format;
Periodical = ''; -- redundant so unset
TransTitle = ''; -- redundant so unset
URL = ''; -- redundant so unset
Format = ''; -- redundant so unset
end
else -- |title not set
Title = Periodical; -- |encyclopedia set and |article set or not set so map |encyclopedia to |title
Periodical = ''; -- redundant so unset
end
end
end
-- Special case for cite techreport.
if (config.CitationClass == "techreport") then -- special case for cite techreport
if is_set(Issue) then -- cite techreport uses 'number', which other citations aliase to 'issue'
if not is_set(ID) then -- can we use ID for the "number"?
ID = Issue; -- yes, use it
Issue = ""; -- unset Issue so that "number" isn't duplicated in the rendered citation or COinS metadata
else -- can't use ID so emit error message
ID = ID .. " " .. seterror('redundant_parameters', '<code>|id=</code> and <code>|number=</code>');
end
end
end
-- special case for cite interview
if (config.CitationClass == "interview") then
if is_set(Program) then
ID = ' ' .. Program;
end
if is_set(Callsign) then
if is_set(ID) then
ID = ID .. sepc .. ' ' .. Callsign;
else
ID = ' ' .. Callsign;
end
end
if is_set(City) then
if is_set(ID) then
ID = ID .. sepc .. ' ' .. City;
else
ID = ' ' .. City;
end
end
if is_set(Others) then
if is_set(TitleType) then
Others = ' ' .. TitleType .. ' with ' .. Others;
TitleType = '';
else
Others = ' ' .. 'Interview with ' .. Others;
end
else
Others = '(Interview)';
end
end
-- special case for cite mailing list
if (config.CitationClass == "mailinglist") then
Periodical = A ['MailingList'];
end
--Account for the oddity that is {{cite journal}} with |pmc= set and |url= not set
if config.CitationClass == "journal" and not is_set(URL) and is_set(ID_list['PMC']) then
if not is_embargoed(Embargo) then
URL=cfg.id_handlers['PMC'].prefix .. ID_list['PMC']; -- set url to be the same as the PMC external link if not embargoed
URLorigin = cfg.id_handlers['PMC'].parameters[1]; -- set URLorigin to parameter name for use in error message if citation is missing a |title=
end
end
-- Account for the oddity that is {{cite conference}}, before generation of COinS data.
if 'conference' == config.CitationClass then
if is_set(BookTitle) then
Chapter = Title;
-- ChapterLink = TitleLink; -- |chapterlink= is deprecated
ChapterURL = URL;
ChapterURLorigin = URLorigin;
URLorigin = '';
ChapterFormat = Format;
TransChapter = TransTitle;
Title = BookTitle;
Format = '';
-- TitleLink = '';
TransTitle = '';
URL = '';
end
else
Conference = ''; -- not cite conference so make sure this is empty string
end
-- Account for the oddity that is {{cite episode}}, before generation of COinS data.
--[[ -- {{cite episode}} is not currently supported by this module
if config.CitationClass == "episode" then
local AirDate = A['AirDate'];
local SeriesLink = A['SeriesLink'];
local Season = A['Season'];
local SeriesNumber = A['SeriesNumber'];
local Network = A['Network'];
local Station = A['Station'];
local s, n = {}, {};
local Sep = (first_set(A["SeriesSeparator"], A["Separator"]) or "") .. " ";
if is_set(Issue) then table.insert(s, cfg.messages["episode"] .. " " .. Issue); Issue = ''; end
if is_set(Season) then table.insert(s, cfg.messages["season"] .. " " .. Season); end
if is_set(SeriesNumber) then table.insert(s, cfg.messages["series"] .. " " .. SeriesNumber); end
if is_set(Network) then table.insert(n, Network); end
if is_set(Station) then table.insert(n, Station); end
Date = Date or AirDate;
Chapter = Title;
ChapterLink = TitleLink;
TransChapter = TransTitle;
Title = Series;
TitleLink = SeriesLink;
TransTitle = '';
Series = table.concat(s, Sep);
ID = table.concat(n, Sep);
end
-- end of {{cite episode}} stuff]]
-- legacy: promote concatenation of |month=, and |year= to Date if Date not set; or, promote PublicationDate to Date if neither Date nor Year are set.
if is_set(Date) then
if is_set (Year) then
table.insert( z.maintenance_cats, "CS1 maint: Date and year"); -- add to maint category
end
else
Date = Year; -- promote Year to Date
Year = nil; -- make nil so Year as empty string isn't used for CITEREF
if is_set(Date) then
local Month = A['Month'];
if is_set(Month) then
Date = Month .. " " .. Date;
end
elseif is_set(PublicationDate) then -- use PublicationDate when |date= and |year= are not set
Date = PublicationDate; -- promote PublicationDate to Date
PublicationDate = ''; -- unset, no longer needed
end
end
if PublicationDate == Date then PublicationDate = ''; end -- if PublicationDate is same as Date, don't display in rendered citation
--[[
Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates. This must be done before we do COinS because here is where
we get the date used in the metadata.
Date validation supporting code is in Module:Citation/CS1/Date_validation
]]
anchor_year, COinS_date, error_message = dates({['accessdate']=AccessDate, ['airdate']=AirDate, ['archivedate']=ArchiveDate, ['date']=Date, ['doi_brokendate']=DoiBroken,
['embargo']=Embargo, ['laydate']=LayDate, ['publicationdate']=PublicationDate, ['year']=Year});
if is_set(error_message) then
table.insert( z.message_tail, { seterror( 'bad_date', {error_message}, true ) } ); -- add this error message
end
-- At this point fields may be nil if they weren't specified in the template use. We can use that fact.
-- Test if citation has no title
if not is_set(Title) and
-- not is_set(Periodical) and -- not a title
-- not is_set(Conference) and -- not a title
not is_set(TransTitle) and
not is_set(ScriptTitle) then
table.insert( z.message_tail, { seterror( 'citation_missing_title', {}, true ) } );
end
if 'none' == Title and is_set(Periodical) and not (( config.CitationClass == "encyclopaedia" ) or ( config.CitationClass == "citation" and is_set (Encyclopedia))) then -- special case
Title = ''; -- set title to empty string
table.insert( z.maintenance_cats, "CS1 maint: Untitled periodical"); -- add to maint category
end
-- COinS metadata (see <http://ocoins.info/>) for automated parsing of citation information.
-- handle the oddity that is cite encyclopedia and {{citation |encyclopedia=something}}. Here we presume that
-- when Periodical, Title, and Chapter are all set, then Periodical is the book (encyclopedia) title, Title
-- is the article title, and Chapter is a section within the article. So, we remap
local coins_chapter = Chapter; -- default assuming that remapping not required
local coins_title = Title; -- et tu
if 'encyclopaedia' == config.CitationClass or ('citation' == config.CitationClass and is_set (Encyclopedia)) then
if is_set (Chapter) and is_set (Title) and is_set (Periodical) then -- if all are used then
coins_chapter = Title; -- remap
coins_title = Periodical;
end
end
-- this is the function call to COinS()
local OCinSoutput = COinS{
['Periodical'] = Periodical,
['Chapter'] = strip_apostrophe_markup (coins_chapter), -- Chapter stripped of bold / italic wikimarkup
['Title'] = make_coins_title (coins_title, ScriptTitle), -- Title and ScriptTitle stripped of bold / italic wikimarkup
['PublicationPlace'] = PublicationPlace,
['Date'] = first_set(COinS_date, Date), -- COinS_date has correctly formatted date if Date is valid; any reason to keep Date here? Should we be including invalid dates in metadata?
['Series'] = Series,
['Volume'] = Volume,
['Issue'] = Issue,
['Pages'] = get_coins_pages (first_set(Page, Pages, At)), -- pages stripped of external links
['Edition'] = Edition,
['PublisherName'] = PublisherName,
['URL'] = first_set( URL, ChapterURL ),
['Authors'] = a,
['ID_list'] = ID_list,
['RawPage'] = this_page.prefixedText,
};
--[[Why is this here? Why are we mapping Title to Chapter when Periodical is set?
if is_set(Periodical) and not is_set(Chapter) and is_set(Title) then
Chapter = Title;
ChapterLink = TitleLink;
TransChapter = TransTitle;
Title = '';
TitleLink = '';
TransTitle = '';
end
]]
-- special case for cite newsgroup. Do this after COinS because we are modifying Publishername to include some static text
if 'newsgroup' == config.CitationClass then
if is_set (PublisherName) then
PublisherName = '[[Newsgroup]]: ' .. externallink( 'news:' .. PublisherName, PublisherName );
end
end
-- Now perform various field substitutions.
-- We also add leading spaces and surrounding markup and punctuation to the
-- various parts of the citation, but only when they are non-nil.
if not is_set(Authors) then
local Maximum = tonumber( A['DisplayAuthors'] );
if is_set (Maximum) then
if Maximum >= #a then -- if display-authors value greater than or equal to number of authors
table.insert( z.maintenance_cats, "CS1 maint: display-authors"); -- add maintenance category because display-authors parameter may be removed
end
else
Maximum = #a + 1; -- number of authors + 1
end
local control = {
format = NameListFormat, -- empty string or 'vanc'
maximum = Maximum,
lastauthoramp = LastAuthorAmp,
page_name = this_page.text -- get current page name so that we don't wikilink to it via authorlinkn
};
-- If the coauthor field is also used, prevent ampersand and et al. formatting.
if is_set(Coauthors) then
control.lastauthoramp = nil;
control.maximum = #a + 1;
end
Authors = listpeople(control, a)
end
if not is_set(Authors) and is_set(Coauthors) then -- coauthors aren't displayed if one of authors=, authorn=, or lastn= isn't specified
table.insert( z.message_tail, { seterror('coauthors_missing_author', {}, true) } ); -- emit error message
end
local EditorCount
if not is_set(Editors) then
local Maximum = tonumber( A['DisplayEditors'] );
-- Preserve old-style implicit et al.
if not is_set(Maximum) and #e == 4 then
Maximum = 3;
table.insert( z.message_tail, { seterror('implict_etal_editor', {}, true) } );
elseif not is_set(Maximum) then
Maximum = #e + 1;
end
local control = {
format = NameListFormat, -- empty string or 'vanc'
maximum = Maximum,
lastauthoramp = LastAuthorAmp,
page_name = this_page.text -- get current page name so that we don't wikilink to it via editorlinkn
};
Editors, EditorCount = listpeople(control, e);
else
EditorCount = 1;
end
local Cartography = "";
local Scale = "";
if config.CitationClass == "map" then
if not is_set( Authors ) and is_set( PublisherName ) then
Authors = PublisherName;
PublisherName = "";
end
Cartography = A['Cartography'];
if is_set( Cartography ) then
Cartography = sepc .. " " .. wrap_msg ('cartography', Cartography, use_lowercase);
end
Scale = A['Scale'];
if is_set( Scale ) then
Scale = sepc .. " " .. Scale;
end
end
Format = is_set(Format) and " (" .. Format .. ")" or "";
if not is_set(URL) and
not is_set(ArchiveURL) and
not is_set(ConferenceURL) and -- TODO: keep this here? conference as part of cite web or cite podcast?
not is_set(TranscriptURL) then
-- Test if cite web or cite podcast |url= is missing or empty
if inArray(config.CitationClass, {"web","podcast", "mailinglist"}) then
table.insert( z.message_tail, { seterror( 'cite_web_url', {}, true ) } );
end
-- Test if accessdate is given without giving a URL
if is_set(AccessDate) and not is_set(ChapterURL)then -- ChapterURL may be set when the others are not set; TODO: move this to a separate test?
table.insert( z.message_tail, { seterror( 'accessdate_missing_url', {}, true ) } );
AccessDate = '';
end
-- Test if format is given without giving a URL
if is_set(Format) then
Format = Format .. seterror( 'format_missing_url', {'format', 'url'} );
end
end
--[[
-- Test if citation has no title
if not is_set(Title) and
-- not is_set(Periodical) and -- not a title
-- not is_set(Conference) and -- not a title
not is_set(TransTitle) and
not is_set(ScriptTitle) then
table.insert( z.message_tail, { seterror( 'citation_missing_title', {}, true ) } );
end
if 'none' == Title and is_set(Periodical) then -- special case
Title = ''; -- set title to empty string
table.insert( z.maintenance_cats, "CS1 maint: Untitled periodical"); -- add to maint category
end
]]
local OriginalURL;
DeadURL = DeadURL:lower(); -- used later when assembling archived text
if is_set( ArchiveURL ) then
if is_set (URL) then
OriginalURL = URL; -- save copy of original source URL
if 'no' ~= DeadURL then -- if URL set then archive-url applies to it
URL = ArchiveURL -- swap-in the archive's url
URLorigin = A:ORIGIN('ArchiveURL') -- name of archive url parameter for error messages
end
elseif is_set (ChapterURL) then -- URL not set so if chapter-url is set apply archive url to it
OriginalURL = ChapterURL; -- save copy of source chapter's url for archive text
if 'no' ~= DeadURL then
ChapterURL = ArchiveURL -- swap-in the archive's url
URLorigin = A:ORIGIN('ArchiveURL') -- name of archive url parameter for error messages
end
end
end
if inArray(config.CitationClass, {"web","news","journal","pressrelease","podcast", "newsgroup"}) or
('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia)) then
if is_set (Chapter) or is_set (TransChapter) or is_set (ChapterURL)then -- chapter parameters not supported for these citation types
table.insert( z.message_tail, { seterror( 'chapter_ignored', {}, true ) } ); -- add error message
Chapter = ''; -- set to empty string to be safe with concatenation
TransChapter = '';
ChapterURL = '';
end
else -- otherwise, format chapter / article title
Chapter = format_chapter_title (Chapter, TransChapter, ChapterURL, ChapterURLorigin);
if is_set (Chapter) then
ChapterFormat = is_set(ChapterFormat) and " (" .. ChapterFormat .. ")" or "";
if is_set(ChapterFormat) and not is_set (ChapterURL) then -- Test if |chapter-format= is given without giving a |chapter-url=
ChapterFormat = ChapterFormat .. seterror( 'format_missing_url', {'chapter-format', 'chapter-url'} );
end
Chapter = Chapter .. ChapterFormat .. sepc .. ' ';
end
end
-- Format main title.
if is_set(TitleLink) and is_set(Title) then
Title = "[[" .. TitleLink .. "|" .. Title .. "]]"
end
if inArray(config.CitationClass, {"web","news","journal","pressrelease","podcast", "newsgroup", "mailinglist"}) or
('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia)) then
Title = kern_quotes (Title); -- if necessary, separate title's leading and trailing quote marks from Module provided quote marks
Title = wrap_style ('quoted-title', Title);
Title = script_concatenate (Title, ScriptTitle); -- <bdi> tags, lang atribute, categorization, etc; must be done after title is wrapped
TransTitle= wrap_style ('trans-quoted-title', TransTitle );
elseif 'report' == config.CitationClass then -- no styling for cite report
Title = script_concatenate (Title, ScriptTitle); -- <bdi> tags, lang atribute, categorization, etc; must be done after title is wrapped
TransTitle= wrap_style ('trans-quoted-title', TransTitle ); -- for cite report, use this form for trans-title
else
Title = wrap_style ('italic-title', Title);
Title = script_concatenate (Title, ScriptTitle); -- <bdi> tags, lang atribute, categorization, etc; must be done after title is wrapped
TransTitle = wrap_style ('trans-italic-title', TransTitle);
end
TransError = "";
if is_set(TransTitle) then
if is_set(Title) then
TransTitle = " " .. TransTitle;
else
TransError = " " .. seterror( 'trans_missing_title' );
end
end
Title = Title .. TransTitle;
if is_set(Title) then
if not is_set(TitleLink) and is_set(URL) then
Title = externallink( URL, Title ) .. TransError .. Format
URL = "";
Format = "";
else
Title = Title .. TransError;
end
end
if is_set(Place) then
Place = " " .. wrap_msg ('written', Place, use_lowercase) .. sepc .. " ";
end
if is_set(Conference) then
if is_set(ConferenceURL) then
Conference = externallink( ConferenceURL, Conference );
end
Conference = sepc .. " " .. Conference
elseif is_set(ConferenceURL) then
Conference = sepc .. " " .. externallink( ConferenceURL, nil, ConferenceURLorigin );
end
if not is_set(Position) then
local Minutes = A['Minutes'];
if is_set(Minutes) then
Position = " " .. Minutes .. " " .. cfg.messages['minutes'];
else
local Time = A['Time'];
if is_set(Time) then
local TimeCaption = A['TimeCaption']
if not is_set(TimeCaption) then
TimeCaption = cfg.messages['event'];
if sepc ~= '.' then
TimeCaption = TimeCaption:lower();
end
end
Position = " " .. TimeCaption .. " " .. Time;
end
end
else
Position = " " .. Position;
At = '';
end
if not is_set(Page) then
if is_set(Pages) then
if is_set(Periodical) and
not inArray(config.CitationClass, {"encyclopaedia","web","book","news","podcast"}) then
Pages = ": " .. Pages;
elseif tonumber(Pages) ~= nil then
Pages = sepc .." " .. PPrefix .. Pages;
else
Pages = sepc .." " .. PPPrefix .. Pages;
end
end
else
if is_set(Periodical) and
not inArray(config.CitationClass, {"encyclopaedia","web","book","news","podcast"}) then
Page = ": " .. Page;
else
Page = sepc .." " .. PPrefix .. Page;
end
end
At = is_set(At) and (sepc .. " " .. At) or "";
Position = is_set(Position) and (sepc .. " " .. Position) or "";
if config.CitationClass == 'map' then
local Section = A['Section'];
local Inset = A['Inset'];
if first_set( Pages, Page, At ) ~= nil or sepc ~= '.' then
if is_set( Section ) then
Section = ", " .. wrap_msg ('section', Section, true);
end
if is_set( Inset ) then
Inset = ", " .. wrap_msg ('inset', Inset, true);
end
else
if is_set( Section ) then
Section = sepc .. " " .. wrap_msg ('section', Section, use_lowercase);
if is_set( Inset ) then
Inset = ", " .. wrap_msg ('inset', Inset, true);
end
elseif is_set( Inset ) then
Inset = sepc .. " " .. wrap_msg ('inset', Inset, use_lowercase);
end
end
At = At .. Section .. Inset;
end
if is_set (Language) then
Language = language_parameter (Language, this_page.namespace); -- format, categories (article namespace only), name from ISO639-1, etc
else
Language=""; -- language not specified so make sure this is an empty string;
end
Others = is_set(Others) and (sepc .. " " .. Others) or "";
-- handle type parameter for those CS1 citations that have default values
if inArray(config.CitationClass, {"AV-media-notes", "DVD-notes", "mailinglist", "podcast", "pressrelease", "report", "techreport", "thesis"}) then
TitleType = set_titletype (config.CitationClass, TitleType);
if is_set(Degree) and "Thesis" == TitleType then -- special case for cite thesis
TitleType = Degree .. " thesis";
end
end
if is_set(TitleType) then -- if type parameter is specified
TitleType = " (" .. TitleType .. ")"; -- display it in parentheses
end
TitleNote = is_set(TitleNote) and (sepc .. " " .. TitleNote) or "";
Edition = is_set(Edition) and (" " .. wrap_msg ('edition', Edition)) or "";
Issue = is_set(Issue) and (" (" .. Issue .. ")") or "";
Series = is_set(Series) and (sepc .. " " .. Series) or "";
OrigYear = is_set(OrigYear) and (" [" .. OrigYear .. "]") or "";
Agency = is_set(Agency) and (sepc .. " " .. Agency) or "";
if is_set(Volume) then
if ( mw.ustring.len(Volume) > 4 )
then Volume = sepc .." " .. Volume;
else Volume = " <b>" .. hyphentodash(Volume) .. "</b>";
end
end
------------------------------------ totally unrelated data
if is_set(Via) then
Via = " " .. wrap_msg ('via', Via);
end
--[[
Subscription implies paywall; Registration does not. If both are used in a citation, the subscription required link
note is displayed. There are no error messages for this condition.
]]
if inArray(SubscriptionRequired:lower(), {'yes', 'true', 'y'}) then
SubscriptionRequired = sepc .. " " .. cfg.messages['subscription']; -- subscription required message
elseif inArray(RegistrationRequired:lower(), {'yes', 'true', 'y'}) then
SubscriptionRequired = sepc .. " " .. cfg.messages['registration']; -- registration required message
else
SubscriptionRequired = ''; -- either or both might be set to something other than yes true y
end
if is_set(AccessDate) then
local retrv_text = " " .. cfg.messages['retrieved']
AccessDate = nowrap_date (AccessDate); -- wrap in nowrap span if date in appropriate format
if (sepc ~= ".") then retrv_text = retrv_text:lower() end -- if 'citation', lower case
AccessDate = substitute (retrv_text, AccessDate); -- add retrieved text
-- neither of these work; don't know why; it seems that substitute() isn't being called
AccessDate = substitute (cfg.presentation['accessdate'], {sepc, AccessDate}); -- allow editors to hide accessdates
end
if is_set(ID) then ID = sepc .." ".. ID; end
if "thesis" == config.CitationClass and is_set(Docket) then
ID = sepc .." Docket ".. Docket .. ID;
end
if "report" == config.CitationClass and is_set(Docket) then -- for cite report when |docket= is set
ID = sepc .. ' ' .. Docket; -- overwrite ID even if |id= is set
end
ID_list = buildidlist( ID_list, {DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN, Embargo=Embargo} );
if is_set(URL) then
URL = " " .. externallink( URL, nil, URLorigin );
end
if is_set(Quote) then
if Quote:sub(1,1) == '"' and Quote:sub(-1,-1) == '"' then
Quote = Quote:sub(2,-2);
end
Quote = sepc .." " .. wrap_style ('quoted-text', Quote ); -- wrap in <q>...</q> tags
PostScript = ""; -- CS1 does not supply terminal punctuation when |quote= is set
end
local Archived
if is_set(ArchiveURL) then
if not is_set(ArchiveDate) then
ArchiveDate = seterror('archive_missing_date');
end
if "no" == DeadURL then
local arch_text = cfg.messages['archived'];
if sepc ~= "." then arch_text = arch_text:lower() end
Archived = sepc .. " " .. substitute( cfg.messages['archived-not-dead'],
{ externallink( ArchiveURL, arch_text ), ArchiveDate } );
if not is_set(OriginalURL) then
Archived = Archived .. " " .. seterror('archive_missing_url');
end
elseif is_set(OriginalURL) then
local arch_text = cfg.messages['archived-dead'];
if sepc ~= "." then arch_text = arch_text:lower() end
Archived = sepc .. " " .. substitute( arch_text,
{ externallink( OriginalURL, cfg.messages['original'] ), ArchiveDate } );
else
local arch_text = cfg.messages['archived-missing'];
if sepc ~= "." then arch_text = arch_text:lower() end
Archived = sepc .. " " .. substitute( arch_text,
{ seterror('archive_missing_url'), ArchiveDate } );
end
else
Archived = ""
end
local Lay
if is_set(LayURL) then
if is_set(LayDate) then LayDate = " (" .. LayDate .. ")" end
if is_set(LaySource) then
LaySource = " – ''" .. safeforitalics(LaySource) .. "''";
else
LaySource = "";
end
if sepc == '.' then
Lay = sepc .. " " .. externallink( LayURL, cfg.messages['lay summary'] ) .. LaySource .. LayDate
else
Lay = sepc .. " " .. externallink( LayURL, cfg.messages['lay summary']:lower() ) .. LaySource .. LayDate
end
else
Lay = "";
end
if is_set(Transcript) then
if is_set(TranscriptURL) then Transcript = externallink( TranscriptURL, Transcript ); end
elseif is_set(TranscriptURL) then
Transcript = externallink( TranscriptURL, nil, TranscriptURLorigin );
end
local Publisher;
if is_set(Periodical) and
not inArray(config.CitationClass, {"encyclopaedia","web","pressrelease","podcast"}) then
if is_set(PublisherName) then
if is_set(PublicationPlace) then
Publisher = PublicationPlace .. ": " .. PublisherName;
else
Publisher = PublisherName;
end
elseif is_set(PublicationPlace) then
Publisher= PublicationPlace;
else
Publisher = "";
end
if is_set(PublicationDate) then
if is_set(Publisher) then
Publisher = Publisher .. ", " .. wrap_msg ('published', PublicationDate);
else
Publisher = PublicationDate;
end
end
if is_set(Publisher) then
Publisher = " (" .. Publisher .. ")";
end
else
if is_set(PublicationDate) then
PublicationDate = " (" .. wrap_msg ('published', PublicationDate) .. ")";
end
if is_set(PublisherName) then
if is_set(PublicationPlace) then
Publisher = sepc .. " " .. PublicationPlace .. ": " .. PublisherName .. PublicationDate;
else
Publisher = sepc .. " " .. PublisherName .. PublicationDate;
end
elseif is_set(PublicationPlace) then
Publisher= sepc .. " " .. PublicationPlace .. PublicationDate;
else
Publisher = PublicationDate;
end
end
-- Several of the above rely upon detecting this as nil, so do it last.
if is_set(Periodical) then
if is_set(Title) or is_set(TitleNote) then
Periodical = sepc .. " " .. wrap_style ('italic-title', Periodical)
else
Periodical = wrap_style ('italic-title', Periodical)
end
end
--[[
Handle the oddity that is cite speech. This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be " (Speech)" so that
the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
]]
if "speech" == config.CitationClass then -- cite speech only
TitleNote = " (Speech)"; -- annotate the citation
if is_set (Periodical) then -- if Periodical, perhaps because of an included |website= or |journal= parameter
if is_set (Conference) then -- and if |event= is set
Conference = Conference .. sepc .. " "; -- then add appropriate punctuation to the end of the Conference variable before rendering
end
end
end
-- Piece all bits together at last. Here, all should be non-nil.
-- We build things this way because it is more efficient in LUA
-- not to keep reassigning to the same string variable over and over.
local tcommon
if inArray(config.CitationClass, {"journal","citation"}) and is_set(Periodical) then
if is_set(Others) then Others = Others .. sepc .. " " end
tcommon = safejoin( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Scale, Series,
Language, Cartography, Edition, Publisher, Agency, Volume, Issue}, sepc );
else
tcommon = safejoin( {Title, TitleNote, Conference, Periodical, Format, TitleType, Scale, Series, Language,
Volume, Issue, Others, Cartography, Edition, Publisher, Agency}, sepc );
end
if #ID_list > 0 then
ID_list = safejoin( { sepc .. " ", table.concat( ID_list, sepc .. " " ), ID }, sepc );
else
ID_list = ID;
end
local idcommon = safejoin( { ID_list, URL, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );
local text;
local pgtext = Position .. Page .. Pages .. At;
if is_set(Authors) then
if is_set(Coauthors) then
local sep = '; ';
if 'vanc' == NameListFormat then
sep = ', ';
end
Authors = Authors .. sep .. Coauthors;
end
if is_set(Date) then
Date = " ("..Date..")" .. OrigYear .. sepc .. " "
elseif string.sub(Authors,-1,-1) == sepc then
Authors = Authors .. " "
else
Authors = Authors .. sepc .. " "
end
if is_set(Editors) then
local in_text = " ";
local post_text = "";
if is_set(Chapter) then
in_text = in_text .. cfg.messages['in'] .. " "
else
if EditorCount <= 1 then
post_text = ", " .. cfg.messages['editor'];
else
post_text = ", " .. cfg.messages['editors'];
end
end
if (sepc ~= '.') then in_text = in_text:lower() end
Editors = in_text .. Editors .. post_text;
if (string.sub(Editors,-1,-1) == sepc)
then Editors = Editors .. " "
else Editors = Editors .. sepc .. " "
end
end
text = safejoin( {Authors, Date, Chapter, Place, Editors, tcommon }, sepc );
text = safejoin( {text, pgtext, idcommon}, sepc );
elseif is_set(Editors) then
if is_set(Date) then
if EditorCount <= 1 then
Editors = Editors .. ", " .. cfg.messages['editor'];
else
Editors = Editors .. ", " .. cfg.messages['editors'];
end
Date = " (" .. Date ..")" .. OrigYear .. sepc .. " "
else
if EditorCount <= 1 then
Editors = Editors .. " (" .. cfg.messages['editor'] .. ")" .. sepc .. " "
else
Editors = Editors .. " (" .. cfg.messages['editors'] .. ")" .. sepc .. " "
end
end
text = safejoin( {Editors, Date, Chapter, Place, tcommon}, sepc );
text = safejoin( {text, pgtext, idcommon}, sepc );
else
if is_set(Date) then
if ( string.sub(tcommon,-1,-1) ~= sepc )
then Date = sepc .." " .. Date .. OrigYear
else Date = " " .. Date .. OrigYear
end
end
if config.CitationClass=="journal" and is_set(Periodical) then
text = safejoin( {Chapter, Place, tcommon}, sepc );
text = safejoin( {text, pgtext, Date, idcommon}, sepc );
else
text = safejoin( {Chapter, Place, tcommon, Date}, sepc );
text = safejoin( {text, pgtext, idcommon}, sepc );
end
end
if is_set(PostScript) and PostScript ~= sepc then
text = safejoin( {text, sepc}, sepc ); --Deals with italics, spaces, etc.
text = text:sub(1,-sepc:len()-1);
-- text = text:sub(1,-2); --Remove final separator (assumes that sepc is only one character)
end
text = safejoin( {text, PostScript}, sepc );
-- Now enclose the whole thing in a <span/> element
local options = {};
if is_set(config.CitationClass) and config.CitationClass ~= "citation" then
options.class = "citation " .. config.CitationClass;
else
options.class = "citation";
end
if is_set(Ref) and Ref:lower() ~= "none" then
local id = Ref
if ( "harv" == Ref ) then
local names = {} --table of last names & year
if #a > 0 then
for i,v in ipairs(a) do
names[i] = v.last
if i == 4 then break end
end
elseif #e > 0 then
for i,v in ipairs(e) do
names[i] = v.last
if i == 4 then break end
end
end
names[ #names + 1 ] = first_set(Year, anchor_year); -- Year first for legacy citations and for YMD dates that require disambiguation
id = anchorid(names)
end
options.id = id;
end
if string.len(text:gsub("<span[^>/]*>.-</span>", ""):gsub("%b<>","")) <= 2 then
z.error_categories = {};
text = seterror('empty_citation');
z.message_tail = {};
end
if is_set(options.id) then
text = '<span id="' .. mw.uri.anchorEncode(options.id) ..'" class="' .. mw.text.nowiki(options.class) .. '">' .. text .. "</span>";
else
text = '<span class="' .. mw.text.nowiki(options.class) .. '">' .. text .. "</span>";
end
local empty_span = '<span style="display:none;"> </span>';
-- Note: Using display: none on then COinS span breaks some clients.
local OCinS = '<span title="' .. OCinSoutput .. '" class="Z3988">' .. empty_span .. '</span>';
text = text .. OCinS;
if #z.message_tail ~= 0 then
text = text .. " ";
for i,v in ipairs( z.message_tail ) do
if is_set(v[1]) then
if i == #z.message_tail then
text = text .. errorcomment( v[1], v[2] );
else
text = text .. errorcomment( v[1] .. "; ", v[2] );
end
end
end
end
no_tracking_cats = no_tracking_cats:lower();
if inArray(no_tracking_cats, {"", "no", "false", "n"}) then
for _, v in ipairs( z.error_categories ) do
text = text .. '[[Category:' .. v ..']]';
end
for _, v in ipairs( z.maintenance_cats ) do -- append maintenance categories
text = text .. '[[Category:' .. v ..']]';
end
for _, v in ipairs( z.properties_cats ) do -- append maintenance categories
text = text .. '[[Category:' .. v ..']]';
end
end
return text
end
-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
local pframe = frame:getParent()
if nil ~= string.find( frame:getTitle(), 'sandbox', 1, true ) then -- did the {{#invoke:}} use sandbox version?
cfg = mw.loadData( 'Module:Citation/CS1/Configuration/sandbox' ); -- load sandbox versions of Configuration and Whitelist and ...
whitelist = mw.loadData( 'Module:Citation/CS1/Whitelist/sandbox' );
dates = require('Module:Citation/CS1/Date_validation/sandbox').dates -- ... sandbox version of date validation code
else -- otherwise
cfg = mw.loadData( 'Module:Citation/CS1/Configuration' ); -- load live versions of Configuration and Whitelist and ...
whitelist = mw.loadData( 'Module:Citation/CS1/Whitelist' );
dates = require('Module:Citation/CS1/Date_validation').dates -- ... live version of date validation code
end
local args = {};
local suggestions = {};
local error_text, error_state;
local config = {};
for k, v in pairs( frame.args ) do
config[k] = v;
args[k] = v;
end
for k, v in pairs( pframe.args ) do
if v ~= '' then
if not validate( k ) then
error_text = "";
if type( k ) ~= 'string' then
-- Exclude empty numbered parameters
if v:match("%S+") ~= nil then
error_text, error_state = seterror( 'text_ignored', {v}, true );
end
elseif validate( k:lower() ) then
error_text, error_state = seterror( 'parameter_ignored_suggest', {k, k:lower()}, true );
else
if #suggestions == 0 then
suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );
end
if suggestions[ k:lower() ] ~= nil then
error_text, error_state = seterror( 'parameter_ignored_suggest', {k, suggestions[ k:lower() ]}, true );
else
error_text, error_state = seterror( 'parameter_ignored', {k}, true );
end
end
if error_text ~= '' then
table.insert( z.message_tail, {error_text, error_state} );
end
end
args[k] = v;
elseif args[k] ~= nil or (k == 'postscript') then
args[k] = v;
end
end
return citation0( config, args)
end
return z
nxx5xkgkqtad1cfa2vnlkq7s3kmefh6
189405
189404
2022-08-16T14:06:37Z
Venise12mai1834
8884
Scribunto
text/plain
require ('Module:No globals');
--[[--------------------------< 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+$', -- three or more character hostname.hostname or hostname.tld
'%f[%w][%w][%w%-]+[%w]%.xn%-%-[%w]+$', -- internationalized domain name with ACE prefix
'%f[%a][qxz]%.com$', -- assigned one character .com hostname (x.com times out 2015-12-10)
'%f[%a][iq]%.net$', -- assigned one character .net hostname (q.net registered but not active 2015-12-10)
'%f[%w][%w]%.%a%a$', -- one character hostname and ccTLD (2 chars)
'%f[%w][%w][%w]%.%a%a+$', -- two character hostname and TLD
'^%d%d?%d?%.%d%d?%d?%.%d%d?%d?%.%d%d?%d?', -- IPv4 address
}
for _, pattern in ipairs (patterns) do -- loop through the patterns list
if domain:match (pattern) then
return true; -- if a match then we think that this thing that purports to be a URL is a URL
end
end
for _, d in ipairs ({'cash', 'company', 'today', 'org'}) do -- look for single letter second level domain names for these top level domains
if domain:match ('%f[%w][%w]%.' .. d) then
return true
end
end
return false; -- no matches, we don't know what this thing is
end
--[[--------------------------< I S _ U R L >------------------------------------------------------------------
returns true if the scheme and domain parts of a URL appear to be a valid URL; else false.
This function is the last step in the validation process. This function is separate because there are cases that
are not covered by split_url(), for example is_parameter_ext_wikilink() which is looking for bracketted external
wikilinks.
]]
local function is_url (scheme, domain)
if utilities.is_set (scheme) then -- if scheme is set check it and domain
return is_scheme (scheme) and is_domain_name (domain);
else
return is_domain_name (domain); -- scheme not set when URL is protocol-relative
end
end
--[[--------------------------< S P L I T _ U R L >------------------------------------------------------------
Split a URL into a scheme, authority indicator, and domain.
First remove Fully Qualified Domain Name terminator (a dot following TLD) (if any) and any path(/), query(?) or fragment(#).
If protocol-relative URL, return nil scheme and domain else return nil for both scheme and domain.
When not protocol-relative, get scheme, authority indicator, and domain. If there is an authority indicator (one
or more '/' characters immediately following the scheme's colon), make sure that there are only 2.
Any URL that does not have news: scheme must have authority indicator (//). TODO: are there other common schemes
like news: that don't use authority indicator?
Strip off any port and path;
]]
local function split_url (url_str)
local scheme, authority, domain;
url_str = url_str:gsub ('([%a%d])%.?[/%?#].*$', '%1'); -- strip FQDN terminator and path(/), query(?), fragment (#) (the capture prevents false replacement of '//')
if url_str:match ('^//%S*') then -- if there is what appears to be a protocol-relative URL
domain = url_str:match ('^//(%S*)')
elseif url_str:match ('%S-:/*%S+') then -- if there is what appears to be a scheme, optional authority indicator, and domain name
scheme, authority, domain = url_str:match ('(%S-:)(/*)(%S+)'); -- extract the scheme, authority indicator, and domain portions
if utilities.is_set (authority) then
authority = authority:gsub ('//', '', 1); -- replace place 1 pair of '/' with nothing;
if utilities.is_set(authority) then -- if anything left (1 or 3+ '/' where authority should be) then
return scheme; -- return scheme only making domain nil which will cause an error message
end
else
if not scheme:match ('^news:') then -- except for news:..., MediaWiki won't link URLs that do not have authority indicator; TODO: a better way to do this test?
return scheme; -- return scheme only making domain nil which will cause an error message
end
end
domain = domain:gsub ('(%a):%d+', '%1'); -- strip port number if present
end
return scheme, domain;
end
--[[--------------------------< L I N K _ P A R A M _ O K >---------------------------------------------------
checks the content of |title-link=, |series-link=, |author-link=, etc. for properly formatted content: no wikilinks, no URLs
Link parameters are to hold the title of a Wikipedia article, so none of the WP:TITLESPECIALCHARACTERS are allowed:
# < > [ ] | { } _
except the underscore which is used as a space in wiki URLs and # which is used for section links
returns false when the value contains any of these characters.
When there are no illegal characters, this function returns TRUE if value DOES NOT appear to be a valid URL (the
|<param>-link= parameter is ok); else false when value appears to be a valid URL (the |<param>-link= parameter is NOT ok).
]]
local function link_param_ok (value)
local scheme, domain;
if value:find ('[<>%[%]|{}]') then -- if any prohibited characters
return false;
end
scheme, domain = split_url (value); -- get scheme or nil and domain or nil from URL;
return not is_url (scheme, domain); -- return true if value DOES NOT appear to be a valid URL
end
--[[--------------------------< L I N K _ T I T L E _ O K >---------------------------------------------------
Use link_param_ok() to validate |<param>-link= value and its matching |<title>= value.
|<title>= may be wiki-linked but not when |<param>-link= has a value. This function emits an error message when
that condition exists
check <link> for inter-language interwiki-link prefix. prefix must be a MediaWiki-recognized language
code and must begin with a colon.
]]
local function link_title_ok (link, lorig, title, torig)
local orig;
if utilities.is_set (link) then -- don't bother if <param>-link doesn't have a value
if not link_param_ok (link) then -- check |<param>-link= markup
orig = lorig; -- identify the failing link parameter
elseif title:find ('%[%[') then -- check |title= for wikilink markup
orig = torig; -- identify the failing |title= parameter
elseif link:match ('^%a+:') then -- if the link is what looks like an interwiki
local prefix = link:match ('^(%a+):'):lower(); -- get the interwiki prefix
if cfg.inter_wiki_map[prefix] then -- if prefix is in the map, must have preceding colon
orig = lorig; -- flag as error
end
end
end
if utilities.is_set (orig) then
link = ''; -- unset
utilities.set_message ('err_bad_paramlink', orig); -- URL or wikilink in |title= with |title-link=;
end
return link; -- link if ok, empty string else
end
--[[--------------------------< C H E C K _ U R L >------------------------------------------------------------
Determines whether a URL string appears to be valid.
First we test for space characters. If any are found, return false. Then split the URL into scheme and domain
portions, or for protocol-relative (//example.com) URLs, just the domain. Use is_url() to validate the two
portions of the URL. If both are valid, or for protocol-relative if domain is valid, return true, else false.
Because it is different from a standard URL, and because this module used external_link() to make external links
that work for standard and news: links, we validate newsgroup names here. The specification for a newsgroup name
is at https://tools.ietf.org/html/rfc5536#section-3.1.4
]]
local function check_url( url_str )
if nil == url_str:match ("^%S+$") then -- if there are any spaces in |url=value it can't be a proper URL
return false;
end
local scheme, domain;
scheme, domain = split_url (url_str); -- get scheme or nil and domain or nil from URL;
if 'news:' == scheme then -- special case for newsgroups
return domain:match('^[%a%d%+%-_]+%.[%a%d%+%-_%.]*[%a%d%+%-_]$');
end
return is_url (scheme, domain); -- return true if value appears to be a valid URL
end
--[=[-------------------------< I S _ P A R A M E T E R _ E X T _ W I K I L I N K >----------------------------
Return true if a parameter value has a string that begins and ends with square brackets [ and ] and the first
non-space characters following the opening bracket appear to be a URL. The test will also find external wikilinks
that use protocol-relative URLs. Also finds bare URLs.
The frontier pattern prevents a match on interwiki-links which are similar to scheme:path URLs. The tests that
find bracketed URLs are required because the parameters that call this test (currently |title=, |chapter=, |work=,
and |publisher=) may have wikilinks and there are articles or redirects like '//Hus' so, while uncommon, |title=[[//Hus]]
is possible as might be [[en://Hus]].
]=]
local function is_parameter_ext_wikilink (value)
local scheme, domain;
if value:match ('%f[%[]%[%a%S*:%S+.*%]') then -- if ext. wikilink with scheme and domain: [xxxx://yyyyy.zzz]
scheme, domain = split_url (value:match ('%f[%[]%[(%a%S*:%S+).*%]'));
elseif value:match ('%f[%[]%[//%S+.*%]') then -- if protocol-relative ext. wikilink: [//yyyyy.zzz]
scheme, domain = split_url (value:match ('%f[%[]%[(//%S+).*%]'));
elseif value:match ('%a%S*:%S+') then -- if bare URL with scheme; may have leading or trailing plain text
scheme, domain = split_url (value:match ('(%a%S*:%S+)'));
elseif value:match ('//%S+') then -- if protocol-relative bare URL: //yyyyy.zzz; may have leading or trailing plain text
scheme, domain = split_url (value:match ('(//%S+)')); -- what is left should be the domain
else
return false; -- didn't find anything that is obviously a URL
end
return is_url (scheme, domain); -- return true if value appears to be a valid URL
end
--[[-------------------------< C H E C K _ F O R _ U R L >-----------------------------------------------------
loop through a list of parameters and their values. Look at the value and if it has an external link, emit an error message.
]]
local function check_for_url (parameter_list, error_list)
for k, v in pairs (parameter_list) do -- for each parameter in the list
if is_parameter_ext_wikilink (v) then -- look at the value; if there is a URL add an error message
table.insert (error_list, utilities.wrap_style ('parameter', k));
end
end
end
--[[--------------------------< S A F E _ F O R _ U R L >------------------------------------------------------
Escape sequences for content that will be used for URL descriptions
]]
local function safe_for_url( str )
if str:match( "%[%[.-%]%]" ) ~= nil then
utilities.set_message ('err_wikilink_in_url', {});
end
return str:gsub( '[%[%]\n]', {
['['] = '[',
[']'] = ']',
['\n'] = ' ' } );
end
--[[--------------------------< E X T E R N A L _ L I N K >----------------------------------------------------
Format an external link with error checking
]]
local function external_link (URL, label, source, access)
local err_msg = '';
local domain;
local path;
local base_url;
if not utilities.is_set (label) then
label = URL;
if utilities.is_set (source) then
utilities.set_message ('err_bare_url_missing_title', {utilities.wrap_style ('parameter', source)});
else
error (cfg.messages["bare_url_no_origin"]);
end
end
if not check_url (URL) then
utilities.set_message ('err_bad_url', {utilities.wrap_style ('parameter', source)});
end
domain, path = URL:match ('^([/%.%-%+:%a%d]+)([/%?#].*)$'); -- split the URL into scheme plus domain and path
if path then -- if there is a path portion
path = path:gsub ('[%[%]]', {['['] = '%5b', [']'] = '%5d'}); -- replace '[' and ']' with their percent-encoded values
URL = table.concat ({domain, path}); -- and reassemble
end
base_url = table.concat ({ "[", URL, " ", safe_for_url (label), "]" }); -- assemble a wiki-markup URL
if utilities.is_set (access) then -- access level (subscription, registration, limited)
base_url = utilities.substitute (cfg.presentation['ext-link-access-signal'], {cfg.presentation[access].class, cfg.presentation[access].title, base_url}); -- add the appropriate icon
end
return base_url;
end
--[[--------------------------< D E P R E C A T E D _ P A R A M E T E R >--------------------------------------
Categorize and emit an error message when the citation contains one or more deprecated parameters. The function includes the
offending parameter name to the error message. Only one error message is emitted regardless of the number of deprecated
parameters in the citation.
added_deprecated_cat is a Boolean declared in page scope variables above
]]
local function deprecated_parameter(name)
if not added_deprecated_cat then
added_deprecated_cat = true; -- note that we've added this category
utilities.set_message ('err_deprecated_params', {name}); -- add error message
end
end
--[=[-------------------------< K E R N _ Q U O T E S >--------------------------------------------------------
Apply kerning to open the space between the quote mark provided by the module and a leading or trailing quote
mark contained in a |title= or |chapter= parameter's value.
This function will positive kern either single or double quotes:
"'Unkerned title with leading and trailing single quote marks'"
" 'Kerned title with leading and trailing single quote marks' " (in real life the kerning isn't as wide as this example)
Double single quotes (italic or bold wiki-markup) are not kerned.
Replaces Unicode quote marks in plain text or in the label portion of a [[L|D]] style wikilink with typewriter
quote marks regardless of the need for kerning. Unicode quote marks are not replaced in simple [[D]] wikilinks.
Call this function for chapter titles, for website titles, etc.; not for book titles.
]=]
local function kern_quotes (str)
local cap = '';
local wl_type, label, link;
wl_type, label, link = utilities.is_wikilink (str); -- wl_type is: 0, no wl (text in label variable); 1, [[D]]; 2, [[L|D]]
if 1 == wl_type then -- [[D]] simple wikilink with or without quote marks
if mw.ustring.match (str, '%[%[[\"“”\'‘’].+[\"“”\'‘’]%]%]') then -- leading and trailing quote marks
str = utilities.substitute (cfg.presentation['kern-left'], str);
str = utilities.substitute (cfg.presentation['kern-right'], str);
elseif mw.ustring.match (str, '%[%[[\"“”\'‘’].+%]%]') then -- leading quote marks
str = utilities.substitute (cfg.presentation['kern-left'], str);
elseif mw.ustring.match (str, '%[%[.+[\"“”\'‘’]%]%]') then -- trailing quote marks
str = utilities.substitute (cfg.presentation['kern-right'], str);
end
else -- plain text or [[L|D]]; text in label variable
label = mw.ustring.gsub (label, '[“”]', '\"'); -- replace “” (U+201C & U+201D) with " (typewriter double quote mark)
label = mw.ustring.gsub (label, '[‘’]', '\''); -- replace ‘’ (U+2018 & U+2019) with ' (typewriter single quote mark)
cap = mw.ustring.match (label, "^([\"\'][^\'].+)"); -- match leading double or single quote but not doubled single quotes (italic markup)
if utilities.is_set (cap) then
label = utilities.substitute (cfg.presentation['kern-left'], cap);
end
cap = mw.ustring.match (label, "^(.+[^\'][\"\'])$") -- match trailing double or single quote but not doubled single quotes (italic markup)
if utilities.is_set (cap) then
label = utilities.substitute (cfg.presentation['kern-right'], cap);
end
if 2 == wl_type then
str = utilities.make_wikilink (link, label); -- reassemble the wikilink
else
str = label;
end
end
return str;
end
--[[--------------------------< F O R M A T _ S C R I P T _ V A L U E >----------------------------------------
|script-title= holds title parameters that are not written in Latin-based scripts: Chinese, Japanese, Arabic, Hebrew, etc. These scripts should
not be italicized and may be written right-to-left. The value supplied by |script-title= is concatenated onto Title after Title has been wrapped
in italic markup.
Regardless of language, all values provided by |script-title= are wrapped in <bdi>...</bdi> tags to isolate RTL languages from the English left to right.
|script-title= provides a unique feature. The value in |script-title= may be prefixed with a two-character ISO 639-1 language code and a colon:
|script-title=ja:*** *** (where * represents a Japanese character)
Spaces between the two-character code and the colon and the colon and the first script character are allowed:
|script-title=ja : *** ***
|script-title=ja: *** ***
|script-title=ja :*** ***
Spaces preceding the prefix are allowed: |script-title = ja:*** ***
The prefix is checked for validity. If it is a valid ISO 639-1 language code, the lang attribute (lang="ja") is added to the <bdi> tag so that browsers can
know the language the tag contains. This may help the browser render the script more correctly. If the prefix is invalid, the lang attribute
is not added. At this time there is no error message for this condition.
Supports |script-title=, |script-chapter=, |script-<periodical>=
]]
local function format_script_value (script_value, script_param)
local lang=''; -- initialize to empty string
local name;
if script_value:match('^%l%l%l?%s*:') then -- if first 3 or 4 non-space characters are script language prefix
lang = script_value:match('^(%l%l%l?)%s*:%s*%S.*'); -- get the language prefix or nil if there is no script
if not utilities.is_set (lang) then
utilities.set_message ('err_script_parameter', {script_param, cfg.err_msg_supl['missing title part']}); -- prefix without 'title'; add error message
return ''; -- script_value was just the prefix so return empty string
end
-- if we get this far we have prefix and script
name = cfg.lang_code_remap[lang] or mw.language.fetchLanguageName( lang, cfg.this_wiki_code ); -- get language name so that we can use it to categorize
if utilities.is_set (name) then -- is prefix a proper ISO 639-1 language code?
script_value = script_value:gsub ('^%l+%s*:%s*', ''); -- strip prefix from script
-- is prefix one of these language codes?
if utilities.in_array (lang, cfg.script_lang_codes) then
utilities.add_prop_cat ('script', {name, lang})
else
utilities.set_message ('err_script_parameter', {script_param, cfg.err_msg_supl['unknown language code']}); -- unknown script-language; add error message
end
lang = ' lang="' .. lang .. '" '; -- convert prefix into a lang attribute
else
utilities.set_message ('err_script_parameter', {script_param, cfg.err_msg_supl['invalid language code']}); -- invalid language code; add error message
lang = ''; -- invalid so set lang to empty string
end
else
utilities.set_message ('err_script_parameter', {script_param, cfg.err_msg_supl['missing prefix']}); -- no language code prefix; add error message
end
script_value = utilities.substitute (cfg.presentation['bdi'], {lang, script_value}); -- isolate in case script is RTL
return script_value;
end
--[[--------------------------< S C R I P T _ C O N C A T E N A T E >------------------------------------------
Initially for |title= and |script-title=, this function concatenates those two parameter values after the script
value has been wrapped in <bdi> tags.
]]
local function script_concatenate (title, script, script_param)
if utilities.is_set (script) then
script = format_script_value (script, script_param); -- <bdi> tags, lang attribute, categorization, etc.; returns empty string on error
if utilities.is_set (script) then
title = title .. ' ' .. script; -- concatenate title and script title
end
end
return title;
end
--[[--------------------------< W R A P _ M S G >--------------------------------------------------------------
Applies additional message text to various parameter values. Supplied string is wrapped using a message_list
configuration taking one argument. Supports lower case text for {{citation}} templates. Additional text taken
from citation_config.messages - the reason this function is similar to but separate from wrap_style().
]]
local function wrap_msg (key, str, lower)
if not utilities.is_set ( str ) then
return "";
end
if true == lower then
local msg;
msg = cfg.messages[key]:lower(); -- set the message to lower case before
return utilities.substitute ( msg, str ); -- including template text
else
return utilities.substitute ( cfg.messages[key], str );
end
end
--[[----------------< W I K I S O U R C E _ U R L _ M A K E >-------------------
Makes a Wikisource URL from Wikisource interwiki-link. Returns the URL and appropriate
label; nil else.
str is the value assigned to |chapter= (or aliases) or |title= or |title-link=
]]
local function wikisource_url_make (str)
local wl_type, D, L;
local ws_url, ws_label;
local wikisource_prefix = table.concat ({'https://', cfg.this_wiki_code, '.wikisource.org/wiki/'});
wl_type, D, L = utilities.is_wikilink (str); -- wl_type is 0 (not a wikilink), 1 (simple wikilink), 2 (complex wikilink)
if 0 == wl_type then -- not a wikilink; might be from |title-link=
str = D:match ('^[Ww]ikisource:(.+)') or D:match ('^[Ss]:(.+)'); -- article title from interwiki link with long-form or short-form namespace
if utilities.is_set (str) then
ws_url = table.concat ({ -- build a Wikisource URL
wikisource_prefix, -- prefix
str, -- article title
});
ws_label = str; -- label for the URL
end
elseif 1 == wl_type then -- simple wikilink: [[Wikisource:ws article]]
str = D:match ('^[Ww]ikisource:(.+)') or D:match ('^[Ss]:(.+)'); -- article title from interwiki link with long-form or short-form namespace
if utilities.is_set (str) then
ws_url = table.concat ({ -- build a Wikisource URL
wikisource_prefix, -- prefix
str, -- article title
});
ws_label = str; -- label for the URL
end
elseif 2 == wl_type then -- non-so-simple wikilink: [[Wikisource:ws article|displayed text]] ([[L|D]])
str = L:match ('^[Ww]ikisource:(.+)') or L:match ('^[Ss]:(.+)'); -- article title from interwiki link with long-form or short-form namespace
if utilities.is_set (str) then
ws_label = D; -- get ws article name from display portion of interwiki link
ws_url = table.concat ({ -- build a Wikisource URL
wikisource_prefix, -- prefix
str, -- article title without namespace from link portion of wikilink
});
end
end
if ws_url then
ws_url = mw.uri.encode (ws_url, 'WIKI'); -- make a usable URL
ws_url = ws_url:gsub ('%%23', '#'); -- undo percent-encoding of fragment marker
end
return ws_url, ws_label, L or D; -- return proper URL or nil and a label or nil
end
--[[----------------< F O R M A T _ P E R I O D I C A L >-----------------------
Format the three periodical parameters: |script-<periodical>=, |<periodical>=,
and |trans-<periodical>= into a single Periodical meta-parameter.
]]
local function format_periodical (script_periodical, script_periodical_source, periodical, trans_periodical)
if not utilities.is_set (periodical) then
periodical = ''; -- to be safe for concatenation
else
periodical = utilities.wrap_style ('italic-title', periodical); -- style
end
periodical = script_concatenate (periodical, script_periodical, script_periodical_source); -- <bdi> tags, lang attribute, categorization, etc.; must be done after title is wrapped
if utilities.is_set (trans_periodical) then
trans_periodical = utilities.wrap_style ('trans-italic-title', trans_periodical);
if utilities.is_set (periodical) then
periodical = periodical .. ' ' .. trans_periodical;
else -- here when trans-periodical without periodical or script-periodical
periodical = trans_periodical;
utilities.set_message ('err_trans_missing_title', {'periodical'});
end
end
return periodical;
end
--[[------------------< F O R M A T _ C H A P T E R _ T I T L E >---------------
Format the four chapter parameters: |script-chapter=, |chapter=, |trans-chapter=,
and |chapter-url= into a single chapter meta- parameter (chapter_url_source used
for error messages).
]]
local function format_chapter_title (script_chapter, script_chapter_source, chapter, chapter_source, trans_chapter, trans_chapter_source, chapter_url, chapter_url_source, no_quotes, access)
local ws_url, ws_label, L = wikisource_url_make (chapter); -- make a wikisource URL and label from a wikisource interwiki link
if ws_url then
ws_label = ws_label:gsub ('_', ' '); -- replace underscore separators with space characters
chapter = ws_label;
end
if not utilities.is_set (chapter) then
chapter = ''; -- to be safe for concatenation
else
if false == no_quotes then
chapter = kern_quotes (chapter); -- if necessary, separate chapter title's leading and trailing quote marks from module provided quote marks
chapter = utilities.wrap_style ('quoted-title', chapter);
end
end
chapter = script_concatenate (chapter, script_chapter, script_chapter_source); -- <bdi> tags, lang attribute, categorization, etc.; must be done after title is wrapped
if utilities.is_set (chapter_url) then
chapter = external_link (chapter_url, chapter, chapter_url_source, access); -- adds bare_url_missing_title error if appropriate
elseif ws_url then
chapter = external_link (ws_url, chapter .. ' ', 'ws link in chapter'); -- adds bare_url_missing_title error if appropriate; space char to move icon away from chap text; TODO: better way to do this?
chapter = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, chapter});
end
if utilities.is_set (trans_chapter) then
trans_chapter = utilities.wrap_style ('trans-quoted-title', trans_chapter);
if utilities.is_set (chapter) then
chapter = chapter .. ' ' .. trans_chapter;
else -- here when trans_chapter without chapter or script-chapter
chapter = trans_chapter;
chapter_source = trans_chapter_source:match ('trans%-?(.+)'); -- when no chapter, get matching name from trans-<param>
utilities.set_message ('err_trans_missing_title', {chapter_source});
end
end
return chapter;
end
--[[----------------< H A S _ I N V I S I B L E _ C H A R S >-------------------
This function searches a parameter's value for non-printable or invisible characters.
The search stops at the first match.
This function will detect the visible replacement character when it is part of the Wikisource.
Detects but ignores nowiki and math stripmarkers. Also detects other named stripmarkers
(gallery, math, pre, ref) and identifies them with a slightly different error message.
See also coins_cleanup().
Output of this function is an error message that identifies the character or the
Unicode group, or the stripmarker that was detected along with its position (or,
for multi-byte characters, the position of its first byte) in the parameter value.
]]
local function has_invisible_chars (param, v)
local position = ''; -- position of invisible char or starting position of stripmarker
local capture; -- used by stripmarker detection to hold name of the stripmarker
local stripmarker; -- boolean set true when a stripmarker is found
capture = string.match (v, '[%w%p ]*'); -- test for values that are simple ASCII text and bypass other tests if true
if capture == v then -- if same there are no Unicode characters
return;
end
for _, invisible_char in ipairs (cfg.invisible_chars) do
local char_name = invisible_char[1]; -- the character or group name
local pattern = invisible_char[2]; -- the pattern used to find it
position, _, capture = mw.ustring.find (v, pattern); -- see if the parameter value contains characters that match the pattern
if position and (cfg.invisible_defs.zwj == capture) then -- if we found a zero-width joiner character
if mw.ustring.find (v, cfg.indic_script) then -- it's ok if one of the Indic scripts
position = nil; -- unset position
elseif cfg.emoji[mw.ustring.codepoint (v, position+1)] then -- is zwj followed by a character listed in emoji{}?
position = nil; -- unset position
end
end
if position then
if 'nowiki' == capture or 'math' == capture or -- nowiki and math stripmarkers (not an error condition)
('templatestyles' == capture and utilities.in_array (param, {'id', 'quote'})) then -- templatestyles stripmarker allowed in these parameters
stripmarker = true; -- set a flag
elseif true == stripmarker and cfg.invisible_defs.del == capture then -- because stripmakers begin and end with the delete char, assume that we've found one end of a stripmarker
position = nil; -- unset
else
local err_msg;
if capture and not (cfg.invisible_defs.del == capture or cfg.invisible_defs.zwj == capture) then
err_msg = capture .. ' ' .. char_name;
else
err_msg = char_name .. ' ' .. 'character';
end
utilities.set_message ('err_invisible_char', {err_msg, utilities.wrap_style ('parameter', param), position}); -- add error message
return; -- and done with this parameter
end
end
end
end
--[[-------------------< A R G U M E N T _ W R A P P E R >----------------------
Argument wrapper. This function provides support for argument mapping defined
in the configuration file so that multiple names can be transparently aliased to
single internal variable.
]]
local function argument_wrapper ( args )
local origin = {};
return setmetatable({
ORIGIN = function ( self, k )
local dummy = self[k]; -- force the variable to be loaded.
return origin[k];
end
},
{
__index = function ( tbl, k )
if origin[k] ~= nil then
return nil;
end
local args, list, v = args, cfg.aliases[k];
if type( list ) == 'table' then
v, origin[k] = utilities.select_one ( args, list, 'err_redundant_parameters' );
if origin[k] == nil then
origin[k] = ''; -- Empty string, not nil
end
elseif list ~= nil then
v, origin[k] = args[list], list;
else
-- maybe let through instead of raising an error?
-- v, origin[k] = args[k], k;
error( cfg.messages['unknown_argument_map'] .. ': ' .. k);
end
-- Empty strings, not nil;
if v == nil then
v = '';
origin[k] = '';
end
tbl = rawset( tbl, k, v );
return v;
end,
});
end
--[[--------------------------< N O W R A P _ D A T E >-------------------------
When date is YYYY-MM-DD format wrap in nowrap span: <span ...>YYYY-MM-DD</span>.
When date is DD MMMM YYYY or is MMMM DD, YYYY then wrap in nowrap span:
<span ...>DD MMMM</span> YYYY or <span ...>MMMM DD,</span> YYYY
DOES NOT yet support MMMM YYYY or any of the date ranges.
]]
local function nowrap_date (date)
local cap = '';
local cap2 = '';
if date:match("^%d%d%d%d%-%d%d%-%d%d$") then
date = utilities.substitute (cfg.presentation['nowrap1'], date);
elseif date:match("^%a+%s*%d%d?,%s+%d%d%d%d$") or date:match ("^%d%d?%s*%a+%s+%d%d%d%d$") then
cap, cap2 = string.match (date, "^(.*)%s+(%d%d%d%d)$");
date = utilities.substitute (cfg.presentation['nowrap2'], {cap, cap2});
end
return date;
end
--[[--------------------------< S E T _ T I T L E T Y P E >---------------------
This function sets default title types (equivalent to the citation including
|type=<default value>) for those templates that have defaults. Also handles the
special case where it is desirable to omit the title type from the rendered citation
(|type=none).
]]
local function set_titletype (cite_class, title_type)
if utilities.is_set (title_type) then
if 'none' == cfg.keywords_xlate[title_type] then
title_type = ''; -- if |type=none then type parameter not displayed
end
return title_type; -- if |type= has been set to any other value use that value
end
return cfg.title_types [cite_class] or ''; -- set template's default title type; else empty string for concatenation
end
--[[--------------------------< S A F E _ J O I N >-----------------------------
Joins a sequence of strings together while checking for duplicate separation characters.
]]
local function safe_join( tbl, duplicate_char )
local f = {}; -- create a function table appropriate to type of 'duplicate character'
if 1 == #duplicate_char then -- for single byte ASCII characters use the string library functions
f.gsub = string.gsub
f.match = string.match
f.sub = string.sub
else -- for multi-byte characters use the ustring library functions
f.gsub = mw.ustring.gsub
f.match = mw.ustring.match
f.sub = mw.ustring.sub
end
local str = ''; -- the output string
local comp = ''; -- what does 'comp' mean?
local end_chr = '';
local trim;
for _, value in ipairs( tbl ) do
if value == nil then value = ''; end
if str == '' then -- if output string is empty
str = value; -- assign value to it (first time through the loop)
elseif value ~= '' then
if value:sub(1, 1) == '<' then -- special case of values enclosed in spans and other markup.
comp = value:gsub( "%b<>", "" ); -- remove HTML markup (<span>string</span> -> string)
else
comp = value;
end
-- typically duplicate_char is sepc
if f.sub(comp, 1, 1) == duplicate_char then -- is first character same as duplicate_char? why test first character?
-- Because individual string segments often (always?) begin with terminal punct for the
-- preceding segment: 'First element' .. 'sepc next element' .. etc.?
trim = false;
end_chr = f.sub(str, -1, -1); -- get the last character of the output string
-- str = str .. "<HERE(enchr=" .. end_chr .. ")" -- debug stuff?
if end_chr == duplicate_char then -- if same as separator
str = f.sub(str, 1, -2); -- remove it
elseif end_chr == "'" then -- if it might be wiki-markup
if f.sub(str, -3, -1) == duplicate_char .. "''" then -- if last three chars of str are sepc''
str = f.sub(str, 1, -4) .. "''"; -- remove them and add back ''
elseif f.sub(str, -5, -1) == duplicate_char .. "]]''" then -- if last five chars of str are sepc]]''
trim = true; -- why? why do this and next differently from previous?
elseif f.sub(str, -4, -1) == duplicate_char .. "]''" then -- if last four chars of str are sepc]''
trim = true; -- same question
end
elseif end_chr == "]" then -- if it might be wiki-markup
if f.sub(str, -3, -1) == duplicate_char .. "]]" then -- if last three chars of str are sepc]] wikilink
trim = true;
elseif f.sub(str, -3, -1) == duplicate_char .. '"]' then -- if last three chars of str are sepc"] quoted external link
trim = true;
elseif f.sub(str, -2, -1) == duplicate_char .. "]" then -- if last two chars of str are sepc] external link
trim = true;
elseif f.sub(str, -4, -1) == duplicate_char .. "'']" then -- normal case when |url=something & |title=Title.
trim = true;
end
elseif end_chr == " " then -- if last char of output string is a space
if f.sub(str, -2, -1) == duplicate_char .. " " then -- if last two chars of str are <sepc><space>
str = f.sub(str, 1, -3); -- remove them both
end
end
if trim then
if value ~= comp then -- value does not equal comp when value contains HTML markup
local dup2 = duplicate_char;
if f.match(dup2, "%A" ) then dup2 = "%" .. dup2; end -- if duplicate_char not a letter then escape it
value = f.gsub(value, "(%b<>)" .. dup2, "%1", 1 ) -- remove duplicate_char if it follows HTML markup
else
value = f.sub(value, 2, -1 ); -- remove duplicate_char when it is first character
end
end
end
str = str .. value; -- add it to the output string
end
end
return str;
end
--[[--------------------------< I S _ S U F F I X >-----------------------------
returns true if suffix is properly formed Jr, Sr, or ordinal in the range 1–9.
Puncutation not allowed.
]]
local function is_suffix (suffix)
if utilities.in_array (suffix, {'Jr', 'Sr', 'Jnr', 'Snr', '1st', '2nd', '3rd'}) or suffix:match ('^%dth$') then
return true;
end
return false;
end
--[[--------------------< I S _ G O O D _ V A N C _ N A M E >-------------------
For Vancouver style, author/editor names are supposed to be rendered in Latin
(read ASCII) characters. When a name uses characters that contain diacritical
marks, those characters are to be converted to the corresponding Latin
character. When a name is written using a non-Latin alphabet or logogram, that
name is to be transliterated into Latin characters. The module doesn't do this
so editors may/must.
This test allows |first= and |last= names to contain any of the letters defined
in the four Unicode Latin character sets
[http://www.unicode.org/charts/PDF/U0000.pdf C0 Controls and Basic Latin] 0041–005A, 0061–007A
[http://www.unicode.org/charts/PDF/U0080.pdf C1 Controls and Latin-1 Supplement] 00C0–00D6, 00D8–00F6, 00F8–00FF
[http://www.unicode.org/charts/PDF/U0100.pdf Latin Extended-A] 0100–017F
[http://www.unicode.org/charts/PDF/U0180.pdf Latin Extended-B] 0180–01BF, 01C4–024F
|lastn= also allowed to contain hyphens, spaces, and apostrophes.
(http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
|firstn= also allowed to contain hyphens, spaces, apostrophes, and periods
This original test:
if nil == mw.ustring.find (last, "^[A-Za-zÀ-ÖØ-öø-ƿDŽ-ɏ%-%s%']*$")
or nil == mw.ustring.find (first, "^[A-Za-zÀ-ÖØ-öø-ƿDŽ-ɏ%-%s%'%.]+[2-6%a]*$") then
was written outside of the code editor and pasted here because the code editor
gets confused between character insertion point and cursor position. The test has
been rewritten to use decimal character escape sequence for the individual bytes
of the Unicode characters so that it is not necessary to use an external editor
to maintain this code.
\195\128-\195\150 – À-Ö (U+00C0–U+00D6 – C0 controls)
\195\152-\195\182 – Ø-ö (U+00D8-U+00F6 – C0 controls)
\195\184-\198\191 – ø-ƿ (U+00F8-U+01BF – C0 controls, Latin extended A & B)
\199\132-\201\143 – DŽ-ɏ (U+01C4-U+024F – Latin extended B)
]]
local function is_good_vanc_name (last, first, suffix, position)
if not suffix then
if first:find ('[,%s]') then -- when there is a space or comma, might be first name/initials + generational suffix
first = first:match ('(.-)[,%s]+'); -- get name/initials
suffix = first:match ('[,%s]+(.+)$'); -- get generational suffix
end
end
if utilities.is_set (suffix) then
if not is_suffix (suffix) then
add_vanc_error (cfg.err_msg_supl.suffix, position);
return false; -- not a name with an appropriate suffix
end
end
if nil == mw.ustring.find (last, "^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%']*$") or
nil == mw.ustring.find (first, "^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%'%.]*$") then
add_vanc_error (cfg.err_msg_supl['non-Latin char'], position);
return false; -- not a string of Latin characters; Vancouver requires Romanization
end;
return true;
end
--[[--------------------------< R E D U C E _ T O _ I N I T I A L S >------------------------------------------
Attempts to convert names to initials in support of |name-list-style=vanc.
Names in |firstn= may be separated by spaces or hyphens, or for initials, a period.
See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35062/.
Vancouver style requires family rank designations (Jr, II, III, etc.) to be rendered
as Jr, 2nd, 3rd, etc. See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35085/.
This code only accepts and understands generational suffix in the Vancouver format
because Roman numerals look like, and can be mistaken for, initials.
This function uses ustring functions because firstname initials may be any of the
Unicode Latin characters accepted by is_good_vanc_name ().
]]
local function reduce_to_initials(first, position)
local name, suffix = mw.ustring.match(first, "^(%u+) ([%dJS][%drndth]+)$");
if not name then -- if not initials and a suffix
name = mw.ustring.match(first, "^(%u+)$"); -- is it just initials?
end
if name then -- if first is initials with or without suffix
if 3 > mw.ustring.len (name) then -- if one or two initials
if suffix then -- if there is a suffix
if is_suffix (suffix) then -- is it legitimate?
return first; -- one or two initials and a valid suffix so nothing to do
else
add_vanc_error (cfg.err_msg_supl.suffix, position); -- one or two initials with invalid suffix so error message
return first; -- and return first unmolested
end
else
return first; -- one or two initials without suffix; nothing to do
end
end
end -- if here then name has 3 or more uppercase letters so treat them as a word
local initials, names = {}, {}; -- tables to hold name parts and initials
local i = 1; -- counter for number of initials
names = mw.text.split (first, '[%s,]+'); -- split into a table of names and possible suffix
while names[i] do -- loop through the table
if 1 < i and names[i]:match ('[%dJS][%drndth]+%.?$') then -- if not the first name, and looks like a suffix (may have trailing dot)
names[i] = names[i]:gsub ('%.', ''); -- remove terminal dot if present
if is_suffix (names[i]) then -- if a legitimate suffix
table.insert (initials, ' ' .. names[i]); -- add a separator space, insert at end of initials table
break; -- and done because suffix must fall at the end of a name
end -- no error message if not a suffix; possibly because of Romanization
end
if 3 > i then
table.insert (initials, mw.ustring.sub(names[i], 1, 1)); -- insert the initial at end of initials table
end
i = i + 1; -- bump the counter
end
return table.concat(initials) -- Vancouver format does not include spaces.
end
--[[--------------------------< L I S T _ P E O P L E >--------------------------
Formats a list of people (authors, contributors, editors, interviewers, translators)
names in the list will be linked when
|<name>-link= has a value
|<name>-mask- does NOT have a value; masked names are presumed to have been
rendered previously so should have been linked there
when |<name>-mask=0, the associated name is not rendered
]]
local function list_people (control, people, etal)
local sep;
local namesep;
local format = control.format;
local maximum = control.maximum;
local name_list = {};
if 'vanc' == format then -- Vancouver-like name styling?
sep = cfg.presentation['sep_nl_vanc']; -- name-list separator between names is a comma
namesep = cfg.presentation['sep_name_vanc']; -- last/first separator is a space
else
sep = cfg.presentation['sep_nl']; -- name-list separator between names is a semicolon
namesep = cfg.presentation['sep_name']; -- last/first separator is <comma><space>
end
if sep:sub (-1, -1) ~= " " then sep = sep .. " " end
if utilities.is_set (maximum) and maximum < 1 then return "", 0; end -- returned 0 is for EditorCount; not used for other names
for i, person in ipairs (people) do
if utilities.is_set (person.last) then
local mask = person.mask;
local one;
local sep_one = sep;
if utilities.is_set (maximum) and i > maximum then
etal = true;
break;
end
if mask then
local n = tonumber (mask); -- convert to a number if it can be converted; nil else
if n then
one = 0 ~= n and string.rep("—", n) or nil; -- make a string of (n > 0) mdashes, nil else, to replace name
person.link = nil; -- don't create link to name if name is replaces with mdash string or has been set nil
else
one = mask; -- replace name with mask text (must include name-list separator)
sep_one = " "; -- modify name-list separator
end
else
one = person.last; -- get surname
local first = person.first -- get given name
if utilities.is_set (first) then
if ("vanc" == format) then -- if Vancouver format
one = one:gsub ('%.', ''); -- remove periods from surnames (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
if not person.corporate and is_good_vanc_name (one, first, nil, i) then -- and name is all Latin characters; corporate authors not tested
first = reduce_to_initials (first, i); -- attempt to convert first name(s) to initials
end
end
one = one .. namesep .. first;
end
end
if utilities.is_set (person.link) then
one = utilities.make_wikilink (person.link, one); -- link author/editor
end
if one then -- if <one> has a value (name, mdash replacement, or mask text replacement)
table.insert (name_list, one); -- add it to the list of names
table.insert (name_list, sep_one); -- add the proper name-list separator
end
end
end
local count = #name_list / 2; -- (number of names + number of separators) divided by 2
if 0 < count then
if 1 < count and not etal then
if 'amp' == format then
name_list[#name_list-2] = " & "; -- replace last separator with ampersand text
elseif 'and' == format then
if 2 == count then
name_list[#name_list-2] = cfg.presentation.sep_nl_and; -- replace last separator with 'and' text
else
name_list[#name_list-2] = cfg.presentation.sep_nl_end; -- replace last separator with '(sep) and' text
end
end
end
name_list[#name_list] = nil; -- erase the last separator
end
local result = table.concat (name_list); -- construct list
if etal and utilities.is_set (result) then -- etal may be set by |display-authors=etal but we might not have a last-first list
result = result .. sep .. ' ' .. cfg.messages['et al']; -- we've got a last-first list and etal so add et al.
end
return result, count; -- return name-list string and count of number of names (count used for editor names only)
end
--[[--------------------< M A K E _ C I T E R E F _ I D >-----------------------
Generates a CITEREF anchor ID if we have at least one name or a date. Otherwise
returns an empty string.
namelist is one of the contributor-, author-, or editor-name lists chosen in that
order. year is Year or anchor_year.
]]
local function make_citeref_id (namelist, year)
local names={}; -- a table for the one to four names and year
for i,v in ipairs (namelist) do -- loop through the list and take up to the first four last names
names[i] = v.last
if i == 4 then break end -- if four then done
end
table.insert (names, year); -- add the year at the end
local id = table.concat(names); -- concatenate names and year for CITEREF id
if utilities.is_set (id) then -- if concatenation is not an empty string
return "CITEREF" .. id; -- add the CITEREF portion
else
return ''; -- return an empty string; no reason to include CITEREF id in this citation
end
end
--[[--------------------------< C I T E _ C L A S S _A T T R I B U T E _M A K E >------------------------------
construct <cite> tag class attribute for this citation.
<cite_class> – config.CitationClass from calling template
<mode> – value from |mode= parameter
]]
local function cite_class_attribute_make (cite_class, mode)
local class_t = {};
table.insert (class_t, 'citation'); -- required for blue highlight
if 'citation' ~= cite_class then
table.insert (class_t, cite_class); -- identify this template for user css
table.insert (class_t, utilities.is_set (mode) and mode or 'cs1'); -- identify the citation style for user css or javascript
else
table.insert (class_t, utilities.is_set (mode) and mode or 'cs2'); -- identify the citation style for user css or javascript
end
for _, prop_key in ipairs (z.prop_keys_t) do
table.insert (class_t, prop_key); -- identify various properties for user css or javascript
end
return table.concat (class_t, ' '); -- make a big string and done
end
--[[---------------------< N A M E _ H A S _ E T A L >--------------------------
Evaluates the content of name parameters (author, editor, etc.) for variations on
the theme of et al. If found, the et al. is removed, a flag is set to true and
the function returns the modified name and the flag.
This function never sets the flag to false but returns its previous state because
it may have been set by previous passes through this function or by the associated
|display-<names>=etal parameter
]]
local function name_has_etal (name, etal, nocat, param)
if utilities.is_set (name) then -- name can be nil in which case just return
local patterns = cfg.et_al_patterns; -- get patterns from configuration
for _, pattern in ipairs (patterns) do -- loop through all of the patterns
if name:match (pattern) then -- if this 'et al' pattern is found in name
name = name:gsub (pattern, ''); -- remove the offending text
etal = true; -- set flag (may have been set previously here or by |display-<names>=etal)
if not nocat then -- no categorization for |vauthors=
utilities.set_message ('err_etal', {param}); -- and set an error if not added
end
end
end
end
return name, etal;
end
--[[---------------------< N A M E _ I S _ N U M E R I C >----------------------
Add maint cat when name parameter value does not contain letters. Does not catch
mixed alphanumeric names so |last=A. Green (1922-1987) does not get caught in the
current version of this test but |first=(1888) is caught.
returns nothing
]]
local function name_is_numeric (name, list_name)
if utilities.is_set (name) then
if mw.ustring.match (name, '^[%A]+$') then -- when name does not contain any letters
utilities.set_message ('maint_numeric_names', cfg.special_case_translation [list_name]); -- add a maint cat for this template
end
end
end
--[[-----------------< N A M E _ H A S _ M U L T _ N A M E S >------------------
Evaluates the content of last/surname (authors etc.) parameters for multiple names.
Multiple names are indicated if there is more than one comma or any "unescaped"
semicolons. Escaped semicolons are ones used as part of selected HTML entities.
If the condition is met, the function adds the multiple name maintenance category.
returns nothing
]]
local function name_has_mult_names (name, list_name)
local _, commas, semicolons, nbsps;
if utilities.is_set (name) then
_, commas = name:gsub (',', ''); -- count the number of commas
_, semicolons = name:gsub (';', ''); -- count the number of semicolons
-- nbsps probably should be its own separate count rather than merged in
-- some way with semicolons because Lua patterns do not support the
-- grouping operator that regex does, which means there is no way to add
-- more entities to escape except by adding more counts with the new
-- entities
_, nbsps = name:gsub (' ',''); -- count nbsps
-- There is exactly 1 semicolon per entity, so subtract nbsps
-- from semicolons to 'escape' them. If additional entities are added,
-- they also can be subtracted.
if 1 < commas or 0 < (semicolons - nbsps) then
utilities.set_message ('maint_mult_names', cfg.special_case_translation [list_name]); -- add a maint message
end
end
end
--[=[-------------------------< I S _ G E N E R I C >----------------------------------------------------------
Compares values assigned to various parameters according to the string provided as <item> in the function call.
<item> can have on of two values:
'generic_names' – for name-holding parameters: |last=, |first=, |editor-last=, etc
'generic_titles' – for |title=
There are two types of generic tests. The 'accept' tests look for a pattern that should not be rejected by the
'reject' test. For example,
|author=[[John Smith (author)|Smith, John]]
would be rejected by the 'author' reject test. But piped wikilinks with 'author' disambiguation should not be
rejected so the 'accept' test prevents that from happening. Accept tests are always performed before reject
tests.
Each of the 'accept' and 'reject' sequence tables hold tables for en.wiki (['en']) and local.wiki (['local'])
that each can hold a test sequence table The sequence table holds, at index [1], a test pattern, and, at index
[2], a boolean control value. The control value tells string.find() or mw.ustring.find() to do plain-text search (true)
or a pattern search (false). The intent of all this complexity is to make these searches as fast as possible so
that we don't run out of processing time on very large articles.
Returns
true when a reject test finds the pattern or string
false when an accept test finds the pattern or string
nil else
]=]
local function is_generic (item, value, wiki)
local test_val;
local str_lower = { -- use string.lower() for en.wiki (['en']) and use mw.ustring.lower() or local.wiki (['local'])
['en'] = string.lower,
['local'] = mw.ustring.lower,
}
local str_find = { -- use string.find() for en.wiki (['en']) and use mw.ustring.find() or local.wiki (['local'])
['en'] = string.find,
['local'] = mw.ustring.find,
}
local function test (val, test_t, wiki) -- local function to do the testing; <wiki> selects lower() and find() functions
val = test_t[2] and str_lower[wiki](value) or val; -- when <test_t[2]> set to 'true', plaintext search using lowercase value
return str_find[wiki] (val, test_t[1], 1, test_t[2]); -- return nil when not found or matched
end
local test_types_t = {'accept', 'reject'}; -- test accept patterns first, then reject patterns
local wikis_t = {'en', 'local'}; -- do tests for each of these keys; en.wiki first, local.wiki second
for _, test_type in ipairs (test_types_t) do -- for each test type
for _, generic_value in pairs (cfg.special_case_translation[item][test_type]) do -- spin through the list of generic value fragments to accept or reject
for _, wiki in ipairs (wikis_t) do
if generic_value[wiki] then
if test (value, generic_value[wiki], wiki) then -- go do the test
return ('reject' == test_type); -- param value rejected, return true; false else
end
end
end
end
end
end
--[[--------------------------< N A M E _ I S _ G E N E R I C >------------------------------------------------
calls is_generic() to determine if <name> is a 'generic name' listed in cfg.generic_names; <name_alias> is the
parameter name used in error messaging
]]
local function name_is_generic (name, name_alias)
if not added_generic_name_errs and is_generic ('generic_names', name) then
utilities.set_message ('err_generic_name', name_alias); -- set an error message
added_generic_name_errs = true;
end
end
--[[--------------------------< N A M E _ C H E C K S >--------------------------------------------------------
This function calls various name checking functions used to validate the content of the various name-holding parameters.
]]
local function name_checks (last, first, list_name, last_alias, first_alias)
local accept_name;
if utilities.is_set (last) then
last, accept_name = utilities.has_accept_as_written (last); -- remove accept-this-as-written markup when it wraps all of <last>
if not accept_name then -- <last> not wrapped in accept-as-written markup
name_has_mult_names (last, list_name); -- check for multiple names in the parameter (last only)
name_is_numeric (last, list_name); -- check for names that are composed of digits and punctuation
name_is_generic (last, last_alias); -- check for names found in the generic names list
end
end
if utilities.is_set (first) then
first, accept_name = utilities.has_accept_as_written (first); -- remove accept-this-as-written markup when it wraps all of <first>
if not accept_name then -- <first> not wrapped in accept-as-written markup
name_is_numeric (first, list_name); -- check for names that are composed of digits and punctuation
name_is_generic (first, first_alias); -- check for names found in the generic names list
end
local wl_type, D = utilities.is_wikilink (first);
if 0 ~= wl_type then
first = D;
utilities.set_message ('err_bad_paramlink', first_alias);
end
end
return last, first; -- done
end
--[[----------------------< E X T R A C T _ N A M E S >-------------------------
Gets name list from the input arguments
Searches through args in sequential order to find |lastn= and |firstn= parameters
(or their aliases), and their matching link and mask parameters. Stops searching
when both |lastn= and |firstn= are not found in args after two sequential attempts:
found |last1=, |last2=, and |last3= but doesn't find |last4= and |last5= then the
search is done.
This function emits an error message when there is a |firstn= without a matching
|lastn=. When there are 'holes' in the list of last names, |last1= and |last3=
are present but |last2= is missing, an error message is emitted. |lastn= is not
required to have a matching |firstn=.
When an author or editor parameter contains some form of 'et al.', the 'et al.'
is stripped from the parameter and a flag (etal) returned that will cause list_people()
to add the static 'et al.' text from Module:Citation/CS1/Configuration. This keeps
'et al.' out of the template's metadata. When this occurs, an error is emitted.
]]
local function extract_names(args, list_name)
local names = {}; -- table of names
local last; -- individual name components
local first;
local link;
local mask;
local i = 1; -- loop counter/indexer
local n = 1; -- output table indexer
local count = 0; -- used to count the number of times we haven't found a |last= (or alias for authors, |editor-last or alias for editors)
local etal = false; -- return value set to true when we find some form of et al. in an author parameter
local last_alias, first_alias, link_alias; -- selected parameter aliases used in error messaging
while true do
last, last_alias = utilities.select_one ( args, cfg.aliases[list_name .. '-Last'], 'err_redundant_parameters', i ); -- search through args for name components beginning at 1
first, first_alias = utilities.select_one ( args, cfg.aliases[list_name .. '-First'], 'err_redundant_parameters', i );
link, link_alias = utilities.select_one ( args, cfg.aliases[list_name .. '-Link'], 'err_redundant_parameters', i );
mask = utilities.select_one ( args, cfg.aliases[list_name .. '-Mask'], 'err_redundant_parameters', i );
last, etal = name_has_etal (last, etal, false, last_alias); -- find and remove variations on et al.
first, etal = name_has_etal (first, etal, false, first_alias); -- find and remove variations on et al.
last, first = name_checks (last, first, list_name, last_alias, first_alias); -- multiple names, extraneous annotation, etc. checks
if first and not last then -- if there is a firstn without a matching lastn
local alias = first_alias:find ('given', 1, true) and 'given' or 'first'; -- get first or given form of the alias
utilities.set_message ('err_first_missing_last', {
first_alias, -- param name of alias missing its mate
first_alias:gsub (alias, {['first'] = 'last', ['given'] = 'surname'}), -- make param name appropriate to the alias form
}); -- add this error message
elseif not first and not last then -- if both firstn and lastn aren't found, are we done?
count = count + 1; -- number of times we haven't found last and first
if 2 <= count then -- two missing names and we give up
break; -- normal exit or there is a two-name hole in the list; can't tell which
end
else -- we have last with or without a first
local result;
link = link_title_ok (link, link_alias, last, last_alias); -- check for improper wiki-markup
if first then
link = link_title_ok (link, link_alias, first, first_alias); -- check for improper wiki-markup
end
names[n] = {last = last, first = first, link = link, mask = mask, corporate = false}; -- add this name to our names list (corporate for |vauthors= only)
n = n + 1; -- point to next location in the names table
if 1 == count then -- if the previous name was missing
utilities.set_message ('err_missing_name', {list_name:match ("(%w+)List"):lower(), i - 1}); -- add this error message
end
count = 0; -- reset the counter, we're looking for two consecutive missing names
end
i = i + 1; -- point to next args location
end
return names, etal; -- all done, return our list of names and the etal flag
end
--[[--------------------------< N A M E _ T A G _ G E T >------------------------------------------------------
attempt to decode |language=<lang_param> and return language name and matching tag; nil else.
This function looks for:
<lang_param> as a tag in cfg.lang_code_remap{}
<lang_param> as a name in cfg.lang_name_remap{}
<lang_param> as a name in cfg.mw_languages_by_name_t
<lang_param> as a tag in cfg.mw_languages_by_tag_t
when those fail, presume that <lang_param> is an IETF-like tag that MediaWiki does not recognize. Strip all
script, region, variant, whatever subtags from <lang_param> to leave just a two or three character language tag
and look for the new <lang_param> in cfg.mw_languages_by_tag_t{}
on success, returns name (in properly capitalized form) and matching tag (in lowercase); on failure returns nil
]]
local function name_tag_get (lang_param)
local lang_param_lc = mw.ustring.lower (lang_param); -- use lowercase as an index into the various tables
local name;
local tag;
name = cfg.lang_code_remap[lang_param_lc]; -- assume <lang_param_lc> is a tag; attempt to get remapped language name
if name then -- when <name>, <lang_param> is a tag for a remapped language name
return name, lang_param_lc; -- so return <name> from remap and <lang_param_lc>
end
tag = lang_param_lc:match ('^(%a%a%a?)%-.*'); -- still assuming that <lang_param_lc> is a tag; strip script, region, variant subtags
name = cfg.lang_code_remap[tag]; -- attempt to get remapped language name with language subtag only
if name then -- when <name>, <tag> is a tag for a remapped language name
return name, tag; -- so return <name> from remap and <tag>
end
if cfg.lang_name_remap[lang_param_lc] then -- not a tag, assume <lang_param_lc> is a name; attempt to get remapped language tag
return cfg.lang_name_remap[lang_param_lc][1], cfg.lang_name_remap[lang_param_lc][2]; -- for this <lang_param_lc>, return a (possibly) new name and appropriate tag
end
tag = cfg.mw_languages_by_name_t[lang_param_lc]; -- assume that <lang_param_lc> is a language name; attempt to get its matching tag
if tag then
return cfg.mw_languages_by_tag_t[tag], tag; -- <lang_param_lc> is a name so return the name from the table and <tag>
end
name = cfg.mw_languages_by_tag_t[lang_param_lc]; -- assume that <lang_param_lc> is a tag; attempt to get its matching language name
if name then
return name, lang_param_lc; -- <lang_param_lc> is a tag so return it and <name>
end
tag = lang_param_lc:match ('^(%a%a%a?)%-.*'); -- is <lang_param_lc> an IETF-like tag that MediaWiki doesn't recognize? <tag> gets the language subtag; nil else
if tag then
name = cfg.mw_languages_by_tag_t[tag]; -- attempt to get a language name using the shortened <tag>
if name then
return name, tag; -- <lang_param_lc> is an unrecognized IETF-like tag so return <name> and language subtag
end
end
end
--[[-------------------< L A N G U A G E _ P A R A M E T E R >------------------
Gets language name from a provided two- or three-character ISO 639 code. If a code
is recognized by MediaWiki, use the returned name; if not, then use the value that
was provided with the language parameter.
When |language= contains a recognized language (either code or name), the page is
assigned to the category for that code: Category:Norwegian-language sources (no).
For valid three-character code languages, the page is assigned to the single category
for '639-2' codes: Category:CS1 ISO 639-2 language sources.
Languages that are the same as the local wiki are not categorized. MediaWiki does
not recognize three-character equivalents of two-character codes: code 'ar' is
recognized but code 'ara' is not.
This function supports multiple languages in the form |language=nb, French, th
where the language names or codes are separated from each other by commas with
optional space characters.
]]
local function language_parameter (lang)
local tag; -- some form of IETF-like language tag; language subtag with optional region, sript, vatiant, etc subtags
local lang_subtag; -- ve populates |language= with mostly unecessary region subtags the MediaWiki does not recognize; this is the base language subtag
local name; -- the language name
local language_list = {}; -- table of language names to be rendered
local names_t = {}; -- table made from the value assigned to |language=
local this_wiki_name = mw.language.fetchLanguageName (cfg.this_wiki_code, cfg.this_wiki_code); -- get this wiki's language name
names_t = mw.text.split (lang, '%s*,%s*'); -- names should be a comma separated list
for _, lang in ipairs (names_t) do -- reuse lang here because we don't yet know if lang is a language name or a language tag
name, tag = name_tag_get (lang); -- attempt to get name/tag pair for <lang>; <name> has proper capitalization; <tag> is lowercase
if utilities.is_set (tag) then
lang_subtag = tag:gsub ('^(%a%a%a?)%-.*', '%1'); -- for categorization, strip any IETF-like tags from language tag
if cfg.this_wiki_code ~= lang_subtag then -- when the language is not the same as this wiki's language
if 2 == lang_subtag:len() then -- and is a two-character tag
-- utilities.add_prop_cat ('foreign-lang-source', {name, lang_subtag}, lang_subtag); -- categorize it; tag appended to allow for multiple language categorization
utilities.add_prop_cat ('foreign-lang-source', {name, tag}, lang_subtag); -- categorize it; tag appended to allow for multiple language categorization
else -- or is a recognized language (but has a three-character tag)
utilities.add_prop_cat ('foreign-lang-source-2', {lang_subtag}, lang_subtag); -- categorize it differently TODO: support multiple three-character tag categories per cs1|2 template?
end
elseif cfg.local_lang_cat_enable then -- when the language and this wiki's language are the same and categorization is enabled
utilities.add_prop_cat ('local-lang-source', {name, lang_subtag}); -- categorize it
end
else
name = lang; -- return whatever <lang> has so that we show something
utilities.set_message ('maint_unknown_lang'); -- add maint category if not already added
end
table.insert (language_list, name);
name = ''; -- so we can reuse it
end
name = utilities.make_sep_list (#language_list, language_list);
if (1 == #language_list) and (lang_subtag == cfg.this_wiki_code) then -- when only one language, find lang name in this wiki lang name; for |language=en-us, 'English' in 'American English'
return ''; -- if one language and that language is this wiki's return an empty string (no annotation)
end
return (" " .. wrap_msg ('language', name)); -- otherwise wrap with '(in ...)'
--[[ TODO: should only return blank or name rather than full list
so we can clean up the bunched parenthetical elements Language, Type, Format
]]
end
--[[-----------------------< S E T _ C S _ S T Y L E >--------------------------
Gets the default CS style configuration for the given mode.
Returns default separator and either postscript as passed in or the default.
In CS1, the default postscript and separator are '.'.
In CS2, the default postscript is the empty string and the default separator is ','.
]]
local function set_cs_style (postscript, mode)
if utilities.is_set(postscript) then
-- emit a maintenance message if user postscript is the default cs1 postscript
-- we catch the opposite case for cs2 in set_style
if mode == 'cs1' and postscript == cfg.presentation['ps_' .. mode] then
utilities.set_message ('maint_postscript');
end
else
postscript = cfg.presentation['ps_' .. mode];
end
return cfg.presentation['sep_' .. mode], postscript;
end
--[[--------------------------< S E T _ S T Y L E >-----------------------------
Sets the separator and postscript styles. Checks the |mode= first and the
#invoke CitationClass second. Removes the postscript if postscript == none.
]]
local function set_style (mode, postscript, cite_class)
local sep;
if 'cs2' == mode then
sep, postscript = set_cs_style (postscript, 'cs2');
elseif 'cs1' == mode then
sep, postscript = set_cs_style (postscript, 'cs1');
elseif 'citation' == cite_class then
sep, postscript = set_cs_style (postscript, 'cs2');
else
sep, postscript = set_cs_style (postscript, 'cs1');
end
if cfg.keywords_xlate[postscript:lower()] == 'none' then
-- emit a maintenance message if user postscript is the default cs2 postscript
-- we catch the opposite case for cs1 in set_cs_style
if 'cs2' == mode or 'citation' == cite_class then
utilities.set_message ('maint_postscript');
end
postscript = '';
end
return sep, postscript
end
--[=[-------------------------< I S _ P D F >-----------------------------------
Determines if a URL has the file extension that is one of the PDF file extensions
used by [[MediaWiki:Common.css]] when applying the PDF icon to external links.
returns true if file extension is one of the recognized extensions, else false
]=]
local function is_pdf (url)
return url:match ('%.pdf$') or url:match ('%.PDF$') or
url:match ('%.pdf[%?#]') or url:match ('%.PDF[%?#]') or
url:match ('%.PDF#') or url:match ('%.pdf#');
end
--[[--------------------------< S T Y L E _ F O R M A T >-----------------------
Applies CSS style to |format=, |chapter-format=, etc. Also emits an error message
if the format parameter does not have a matching URL parameter. If the format parameter
is not set and the URL contains a file extension that is recognized as a PDF document
by MediaWiki's commons.css, this code will set the format parameter to (PDF) with
the appropriate styling.
]]
local function style_format (format, url, fmt_param, url_param)
if utilities.is_set (format) then
format = utilities.wrap_style ('format', format); -- add leading space, parentheses, resize
if not utilities.is_set (url) then
utilities.set_message ('err_format_missing_url', {fmt_param, url_param}); -- add an error message
end
elseif is_pdf (url) then -- format is not set so if URL is a PDF file then
format = utilities.wrap_style ('format', 'PDF'); -- set format to PDF
else
format = ''; -- empty string for concatenation
end
return format;
end
--[[---------------------< G E T _ D I S P L A Y _ N A M E S >------------------
Returns a number that defines the number of names displayed for author and editor
name lists and a Boolean flag to indicate when et al. should be appended to the name list.
When the value assigned to |display-xxxxors= is a number greater than or equal to zero,
return the number and the previous state of the 'etal' flag (false by default
but may have been set to true if the name list contains some variant of the text 'et al.').
When the value assigned to |display-xxxxors= is the keyword 'etal', return a number
that is one greater than the number of authors in the list and set the 'etal' flag true.
This will cause the list_people() to display all of the names in the name list followed by 'et al.'
In all other cases, returns nil and the previous state of the 'etal' flag.
inputs:
max: A['DisplayAuthors'] or A['DisplayEditors']; a number or some flavor of etal
count: #a or #e
list_name: 'authors' or 'editors'
etal: author_etal or editor_etal
]]
local function get_display_names (max, count, list_name, etal, param)
if utilities.is_set (max) then
if 'etal' == max:lower():gsub("[ '%.]", '') then -- the :gsub() portion makes 'etal' from a variety of 'et al.' spellings and stylings
max = count + 1; -- number of authors + 1 so display all author name plus et al.
etal = true; -- overrides value set by extract_names()
elseif max:match ('^%d+$') then -- if is a string of numbers
max = tonumber (max); -- make it a number
if max >= count then -- if |display-xxxxors= value greater than or equal to number of authors/editors
utilities.set_message ('err_disp_name', {param, max}); -- add error message
max = nil;
end
else -- not a valid keyword or number
utilities.set_message ('err_disp_name', {param, max}); -- add error message
max = nil; -- unset; as if |display-xxxxors= had not been set
end
end
return max, etal;
end
--[[----------< E X T R A _ T E X T _ I N _ P A G E _ C H E C K >---------------
Adds error if |page=, |pages=, |quote-page=, |quote-pages= has what appears to be
some form of p. or pp. abbreviation in the first characters of the parameter content.
check page for extraneous p, p., pp, pp., pg, pg. at start of parameter value:
good pattern: '^P[^%.P%l]' matches when page begins PX or P# but not Px
where x and X are letters and # is a digit
bad pattern: '^[Pp][PpGg]' matches when page begins pp, pP, Pp, PP, pg, pG, Pg, PG
]]
local function extra_text_in_page_check (val, name)
if not val:match (cfg.vol_iss_pg_patterns.good_ppattern) then
for _, pattern in ipairs (cfg.vol_iss_pg_patterns.bad_ppatterns) do -- spin through the selected sequence table of patterns
if val:match (pattern) then -- when a match, error so
utilities.set_message ('err_extra_text_pages', name); -- add error message
return; -- and done
end
end
end
end
--[[--------------------------< E X T R A _ T E X T _ I N _ V O L _ I S S _ C H E C K >------------------------
Adds error if |volume= or |issue= has what appears to be some form of redundant 'type' indicator.
For |volume=:
'V.', or 'Vol.' (with or without the dot) abbreviations or 'Volume' in the first characters of the parameter
content (all case insensitive). 'V' and 'v' (without the dot) are presumed to be roman numerals so
are allowed.
For |issue=:
'No.', 'I.', 'Iss.' (with or without the dot) abbreviations, or 'Issue' in the first characters of the
parameter content (all case insensitive).
Single character values ('v', 'i', 'n') allowed when not followed by separator character ('.', ':', '=', or
whitespace character) – param values are trimmed of whitespace by MediaWiki before delivered to the module.
<val> is |volume= or |issue= parameter value
<name> is |volume= or |issue= parameter name for error message
<selector> is 'v' for |volume=, 'i' for |issue=
sets error message on failure; returns nothing
]]
local function extra_text_in_vol_iss_check (val, name, selector)
if not utilities.is_set (val) then
return;
end
local patterns = 'v' == selector and cfg.vol_iss_pg_patterns.vpatterns or cfg.vol_iss_pg_patterns.ipatterns;
local handler = 'v' == selector and 'err_extra_text_volume' or 'err_extra_text_issue';
val = val:lower(); -- force parameter value to lower case
for _, pattern in ipairs (patterns) do -- spin through the selected sequence table of patterns
if val:match (pattern) then -- when a match, error so
utilities.set_message (handler, name); -- add error message
return; -- and done
end
end
end
--[=[-------------------------< G E T _ V _ N A M E _ T A B L E >----------------------------------------------
split apart a |vauthors= or |veditors= parameter. This function allows for corporate names, wrapped in doubled
parentheses to also have commas; in the old version of the code, the doubled parentheses were included in the
rendered citation and in the metadata. Individual author names may be wikilinked
|vauthors=Jones AB, [[E. B. White|White EB]], ((Black, Brown, and Co.))
]=]
local function get_v_name_table (vparam, output_table, output_link_table)
local name_table = mw.text.split(vparam, "%s*,%s*"); -- names are separated by commas
local wl_type, label, link; -- wl_type not used here; just a placeholder
local i = 1;
while name_table[i] do
if name_table[i]:match ('^%(%(.*[^%)][^%)]$') then -- first segment of corporate with one or more commas; this segment has the opening doubled parentheses
local name = name_table[i];
i = i + 1; -- bump indexer to next segment
while name_table[i] do
name = name .. ', ' .. name_table[i]; -- concatenate with previous segments
if name_table[i]:match ('^.*%)%)$') then -- if this table member has the closing doubled parentheses
break; -- and done reassembling so
end
i = i + 1; -- bump indexer
end
table.insert (output_table, name); -- and add corporate name to the output table
table.insert (output_link_table, ''); -- no wikilink
else
wl_type, label, link = utilities.is_wikilink (name_table[i]); -- wl_type is: 0, no wl (text in label variable); 1, [[D]]; 2, [[L|D]]
table.insert (output_table, label); -- add this name
if 1 == wl_type then
table.insert (output_link_table, label); -- simple wikilink [[D]]
else
table.insert (output_link_table, link); -- no wikilink or [[L|D]]; add this link if there is one, else empty string
end
end
i = i + 1;
end
return output_table;
end
--[[--------------------------< P A R S E _ V A U T H O R S _ V E D I T O R S >--------------------------------
This function extracts author / editor names from |vauthors= or |veditors= and finds matching |xxxxor-maskn= and
|xxxxor-linkn= in args. It then returns a table of assembled names just as extract_names() does.
Author / editor names in |vauthors= or |veditors= must be in Vancouver system style. Corporate or institutional names
may sometimes be required and because such names will often fail the is_good_vanc_name() and other format compliance
tests, are wrapped in doubled parentheses ((corporate name)) to suppress the format tests.
Supports generational suffixes Jr, 2nd, 3rd, 4th–6th.
This function sets the Vancouver error when a required comma is missing and when there is a space between an author's initials.
]]
local function parse_vauthors_veditors (args, vparam, list_name)
local names = {}; -- table of names assembled from |vauthors=, |author-maskn=, |author-linkn=
local v_name_table = {};
local v_link_table = {}; -- when name is wikilinked, targets go in this table
local etal = false; -- return value set to true when we find some form of et al. vauthors parameter
local last, first, link, mask, suffix;
local corporate = false;
vparam, etal = name_has_etal (vparam, etal, true); -- find and remove variations on et al. do not categorize (do it here because et al. might have a period)
v_name_table = get_v_name_table (vparam, v_name_table, v_link_table); -- names are separated by commas
for i, v_name in ipairs(v_name_table) do
first = ''; -- set to empty string for concatenation and because it may have been set for previous author/editor
local accept_name;
v_name, accept_name = utilities.has_accept_as_written (v_name); -- remove accept-this-as-written markup when it wraps all of <v_name>
if accept_name then
last = v_name;
corporate = true; -- flag used in list_people()
elseif string.find(v_name, "%s") then
if v_name:find('[;%.]') then -- look for commonly occurring punctuation characters;
add_vanc_error (cfg.err_msg_supl.punctuation, i);
end
local lastfirstTable = {}
lastfirstTable = mw.text.split(v_name, "%s+")
first = table.remove(lastfirstTable); -- removes and returns value of last element in table which should be initials or generational suffix
if not mw.ustring.match (first, '^%u+$') then -- mw.ustring here so that later we will catch non-Latin characters
suffix = first; -- not initials so assume that whatever we got is a generational suffix
first = table.remove(lastfirstTable); -- get what should be the initials from the table
end
last = table.concat(lastfirstTable, ' ') -- returns a string that is the concatenation of all other names that are not initials and generational suffix
if not utilities.is_set (last) then
first = ''; -- unset
last = v_name; -- last empty because something wrong with first
add_vanc_error (cfg.err_msg_supl.name, i);
end
if mw.ustring.match (last, '%a+%s+%u+%s+%a+') then
add_vanc_error (cfg.err_msg_supl['missing comma'], i); -- matches last II last; the case when a comma is missing
end
if mw.ustring.match (v_name, ' %u %u$') then -- this test is in the wrong place TODO: move or replace with a more appropriate test
add_vanc_error (cfg.err_msg_supl.initials, i); -- matches a space between two initials
end
else
last = v_name; -- last name or single corporate name? Doesn't support multiword corporate names? do we need this?
end
if utilities.is_set (first) then
if not mw.ustring.match (first, "^%u?%u$") then -- first shall contain one or two upper-case letters, nothing else
add_vanc_error (cfg.err_msg_supl.initials, i); -- too many initials; mixed case initials (which may be ok Romanization); hyphenated initials
end
is_good_vanc_name (last, first, suffix, i); -- check first and last before restoring the suffix which may have a non-Latin digit
if utilities.is_set (suffix) then
first = first .. ' ' .. suffix; -- if there was a suffix concatenate with the initials
suffix = ''; -- unset so we don't add this suffix to all subsequent names
end
else
if not corporate then
is_good_vanc_name (last, '', nil, i);
end
end
link = utilities.select_one ( args, cfg.aliases[list_name .. '-Link'], 'err_redundant_parameters', i ) or v_link_table[i];
mask = utilities.select_one ( args, cfg.aliases[list_name .. '-Mask'], 'err_redundant_parameters', i );
names[i] = {last = last, first = first, link = link, mask = mask, corporate = corporate}; -- add this assembled name to our names list
end
return names, etal; -- all done, return our list of names
end
--[[--------------------------< S E L E C T _ A U T H O R _ E D I T O R _ S O U R C E >------------------------
Select one of |authors=, |authorn= / |lastn / firstn=, or |vauthors= as the source of the author name list or
select one of |editorn= / editor-lastn= / |editor-firstn= or |veditors= as the source of the editor name list.
Only one of these appropriate three will be used. The hierarchy is: |authorn= (and aliases) highest and |authors= lowest;
|editorn= (and aliases) highest and |veditors= lowest (support for |editors= withdrawn)
When looking for |authorn= / |editorn= parameters, test |xxxxor1= and |xxxxor2= (and all of their aliases); stops after the second
test which mimicks the test used in extract_names() when looking for a hole in the author name list. There may be a better
way to do this, I just haven't discovered what that way is.
Emits an error message when more than one xxxxor name source is provided.
In this function, vxxxxors = vauthors or veditors; xxxxors = authors as appropriate.
]]
local function select_author_editor_source (vxxxxors, xxxxors, args, list_name)
local lastfirst = false;
if utilities.select_one ( args, cfg.aliases[list_name .. '-Last'], 'none', 1 ) or -- do this twice in case we have a |first1= without a |last1=; this ...
utilities.select_one ( args, cfg.aliases[list_name .. '-First'], 'none', 1 ) or -- ... also catches the case where |first= is used with |vauthors=
utilities.select_one ( args, cfg.aliases[list_name .. '-Last'], 'none', 2 ) or
utilities.select_one ( args, cfg.aliases[list_name .. '-First'], 'none', 2 ) then
lastfirst = true;
end
if (utilities.is_set (vxxxxors) and true == lastfirst) or -- these are the three error conditions
(utilities.is_set (vxxxxors) and utilities.is_set (xxxxors)) or
(true == lastfirst and utilities.is_set (xxxxors)) then
local err_name;
if 'AuthorList' == list_name then -- figure out which name should be used in error message
err_name = 'author';
else
err_name = 'editor';
end
utilities.set_message ('err_redundant_parameters', err_name .. '-name-list parameters'); -- add error message
end
if true == lastfirst then return 1 end; -- return a number indicating which author name source to use
if utilities.is_set (vxxxxors) then return 2 end;
if utilities.is_set (xxxxors) then return 3 end;
return 1; -- no authors so return 1; this allows missing author name test to run in case there is a first without last
end
--[[--------------------------< I S _ V A L I D _ P A R A M E T E R _ V A L U E >------------------------------
This function is used to validate a parameter's assigned value for those parameters that have only a limited number
of allowable values (yes, y, true, live, dead, etc.). When the parameter value has not been assigned a value (missing
or empty in the source template) the function returns the value specified by ret_val. If the parameter value is one
of the list of allowed values returns the translated value; else, emits an error message and returns the value
specified by ret_val.
TODO: explain <invert>
]]
local function is_valid_parameter_value (value, name, possible, ret_val, invert)
if not utilities.is_set (value) then
return ret_val; -- an empty parameter is ok
end
if (not invert and utilities.in_array (value, possible)) then -- normal; <value> is in <possible> table
return cfg.keywords_xlate[value]; -- return translation of parameter keyword
elseif invert and not utilities.in_array (value, possible) then -- invert; <value> is not in <possible> table
return value; -- return <value> as it is
else
utilities.set_message ('err_invalid_param_val', {name, value}); -- not an allowed value so add error message
return ret_val;
end
end
--[[--------------------------< T E R M I N A T E _ N A M E _ L I S T >----------------------------------------
This function terminates a name list (author, contributor, editor) with a separator character (sepc) and a space
when the last character is not a sepc character or when the last three characters are not sepc followed by two
closing square brackets (close of a wikilink). When either of these is true, the name_list is terminated with a
single space character.
]]
local function terminate_name_list (name_list, sepc)
if (string.sub (name_list, -3, -1) == sepc .. '. ') then -- if already properly terminated
return name_list; -- just return the name list
elseif (string.sub (name_list, -1, -1) == sepc) or (string.sub (name_list, -3, -1) == sepc .. ']]') then -- if last name in list ends with sepc char
return name_list .. " "; -- don't add another
else
return name_list .. sepc .. ' '; -- otherwise terminate the name list
end
end
--[[-------------------------< F O R M A T _ V O L U M E _ I S S U E >----------------------------------------
returns the concatenation of the formatted volume and issue parameters as a single string; or formatted volume
or formatted issue, or an empty string if neither are set.
]]
local function format_volume_issue (volume, issue, cite_class, origin, sepc, lower)
if not utilities.is_set (volume) and not utilities.is_set (issue) then
return '';
end
-- same condition as in format_pages_sheets()
local is_journal = 'journal' == cite_class or (utilities.in_array (cite_class, {'citation', 'map', 'interview'}) and 'journal' == origin);
local is_numeric_vol = volume and (volume:match ('^[MDCLXVI]+$') or volume:match ('^%d+$')); -- is only uppercase roman numerals or only digits?
local is_long_vol = volume and (4 < mw.ustring.len(volume)); -- is |volume= value longer than 4 characters?
if volume and (not is_numeric_vol and is_long_vol) then -- when not all digits or Roman numerals, is |volume= longer than 4 characters?
utilities.add_prop_cat ('long-vol'); -- yes, add properties cat
end
if is_journal then -- journal-style formatting
local vol = '';
if utilities.is_set (volume) then
if is_numeric_vol then -- |volume= value all digits or all uppercase Roman numerals?
vol = utilities.substitute (cfg.presentation['vol-bold'], {sepc, volume}); -- render in bold face
elseif is_long_vol then -- not all digits or Roman numerals; longer than 4 characters?
vol = utilities.substitute (cfg.messages['j-vol'], {sepc, utilities.hyphen_to_dash (volume)}); -- not bold
else -- four or fewer characters
vol = utilities.substitute (cfg.presentation['vol-bold'], {sepc, utilities.hyphen_to_dash (volume)}); -- bold
end
end
if utilities.is_set (issue) then
return vol .. utilities.substitute (cfg.messages['j-issue'], issue);
end
return vol;
end
if 'podcast' == cite_class and utilities.is_set (issue) then
return wrap_msg ('issue', {sepc, issue}, lower);
end
-- all other types of citation
if utilities.is_set (volume) and utilities.is_set (issue) then
return wrap_msg ('vol-no', {sepc, utilities.hyphen_to_dash (volume), issue}, lower);
elseif utilities.is_set (volume) then
return wrap_msg ('vol', {sepc, utilities.hyphen_to_dash (volume)}, lower);
else
return wrap_msg ('issue', {sepc, issue}, lower);
end
end
--[[-------------------------< F O R M A T _ P A G E S _ S H E E T S >-----------------------------------------
adds static text to one of |page(s)= or |sheet(s)= values and returns it with all of the others set to empty strings.
The return order is:
page, pages, sheet, sheets
Singular has priority over plural when both are provided.
]]
local function format_pages_sheets (page, pages, sheet, sheets, cite_class, origin, sepc, nopp, lower)
if 'map' == cite_class then -- only cite map supports sheet(s) as in-source locators
if utilities.is_set (sheet) then
if 'journal' == origin then
return '', '', wrap_msg ('j-sheet', sheet, lower), '';
else
return '', '', wrap_msg ('sheet', {sepc, sheet}, lower), '';
end
elseif utilities.is_set (sheets) then
if 'journal' == origin then
return '', '', '', wrap_msg ('j-sheets', sheets, lower);
else
return '', '', '', wrap_msg ('sheets', {sepc, sheets}, lower);
end
end
end
local is_journal = 'journal' == cite_class or (utilities.in_array (cite_class, {'citation', 'map', 'interview'}) and 'journal' == origin);
if utilities.is_set (page) then
if is_journal then
return utilities.substitute (cfg.messages['j-page(s)'], page), '', '', '';
elseif not nopp then
return utilities.substitute (cfg.messages['p-prefix'], {sepc, page}), '', '', '';
else
return utilities.substitute (cfg.messages['nopp'], {sepc, page}), '', '', '';
end
elseif utilities.is_set (pages) then
if is_journal then
return utilities.substitute (cfg.messages['j-page(s)'], pages), '', '', '';
elseif tonumber(pages) ~= nil and not nopp then -- if pages is only digits, assume a single page number
return '', utilities.substitute (cfg.messages['p-prefix'], {sepc, pages}), '', '';
elseif not nopp then
return '', utilities.substitute (cfg.messages['pp-prefix'], {sepc, pages}), '', '';
else
return '', utilities.substitute (cfg.messages['nopp'], {sepc, pages}), '', '';
end
end
return '', '', '', ''; -- return empty strings
end
--[[--------------------------< I N S O U R C E _ L O C _ G E T >----------------------------------------------
returns one of the in-source locators: page, pages, or at.
If any of these are interwiki links to Wikisource, returns the label portion of the interwiki-link as plain text
for use in COinS. This COinS thing is done because here we convert an interwiki-link to an external link and
add an icon span around that; get_coins_pages() doesn't know about the span. TODO: should it?
TODO: add support for sheet and sheets?; streamline;
TODO: make it so that this function returns only one of the three as the single in-source (the return value assigned
to a new name)?
]]
local function insource_loc_get (page, page_orig, pages, pages_orig, at)
local ws_url, ws_label, coins_pages, L; -- for Wikisource interwiki-links; TODO: this corrupts page metadata (span remains in place after cleanup; fix there?)
if utilities.is_set (page) then
if utilities.is_set (pages) or utilities.is_set (at) then
pages = ''; -- unset the others
at = '';
end
extra_text_in_page_check (page, page_orig); -- emit error message when |page= value begins with what looks like p., pp., etc.
ws_url, ws_label, L = wikisource_url_make (page); -- make ws URL from |page= interwiki link; link portion L becomes tooltip label
if ws_url then
page = external_link (ws_url, ws_label .. ' ', 'ws link in page'); -- space char after label to move icon away from in-source text; TODO: a better way to do this?
page = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, page});
coins_pages = ws_label;
end
elseif utilities.is_set (pages) then
if utilities.is_set (at) then
at = ''; -- unset
end
extra_text_in_page_check (pages, pages_orig); -- emit error message when |page= value begins with what looks like p., pp., etc.
ws_url, ws_label, L = wikisource_url_make (pages); -- make ws URL from |pages= interwiki link; link portion L becomes tooltip label
if ws_url then
pages = external_link (ws_url, ws_label .. ' ', 'ws link in pages'); -- space char after label to move icon away from in-source text; TODO: a better way to do this?
pages = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, pages});
coins_pages = ws_label;
end
elseif utilities.is_set (at) then
ws_url, ws_label, L = wikisource_url_make (at); -- make ws URL from |at= interwiki link; link portion L becomes tooltip label
if ws_url then
at = external_link (ws_url, ws_label .. ' ', 'ws link in at'); -- space char after label to move icon away from in-source text; TODO: a better way to do this?
at = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, at});
coins_pages = ws_label;
end
end
return page, pages, at, coins_pages;
end
--[[--------------------------< I S _ U N I Q U E _ A R C H I V E _ U R L >------------------------------------
add error message when |archive-url= value is same as |url= or chapter-url= (or alias...) value
]]
local function is_unique_archive_url (archive, url, c_url, source, date)
if utilities.is_set (archive) then
if archive == url or archive == c_url then
utilities.set_message ('err_bad_url', {utilities.wrap_style ('parameter', source)}); -- add error message
return '', ''; -- unset |archive-url= and |archive-date= because same as |url= or |chapter-url=
end
end
return archive, date;
end
--[=[-------------------------< A R C H I V E _ U R L _ C H E C K >--------------------------------------------
Check archive.org URLs to make sure they at least look like they are pointing at valid archives and not to the
save snapshot URL or to calendar pages. When the archive URL is 'https://web.archive.org/save/' (or http://...)
archive.org saves a snapshot of the target page in the URL. That is something that Wikipedia should not allow
unwitting readers to do.
When the archive.org URL does not have a complete timestamp, archive.org chooses a snapshot according to its own
algorithm or provides a calendar 'search' result. [[WP:ELNO]] discourages links to search results.
This function looks at the value assigned to |archive-url= and returns empty strings for |archive-url= and
|archive-date= and an error message when:
|archive-url= holds an archive.org save command URL
|archive-url= is an archive.org URL that does not have a complete timestamp (YYYYMMDDhhmmss 14 digits) in the
correct place
otherwise returns |archive-url= and |archive-date=
There are two mostly compatible archive.org URLs:
//web.archive.org/<timestamp>... -- the old form
//web.archive.org/web/<timestamp>... -- the new form
The old form does not support or map to the new form when it contains a display flag. There are four identified flags
('id_', 'js_', 'cs_', 'im_') but since archive.org ignores others following the same form (two letters and an underscore)
we don't check for these specific flags but we do check the form.
This function supports a preview mode. When the article is rendered in preview mode, this function may return a modified
archive URL:
for save command errors, return undated wildcard (/*/)
for timestamp errors when the timestamp has a wildcard, return the URL unmodified
for timestamp errors when the timestamp does not have a wildcard, return with timestamp limited to six digits plus wildcard (/yyyymm*/)
]=]
local function archive_url_check (url, date)
local err_msg = ''; -- start with the error message empty
local path, timestamp, flag; -- portions of the archive.org URL
if (not url:match('//web%.archive%.org/')) and (not url:match('//liveweb%.archive%.org/')) then -- also deprecated liveweb Wayback machine URL
return url, date; -- not an archive.org archive, return ArchiveURL and ArchiveDate
end
if url:match('//web%.archive%.org/save/') then -- if a save command URL, we don't want to allow saving of the target page
err_msg = cfg.err_msg_supl.save;
url = url:gsub ('(//web%.archive%.org)/save/', '%1/*/', 1); -- for preview mode: modify ArchiveURL
elseif url:match('//liveweb%.archive%.org/') then
err_msg = cfg.err_msg_supl.liveweb;
else
path, timestamp, flag = url:match('//web%.archive%.org/([^%d]*)(%d+)([^/]*)/'); -- split out some of the URL parts for evaluation
if not path then -- malformed in some way; pattern did not match
err_msg = cfg.err_msg_supl.timestamp;
elseif 14 ~= timestamp:len() then -- path and flag optional, must have 14-digit timestamp here
err_msg = cfg.err_msg_supl.timestamp;
if '*' ~= flag then
local replacement = timestamp:match ('^%d%d%d%d%d%d') or timestamp:match ('^%d%d%d%d'); -- get the first 6 (YYYYMM) or first 4 digits (YYYY)
if replacement then -- nil if there aren't at least 4 digits (year)
replacement = replacement .. string.rep ('0', 14 - replacement:len()); -- year or yearmo (4 or 6 digits) zero-fill to make 14-digit timestamp
url=url:gsub ('(//web%.archive%.org/[^%d]*)%d[^/]*', '%1' .. replacement .. '*', 1) -- for preview, modify ts to 14 digits plus splat for calendar display
end
end
elseif utilities.is_set (path) and 'web/' ~= path then -- older archive URLs do not have the extra 'web/' path element
err_msg = cfg.err_msg_supl.path;
elseif utilities.is_set (flag) and not utilities.is_set (path) then -- flag not allowed with the old form URL (without the 'web/' path element)
err_msg = cfg.err_msg_supl.flag;
elseif utilities.is_set (flag) and not flag:match ('%a%a_') then -- flag if present must be two alpha characters and underscore (requires 'web/' path element)
err_msg = cfg.err_msg_supl.flag;
else
return url, date; -- return ArchiveURL and ArchiveDate
end
end
-- if here, something not right so
utilities.set_message ('err_archive_url', {err_msg}); -- add error message and
if is_preview_mode then
return url, date; -- preview mode so return ArchiveURL and ArchiveDate
else
return '', ''; -- return empty strings for ArchiveURL and ArchiveDate
end
end
--[[--------------------------< P L A C E _ C H E C K >--------------------------------------------------------
check |place=, |publication-place=, |location= to see if these params include digits. This function added because
many editors misuse location to specify the in-source location (|page(s)= and |at= are supposed to do that)
returns the original parameter value without modification; added maint cat when parameter value contains digits
]]
local function place_check (param_val)
if not utilities.is_set (param_val) then -- parameter empty or omitted
return param_val; -- return that empty state
end
if mw.ustring.find (param_val, '%d') then -- not empty, are there digits in the parameter value
utilities.set_message ('maint_location'); -- yep, add maint cat
end
return param_val; -- and done
end
--[[--------------------------< I S _ A R C H I V E D _ C O P Y >----------------------------------------------
compares |title= to 'Archived copy' (placeholder added by bots that can't find proper title); if matches, return true; nil else
]]
local function is_archived_copy (title)
title = mw.ustring.lower(title); -- switch title to lower case
if title:find (cfg.special_case_translation.archived_copy.en) then -- if title is 'Archived copy'
return true;
elseif cfg.special_case_translation.archived_copy['local'] then
if mw.ustring.find (title, cfg.special_case_translation.archived_copy['local']) then -- mw.ustring() because might not be Latin script
return true;
end
end
end
--[[--------------------------< C I T A T I O N 0 >------------------------------------------------------------
This is the main function doing the majority of the citation formatting.
]]
local function citation0( config, args )
--[[
Load Input Parameters
The argument_wrapper facilitates the mapping of multiple aliases to single internal variable.
]]
local A = argument_wrapper ( args );
local i
-- Pick out the relevant fields from the arguments. Different citation templates
-- define different field names for the same underlying things.
local author_etal;
local a = {}; -- authors list from |lastn= / |firstn= pairs or |vauthors=
local Authors;
local NameListStyle = is_valid_parameter_value (A['NameListStyle'], A:ORIGIN('NameListStyle'), cfg.keywords_lists['name-list-style'], '');
local Collaboration = A['Collaboration'];
do -- to limit scope of selected
local selected = select_author_editor_source (A['Vauthors'], A['Authors'], args, 'AuthorList');
if 1 == selected then
a, author_etal = extract_names (args, 'AuthorList'); -- fetch author list from |authorn= / |lastn= / |firstn=, |author-linkn=, and |author-maskn=
elseif 2 == selected then
NameListStyle = 'vanc'; -- override whatever |name-list-style= might be
a, author_etal = parse_vauthors_veditors (args, args.vauthors, 'AuthorList'); -- fetch author list from |vauthors=, |author-linkn=, and |author-maskn=
elseif 3 == selected then
Authors = A['Authors']; -- use content of |authors=
if 'authors' == A:ORIGIN('Authors') then -- but add a maint cat if the parameter is |authors=
utilities.set_message ('maint_authors'); -- because use of this parameter is discouraged; what to do about the aliases is a TODO:
end
end
if utilities.is_set (Collaboration) then
author_etal = true; -- so that |display-authors=etal not required
end
end
local editor_etal;
local e = {}; -- editors list from |editor-lastn= / |editor-firstn= pairs or |veditors=
do -- to limit scope of selected
local selected = select_author_editor_source (A['Veditors'], nil, args, 'EditorList'); -- support for |editors= withdrawn
if 1 == selected then
e, editor_etal = extract_names (args, 'EditorList'); -- fetch editor list from |editorn= / |editor-lastn= / |editor-firstn=, |editor-linkn=, and |editor-maskn=
elseif 2 == selected then
NameListStyle = 'vanc'; -- override whatever |name-list-style= might be
e, editor_etal = parse_vauthors_veditors (args, args.veditors, 'EditorList'); -- fetch editor list from |veditors=, |editor-linkn=, and |editor-maskn=
end
end
local Chapter = A['Chapter']; -- done here so that we have access to |contribution= from |chapter= aliases
local Chapter_origin = A:ORIGIN ('Chapter');
local Contribution; -- because contribution is required for contributor(s)
if 'contribution' == Chapter_origin then
Contribution = Chapter; -- get the name of the contribution
end
local c = {}; -- contributors list from |contributor-lastn= / contributor-firstn= pairs
if utilities.in_array (config.CitationClass, {"book", "citation"}) and not utilities.is_set (A['Periodical']) then -- |contributor= and |contribution= only supported in book cites
c = extract_names (args, 'ContributorList'); -- fetch contributor list from |contributorn= / |contributor-lastn=, -firstn=, -linkn=, -maskn=
if 0 < #c then
if not utilities.is_set (Contribution) then -- |contributor= requires |contribution=
utilities.set_message ('err_contributor_missing_required_param', 'contribution'); -- add missing contribution error message
c = {}; -- blank the contributors' table; it is used as a flag later
end
if 0 == #a then -- |contributor= requires |author=
utilities.set_message ('err_contributor_missing_required_param', 'author'); -- add missing author error message
c = {}; -- blank the contributors' table; it is used as a flag later
end
end
else -- if not a book cite
if utilities.select_one (args, cfg.aliases['ContributorList-Last'], 'err_redundant_parameters', 1 ) then -- are there contributor name list parameters?
utilities.set_message ('err_contributor_ignored'); -- add contributor ignored error message
end
Contribution = nil; -- unset
end
local Title = A['Title'];
local TitleLink = A['TitleLink'];
local auto_select = ''; -- default is auto
local accept_link;
TitleLink, accept_link = utilities.has_accept_as_written (TitleLink, true); -- test for accept-this-as-written markup
if (not accept_link) and utilities.in_array (TitleLink, {'none', 'pmc', 'doi'}) then -- check for special keywords
auto_select = TitleLink; -- remember selection for later
TitleLink = ''; -- treat as if |title-link= would have been empty
end
TitleLink = link_title_ok (TitleLink, A:ORIGIN ('TitleLink'), Title, 'title'); -- check for wiki-markup in |title-link= or wiki-markup in |title= when |title-link= is set
local Section = ''; -- {{cite map}} only; preset to empty string for concatenation if not used
if 'map' == config.CitationClass and 'section' == Chapter_origin then
Section = A['Chapter']; -- get |section= from |chapter= alias list; |chapter= and the other aliases not supported in {{cite map}}
Chapter = ''; -- unset for now; will be reset later from |map= if present
end
local Periodical = A['Periodical'];
local Periodical_origin = '';
if utilities.is_set (Periodical) then
Periodical_origin = A:ORIGIN('Periodical'); -- get the name of the periodical parameter
local i;
Periodical, i = utilities.strip_apostrophe_markup (Periodical); -- strip apostrophe markup so that metadata isn't contaminated
if i then -- non-zero when markup was stripped so emit an error message
utilities.set_message ('err_apostrophe_markup', {Periodical_origin});
end
end
if 'mailinglist' == config.CitationClass then -- special case for {{cite mailing list}}
if utilities.is_set (Periodical) and utilities.is_set (A ['MailingList']) then -- both set emit an error TODO: make a function for this and similar?
utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', Periodical_origin) .. ' and ' .. utilities.wrap_style ('parameter', 'mailinglist')});
end
Periodical = A ['MailingList']; -- error or no, set Periodical to |mailinglist= value because this template is {{cite mailing list}}
Periodical_origin = A:ORIGIN('MailingList');
end
local ScriptPeriodical = A['ScriptPeriodical'];
-- web and news not tested for now because of
-- Wikipedia:Administrators%27_noticeboard#Is_there_a_semi-automated_tool_that_could_fix_these_annoying_"Cite_Web"_errors?
if not (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) then -- 'periodical' templates require periodical parameter
-- local p = {['journal'] = 'journal', ['magazine'] = 'magazine', ['news'] = 'newspaper', ['web'] = 'website'}; -- for error message
local p = {['journal'] = 'journal', ['magazine'] = 'magazine'}; -- for error message
if p[config.CitationClass] then
utilities.set_message ('err_missing_periodical', {config.CitationClass, p[config.CitationClass]});
end
end
local Volume;
local ScriptPeriodical_origin = A:ORIGIN('ScriptPeriodical');
if 'citation' == config.CitationClass then
if utilities.is_set (Periodical) then
if not utilities.in_array (Periodical_origin, cfg.citation_no_volume_t) then -- {{citation}} does not render |volume= when these parameters are used
Volume = A['Volume']; -- but does for all other 'periodicals'
end
elseif utilities.is_set (ScriptPeriodical) then
if 'script-website' ~= ScriptPeriodical_origin then -- {{citation}} does not render volume for |script-website=
Volume = A['Volume']; -- but does for all other 'periodicals'
end
else
Volume = A['Volume']; -- and does for non-'periodical' cites
end
elseif utilities.in_array (config.CitationClass, cfg.templates_using_volume) then -- render |volume= for cs1 according to the configuration settings
Volume = A['Volume'];
end
extra_text_in_vol_iss_check (Volume, A:ORIGIN ('Volume'), 'v');
local Issue;
if 'citation' == config.CitationClass then
if utilities.is_set (Periodical) and utilities.in_array (Periodical_origin, cfg.citation_issue_t) then -- {{citation}} may render |issue= when these parameters are used
Issue = utilities.hyphen_to_dash (A['Issue']);
end
elseif utilities.in_array (config.CitationClass, cfg.templates_using_issue) then -- conference & map books do not support issue; {{citation}} listed here because included in settings table
if not (utilities.in_array (config.CitationClass, {'conference', 'map', 'citation'}) and not (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical))) then
Issue = utilities.hyphen_to_dash (A['Issue']);
end
end
extra_text_in_vol_iss_check (Issue, A:ORIGIN ('Issue'), 'i');
local Page;
local Pages;
local At;
if not utilities.in_array (config.CitationClass, cfg.templates_not_using_page) then
Page = A['Page'];
Pages = utilities.hyphen_to_dash (A['Pages']);
At = A['At'];
end
local Edition = A['Edition'];
local PublicationPlace = place_check (A['PublicationPlace'], A:ORIGIN('PublicationPlace'));
local Place = place_check (A['Place'], A:ORIGIN('Place'));
local PublisherName = A['PublisherName'];
local PublisherName_origin = A:ORIGIN('PublisherName');
if utilities.is_set (PublisherName) then
local i = 0;
PublisherName, i = utilities.strip_apostrophe_markup (PublisherName); -- strip apostrophe markup so that metadata isn't contaminated; publisher is never italicized
if i then -- non-zero when markup was stripped so emit an error message
utilities.set_message ('err_apostrophe_markup', {PublisherName_origin});
end
end
local Newsgroup = A['Newsgroup']; -- TODO: strip apostrophe markup?
local Newsgroup_origin = A:ORIGIN('Newsgroup');
if 'newsgroup' == config.CitationClass then
if utilities.is_set (PublisherName) then -- general use parameter |publisher= not allowed in cite newsgroup
utilities.set_message ('err_parameter_ignored', {PublisherName_origin});
end
PublisherName = nil; -- ensure that this parameter is unset for the time being; will be used again after COinS
end
local URL = A['URL']; -- TODO: better way to do this for URL, ChapterURL, and MapURL?
local UrlAccess = is_valid_parameter_value (A['UrlAccess'], A:ORIGIN('UrlAccess'), cfg.keywords_lists['url-access'], nil);
if not utilities.is_set (URL) and utilities.is_set (UrlAccess) then
UrlAccess = nil;
utilities.set_message ('err_param_access_requires_param', 'url');
end
local ChapterURL = A['ChapterURL'];
local ChapterUrlAccess = is_valid_parameter_value (A['ChapterUrlAccess'], A:ORIGIN('ChapterUrlAccess'), cfg.keywords_lists['url-access'], nil);
if not utilities.is_set (ChapterURL) and utilities.is_set (ChapterUrlAccess) then
ChapterUrlAccess = nil;
utilities.set_message ('err_param_access_requires_param', {A:ORIGIN('ChapterUrlAccess'):gsub ('%-access', '')});
end
local MapUrlAccess = is_valid_parameter_value (A['MapUrlAccess'], A:ORIGIN('MapUrlAccess'), cfg.keywords_lists['url-access'], nil);
if not utilities.is_set (A['MapURL']) and utilities.is_set (MapUrlAccess) then
MapUrlAccess = nil;
utilities.set_message ('err_param_access_requires_param', {'map-url'});
end
local this_page = mw.title.getCurrentTitle(); -- also used for COinS and for language
local no_tracking_cats = is_valid_parameter_value (A['NoTracking'], A:ORIGIN('NoTracking'), cfg.keywords_lists['yes_true_y'], nil);
-- check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories
if not utilities.is_set (no_tracking_cats) then -- ignore if we are already not going to categorize this page
if utilities.in_array (this_page.nsText, cfg.uncategorized_namespaces) then
no_tracking_cats = "true"; -- set no_tracking_cats
end
for _, v in ipairs (cfg.uncategorized_subpages) do -- cycle through page name patterns
if this_page.text:match (v) then -- test page name against each pattern
no_tracking_cats = "true"; -- set no_tracking_cats
break; -- bail out if one is found
end
end
end
-- check for extra |page=, |pages= or |at= parameters. (also sheet and sheets while we're at it)
utilities.select_one (args, {'page', 'p', 'pp', 'pages', 'at', 'sheet', 'sheets'}, 'err_redundant_parameters'); -- this is a dummy call simply to get the error message and category
local coins_pages;
Page, Pages, At, coins_pages = insource_loc_get (Page, A:ORIGIN('Page'), Pages, A:ORIGIN('Pages'), At);
local NoPP = is_valid_parameter_value (A['NoPP'], A:ORIGIN('NoPP'), cfg.keywords_lists['yes_true_y'], nil);
if utilities.is_set (PublicationPlace) and utilities.is_set (Place) then -- both |publication-place= and |place= (|location=) allowed if different
utilities.add_prop_cat ('location-test'); -- add property cat to evaluate how often PublicationPlace and Place are used together
if PublicationPlace == Place then
Place = ''; -- unset; don't need both if they are the same
end
elseif not utilities.is_set (PublicationPlace) and utilities.is_set (Place) then -- when only |place= (|location=) is set ...
PublicationPlace = Place; -- promote |place= (|location=) to |publication-place
end
if PublicationPlace == Place then Place = ''; end -- don't need both if they are the same
local URL_origin = A:ORIGIN('URL'); -- get name of parameter that holds URL
local ChapterURL_origin = A:ORIGIN('ChapterURL'); -- get name of parameter that holds ChapterURL
local ScriptChapter = A['ScriptChapter'];
local ScriptChapter_origin = A:ORIGIN ('ScriptChapter');
local Format = A['Format'];
local ChapterFormat = A['ChapterFormat'];
local TransChapter = A['TransChapter'];
local TransChapter_origin = A:ORIGIN ('TransChapter');
local TransTitle = A['TransTitle'];
local ScriptTitle = A['ScriptTitle'];
--[[
Parameter remapping for cite encyclopedia:
When the citation has these parameters:
|encyclopedia= and |title= then map |title= to |article= and |encyclopedia= to |title=
|encyclopedia= and |article= then map |encyclopedia= to |title=
|trans-title= maps to |trans-chapter= when |title= is re-mapped
|url= maps to |chapter-url= when |title= is remapped
All other combinations of |encyclopedia=, |title=, and |article= are not modified
]]
local Encyclopedia = A['Encyclopedia']; -- used as a flag by this module and by ~/COinS
if utilities.is_set (Encyclopedia) then -- emit error message when Encyclopedia set but template is other than {{cite encyclopedia}} or {{citation}}
if 'encyclopaedia' ~= config.CitationClass and 'citation' ~= config.CitationClass then
utilities.set_message ('err_parameter_ignored', {A:ORIGIN ('Encyclopedia')});
Encyclopedia = nil; -- unset because not supported by this template
end
end
if ('encyclopaedia' == config.CitationClass) or ('citation' == config.CitationClass and utilities.is_set (Encyclopedia)) then
if utilities.is_set (Periodical) and utilities.is_set (Encyclopedia) then -- when both set emit an error TODO: make a function for this and similar?
utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', A:ORIGIN ('Encyclopedia')) .. ' and ' .. utilities.wrap_style ('parameter', Periodical_origin)});
end
if utilities.is_set (Encyclopedia) then
Periodical = Encyclopedia; -- error or no, set Periodical to Encyclopedia; allow periodical without encyclopedia
Periodical_origin = A:ORIGIN ('Encyclopedia');
end
if utilities.is_set (Periodical) then -- Periodical is set when |encyclopedia= is set
if utilities.is_set (Title) or utilities.is_set (ScriptTitle) then
if not utilities.is_set (Chapter) then
Chapter = Title; -- |encyclopedia= and |title= are set so map |title= to |article= and |encyclopedia= to |title=
ScriptChapter = ScriptTitle;
ScriptChapter_origin = A:ORIGIN('ScriptTitle')
TransChapter = TransTitle;
ChapterURL = URL;
ChapterURL_origin = URL_origin;
ChapterUrlAccess = UrlAccess;
if not utilities.is_set (ChapterURL) and utilities.is_set (TitleLink) then
Chapter = utilities.make_wikilink (TitleLink, Chapter);
end
Title = Periodical;
ChapterFormat = Format;
Periodical = ''; -- redundant so unset
TransTitle = '';
URL = '';
Format = '';
TitleLink = '';
ScriptTitle = '';
end
elseif utilities.is_set (Chapter) or utilities.is_set (ScriptChapter) then -- |title= not set
Title = Periodical; -- |encyclopedia= set and |article= set so map |encyclopedia= to |title=
Periodical = ''; -- redundant so unset
end
end
end
-- special case for cite techreport.
local ID = A['ID'];
if (config.CitationClass == "techreport") then -- special case for cite techreport
if utilities.is_set (A['Number']) then -- cite techreport uses 'number', which other citations alias to 'issue'
if not utilities.is_set (ID) then -- can we use ID for the "number"?
ID = A['Number']; -- yes, use it
else -- ID has a value so emit error message
utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', 'id') .. ' and ' .. utilities.wrap_style ('parameter', 'number')});
end
end
end
-- Account for the oddity that is {{cite conference}}, before generation of COinS data.
local ChapterLink -- = A['ChapterLink']; -- deprecated as a parameter but still used internally by cite episode
local Conference = A['Conference'];
local BookTitle = A['BookTitle'];
local TransTitle_origin = A:ORIGIN ('TransTitle');
if 'conference' == config.CitationClass then
if utilities.is_set (BookTitle) then
Chapter = Title;
Chapter_origin = 'title';
-- ChapterLink = TitleLink; -- |chapter-link= is deprecated
ChapterURL = URL;
ChapterUrlAccess = UrlAccess;
ChapterURL_origin = URL_origin;
URL_origin = '';
ChapterFormat = Format;
TransChapter = TransTitle;
TransChapter_origin = TransTitle_origin;
Title = BookTitle;
Format = '';
-- TitleLink = '';
TransTitle = '';
URL = '';
end
elseif 'speech' ~= config.CitationClass then
Conference = ''; -- not cite conference or cite speech so make sure this is empty string
end
-- CS1/2 mode
local Mode = is_valid_parameter_value (A['Mode'], A:ORIGIN('Mode'), cfg.keywords_lists['mode'], '');
-- separator character and postscript
local sepc, PostScript = set_style (Mode:lower(), A['PostScript'], config.CitationClass);
-- controls capitalization of certain static text
local use_lowercase = ( sepc == ',' );
-- cite map oddities
local Cartography = "";
local Scale = "";
local Sheet = A['Sheet'] or '';
local Sheets = A['Sheets'] or '';
if config.CitationClass == "map" then
if utilities.is_set (Chapter) then --TODO: make a function for this and similar?
utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', 'map') .. ' and ' .. utilities.wrap_style ('parameter', Chapter_origin)}); -- add error message
end
Chapter = A['Map'];
Chapter_origin = A:ORIGIN('Map');
ChapterURL = A['MapURL'];
ChapterURL_origin = A:ORIGIN('MapURL');
TransChapter = A['TransMap'];
ScriptChapter = A['ScriptMap']
ScriptChapter_origin = A:ORIGIN('ScriptMap')
ChapterUrlAccess = MapUrlAccess;
ChapterFormat = A['MapFormat'];
Cartography = A['Cartography'];
if utilities.is_set ( Cartography ) then
Cartography = sepc .. " " .. wrap_msg ('cartography', Cartography, use_lowercase);
end
Scale = A['Scale'];
if utilities.is_set ( Scale ) then
Scale = sepc .. " " .. Scale;
end
end
-- Account for the oddities that are {{cite episode}} and {{cite serial}}, before generation of COinS data.
local Series = A['Series'];
if 'episode' == config.CitationClass or 'serial' == config.CitationClass then
local SeriesLink = A['SeriesLink'];
SeriesLink = link_title_ok (SeriesLink, A:ORIGIN ('SeriesLink'), Series, 'series'); -- check for wiki-markup in |series-link= or wiki-markup in |series= when |series-link= is set
local Network = A['Network'];
local Station = A['Station'];
local s, n = {}, {};
-- do common parameters first
if utilities.is_set (Network) then table.insert(n, Network); end
if utilities.is_set (Station) then table.insert(n, Station); end
ID = table.concat(n, sepc .. ' ');
if 'episode' == config.CitationClass then -- handle the oddities that are strictly {{cite episode}}
local Season = A['Season'];
local SeriesNumber = A['SeriesNumber'];
if utilities.is_set (Season) and utilities.is_set (SeriesNumber) then -- these are mutually exclusive so if both are set TODO: make a function for this and similar?
utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', 'season') .. ' and ' .. utilities.wrap_style ('parameter', 'seriesno')}); -- add error message
SeriesNumber = ''; -- unset; prefer |season= over |seriesno=
end
-- assemble a table of parts concatenated later into Series
if utilities.is_set (Season) then table.insert(s, wrap_msg ('season', Season, use_lowercase)); end
if utilities.is_set (SeriesNumber) then table.insert(s, wrap_msg ('seriesnum', SeriesNumber, use_lowercase)); end
if utilities.is_set (Issue) then table.insert(s, wrap_msg ('episode', Issue, use_lowercase)); end
Issue = ''; -- unset because this is not a unique parameter
Chapter = Title; -- promote title parameters to chapter
ScriptChapter = ScriptTitle;
ScriptChapter_origin = A:ORIGIN('ScriptTitle');
ChapterLink = TitleLink; -- alias |episode-link=
TransChapter = TransTitle;
ChapterURL = URL;
ChapterUrlAccess = UrlAccess;
ChapterURL_origin = URL_origin;
ChapterFormat = Format;
Title = Series; -- promote series to title
TitleLink = SeriesLink;
Series = table.concat(s, sepc .. ' '); -- this is concatenation of season, seriesno, episode number
if utilities.is_set (ChapterLink) and not utilities.is_set (ChapterURL) then -- link but not URL
Chapter = utilities.make_wikilink (ChapterLink, Chapter);
elseif utilities.is_set (ChapterLink) and utilities.is_set (ChapterURL) then -- if both are set, URL links episode;
Series = utilities.make_wikilink (ChapterLink, Series);
end
URL = ''; -- unset
TransTitle = '';
ScriptTitle = '';
Format = '';
else -- now oddities that are cite serial
Issue = ''; -- unset because this parameter no longer supported by the citation/core version of cite serial
Chapter = A['Episode']; -- TODO: make |episode= available to cite episode someday?
if utilities.is_set (Series) and utilities.is_set (SeriesLink) then
Series = utilities.make_wikilink (SeriesLink, Series);
end
Series = utilities.wrap_style ('italic-title', Series); -- series is italicized
end
end
-- end of {{cite episode}} stuff
-- handle type parameter for those CS1 citations that have default values
local TitleType = A['TitleType'];
local Degree = A['Degree'];
if utilities.in_array (config.CitationClass, {'AV-media-notes', 'interview', 'mailinglist', 'map', 'podcast', 'pressrelease', 'report', 'speech', 'techreport', 'thesis'}) then
TitleType = set_titletype (config.CitationClass, TitleType);
if utilities.is_set (Degree) and "Thesis" == TitleType then -- special case for cite thesis
TitleType = Degree .. ' ' .. cfg.title_types ['thesis']:lower();
end
end
if utilities.is_set (TitleType) then -- if type parameter is specified
TitleType = utilities.substitute ( cfg.messages['type'], TitleType); -- display it in parentheses
-- TODO: Hack on TitleType to fix bunched parentheses problem
end
-- legacy: promote PublicationDate to Date if neither Date nor Year are set.
local Date = A['Date'];
local Date_origin; -- to hold the name of parameter promoted to Date; required for date error messaging
local PublicationDate = A['PublicationDate'];
local Year = A['Year'];
if not utilities.is_set (Date) then
Date = Year; -- promote Year to Date
Year = nil; -- make nil so Year as empty string isn't used for CITEREF
if not utilities.is_set (Date) and utilities.is_set (PublicationDate) then -- use PublicationDate when |date= and |year= are not set
Date = PublicationDate; -- promote PublicationDate to Date
PublicationDate = ''; -- unset, no longer needed
Date_origin = A:ORIGIN('PublicationDate'); -- save the name of the promoted parameter
else
Date_origin = A:ORIGIN('Year'); -- save the name of the promoted parameter
end
else
Date_origin = A:ORIGIN('Date'); -- not a promotion; name required for error messaging
end
if PublicationDate == Date then PublicationDate = ''; end -- if PublicationDate is same as Date, don't display in rendered citation
--[[
Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates. This must be done before we do COinS because here is where
we get the date used in the metadata.
Date validation supporting code is in Module:Citation/CS1/Date_validation
]]
local DF = is_valid_parameter_value (A['DF'], A:ORIGIN('DF'), cfg.keywords_lists['df'], '');
if not utilities.is_set (DF) then
DF = cfg.global_df; -- local |df= if present overrides global df set by {{use xxx date}} template
end
local ArchiveURL;
local ArchiveDate;
local ArchiveFormat = A['ArchiveFormat'];
ArchiveURL, ArchiveDate = archive_url_check (A['ArchiveURL'], A['ArchiveDate'])
ArchiveFormat = style_format (ArchiveFormat, ArchiveURL, 'archive-format', 'archive-url');
ArchiveURL, ArchiveDate = is_unique_archive_url (ArchiveURL, URL, ChapterURL, A:ORIGIN('ArchiveURL'), ArchiveDate); -- add error message when URL or ChapterURL == ArchiveURL
local AccessDate = A['AccessDate'];
local LayDate = A['LayDate'];
local COinS_date = {}; -- holds date info extracted from |date= for the COinS metadata by Module:Date verification
local DoiBroken = A['DoiBroken'];
local Embargo = A['Embargo'];
local anchor_year; -- used in the CITEREF identifier
do -- create defined block to contain local variables error_message, date_parameters_list, mismatch
local error_message = '';
-- AirDate has been promoted to Date so not necessary to check it
local date_parameters_list = {
['access-date'] = {val = AccessDate, name = A:ORIGIN ('AccessDate')},
['archive-date'] = {val = ArchiveDate, name = A:ORIGIN ('ArchiveDate')},
['date'] = {val = Date, name = Date_origin},
['doi-broken-date'] = {val = DoiBroken, name = A:ORIGIN ('DoiBroken')},
['pmc-embargo-date'] = {val = Embargo, name = A:ORIGIN ('Embargo')},
['lay-date'] = {val = LayDate, name = A:ORIGIN ('LayDate')},
['publication-date'] = {val = PublicationDate, name = A:ORIGIN ('PublicationDate')},
['year'] = {val = Year, name = A:ORIGIN ('Year')},
};
local error_list = {};
anchor_year, Embargo = validation.dates(date_parameters_list, COinS_date, error_list);
-- start temporary Julian / Gregorian calendar uncertainty categorization
if COinS_date.inter_cal_cat then
utilities.add_prop_cat ('jul-greg-uncertainty');
end
-- end temporary Julian / Gregorian calendar uncertainty categorization
if utilities.is_set (Year) and utilities.is_set (Date) then -- both |date= and |year= not normally needed;
validation.year_date_check (Year, A:ORIGIN ('Year'), Date, A:ORIGIN ('Date'), error_list);
end
if 0 == #error_list then -- error free dates only; 0 when error_list is empty
local modified = false; -- flag
if utilities.is_set (DF) then -- if we need to reformat dates
modified = validation.reformat_dates (date_parameters_list, DF); -- reformat to DF format, use long month names if appropriate
end
if true == validation.date_hyphen_to_dash (date_parameters_list) then -- convert hyphens to dashes where appropriate
modified = true;
utilities.set_message ('maint_date_format'); -- hyphens were converted so add maint category
end
-- for those wikis that can and want to have English date names translated to the local language; not supported at en.wiki
if cfg.date_name_auto_xlate_enable and validation.date_name_xlate (date_parameters_list, cfg.date_digit_auto_xlate_enable ) then
utilities.set_message ('maint_date_auto_xlated'); -- add maint cat
modified = true;
end
if modified then -- if the date_parameters_list values were modified
AccessDate = date_parameters_list['access-date'].val; -- overwrite date holding parameters with modified values
ArchiveDate = date_parameters_list['archive-date'].val;
Date = date_parameters_list['date'].val;
DoiBroken = date_parameters_list['doi-broken-date'].val;
LayDate = date_parameters_list['lay-date'].val;
PublicationDate = date_parameters_list['publication-date'].val;
end
else
utilities.set_message ('err_bad_date', {utilities.make_sep_list (#error_list, error_list)}); -- add this error message
end
end -- end of do
local ID_list = {}; -- sequence table of rendered identifiers
local ID_list_coins = {}; -- table of identifiers and their values from args; key is same as cfg.id_handlers's key
local Class = A['Class']; -- arxiv class identifier
local ID_support = {
{A['ASINTLD'], 'ASIN', 'err_asintld_missing_asin', A:ORIGIN ('ASINTLD')},
{DoiBroken, 'DOI', 'err_doibroken_missing_doi', A:ORIGIN ('DoiBroken')},
{Embargo, 'PMC', 'err_embargo_missing_pmc', A:ORIGIN ('Embargo')},
}
ID_list, ID_list_coins = identifiers.identifier_lists_get (args, {DoiBroken = DoiBroken, ASINTLD = A['ASINTLD'], Embargo = Embargo, Class = Class}, ID_support);
-- Account for the oddities that are {{cite arxiv}}, {{cite biorxiv}}, {{cite citeseerx}}, {{cite ssrn}}, before generation of COinS data.
if utilities.in_array (config.CitationClass, whitelist.preprint_template_list) then
if not utilities.is_set (ID_list_coins[config.CitationClass:upper()]) then -- |arxiv= or |eprint= required for cite arxiv; |biorxiv= & |citeseerx= required for their templates
utilities.set_message ('err_' .. config.CitationClass .. '_missing'); -- add error message
end
Periodical = ({['arxiv'] = 'arXiv', ['biorxiv'] = 'bioRxiv', ['citeseerx'] = 'CiteSeerX', ['ssrn'] = 'Social Science Research Network'})[config.CitationClass];
end
-- Link the title of the work if no |url= was provided, but we have a |pmc= or a |doi= with |doi-access=free
if config.CitationClass == "journal" and not utilities.is_set (URL) and not utilities.is_set (TitleLink) and not utilities.in_array (cfg.keywords_xlate[Title], {'off', 'none'}) then -- TODO: remove 'none' once existing citations have been switched to 'off', so 'none' can be used as token for "no title" instead
if 'none' ~= cfg.keywords_xlate[auto_select] then -- if auto-linking not disabled
if identifiers.auto_link_urls[auto_select] then -- manual selection
URL = identifiers.auto_link_urls[auto_select]; -- set URL to be the same as identifier's external link
URL_origin = cfg.id_handlers[auto_select:upper()].parameters[1]; -- set URL_origin to parameter name for use in error message if citation is missing a |title=
elseif identifiers.auto_link_urls['pmc'] then -- auto-select PMC
URL = identifiers.auto_link_urls['pmc']; -- set URL to be the same as the PMC external link if not embargoed
URL_origin = cfg.id_handlers['PMC'].parameters[1]; -- set URL_origin to parameter name for use in error message if citation is missing a |title=
elseif identifiers.auto_link_urls['doi'] then -- auto-select DOI
URL = identifiers.auto_link_urls['doi'];
URL_origin = cfg.id_handlers['DOI'].parameters[1];
end
end
if utilities.is_set (URL) then -- set when using an identifier-created URL
if utilities.is_set (AccessDate) then -- |access-date= requires |url=; identifier-created URL is not |url=
utilities.set_message ('err_accessdate_missing_url'); -- add an error message
AccessDate = ''; -- unset
end
if utilities.is_set (ArchiveURL) then -- |archive-url= requires |url=; identifier-created URL is not |url=
utilities.set_message ('err_archive_missing_url'); -- add an error message
ArchiveURL = ''; -- unset
end
end
end
-- At this point fields may be nil if they weren't specified in the template use. We can use that fact.
-- Test if citation has no title
if not utilities.is_set (Title) and not utilities.is_set (TransTitle) and not utilities.is_set (ScriptTitle) then -- has special case for cite episode
utilities.set_message ('err_citation_missing_title', {'episode' == config.CitationClass and 'series' or 'title'});
end
if utilities.in_array (cfg.keywords_xlate[Title], {'off', 'none'}) and
utilities.in_array (config.CitationClass, {'journal', 'citation'}) and
(utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and
('journal' == Periodical_origin or 'script-journal' == ScriptPeriodical_origin) then -- special case for journal cites
Title = ''; -- set title to empty string
utilities.set_message ('maint_untitled'); -- add maint cat
end
-- COinS metadata (see <http://ocoins.info/>) for automated parsing of citation information.
-- handle the oddity that is cite encyclopedia and {{citation |encyclopedia=something}}. Here we presume that
-- when Periodical, Title, and Chapter are all set, then Periodical is the book (encyclopedia) title, Title
-- is the article title, and Chapter is a section within the article. So, we remap
local coins_chapter = Chapter; -- default assuming that remapping not required
local coins_title = Title; -- et tu
if 'encyclopaedia' == config.CitationClass or ('citation' == config.CitationClass and utilities.is_set (Encyclopedia)) then
if utilities.is_set (Chapter) and utilities.is_set (Title) and utilities.is_set (Periodical) then -- if all are used then
coins_chapter = Title; -- remap
coins_title = Periodical;
end
end
local coins_author = a; -- default for coins rft.au
if 0 < #c then -- but if contributor list
coins_author = c; -- use that instead
end
local QuotePage = A['QuotePage'];
local QuotePages = utilities.hyphen_to_dash (A['QuotePages']);
-- this is the function call to COinS()
local OCinSoutput = metadata.COinS({
['Periodical'] = utilities.strip_apostrophe_markup (Periodical), -- no markup in the metadata
['Encyclopedia'] = Encyclopedia, -- just a flag; content ignored by ~/COinS
['Chapter'] = metadata.make_coins_title (coins_chapter, ScriptChapter), -- Chapter and ScriptChapter stripped of bold / italic / accept-as-written markup
['Degree'] = Degree; -- cite thesis only
['Title'] = metadata.make_coins_title (coins_title, ScriptTitle), -- Title and ScriptTitle stripped of bold / italic / accept-as-written markup
['PublicationPlace'] = PublicationPlace,
['Date'] = COinS_date.rftdate, -- COinS_date has correctly formatted date if Date is valid;
['Season'] = COinS_date.rftssn,
['Quarter'] = COinS_date.rftquarter,
['Chron'] = COinS_date.rftchron or (not COinS_date.rftdate and Date) or '', -- chron but if not set and invalid date format use Date; keep this last bit?
['Series'] = Series,
['Volume'] = Volume,
['Issue'] = Issue,
['Pages'] = coins_pages or metadata.get_coins_pages (first_set ({Sheet, Sheets, Page, Pages, At, QuotePage, QuotePages}, 7)), -- pages stripped of external links
['Edition'] = Edition,
['PublisherName'] = PublisherName or Newsgroup, -- any apostrophe markup already removed from PublisherName
['URL'] = first_set ({ChapterURL, URL}, 2),
['Authors'] = coins_author,
['ID_list'] = ID_list_coins,
['RawPage'] = this_page.prefixedText,
}, config.CitationClass);
-- Account for the oddities that are {{cite arxiv}}, {{cite biorxiv}}, {{cite citeseerx}}, and {{cite ssrn}} AFTER generation of COinS data.
if utilities.in_array (config.CitationClass, whitelist.preprint_template_list) then -- we have set rft.jtitle in COinS to arXiv, bioRxiv, CiteSeerX, or ssrn now unset so it isn't displayed
Periodical = ''; -- periodical not allowed in these templates; if article has been published, use cite journal
end
-- special case for cite newsgroup. Do this after COinS because we are modifying Publishername to include some static text
if 'newsgroup' == config.CitationClass and utilities.is_set (Newsgroup) then
PublisherName = utilities.substitute (cfg.messages['newsgroup'], external_link( 'news:' .. Newsgroup, Newsgroup, Newsgroup_origin, nil ));
end
local Editors;
local EditorCount; -- used only for choosing {ed.) or (eds.) annotation at end of editor name-list
local Contributors; -- assembled contributors name list
local contributor_etal;
local Translators; -- assembled translators name list
local translator_etal;
local t = {}; -- translators list from |translator-lastn= / translator-firstn= pairs
t = extract_names (args, 'TranslatorList'); -- fetch translator list from |translatorn= / |translator-lastn=, -firstn=, -linkn=, -maskn=
local Interviewers;
local interviewers_list = {};
interviewers_list = extract_names (args, 'InterviewerList'); -- process preferred interviewers parameters
local interviewer_etal;
-- Now perform various field substitutions.
-- We also add leading spaces and surrounding markup and punctuation to the
-- various parts of the citation, but only when they are non-nil.
do
local last_first_list;
local control = {
format = NameListStyle, -- empty string or 'vanc'
maximum = nil, -- as if display-authors or display-editors not set
mode = Mode
};
do -- do editor name list first because the now unsupported coauthors used to modify control table
control.maximum , editor_etal = get_display_names (A['DisplayEditors'], #e, 'editors', editor_etal, A:ORIGIN ('DisplayEditors'));
Editors, EditorCount = list_people (control, e, editor_etal);
if 1 == EditorCount and (true == editor_etal or 1 < #e) then -- only one editor displayed but includes etal then
EditorCount = 2; -- spoof to display (eds.) annotation
end
end
do -- now do interviewers
control.maximum, interviewer_etal = get_display_names (A['DisplayInterviewers'], #interviewers_list, 'interviewers', interviewer_etal, A:ORIGIN ('DisplayInterviewers'));
Interviewers = list_people (control, interviewers_list, interviewer_etal);
end
do -- now do translators
control.maximum, translator_etal = get_display_names (A['DisplayTranslators'], #t, 'translators', translator_etal, A:ORIGIN ('DisplayTranslators'));
Translators = list_people (control, t, translator_etal);
end
do -- now do contributors
control.maximum, contributor_etal = get_display_names (A['DisplayContributors'], #c, 'contributors', contributor_etal, A:ORIGIN ('DisplayContributors'));
Contributors = list_people (control, c, contributor_etal);
end
do -- now do authors
control.maximum, author_etal = get_display_names (A['DisplayAuthors'], #a, 'authors', author_etal, A:ORIGIN ('DisplayAuthors'));
last_first_list = list_people (control, a, author_etal);
if utilities.is_set (Authors) then
Authors, author_etal = name_has_etal (Authors, author_etal, false, 'authors'); -- find and remove variations on et al.
if author_etal then
Authors = Authors .. ' ' .. cfg.messages['et al']; -- add et al. to authors parameter
end
else
Authors = last_first_list; -- either an author name list or an empty string
end
end -- end of do
if utilities.is_set (Authors) and utilities.is_set (Collaboration) then
Authors = Authors .. ' (' .. Collaboration .. ')'; -- add collaboration after et al.
end
end
local ConferenceFormat = A['ConferenceFormat'];
local ConferenceURL = A['ConferenceURL'];
ConferenceFormat = style_format (ConferenceFormat, ConferenceURL, 'conference-format', 'conference-url');
Format = style_format (Format, URL, 'format', 'url');
-- special case for chapter format so no error message or cat when chapter not supported
if not (utilities.in_array (config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) or
('citation' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and not utilities.is_set (Encyclopedia))) then
ChapterFormat = style_format (ChapterFormat, ChapterURL, 'chapter-format', 'chapter-url');
end
if not utilities.is_set (URL) then
if utilities.in_array (config.CitationClass, {"web", "podcast", "mailinglist"}) or -- |url= required for cite web, cite podcast, and cite mailinglist
('citation' == config.CitationClass and ('website' == Periodical_origin or 'script-website' == ScriptPeriodical_origin)) then -- and required for {{citation}} with |website= or |script-website=
utilities.set_message ('err_cite_web_url');
end
-- do we have |accessdate= without either |url= or |chapter-url=?
if utilities.is_set (AccessDate) and not utilities.is_set (ChapterURL) then -- ChapterURL may be set when URL is not set;
utilities.set_message ('err_accessdate_missing_url');
AccessDate = '';
end
end
local UrlStatus = is_valid_parameter_value (A['UrlStatus'], A:ORIGIN('UrlStatus'), cfg.keywords_lists['url-status'], '');
local OriginalURL
local OriginalURL_origin
local OriginalFormat
local OriginalAccess;
UrlStatus = UrlStatus:lower(); -- used later when assembling archived text
if utilities.is_set ( ArchiveURL ) then
if utilities.is_set (ChapterURL) then -- if chapter-url= is set apply archive url to it
OriginalURL = ChapterURL; -- save copy of source chapter's url for archive text
OriginalURL_origin = ChapterURL_origin; -- name of |chapter-url= parameter for error messages
OriginalFormat = ChapterFormat; -- and original |chapter-format=
if 'live' ~= UrlStatus then
ChapterURL = ArchiveURL -- swap-in the archive's URL
ChapterURL_origin = A:ORIGIN('ArchiveURL') -- name of |archive-url= parameter for error messages
ChapterFormat = ArchiveFormat or ''; -- swap in archive's format
ChapterUrlAccess = nil; -- restricted access levels do not make sense for archived URLs
end
elseif utilities.is_set (URL) then
OriginalURL = URL; -- save copy of original source URL
OriginalURL_origin = URL_origin; -- name of URL parameter for error messages
OriginalFormat = Format; -- and original |format=
OriginalAccess = UrlAccess;
if 'live' ~= UrlStatus then -- if URL set then |archive-url= applies to it
URL = ArchiveURL -- swap-in the archive's URL
URL_origin = A:ORIGIN('ArchiveURL') -- name of archive URL parameter for error messages
Format = ArchiveFormat or ''; -- swap in archive's format
UrlAccess = nil; -- restricted access levels do not make sense for archived URLs
end
end
elseif utilities.is_set (UrlStatus) then -- if |url-status= is set when |archive-url= is not set
utilities.set_message ('maint_url_status'); -- add maint cat
end
if utilities.in_array (config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) or -- if any of the 'periodical' cites except encyclopedia
('citation' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and not utilities.is_set (Encyclopedia)) then
local chap_param;
if utilities.is_set (Chapter) then -- get a parameter name from one of these chapter related meta-parameters
chap_param = A:ORIGIN ('Chapter')
elseif utilities.is_set (TransChapter) then
chap_param = A:ORIGIN ('TransChapter')
elseif utilities.is_set (ChapterURL) then
chap_param = A:ORIGIN ('ChapterURL')
elseif utilities.is_set (ScriptChapter) then
chap_param = ScriptChapter_origin;
else utilities.is_set (ChapterFormat)
chap_param = A:ORIGIN ('ChapterFormat')
end
if utilities.is_set (chap_param) then -- if we found one
utilities.set_message ('err_chapter_ignored', {chap_param}); -- add error message
Chapter = ''; -- and set them to empty string to be safe with concatenation
TransChapter = '';
ChapterURL = '';
ScriptChapter = '';
ChapterFormat = '';
end
else -- otherwise, format chapter / article title
local no_quotes = false; -- default assume that we will be quoting the chapter parameter value
if utilities.is_set (Contribution) and 0 < #c then -- if this is a contribution with contributor(s)
if utilities.in_array (Contribution:lower(), cfg.keywords_lists.contribution) then -- and a generic contribution title
no_quotes = true; -- then render it unquoted
end
end
Chapter = format_chapter_title (ScriptChapter, ScriptChapter_origin, Chapter, Chapter_origin, TransChapter, TransChapter_origin, ChapterURL, ChapterURL_origin, no_quotes, ChapterUrlAccess); -- Contribution is also in Chapter
if utilities.is_set (Chapter) then
Chapter = Chapter .. ChapterFormat ;
if 'map' == config.CitationClass and utilities.is_set (TitleType) then
Chapter = Chapter .. ' ' .. TitleType; -- map annotation here; not after title
end
Chapter = Chapter .. sepc .. ' ';
elseif utilities.is_set (ChapterFormat) then -- |chapter= not set but |chapter-format= is so ...
Chapter = ChapterFormat .. sepc .. ' '; -- ... ChapterFormat has error message, we want to see it
end
end
-- Format main title
local plain_title = false;
local accept_title;
Title, accept_title = utilities.has_accept_as_written (Title, true); -- remove accept-this-as-written markup when it wraps all of <Title>
if accept_title and ('' == Title) then -- only support forced empty for now "(())"
Title = cfg.messages['notitle']; -- replace by predefined "No title" message
-- TODO: utilities.set_message ( 'err_redundant_parameters', ...); -- issue proper error message instead of muting
ScriptTitle = ''; -- just mute for now
TransTitle = ''; -- just mute for now
plain_title = true; -- suppress text decoration for descriptive title
utilities.set_message ('maint_untitled'); -- add maint cat
end
if not accept_title then -- <Title> not wrapped in accept-as-written markup
if '...' == Title:sub (-3) then -- if ellipsis is the last three characters of |title=
Title = Title:gsub ('(%.%.%.)%.+$', '%1'); -- limit the number of dots to three
elseif not mw.ustring.find (Title, '%.%s*%a%.$') and -- end of title is not a 'dot-(optional space-)letter-dot' initialism ...
not mw.ustring.find (Title, '%s+%a%.$') then -- ...and not a 'space-letter-dot' initial (''Allium canadense'' L.)
Title = mw.ustring.gsub(Title, '%' .. sepc .. '$', ''); -- remove any trailing separator character; sepc and ms.ustring() here for languages that use multibyte separator characters
end
if utilities.is_set (ArchiveURL) and is_archived_copy (Title) then
utilities.set_message ('maint_archived_copy'); -- add maintenance category before we modify the content of Title
end
if is_generic ('generic_titles', Title) then
utilities.set_message ('err_generic_title'); -- set an error message
end
end
if (not plain_title) and (utilities.in_array (config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'mailinglist', 'interview', 'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) or
('citation' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and not utilities.is_set (Encyclopedia)) or
('map' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)))) then -- special case for cite map when the map is in a periodical treat as an article
Title = kern_quotes (Title); -- if necessary, separate title's leading and trailing quote marks from module provided quote marks
Title = utilities.wrap_style ('quoted-title', Title);
Title = script_concatenate (Title, ScriptTitle, 'script-title'); -- <bdi> tags, lang attribute, categorization, etc.; must be done after title is wrapped
TransTitle = utilities.wrap_style ('trans-quoted-title', TransTitle );
elseif plain_title or ('report' == config.CitationClass) then -- no styling for cite report and descriptive titles (otherwise same as above)
Title = script_concatenate (Title, ScriptTitle, 'script-title'); -- <bdi> tags, lang attribute, categorization, etc.; must be done after title is wrapped
TransTitle = utilities.wrap_style ('trans-quoted-title', TransTitle ); -- for cite report, use this form for trans-title
else
Title = utilities.wrap_style ('italic-title', Title);
Title = script_concatenate (Title, ScriptTitle, 'script-title'); -- <bdi> tags, lang attribute, categorization, etc.; must be done after title is wrapped
TransTitle = utilities.wrap_style ('trans-italic-title', TransTitle);
end
if utilities.is_set (TransTitle) then
if utilities.is_set (Title) then
TransTitle = " " .. TransTitle;
else
utilities.set_message ('err_trans_missing_title', {'title'});
end
end
if utilities.is_set (Title) then -- TODO: is this the right place to be making Wikisource URLs?
if utilities.is_set (TitleLink) and utilities.is_set (URL) then
utilities.set_message ('err_wikilink_in_url'); -- set an error message because we can't have both
TitleLink = ''; -- unset
end
if not utilities.is_set (TitleLink) and utilities.is_set (URL) then
Title = external_link (URL, Title, URL_origin, UrlAccess) .. TransTitle .. Format;
URL = ''; -- unset these because no longer needed
Format = "";
elseif utilities.is_set (TitleLink) and not utilities.is_set (URL) then
local ws_url;
ws_url = wikisource_url_make (TitleLink); -- ignore ws_label return; not used here
if ws_url then
Title = external_link (ws_url, Title .. ' ', 'ws link in title-link'); -- space char after Title to move icon away from italic text; TODO: a better way to do this?
Title = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], TitleLink, Title});
Title = Title .. TransTitle;
else
Title = utilities.make_wikilink (TitleLink, Title) .. TransTitle;
end
else
local ws_url, ws_label, L; -- Title has italic or quote markup by the time we get here which causes is_wikilink() to return 0 (not a wikilink)
ws_url, ws_label, L = wikisource_url_make (Title:gsub('^[\'"]*(.-)[\'"]*$', '%1')); -- make ws URL from |title= interwiki link (strip italic or quote markup); link portion L becomes tooltip label
if ws_url then
Title = Title:gsub ('%b[]', ws_label); -- replace interwiki link with ws_label to retain markup
Title = external_link (ws_url, Title .. ' ', 'ws link in title'); -- space char after Title to move icon away from italic text; TODO: a better way to do this?
Title = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, Title});
Title = Title .. TransTitle;
else
Title = Title .. TransTitle;
end
end
else
Title = TransTitle;
end
if utilities.is_set (Place) then
Place = " " .. wrap_msg ('written', Place, use_lowercase) .. sepc .. " ";
end
local ConferenceURL_origin = A:ORIGIN('ConferenceURL'); -- get name of parameter that holds ConferenceURL
if utilities.is_set (Conference) then
if utilities.is_set (ConferenceURL) then
Conference = external_link( ConferenceURL, Conference, ConferenceURL_origin, nil );
end
Conference = sepc .. " " .. Conference .. ConferenceFormat;
elseif utilities.is_set (ConferenceURL) then
Conference = sepc .. " " .. external_link( ConferenceURL, nil, ConferenceURL_origin, nil );
end
local Position = '';
if not utilities.is_set (Position) then
local Minutes = A['Minutes'];
local Time = A['Time'];
if utilities.is_set (Minutes) then
if utilities.is_set (Time) then --TODO: make a function for this and similar?
utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', 'minutes') .. ' and ' .. utilities.wrap_style ('parameter', 'time')});
end
Position = " " .. Minutes .. " " .. cfg.messages['minutes'];
else
if utilities.is_set (Time) then
local TimeCaption = A['TimeCaption']
if not utilities.is_set (TimeCaption) then
TimeCaption = cfg.messages['event'];
if sepc ~= '.' then
TimeCaption = TimeCaption:lower();
end
end
Position = " " .. TimeCaption .. " " .. Time;
end
end
else
Position = " " .. Position;
At = '';
end
Page, Pages, Sheet, Sheets = format_pages_sheets (Page, Pages, Sheet, Sheets, config.CitationClass, Periodical_origin, sepc, NoPP, use_lowercase);
At = utilities.is_set (At) and (sepc .. " " .. At) or "";
Position = utilities.is_set (Position) and (sepc .. " " .. Position) or "";
if config.CitationClass == 'map' then
local Sections = A['Sections']; -- Section (singular) is an alias of Chapter so set earlier
local Inset = A['Inset'];
if utilities.is_set ( Inset ) then
Inset = sepc .. " " .. wrap_msg ('inset', Inset, use_lowercase);
end
if utilities.is_set ( Sections ) then
Section = sepc .. " " .. wrap_msg ('sections', Sections, use_lowercase);
elseif utilities.is_set ( Section ) then
Section = sepc .. " " .. wrap_msg ('section', Section, use_lowercase);
end
At = At .. Inset .. Section;
end
local Others = A['Others'];
if utilities.is_set (Others) and 0 == #a and 0 == #e then -- add maint cat when |others= has value and used without |author=, |editor=
if config.CitationClass == "AV-media-notes"
or config.CitationClass == "audio-visual" then -- special maint for AV/M which has a lot of 'false' positives right now
utilities.set_message ('maint_others_avm')
else
utilities.set_message ('maint_others');
end
end
Others = utilities.is_set (Others) and (sepc .. " " .. Others) or "";
if utilities.is_set (Translators) then
Others = safe_join ({sepc .. ' ', wrap_msg ('translated', Translators, use_lowercase), Others}, sepc);
end
if utilities.is_set (Interviewers) then
Others = safe_join ({sepc .. ' ', wrap_msg ('interview', Interviewers, use_lowercase), Others}, sepc);
end
local TitleNote = A['TitleNote'];
TitleNote = utilities.is_set (TitleNote) and (sepc .. " " .. TitleNote) or "";
if utilities.is_set (Edition) then
if Edition:match ('%f[%a][Ee]d%n?%.?$') or Edition:match ('%f[%a][Ee]dition$') then -- Ed, ed, Ed., ed., Edn, edn, Edn., edn.
utilities.set_message ('err_extra_text_edition'); -- add error message
end
Edition = " " .. wrap_msg ('edition', Edition);
else
Edition = '';
end
Series = utilities.is_set (Series) and wrap_msg ('series', {sepc, Series}) or ""; -- not the same as SeriesNum
local Agency = A['Agency'];
Agency = utilities.is_set (Agency) and wrap_msg ('agency', {sepc, Agency}) or "";
Volume = format_volume_issue (Volume, Issue, config.CitationClass, Periodical_origin, sepc, use_lowercase);
if utilities.is_set (AccessDate) then
local retrv_text = " " .. cfg.messages['retrieved']
AccessDate = nowrap_date (AccessDate); -- wrap in nowrap span if date in appropriate format
if (sepc ~= ".") then retrv_text = retrv_text:lower() end -- if mode is cs2, lower case
AccessDate = utilities.substitute (retrv_text, AccessDate); -- add retrieved text
AccessDate = utilities.substitute (cfg.presentation['accessdate'], {sepc, AccessDate}); -- allow editors to hide accessdates
end
if utilities.is_set (ID) then ID = sepc .. " " .. ID; end
local Docket = A['Docket'];
if "thesis" == config.CitationClass and utilities.is_set (Docket) then
ID = sepc .. " Docket " .. Docket .. ID;
end
if "report" == config.CitationClass and utilities.is_set (Docket) then -- for cite report when |docket= is set
ID = sepc .. ' ' .. Docket; -- overwrite ID even if |id= is set
end
if utilities.is_set (URL) then
URL = " " .. external_link( URL, nil, URL_origin, UrlAccess );
end
local Quote = A['Quote'];
local TransQuote = A['TransQuote'];
local ScriptQuote = A['ScriptQuote'];
if utilities.is_set (Quote) or utilities.is_set (TransQuote) or utilities.is_set (ScriptQuote) then
if utilities.is_set (Quote) then
if Quote:sub(1, 1) == '"' and Quote:sub(-1, -1) == '"' then -- if first and last characters of quote are quote marks
Quote = Quote:sub(2, -2); -- strip them off
end
end
Quote = utilities.wrap_style ('quoted-text', Quote ); -- wrap in <q>...</q> tags
if utilities.is_set (ScriptQuote) then
Quote = script_concatenate (Quote, ScriptQuote, 'script-quote'); -- <bdi> tags, lang attribute, categorization, etc.; must be done after quote is wrapped
end
if utilities.is_set (TransQuote) then
if TransQuote:sub(1, 1) == '"' and TransQuote:sub(-1, -1) == '"' then -- if first and last characters of |trans-quote are quote marks
TransQuote = TransQuote:sub(2, -2); -- strip them off
end
Quote = Quote .. " " .. utilities.wrap_style ('trans-quoted-title', TransQuote );
end
if utilities.is_set (QuotePage) or utilities.is_set (QuotePages) then -- add page prefix
local quote_prefix = '';
if utilities.is_set (QuotePage) then
extra_text_in_page_check (QuotePage, 'quote-page'); -- add to maint cat if |quote-page= value begins with what looks like p., pp., etc.
if not NoPP then
quote_prefix = utilities.substitute (cfg.messages['p-prefix'], {sepc, QuotePage}), '', '', '';
else
quote_prefix = utilities.substitute (cfg.messages['nopp'], {sepc, QuotePage}), '', '', '';
end
elseif utilities.is_set (QuotePages) then
extra_text_in_page_check (QuotePages, 'quote-pages'); -- add to maint cat if |quote-pages= value begins with what looks like p., pp., etc.
if tonumber(QuotePages) ~= nil and not NoPP then -- if only digits, assume single page
quote_prefix = utilities.substitute (cfg.messages['p-prefix'], {sepc, QuotePages}), '', '';
elseif not NoPP then
quote_prefix = utilities.substitute (cfg.messages['pp-prefix'], {sepc, QuotePages}), '', '';
else
quote_prefix = utilities.substitute (cfg.messages['nopp'], {sepc, QuotePages}), '', '';
end
end
Quote = quote_prefix .. ": " .. Quote;
else
Quote = sepc .. " " .. Quote;
end
PostScript = ""; -- cs1|2 does not supply terminal punctuation when |quote= is set
end
-- We check length of PostScript here because it will have been nuked by
-- the quote parameters. We'd otherwise emit a message even if there wasn't
-- a displayed postscript.
-- TODO: Should the max size (1) be configurable?
-- TODO: Should we check a specific pattern?
if utilities.is_set(PostScript) and mw.ustring.len(PostScript) > 1 then
utilities.set_message ('maint_postscript')
end
local Archived;
if utilities.is_set (ArchiveURL) then
local arch_text;
if not utilities.is_set (ArchiveDate) then
utilities.set_message ('err_archive_missing_date');
ArchiveDate = ''; -- empty string for concatenation
end
if "live" == UrlStatus then
arch_text = cfg.messages['archived'];
if sepc ~= "." then arch_text = arch_text:lower() end
if utilities.is_set (ArchiveDate) then
Archived = sepc .. ' ' .. utilities.substitute ( cfg.messages['archived-live'],
{external_link( ArchiveURL, arch_text, A:ORIGIN('ArchiveURL'), nil) .. ArchiveFormat, ArchiveDate } );
else
Archived = '';
end
if not utilities.is_set (OriginalURL) then
utilities.set_message ('err_archive_missing_url');
Archived = ''; -- empty string for concatenation
end
elseif utilities.is_set (OriginalURL) then -- UrlStatus is empty, 'dead', 'unfit', 'usurped', 'bot: unknown'
if utilities.in_array (UrlStatus, {'unfit', 'usurped', 'bot: unknown'}) then
arch_text = cfg.messages['archived-unfit'];
if sepc ~= "." then arch_text = arch_text:lower() end
Archived = sepc .. ' ' .. arch_text .. ArchiveDate; -- format already styled
if 'bot: unknown' == UrlStatus then
utilities.set_message ('maint_bot_unknown'); -- and add a category if not already added
else
utilities.set_message ('maint_unfit'); -- and add a category if not already added
end
else -- UrlStatus is empty, 'dead'
arch_text = cfg.messages['archived-dead'];
if sepc ~= "." then arch_text = arch_text:lower() end
if utilities.is_set (ArchiveDate) then
Archived = sepc .. " " .. utilities.substitute ( arch_text,
{ external_link( OriginalURL, cfg.messages['original'], OriginalURL_origin, OriginalAccess ) .. OriginalFormat, ArchiveDate } ); -- format already styled
else
Archived = ''; -- unset for concatenation
end
end
else -- OriginalUrl not set
arch_text = cfg.messages['archived-missing'];
if sepc ~= "." then arch_text = arch_text:lower() end
utilities.set_message ('err_archive_missing_url');
Archived = ''; -- empty string for concatenation
end
elseif utilities.is_set (ArchiveFormat) then
Archived = ArchiveFormat; -- if set and ArchiveURL not set ArchiveFormat has error message
else
Archived = '';
end
local Lay = '';
local LaySource = A['LaySource'];
local LayURL = A['LayURL'];
local LayFormat = A['LayFormat'];
LayFormat = style_format (LayFormat, LayURL, 'lay-format', 'lay-url');
if utilities.is_set (LayURL) then
if utilities.is_set (LayDate) then LayDate = " (" .. LayDate .. ")" end
if utilities.is_set (LaySource) then
LaySource = " – ''" .. utilities.safe_for_italics (LaySource) .. "''";
else
LaySource = "";
end
if sepc == '.' then
Lay = sepc .. " " .. external_link( LayURL, cfg.messages['lay summary'], A:ORIGIN('LayURL'), nil ) .. LayFormat .. LaySource .. LayDate
else
Lay = sepc .. " " .. external_link( LayURL, cfg.messages['lay summary']:lower(), A:ORIGIN('LayURL'), nil ) .. LayFormat .. LaySource .. LayDate
end
elseif utilities.is_set (LayFormat) then -- Test if |lay-format= is given without giving a |lay-url=
Lay = sepc .. LayFormat; -- if set and LayURL not set, then LayFormat has error message
end
local TranscriptURL = A['TranscriptURL']
local TranscriptFormat = A['TranscriptFormat'];
TranscriptFormat = style_format (TranscriptFormat, TranscriptURL, 'transcript-format', 'transcripturl');
local Transcript = A['Transcript'];
local TranscriptURL_origin = A:ORIGIN('TranscriptURL'); -- get name of parameter that holds TranscriptURL
if utilities.is_set (Transcript) then
if utilities.is_set (TranscriptURL) then
Transcript = external_link( TranscriptURL, Transcript, TranscriptURL_origin, nil );
end
Transcript = sepc .. ' ' .. Transcript .. TranscriptFormat;
elseif utilities.is_set (TranscriptURL) then
Transcript = external_link( TranscriptURL, nil, TranscriptURL_origin, nil );
end
local Publisher;
if utilities.is_set (PublicationDate) then
PublicationDate = wrap_msg ('published', PublicationDate);
end
if utilities.is_set (PublisherName) then
if utilities.is_set (PublicationPlace) then
Publisher = sepc .. " " .. PublicationPlace .. ": " .. PublisherName .. PublicationDate;
else
Publisher = sepc .. " " .. PublisherName .. PublicationDate;
end
elseif utilities.is_set (PublicationPlace) then
Publisher= sepc .. " " .. PublicationPlace .. PublicationDate;
else
Publisher = PublicationDate;
end
local TransPeriodical = A['TransPeriodical'];
local TransPeriodical_origin = A:ORIGIN ('TransPeriodical');
-- Several of the above rely upon detecting this as nil, so do it last.
if (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical) or utilities.is_set (TransPeriodical)) then
if utilities.is_set (Title) or utilities.is_set (TitleNote) then
Periodical = sepc .. " " .. format_periodical (ScriptPeriodical, ScriptPeriodical_origin, Periodical, TransPeriodical, TransPeriodical_origin);
else
Periodical = format_periodical (ScriptPeriodical, ScriptPeriodical_origin, Periodical, TransPeriodical, TransPeriodical_origin);
end
end
local Language = A['Language'];
if utilities.is_set (Language) then
Language = language_parameter (Language); -- format, categories, name from ISO639-1, etc.
else
Language=''; -- language not specified so make sure this is an empty string;
--[[ TODO: need to extract the wrap_msg from language_parameter
so that we can solve parentheses bunching problem with Format/Language/TitleType
]]
end
--[[
Handle the oddity that is cite speech. This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be " (Speech)" so that
the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
]]
if "speech" == config.CitationClass then -- cite speech only
TitleNote = TitleType; -- move TitleType to TitleNote so that it renders ahead of |event=
TitleType = ''; -- and unset
if utilities.is_set (Periodical) then -- if Periodical, perhaps because of an included |website= or |journal= parameter
if utilities.is_set (Conference) then -- and if |event= is set
Conference = Conference .. sepc .. " "; -- then add appropriate punctuation to the end of the Conference variable before rendering
end
end
end
-- Piece all bits together at last. Here, all should be non-nil.
-- We build things this way because it is more efficient in LUA
-- not to keep reassigning to the same string variable over and over.
local tcommon;
local tcommon2; -- used for book cite when |contributor= is set
if utilities.in_array (config.CitationClass, {"journal", "citation"}) and utilities.is_set (Periodical) then
if utilities.is_set (Others) then Others = safe_join ({Others, sepc .. " "}, sepc) end -- add terminal punctuation & space; check for dup sepc; TODO why do we need to do this here?
tcommon = safe_join( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Edition, Publisher, Agency, Volume}, sepc );
elseif utilities.in_array (config.CitationClass, {"book", "citation"}) and not utilities.is_set (Periodical) then -- special cases for book cites
if utilities.is_set (Contributors) then -- when we are citing foreword, preface, introduction, etc.
tcommon = safe_join( {Title, TitleNote}, sepc ); -- author and other stuff will come after this and before tcommon2
tcommon2 = safe_join( {Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
else
tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
end
elseif 'map' == config.CitationClass then -- special cases for cite map
if utilities.is_set (Chapter) then -- map in a book; TitleType is part of Chapter
tcommon = safe_join( {Title, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
elseif utilities.is_set (Periodical) then -- map in a periodical
tcommon = safe_join( {Title, TitleType, Format, Periodical, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
else -- a sheet or stand-alone map
tcommon = safe_join( {Title, TitleType, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher}, sepc );
end
elseif 'episode' == config.CitationClass then -- special case for cite episode
tcommon = safe_join( {Title, TitleNote, TitleType, Series, Language, Edition, Publisher}, sepc );
else -- all other CS1 templates
tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language,
Volume, Others, Edition, Publisher, Agency}, sepc );
end
if #ID_list > 0 then
ID_list = safe_join( { sepc .. " ", table.concat( ID_list, sepc .. " " ), ID }, sepc );
else
ID_list = ID;
end
local Via = A['Via'];
Via = utilities.is_set (Via) and wrap_msg ('via', Via) or '';
local idcommon;
if 'audio-visual' == config.CitationClass or 'episode' == config.CitationClass then -- special case for cite AV media & cite episode position transcript
idcommon = safe_join( { ID_list, URL, Archived, Transcript, AccessDate, Via, Lay, Quote }, sepc );
else
idcommon = safe_join( { ID_list, URL, Archived, AccessDate, Via, Lay, Quote }, sepc );
end
local text;
local pgtext = Position .. Sheet .. Sheets .. Page .. Pages .. At;
local OrigDate = A['OrigDate'];
OrigDate = utilities.is_set (OrigDate) and wrap_msg ('origdate', OrigDate) or '';
if utilities.is_set (Date) then
if utilities.is_set (Authors) or utilities.is_set (Editors) then -- date follows authors or editors when authors not set
Date = " (" .. Date .. ")" .. OrigDate .. sepc .. " "; -- in parentheses
else -- neither of authors and editors set
if (string.sub(tcommon, -1, -1) == sepc) then -- if the last character of tcommon is sepc
Date = " " .. Date .. OrigDate; -- Date does not begin with sepc
else
Date = sepc .. " " .. Date .. OrigDate; -- Date begins with sepc
end
end
end
if utilities.is_set (Authors) then
if (not utilities.is_set (Date)) then -- when date is set it's in parentheses; no Authors termination
Authors = terminate_name_list (Authors, sepc); -- when no date, terminate with 0 or 1 sepc and a space
end
if utilities.is_set (Editors) then
local in_text = " ";
local post_text = "";
if utilities.is_set (Chapter) and 0 == #c then
in_text = in_text .. cfg.messages['in'] .. " "
if (sepc ~= '.') then
in_text = in_text:lower() -- lowercase for cs2
end
end
if EditorCount <= 1 then
post_text = " (" .. cfg.messages['editor'] .. ")"; -- be consistent with no-author, no-date case
else
post_text = " (" .. cfg.messages['editors'] .. ")";
end
Editors = terminate_name_list (in_text .. Editors .. post_text, sepc); -- terminate with 0 or 1 sepc and a space
end
if utilities.is_set (Contributors) then -- book cite and we're citing the intro, preface, etc.
local by_text = sepc .. ' ' .. cfg.messages['by'] .. ' ';
if (sepc ~= '.') then by_text = by_text:lower() end -- lowercase for cs2
Authors = by_text .. Authors; -- author follows title so tweak it here
if utilities.is_set (Editors) and utilities.is_set (Date) then -- when Editors make sure that Authors gets terminated
Authors = terminate_name_list (Authors, sepc); -- terminate with 0 or 1 sepc and a space
end
if (not utilities.is_set (Date)) then -- when date is set it's in parentheses; no Contributors termination
Contributors = terminate_name_list (Contributors, sepc); -- terminate with 0 or 1 sepc and a space
end
text = safe_join( {Contributors, Date, Chapter, tcommon, Authors, Place, Editors, tcommon2, pgtext, idcommon }, sepc );
else
text = safe_join( {Authors, Date, Chapter, Place, Editors, tcommon, pgtext, idcommon }, sepc );
end
elseif utilities.is_set (Editors) then
if utilities.is_set (Date) then
if EditorCount <= 1 then
Editors = Editors .. ", " .. cfg.messages['editor'];
else
Editors = Editors .. ", " .. cfg.messages['editors'];
end
else
if EditorCount <= 1 then
Editors = Editors .. " (" .. cfg.messages['editor'] .. ")" .. sepc .. " "
else
Editors = Editors .. " (" .. cfg.messages['editors'] .. ")" .. sepc .. " "
end
end
text = safe_join( {Editors, Date, Chapter, Place, tcommon, pgtext, idcommon}, sepc );
else
if utilities.in_array (config.CitationClass, {"journal", "citation"}) and utilities.is_set (Periodical) then
text = safe_join( {Chapter, Place, tcommon, pgtext, Date, idcommon}, sepc );
else
text = safe_join( {Chapter, Place, tcommon, Date, pgtext, idcommon}, sepc );
end
end
if utilities.is_set (PostScript) and PostScript ~= sepc then
text = safe_join( {text, sepc}, sepc ); -- Deals with italics, spaces, etc.
text = text:sub(1, -sepc:len() - 1);
end
text = safe_join( {text, PostScript}, sepc );
-- Now enclose the whole thing in a <cite> element
local options_t = {};
options_t.class = cite_class_attribute_make (config.CitationClass, Mode);
local Ref = is_valid_parameter_value (A['Ref'], A:ORIGIN('Ref'), cfg.keywords_lists['ref'], nil, true); -- nil when |ref=harv; A['Ref'] else
if 'none' ~= cfg.keywords_xlate[(Ref and Ref:lower()) or ''] then
local namelist_t = {}; -- holds selected contributor, author, editor name list
local year = first_set ({Year, anchor_year}, 2); -- Year first for legacy citations and for YMD dates that require disambiguation
if #c > 0 then -- if there is a contributor list
namelist_t = c; -- select it
elseif #a > 0 then -- or an author list
namelist_t = a;
elseif #e > 0 then -- or an editor list
namelist_t = e;
end
local citeref_id;
if #namelist_t > 0 then -- if there are names in namelist_t
citeref_id = make_citeref_id (namelist_t, year); -- go make the CITEREF anchor
if mw.uri.anchorEncode (citeref_id) == ((Ref and mw.uri.anchorEncode (Ref)) or '') then -- Ref may already be encoded (by {{sfnref}}) so citeref_id must be encoded before comparison
utilities.set_message ('maint_ref_duplicates_default');
end
else
citeref_id = ''; -- unset
end
options_t.id = Ref or citeref_id;
end
if string.len (text:gsub('%b<>', '')) <= 2 then -- remove html and html-like tags; then get length of what remains;
z.error_cats_t = {}; -- blank the categories list
z.error_msgs_t = {}; -- blank the error messages list
OCinSoutput = nil; -- blank the metadata string
text = ''; -- blank the the citation
utilities.set_message ('err_empty_citation'); -- set empty citation message and category
end
local render_t = {}; -- here we collect the final bits for concatenation into the rendered citation
if utilities.is_set (options_t.id) then -- here we wrap the rendered citation in <cite ...>...</cite> tags
table.insert (render_t, utilities.substitute (cfg.presentation['cite-id'], {mw.uri.anchorEncode(options_t.id), mw.text.nowiki(options_t.class), text})); -- when |ref= is set or when there is a namelist
else
table.insert (render_t, utilities.substitute (cfg.presentation['cite'], {mw.text.nowiki(options_t.class), text})); -- when |ref=none or when namelist_t empty and |ref= is missing or is empty
end
if OCinSoutput then -- blanked when citation is 'empty' so don't bother to add boilerplate metadata span
table.insert (render_t, utilities.substitute (cfg.presentation['ocins'], OCinSoutput)); -- format and append metadata to the citation
end
local template_name = ('citation' == config.CitationClass) and 'citation' or 'cite ' .. (cfg.citation_class_map_t[config.CitationClass] or config.CitationClass);
local template_link = '[[Template:' .. template_name .. '|' .. template_name .. ']]';
local msg_prefix = '<code class="cs1-code">{{' .. template_link .. '}}</code>: ';
if 0 ~= #z.error_msgs_t then
mw.addWarning (utilities.substitute (cfg.messages.warning_msg_e, template_link));
table.insert (render_t, ' '); -- insert a space between citation and its error messages
table.sort (z.error_msgs_t); -- sort the error messages list; sorting includes wrapping <span> and <code> tags; hidden-error sorts ahead of visible-error
local hidden = true; -- presume that the only error messages emited by this template are hidden
for _, v in ipairs (z.error_msgs_t) do -- spin through the list of error messages
if v:find ('cs1-visible-error', 1, true) then -- look for the visible error class name
hidden = false; -- found one; so don't hide the error message prefix
break; -- and done because no need to look further
end
end
z.error_msgs_t[1] = table.concat ({utilities.error_comment (msg_prefix, hidden), z.error_msgs_t[1]}); -- add error message prefix to first error message to prevent extraneous punctuation
table.insert (render_t, table.concat (z.error_msgs_t, '; ')); -- make a big string of error messages and add it to the rendering
end
if 0 ~= #z.maint_cats_t then
mw.addWarning (utilities.substitute (cfg.messages.warning_msg_m, template_link));
table.sort (z.maint_cats_t); -- sort the maintenance messages list
local maint_msgs_t = {}; -- here we collect all of the maint messages
if 0 == #z.error_msgs_t then -- if no error messages
table.insert (maint_msgs_t, msg_prefix); -- insert message prefix in maint message livery
end
for _, v in ipairs( z.maint_cats_t ) do -- append maintenance categories
table.insert (maint_msgs_t, -- assemble new maint message and add it to the maint_msgs_t table
table.concat ({v, ' (', utilities.substitute (cfg.messages[':cat wikilink'], v), ')'})
);
end
table.insert (render_t, utilities.substitute (cfg.presentation['hidden-maint'], table.concat (maint_msgs_t, ' '))); -- wrap the group of maint messages with proper presentation and save
end
if not no_tracking_cats then
for _, v in ipairs (z.error_cats_t) do -- append error categories
table.insert (render_t, utilities.substitute (cfg.messages['cat wikilink'], v));
end
for _, v in ipairs (z.maint_cats_t) do -- append maintenance categories
table.insert (render_t, utilities.substitute (cfg.messages['cat wikilink'], v));
end
for _, v in ipairs (z.prop_cats_t) do -- append properties categories
table.insert (render_t, utilities.substitute (cfg.messages['cat wikilink'], v));
end
end
return table.concat (render_t); -- make a big string and done
end
--[[--------------------------< V A L I D A T E >--------------------------------------------------------------
Looks for a parameter's name in one of several whitelists.
Parameters in the whitelist can have three values:
true - active, supported parameters
false - deprecated, supported parameters
nil - unsupported parameters
]]
local function validate (name, cite_class, empty)
local name = tostring (name);
local enum_name; -- for enumerated parameters, is name with enumerator replaced with '#'
local state;
local function state_test (state, name) -- local function to do testing of state values
if true == state then return true; end -- valid actively supported parameter
if false == state then
if empty then return nil; end -- empty deprecated parameters are treated as unknowns
deprecated_parameter (name); -- parameter is deprecated but still supported
return true;
end
if 'tracked' == state then
local base_name = name:gsub ('%d', ''); -- strip enumerators from parameter names that have them to get the base name
utilities.add_prop_cat ('tracked-param', {base_name}, base_name); -- add a properties category; <base_name> modifies <key>
return true;
end
return nil;
end
if name:find ('#') then -- # is a cs1|2 reserved character so parameters with # not permitted
return nil;
end
if utilities.in_array (cite_class, whitelist.preprint_template_list ) then -- limited parameter sets allowed for these templates
state = whitelist.limited_basic_arguments[name];
if true == state_test (state, name) then return true; end
state = whitelist.preprint_arguments[cite_class][name]; -- look in the parameter-list for the template identified by cite_class
if true == state_test (state, name) then return true; end
-- limited enumerated parameters list
enum_name = name:gsub("%d+", "#" ); -- replace digit(s) with # (last25 becomes last#) (mw.ustring because non-Western 'local' digits)
state = whitelist.limited_numbered_arguments[enum_name];
if true == state_test (state, name) then return true; end
return false; -- not supported because not found or name is set to nil
end -- end limited parameter-set templates
if utilities.in_array (cite_class, whitelist.unique_param_template_list) then -- experiment for template-specific parameters for templates that accept parameters from the basic argument list
state = whitelist.unique_arguments[cite_class][name]; -- look in the template-specific parameter-lists for the template identified by cite_class
if true == state_test (state, name) then return true; end
end -- if here, fall into general validation
state = whitelist.basic_arguments[name]; -- all other templates; all normal parameters allowed
if true == state_test (state, name) then return true; end
-- all enumerated parameters allowed
enum_name = name:gsub("%d+", "#" ); -- replace digit(s) with # (last25 becomes last#) (mw.ustring because non-Western 'local' digits)
state = whitelist.numbered_arguments[enum_name];
if true == state_test (state, name) then return true; end
return false; -- not supported because not found or name is set to nil
end
--[=[-------------------------< I N T E R _ W I K I _ C H E C K >----------------------------------------------
check <value> for inter-language interwiki-link markup. <prefix> must be a MediaWiki-recognized language
code. when these values have the form (without leading colon):
[[<prefix>:link|label]] return label as plain-text
[[<prefix>:link]] return <prefix>:link as plain-text
return value as is else
]=]
local function inter_wiki_check (parameter, value)
local prefix = value:match ('%[%[(%a+):'); -- get an interwiki prefix if one exists
local _;
if prefix and cfg.inter_wiki_map[prefix:lower()] then -- if prefix is in the map, needs preceding colon so
utilities.set_message ('err_bad_paramlink', parameter); -- emit an error message
_, value, _ = utilities.is_wikilink (value); -- extract label portion from wikilink
end
return value;
end
--[[--------------------------< M I S S I N G _ P I P E _ C H E C K >------------------------------------------
Look at the contents of a parameter. If the content has a string of characters and digits followed by an equal
sign, compare the alphanumeric string to the list of cs1|2 parameters. If found, then the string is possibly a
parameter that is missing its pipe. There are two tests made:
{{cite ... |title=Title access-date=2016-03-17}} -- the first parameter has a value and whitespace separates that value from the missing pipe parameter name
{{cite ... |title=access-date=2016-03-17}} -- the first parameter has no value (whitespace after the first = is trimmed by MediaWiki)
cs1|2 shares some parameter names with XML/HTML attributes: class=, title=, etc. To prevent false positives XML/HTML
tags are removed before the search.
If a missing pipe is detected, this function adds the missing pipe maintenance category.
]]
local function missing_pipe_check (parameter, value)
local capture;
value = value:gsub ('%b<>', ''); -- remove XML/HTML tags because attributes: class=, title=, etc.
capture = value:match ('%s+(%a[%w%-]+)%s*=') or value:match ('^(%a[%w%-]+)%s*='); -- find and categorize parameters with possible missing pipes
if capture and validate (capture) then -- if the capture is a valid parameter name
utilities.set_message ('err_missing_pipe', parameter);
end
end
--[[--------------------------< H A S _ E X T R A N E O U S _ P U N C T >--------------------------------------
look for extraneous terminal punctuation in most parameter values; parameters listed in skip table are not checked
]]
local function has_extraneous_punc (param, value)
if 'number' == type (param) then
return;
end
param = param:gsub ('%d+', '#'); -- enumerated name-list mask params allow terminal punct; normalize
if cfg.punct_skip[param] then
return; -- parameter name found in the skip table so done
end
if value:match ('[,;:]$') then
utilities.set_message ('maint_extra_punct'); -- has extraneous punctuation; add maint cat
end
if value:match ('^=') then -- sometimes an extraneous '=' character appears ...
utilities.set_message ('maint_extra_punct'); -- has extraneous punctuation; add maint cat
end
end
--[[--------------------------< H A S _ E X T R A N E O U S _ U R L >------------------------------------------
look for extraneous url parameter values; parameters listed in skip table are not checked
]]
local function has_extraneous_url (url_param_t)
local url_error_t = {};
check_for_url (url_param_t, url_error_t); -- extraneous url check
if 0 ~= #url_error_t then -- non-zero when there are errors
table.sort (url_error_t);
utilities.set_message ('err_param_has_ext_link', {utilities.make_sep_list (#url_error_t, url_error_t)}); -- add this error message
end
end
--[[--------------------------< C I T A T I O N >--------------------------------------------------------------
This is used by templates such as {{cite book}} to create the actual citation text.
]]
local function citation(frame)
Frame = frame; -- save a copy in case we need to display an error message in preview mode
local sandbox = '/sandbox' -- i18n: replace this rvalue with the name that your wiki uses to identify sandbox subpages
is_sandbox = nil ~= string.find (frame:getTitle(), sandbox, 1, true); -- is this invoke the sandbox module?
sandbox = is_sandbox and sandbox or ''; -- use i18n sandbox to load sandbox modules when this module is the sandox; live modules else
local pframe = frame:getParent()
local styles;
cfg = mw.loadData ('Module:Citation/CS1/Configuration' .. sandbox); -- load sandbox versions of support modules when {{#invoke:Citation/CS1/sandbox|...}}; live modules else
whitelist = mw.loadData ('Module:Citation/CS1/Whitelist' .. sandbox);
utilities = require ('Module:Citation/CS1/Utilities' .. sandbox);
validation = require ('Module:Citation/CS1/Date_validation' .. sandbox);
identifiers = require ('Module:Citation/CS1/Identifiers' .. sandbox);
metadata = require ('Module:Citation/CS1/COinS' .. sandbox);
styles = 'Module:Citation/CS1' .. sandbox .. '/styles.css';
utilities.set_selected_modules (cfg); -- so that functions in Utilities can see the selected cfg tables
identifiers.set_selected_modules (cfg, utilities); -- so that functions in Identifiers can see the selected cfg tables and selected Utilities module
validation.set_selected_modules (cfg, utilities); -- so that functions in Date validataion can see selected cfg tables and the selected Utilities module
metadata.set_selected_modules (cfg, utilities); -- so that functions in COinS can see the selected cfg tables and selected Utilities module
z = utilities.z; -- table of error and category tables in Module:Citation/CS1/Utilities
is_preview_mode = not utilities.is_set (frame:preprocess ('{{REVISIONID}}'));
local args = {}; -- table where we store all of the template's arguments
local suggestions = {}; -- table where we store suggestions if we need to loadData them
local error_text; -- used as a flag
local config = {}; -- table to store parameters from the module {{#invoke:}}
for k, v in pairs( frame.args ) do -- get parameters from the {{#invoke}} frame
config[k] = v;
-- args[k] = v; -- crude debug support that allows us to render a citation from module {{#invoke:}}; skips parameter validation; TODO: keep?
end
local capture; -- the single supported capture when matching unknown parameters using patterns
local empty_unknowns = {}; -- sequence table to hold empty unknown params for error message listing
for k, v in pairs( pframe.args ) do -- get parameters from the parent (template) frame
v = mw.ustring.gsub (v, '^%s*(.-)%s*$', '%1'); -- trim leading/trailing whitespace; when v is only whitespace, becomes empty string
if v ~= '' then
if ('string' == type (k)) then
k = mw.ustring.gsub (k, '%d', cfg.date_names.local_digits); -- for enumerated parameters, translate 'local' digits to Western 0-9
end
if not validate( k, config.CitationClass ) then
if type (k) ~= 'string' then -- exclude empty numbered parameters
if v:match("%S+") ~= nil then
error_text = utilities.set_message ('err_text_ignored', {v});
end
elseif validate (k:lower(), config.CitationClass) then
error_text = utilities.set_message ('err_parameter_ignored_suggest', {k, k:lower()}); -- suggest the lowercase version of the parameter
else
if nil == suggestions.suggestions then -- if this table is nil then we need to load it
if is_sandbox then -- did the {{#invoke:}} use sandbox version?
suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions/sandbox' ); -- use the sandbox version
else
suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' ); -- use the live version
end
end
for pattern, param in pairs (suggestions.patterns) do -- loop through the patterns to see if we can suggest a proper parameter
capture = k:match (pattern); -- the whole match if no capture in pattern else the capture if a match
if capture then -- if the pattern matches
param = utilities.substitute (param, capture); -- add the capture to the suggested parameter (typically the enumerator)
if validate (param, config.CitationClass) then -- validate the suggestion to make sure that the suggestion is supported by this template (necessary for limited parameter lists)
error_text = utilities.set_message ('err_parameter_ignored_suggest', {k, param}); -- set the suggestion error message
else
error_text = utilities.set_message ('err_parameter_ignored', {k}); -- suggested param not supported by this template
v = ''; -- unset
end
end
end
if not utilities.is_set (error_text) then -- couldn't match with a pattern, is there an explicit suggestion?
if (suggestions.suggestions[ k:lower() ] ~= nil) and validate (suggestions.suggestions[ k:lower() ], config.CitationClass) then
utilities.set_message ('err_parameter_ignored_suggest', {k, suggestions.suggestions[ k:lower() ]});
else
utilities.set_message ('err_parameter_ignored', {k});
v = ''; -- unset value assigned to unrecognized parameters (this for the limited parameter lists)
end
end
end
end
args[k] = v; -- save this parameter and its value
elseif not utilities.is_set (v) then -- for empty parameters
if not validate (k, config.CitationClass, true) then -- is this empty parameter a valid parameter
k = ('' == k) and '(empty string)' or k; -- when k is empty string (or was space(s) trimmed to empty string), replace with descriptive text
table.insert (empty_unknowns, utilities.wrap_style ('parameter', k)); -- format for error message and add to the list
end
-- crude debug support that allows us to render a citation from module {{#invoke:}} TODO: keep?
-- elseif args[k] ~= nil or (k == 'postscript') then -- when args[k] has a value from {{#invoke}} frame (we don't normally do that)
-- args[k] = v; -- overwrite args[k] with empty string from pframe.args[k] (template frame); v is empty string here
end -- not sure about the postscript bit; that gets handled in parameter validation; historical artifact?
end
if 0 ~= #empty_unknowns then -- create empty unknown error message
utilities.set_message ('err_param_unknown_empty', {
1 == #empty_unknowns and '' or 's',
utilities.make_sep_list (#empty_unknowns, empty_unknowns)
});
end
local url_param_t = {};
for k, v in pairs( args ) do
if 'string' == type (k) then -- don't evaluate positional parameters
has_invisible_chars (k, v); -- look for invisible characters
end
has_extraneous_punc (k, v); -- look for extraneous terminal punctuation in parameter values
missing_pipe_check (k, v); -- do we think that there is a parameter that is missing a pipe?
args[k] = inter_wiki_check (k, v); -- when language interwiki-linked parameter missing leading colon replace with wiki-link label
if 'string' == type (k) and not cfg.url_skip[k] then -- when parameter k is not positional and not in url skip table
url_param_t[k] = v; -- make a parameter/value list for extraneous url check
end
end
has_extraneous_url (url_param_t); -- look for url in parameter values where a url does not belong
return table.concat ({
frame:extensionTag ('templatestyles', '', {src=styles}),
citation0( config, args)
});
end
--[[--------------------------< E X P O R T E D F U N C T I O N S >------------------------------------------
]]
return {citation = citation};
ap25rq0kh3819w7lon63qbjh3bjokuz
189420
189405
2022-08-16T14:48:38Z
Venise12mai1834
8884
Scribunto
text/plain
local z = {
error_categories = {}; -- for categorizing citations that contain errors
error_ids = {};
message_tail = {};
maintenance_cats = {}; -- for categorizing citations that aren't erroneous per se, but could use a little work
properties_cats = {}; -- for categorizing citations based on certain properties, language of source for instance
}
-- Whether variable is set or not
function is_set( var )
return not (var == nil or var == '');
end
-- First set variable or nil if none
function first_set(...)
local list = {...};
for _, var in pairs(list) do
if is_set( var ) then
return var;
end
end
end
-- Whether needle is in haystack
function inArray( needle, haystack )
if needle == nil then
return false;
end
for n,v in ipairs( haystack ) do
if v == needle then
return n;
end
end
return false;
end
--[[
Categorize and emit an error message when the citation contains one or more deprecated parameters. Because deprecated parameters (currently |month=,
|coauthor=, and |coauthors=) aren't related to each other and because these parameters may be concatenated into the variables used by |date= and |author#= (and aliases)
details of which parameter caused the error message are not provided. Only one error message is emitted regardless of the number of deprecated parameters in the citation.
]]
function deprecated_parameter(name)
if true ~= Page_in_deprecated_cat then -- if we haven't been here before then set a
Page_in_deprecated_cat=true; -- sticky flag so that if there are more than one deprecated parameter the category is added only once
table.insert( z.message_tail, { seterror( 'deprecated_params', {name}, true ) } ); -- add error message
end
end
-- Populates numbered arguments in a message string using an argument table.
function substitute( msg, args )
return args and mw.message.newRawMessage( msg, args ):plain() or msg;
end
--[[--------------------------< K E R N _ Q U O T E S >--------------------------------------------------------
Apply kerning to open the space between the quote mark provided by the Module and a leading or trailing quote mark contained in a |title= or |chapter= parameter's value.
This function will positive kern either single or double quotes:
"'Unkerned title with leading and trailing single quote marks'"
" 'Kerned title with leading and trailing single quote marks' " (in real life the kerning isn't as wide as this example)
Double single quotes (italic or bold wikimarkup) are not kerned.
Call this function for chapter titles, for website titles, etc; not for book titles.
]]
function kern_quotes (str)
local cap='';
local cap2='';
cap, cap2 = str:match ("^([\"\'])([^\'].+)"); -- match leading double or single quote but not double single quotes
if is_set (cap) then
str = substitute (cfg.presentation['kern-left'], {cap, cap2});
end
cap, cap2 = str:match ("^(.+[^\'])([\"\'])$")
if is_set (cap) then
str = substitute (cfg.presentation['kern-right'], {cap, cap2});
end
return str;
end
--[[--------------------------< F O R M A T _ S C R I P T _ V A L U E >----------------------------------------
|script-title= holds title parameters that are not written in Latin based scripts: Chinese, Japanese, Arabic, Hebrew, etc. These scripts should
not be italicized and may be written right-to-left. The value supplied by |script-title= is concatenated onto Title after Title has been wrapped
in italic markup.
Regardless of language, all values provided by |script-title= are wrapped in <bdi>...</bdi> tags to isolate rtl languages from the English left to right.
|script-title= provides a unique feature. The value in |script-title= may be prefixed with a two-character ISO639-1 language code and a colon:
|script-title=ja:*** *** (where * represents a Japanese character)
Spaces between the two-character code and the colon and the colon and the first script character are allowed:
|script-title=ja : *** ***
|script-title=ja: *** ***
|script-title=ja :*** ***
Spaces preceding the prefix are allowed: |script-title = ja:*** ***
The prefix is checked for validity. If it is a valid ISO639-1 language code, the lang attribute (lang="ja") is added to the <bdi> tag so that browsers can
know the language the tag contains. This may help the browser render the script more correctly. If the prefix is invalid, the lang attribute
is not added. At this time there is no error message for this condition.
At this writing, only |script-title= is supported. It is anticipated that additional parameters will be created to use this function.
TODO: error messages when prefix is invalid ISO639-1 code; when script_value has prefix but no script;
]]
function format_script_value (script_value)
local lang=''; -- initialize to empty string
local name;
if script_value:match('^%l%l%s*:') then -- if first 3 non-space characters are script language prefix
lang = script_value:match('^(%l%l)%s*:%s*%S.*'); -- get the language prefix or nil if there is no script
if not is_set (lang) then
return ''; -- script_value was just the prefix so return empty string
end
-- if we get this far we have prefix and script
name = mw.language.fetchLanguageName( lang, "en" ); -- get language name so that we can use it to categorize
if is_set (name) then -- is prefix a proper ISO 639-1 language code?
script_value = script_value:gsub ('^%l%l%s*:%s*', ''); -- strip prefix from script
-- is prefix one of these language codes?
if inArray (lang, {'ar', 'bs', 'dv', 'el', 'fa', 'hy', 'ja', 'ko', 'ku', 'he', 'ps', 'ru', 'sd', 'sr', 'th', 'uk', 'ug', 'yi', 'zh'}) then
table.insert( z.properties_cats, 'CS1 uses ' .. name .. '-language script ('..lang..')'); -- categorize in language-specific categories
else
table.insert( z.properties_cats, 'CS1 uses foreign language script'); -- use this category as a catchall until language-specific category is available
end
lang = ' lang="' .. lang .. '" '; -- convert prefix into a lang attribute
else
lang = ''; -- invalid so set lang to empty string
end
end
script_value = substitute (cfg.presentation['bdi'], {lang, script_value}); -- isolate in case script is rtl
return script_value;
end
--[[--------------------------< S C R I P T _ C O N C A T E N A T E >------------------------------------------
Initially for |title= and |script-title=, this function concatenates those two parameter values after the script value has been
wrapped in <bdi> tags.
]]
function script_concatenate (title, script)
if is_set (script) then
script = format_script_value (script); -- <bdi> tags, lang atribute, categorization, etc; returns empty string on error
if is_set (script) then
title = title .. ' ' .. script; -- concatenate title and script title
end
end
return title;
end
--[[--------------------------< W R A P _ S T Y L E >----------------------------------------------------------
Applies styling to various parameters. Supplied string is wrapped using a message_list configuration taking one
argument; protects italic styled parameters. Additional text taken from citation_config.presentation - the reason
this function is similar to but separate from wrap_msg().
]]
function wrap_style (key, str)
if not is_set( str ) then
return "";
elseif inArray( key, { 'italic-title', 'trans-italic-title' } ) then
str = safeforitalics( str );
end
return substitute( cfg.presentation[key], {str} );
end
--[[--------------------------< W R A P _ M S G >--------------------------------------------------------------
Applies additional message text to various parameter values. Supplied string is wrapped using a message_list
configuration taking one argument. Supports lower case text for {{citation}} templates. Additional text taken
from citation_config.messages - the reason this function is similar to but separate from wrap_style().
]]
function wrap_msg (key, str, lower)
if not is_set( str ) then
return "";
end
if true == lower then
local msg;
msg = cfg.messages[key]:lower(); -- set the message to lower case before
str = substitute( msg, {str} ); -- including template text
return str;
else
return substitute( cfg.messages[key], {str} );
end
end
--[[--------------------------< F O R M A T _ C H A P T E R _ T I T L E >--------------------------------------
Format the three chapter parameters: |chapter=, |trans-chapter=, and |chapter-url= into a single Chapter meta-
parameter (chapter_url_source used for error messages).
]]
function format_chapter_title (chapter, transchapter, chapterurl, chapter_url_source)
local chapter_error = '';
if not is_set (chapter) then
chapter = ''; -- just to be safe for concatenation
if is_set (transchapter) then
chapter = wrap_style ('trans-quoted-title', transchapter);
chapter_error = " " .. seterror ('trans_missing_chapter');
end
if is_set (chapterurl) then
chapter = externallink (chapterurl, chapter, chapter_url_source); -- adds bare_url_missing_title error if appropriate
end
return chapter .. chapter_error;
else -- here when chapter is set
chapter = kern_quotes (chapter); -- if necessary, separate chapter title's leading and trailing quote marks from Module provided quote marks
chapter = wrap_style ('quoted-title', chapter);
if is_set (transchapter) then
transchapter = wrap_style ('trans-quoted-title', transchapter);
chapter = chapter .. ' ' .. transchapter;
end
if is_set (chapterurl) then
chapter = externallink (chapterurl, chapter); -- adds bare_url_missing_title error if appropriate
end
end
return chapter;
end
--[[
Argument wrapper. This function provides support for argument
mapping defined in the configuration file so that multiple names
can be transparently aliased to single internal variable.
]]
function argument_wrapper( args )
local origin = {};
return setmetatable({
ORIGIN = function( self, k )
local dummy = self[k]; --force the variable to be loaded.
return origin[k];
end
},
{
__index = function ( tbl, k )
if origin[k] ~= nil then
return nil;
end
local args, list, v = args, cfg.aliases[k];
if type( list ) == 'table' then
v, origin[k] = selectone( args, list, 'redundant_parameters' );
if origin[k] == nil then
origin[k] = ''; -- Empty string, not nil
end
elseif list ~= nil then
v, origin[k] = args[list], list;
else
-- maybe let through instead of raising an error?
-- v, origin[k] = args[k], k;
error( cfg.messages['unknown_argument_map'] );
end
-- Empty strings, not nil;
if v == nil then
v = cfg.defaults[k] or '';
origin[k] = '';
end
tbl = rawset( tbl, k, v );
return v;
end,
});
end
--[[
Looks for a parameter's name in the whitelist.
Parameters in the whitelist can have three values:
true - active, supported parameters
false - deprecated, supported parameters
nil - unsupported parameters
]]
function validate( name )
local name = tostring( name );
local state = whitelist.basic_arguments[ name ];
-- Normal arguments
if true == state then return true; end -- valid actively supported parameter
if false == state then
deprecated_parameter (name); -- parameter is deprecated but still supported
return true;
end
-- Arguments with numbers in them
name = name:gsub( "%d+", "#" ); -- replace digit(s) with # (last25 becomes last#
state = whitelist.numbered_arguments[ name ];
if true == state then return true; end -- valid actively supported parameter
if false == state then
deprecated_parameter (name); -- parameter is deprecated but still supported
return true;
end
return false; -- Not supported because not found or name is set to nil
end
--[[--------------------------< E R R O R C O M M E N T >------------------------------------------------------
Wraps error messages with css markup according to the state of hidden.
]]
function errorcomment( content, hidden )
return substitute( hidden and cfg.presentation['hidden-error'] or cfg.presentation['visible-error'], content );
end
--[[
Sets an error condition and returns the appropriate error message. The actual placement
of the error message in the output is the responsibility of the calling function.
]]
function seterror( error_id, arguments, raw, prefix, suffix )
local error_state = cfg.error_conditions[ error_id ];
prefix = prefix or "";
suffix = suffix or "";
if error_state == nil then
error( cfg.messages['undefined_error'] );
elseif is_set( error_state.category ) then
table.insert( z.error_categories, error_state.category );
end
local message = substitute( error_state.message, arguments );
message = message .. " ([[" .. cfg.messages['help page link'] ..
"#" .. error_state.anchor .. "|" ..
cfg.messages['help page label'] .. "]])";
z.error_ids[ error_id ] = true;
if inArray( error_id, { 'bare_url_missing_title', 'trans_missing_title' } )
and z.error_ids['citation_missing_title'] then
return '', false;
end
message = table.concat({ prefix, message, suffix });
if raw == true then
return message, error_state.hidden;
end
return errorcomment( message, error_state.hidden );
end
-- Formats a wiki style external link
function externallinkid(options)
local url_string = options.id;
if options.encode == true or options.encode == nil then
url_string = mw.uri.encode( url_string );
end
return mw.ustring.format( '[[%s|%s]]%s[%s%s%s %s]',
options.link, options.label, options.separator or " ",
options.prefix, url_string, options.suffix or "",
mw.text.nowiki(options.id)
);
end
-- Formats a wiki style internal link
function internallinkid(options)
return mw.ustring.format( '[[%s|%s]]%s[[%s%s%s|%s]]',
options.link, options.label, options.separator or " ",
options.prefix, options.id, options.suffix or "",
mw.text.nowiki(options.id)
);
end
-- Format an external link with error checking
function externallink( URL, label, source )
local error_str = "";
if not is_set( label ) then
label = URL;
if is_set( source ) then
error_str = seterror( 'bare_url_missing_title', { wrap_style ('parameter', source) }, false, " " );
else
error( cfg.messages["bare_url_no_origin"] );
end
end
if not checkurl( URL ) then
error_str = seterror( 'bad_url', {}, false, " " ) .. error_str;
end
return table.concat({ "[", URL, " ", safeforurl( label ), "]", error_str });
end
--[[--------------------------< N O W R A P _ D A T E >--------------------------------------------------------
When date is YYYY-MM-DD format wrap in nowrap span: <span ...>YYYY-MM-DD</span>. When date is DD MMMM YYYY or is
MMMM DD, YYYY then wrap in nowrap span: <span ...>DD MMMM</span> YYYY or <span ...>MMMM DD,</span> YYYY
DOES NOT yet support MMMM YYYY or any of the date ranges.
]]
function nowrap_date (date)
local cap='';
local cap2='';
if date:match("^%d%d%d%d%-%d%d%-%d%d$") then
date = substitute (cfg.presentation['nowrap1'], date);
elseif date:match("%a+%s*%d%d?,%s*%d%d%d%d") or date:match ("%d%d?%s*%a+%s*%d%d%d%d") then
cap, cap2 = string.match (date, "^(.*)%s+(%d%d%d%d)$");
date = substitute (cfg.presentation['nowrap2'], {cap, cap2});
end
return date;
end
--[[--------------------------< A M A Z O N >------------------------------------------------------------------
Formats a link to Amazon. Do simple error checking: asin must be mix of 10 numeric or uppercase alpha
characters. If a mix, first character must be uppercase alpha; if all numeric, asins must be 10-digit
isbn. If 10-digit isbn, add a maintenance category so a bot or awb script can replace |asin= with |isbn=.
Error message if not 10 characters, if not isbn10, if mixed and first character is a digit.
]]
function amazon(id, domain)
local err_cat = ""
if not id:match("^[%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u]$") then
err_cat = ' ' .. seterror ('bad_asin'); -- asin is not a mix of 10 uppercase alpha and numeric characters
else
if id:match("^%d%d%d%d%d%d%d%d%d[%dX]$") then -- if 10-digit numeric (or 9 digits with terminal X)
if checkisbn( id ) then -- see if asin value is isbn10
table.insert( z.maintenance_cats, "CS1 maint: ASIN uses ISBN"); -- add to maint category
elseif not is_set (err_cat) then
err_cat = ' ' .. seterror ('bad_asin'); -- asin is not isbn10
end
elseif not id:match("^%u[%d%u]+$") then
err_cat = ' ' .. seterror ('bad_asin'); -- asin doesn't begin with uppercase alpha
end
end
if not is_set(domain) then
domain = "com";
elseif inArray (domain, {'jp', 'uk'}) then -- Japan, United Kingdom
domain = "co." .. domain;
elseif inArray (domain, {'au', 'br', 'mx'}) then -- Australia, Brazil, Mexico
domain = "com." .. domain;
end
local handler = cfg.id_handlers['ASIN'];
return externallinkid({link = handler.link,
label=handler.label , prefix="//www.amazon."..domain.."/dp/",id=id,
encode=handler.encode, separator = handler.separator}) .. err_cat;
end
--[[--------------------------< A R X I V >--------------------------------------------------------------------
See: http://arxiv.org/help/arxiv_identifier
format and error check arXiv identifier. There are three valid forms of the identifier:
the first form, valid only between date codes 9108 and 0703 is:
arXiv:<archive>.<class>/<date code><number><version>
where:
<archive> is a string of alpha characters - may be hyphenated; no other punctuation
<class> is a string of alpha characters - may be hyphenated; no other punctuation
<date code> is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
first digit of YY for this form can only 9 and 0
<number> is a three-digit number
<version> is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
the second form, valid from April 2007 through December 2014 is:
arXiv:<date code>.<number><version>
where:
<date code> is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
<number> is a four-digit number
<version> is a 1 or more digit number preceded with a lowercase v; no spaces
the third form, valid from January 2015 is:
arXiv:<date code>.<number><version>
where:
<date code> and <version> are as defined for 0704-1412
<number> is a five-digit number
]]
function arxiv (id)
local handler = cfg.id_handlers['ARXIV'];
local year, month, version;
local err_cat = ""
if id:match("^%a[%a%.%-]+/[90]%d[01]%d%d%d%d$") or id:match("^%a[%a%.%-]+/[90]%d[01]%d%d%d%dv%d+$") then -- test for the 9108-0703 format w/ & w/o version
year, month = id:match("^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d[v%d]*$");
year = tonumber(year);
month = tonumber(month);
if ((not (90 < year or 8 > year)) or (1 > month or 12 < month)) or -- if invalid year or invalid month
((91 == year and 7 > month) or (7 == year and 3 < month)) then -- if years ok, are starting and ending months ok?
err_cat = ' ' .. seterror( 'bad_arxiv' ); -- set error message
end
elseif id:match("^%d%d[01]%d%.%d%d%d%d$") or id:match("^%d%d[01]%d%.%d%d%d%dv%d+$") then -- test for the 0704-1412 w/ & w/o version
year, month = id:match("^(%d%d)([01]%d)%.%d%d%d%d[v%d]*$");
year = tonumber(year);
month = tonumber(month);
if ((7 > year) or (14 < year) or (1 > month or 12 < month)) or -- is year invalid or is month invalid? (doesn't test for future years)
((7 == year) and (4 > month)) then --or -- when year is 07, is month invalid (before April)?
err_cat = ' ' .. seterror( 'bad_arxiv' ); -- set error message
end
elseif id:match("^%d%d[01]%d%.%d%d%d%d%d$") or id:match("^%d%d[01]%d%.%d%d%d%d%dv%d+$") then -- test for the 1501- format w/ & w/o version
year, month = id:match("^(%d%d)([01]%d)%.%d%d%d%d%d[v%d]*$");
year = tonumber(year);
month = tonumber(month);
if ((15 > year) or (1 > month or 12 < month)) then -- is year invalid or is month invalid? (doesn't test for future years)
err_cat = ' ' .. seterror( 'bad_arxiv' ); -- set error message
end
else
err_cat = ' ' .. seterror( 'bad_arxiv' ); -- arXiv id doesn't match any format
end
return externallinkid({link = handler.link, label = handler.label,
prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end
--[[
lccn normalization (http://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
a. Remove it.
b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
1. All these characters should be digits, and there should be six or less. (not done in this function)
2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.
Returns a normalized lccn for lccn() to validate. There is no error checking (step 3.b.1) performed in this function.
]]
function normalize_lccn (lccn)
lccn = lccn:gsub ("%s", ""); -- 1. strip whitespace
if nil ~= string.find (lccn,'/') then
lccn = lccn:match ("(.-)/"); -- 2. remove forward slash and all character to the right of it
end
local prefix
local suffix
prefix, suffix = lccn:match ("(.+)%-(.+)"); -- 3.a remove hyphen by splitting the string into prefix and suffix
if nil ~= suffix then -- if there was a hyphen
suffix=string.rep("0", 6-string.len (suffix)) .. suffix; -- 3.b.2 left fill the suffix with 0s if suffix length less than 6
lccn=prefix..suffix; -- reassemble the lccn
end
return lccn;
end
--[[
Format LCCN link and do simple error checking. LCCN is a character string 8-12 characters long. The length of the LCCN dictates the character type of the first 1-3 characters; the
rightmost eight are always digits. http://info-uri.info/registry/OAIHandler?verb=GetRecord&metadataPrefix=reg&identifier=info:lccn/
length = 8 then all digits
length = 9 then lccn[1] is lower case alpha
length = 10 then lccn[1] and lccn[2] are both lower case alpha or both digits
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lower case alpha or both digits
length = 12 then lccn[1] and lccn[2] are both lower case alpha
]]
function lccn(lccn)
local handler = cfg.id_handlers['LCCN'];
local err_cat = ''; -- presume that LCCN is valid
local id = lccn; -- local copy of the lccn
id = normalize_lccn (id); -- get canonical form (no whitespace, hyphens, forward slashes)
local len = id:len(); -- get the length of the lccn
if 8 == len then
if id:match("[^%d]") then -- if LCCN has anything but digits (nil if only digits)
err_cat = ' ' .. seterror( 'bad_lccn' ); -- set an error message
end
elseif 9 == len then -- LCCN should be adddddddd
if nil == id:match("%l%d%d%d%d%d%d%d%d") then -- does it match our pattern?
err_cat = ' ' .. seterror( 'bad_lccn' ); -- set an error message
end
elseif 10 == len then -- LCCN should be aadddddddd or dddddddddd
if id:match("[^%d]") then -- if LCCN has anything but digits (nil if only digits) ...
if nil == id:match("^%l%l%d%d%d%d%d%d%d%d") then -- ... see if it matches our pattern
err_cat = ' ' .. seterror( 'bad_lccn' ); -- no match, set an error message
end
end
elseif 11 == len then -- LCCN should be aaadddddddd or adddddddddd
if not (id:match("^%l%l%l%d%d%d%d%d%d%d%d") or id:match("^%l%d%d%d%d%d%d%d%d%d%d")) then -- see if it matches one of our patterns
err_cat = ' ' .. seterror( 'bad_lccn' ); -- no match, set an error message
end
elseif 12 == len then -- LCCN should be aadddddddddd
if not id:match("^%l%l%d%d%d%d%d%d%d%d%d%d") then -- see if it matches our pattern
err_cat = ' ' .. seterror( 'bad_lccn' ); -- no match, set an error message
end
else
err_cat = ' ' .. seterror( 'bad_lccn' ); -- wrong length, set an error message
end
if not is_set (err_cat) and nil ~= lccn:find ('%s') then
err_cat = ' ' .. seterror( 'bad_lccn' ); -- lccn contains a space, set an error message
end
return externallinkid({link = handler.link, label = handler.label,
prefix=handler.prefix,id=lccn,separator=handler.separator, encode=handler.encode}) .. err_cat;
end
--[[
Format PMID and do simple error checking. PMIDs are sequential numbers beginning at 1 and counting up. This code checks the PMID to see that it
contains only digits and is less than test_limit; the value in local variable test_limit will need to be updated periodically as more PMIDs are issued.
]]
function pmid(id)
local test_limit = 30000000; -- update this value as PMIDs approach
local handler = cfg.id_handlers['PMID'];
local err_cat = ''; -- presume that PMID is valid
if id:match("[^%d]") then -- if PMID has anything but digits
err_cat = ' ' .. seterror( 'bad_pmid' ); -- set an error message
else -- PMID is only digits
local id_num = tonumber(id); -- convert id to a number for range testing
if 1 > id_num or test_limit < id_num then -- if PMID is outside test limit boundaries
err_cat = ' ' .. seterror( 'bad_pmid' ); -- set an error message
end
end
return externallinkid({link = handler.link, label = handler.label,
prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end
--[[
Determines if a PMC identifier's online version is embargoed. Compares the date in |embargo= against today's date. If embargo date is
in the future, returns true; otherwise, returns false because the embargo has expired or |embargo= not set in this cite.
]]
function is_embargoed(embargo)
if is_set(embargo) then
local lang = mw.getContentLanguage();
local good1, embargo_date, good2, todays_date;
good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
good2, todays_date = pcall( lang.formatDate, lang, 'U' );
if good1 and good2 and tonumber( embargo_date ) >= tonumber( todays_date ) then --is embargo date is in the future?
return true; -- still embargoed
end
end
return false; -- embargo expired or |embargo= not set
end
--[[
Format a PMC, do simple error checking, and check for embargoed articles.
The embargo parameter takes a date for a value. If the embargo date is in the future
the PMC identifier will not be linked to the article. If the embargo specifies a date in the past, or if it is empty or omitted, then
the PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.
PMCs are sequential numbers beginning at 1 and counting up. This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.
]]
function pmc(id, embargo)
local test_limit = 5000000; -- update this value as PMCs approach
local handler = cfg.id_handlers['PMC'];
local err_cat = ''; -- presume that PMC is valid
local text;
if id:match("[^%d]") then -- if PMC has anything but digits
err_cat = ' ' .. seterror( 'bad_pmc' ); -- set an error message
else -- PMC is only digits
local id_num = tonumber(id); -- convert id to a number for range testing
if 1 > id_num or test_limit < id_num then -- if PMC is outside test limit boundaries
err_cat = ' ' .. seterror( 'bad_pmc' ); -- set an error message
end
end
if is_embargoed(embargo) then
text="[[" .. handler.link .. "|" .. handler.label .. "]]:" .. handler.separator .. id .. err_cat; --still embargoed so no external link
else
text = externallinkid({link = handler.link, label = handler.label, --no embargo date, ok to link to article
prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end
return text;
end
-- Formats a DOI and checks for DOI errors.
-- DOI names contain two parts: prefix and suffix separated by a forward slash.
-- Prefix: directory indicator '10.' followed by a registrant code
-- Suffix: character string of any length chosen by the registrant
-- This function checks a DOI name for: prefix/suffix. If the doi name contains spaces or endashes,
-- or, if it ends with a period or a comma, this function will emit a bad_doi error message.
-- DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
-- and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely if ever used in doi names.
function doi(id, inactive)
local cat = ""
local handler = cfg.id_handlers['DOI'];
local text;
if is_set(inactive) then
local inactive_year = inactive:match("%d%d%d%d") or ''; -- try to get the year portion from the inactive date
text = "[[" .. handler.link .. "|" .. handler.label .. "]]:" .. id;
if is_set(inactive_year) then
table.insert( z.error_categories, "Pages with DOIs inactive since " .. inactive_year );
else
table.insert( z.error_categories, "Pages with inactive DOIs" ); -- when inactive doesn't contain a recognizable year
end
inactive = " (" .. cfg.messages['inactive'] .. " " .. inactive .. ")"
else
text = externallinkid({link = handler.link, label = handler.label,
prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
inactive = ""
end
if nil == id:match("^10%.[^%s–]-/[^%s–]-[^%.,]$") then -- doi must begin with '10.', must contain a fwd slash, must not contain spaces or endashes, and must not end with period or comma
cat = ' ' .. seterror( 'bad_doi' );
end
return text .. inactive .. cat
end
-- Formats an OpenLibrary link, and checks for associated errors.
function openlibrary(id)
local code = id:match("^%d+([AMW])$"); -- only digits followed by 'A', 'M', or 'W'
local handler = cfg.id_handlers['OL'];
if ( code == "A" ) then
return externallinkid({link=handler.link, label=handler.label,
prefix="http://openlibrary.org/authors/OL",id=id, separator=handler.separator,
encode = handler.encode})
elseif ( code == "M" ) then
return externallinkid({link=handler.link, label=handler.label,
prefix="http://openlibrary.org/books/OL",id=id, separator=handler.separator,
encode = handler.encode})
elseif ( code == "W" ) then
return externallinkid({link=handler.link, label=handler.label,
prefix= "http://openlibrary.org/works/OL",id=id, separator=handler.separator,
encode = handler.encode})
else
return externallinkid({link=handler.link, label=handler.label,
prefix= "http://openlibrary.org/OL",id=id, separator=handler.separator,
encode = handler.encode}) ..
' ' .. seterror( 'bad_ol' );
end
end
--[[
Validate and format an issn. This code fixes the case where an editor has included an ISSN in the citation but has separated the two groups of four
digits with a space. When that condition occurred, the resulting link looked like this:
|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327] -- can't have spaces in an external link
This code now prevents that by inserting a hyphen at the issn midpoint. It also validates the issn for length and makes sure that the checkdigit agrees
with the calculated value. Incorrect length (8 digits), characters other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn
error message. The issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.
]]
function issn(id)
local issn_copy = id; -- save a copy of unadulterated issn; use this version for display if issn does not validate
local handler = cfg.id_handlers['ISSN'];
local text;
local valid_issn = true;
id=id:gsub( "[%s-–]", "" ); -- strip spaces, hyphens, and endashes from the issn
if 8 ~= id:len() or nil == id:match( "^%d*X?$" ) then -- validate the issn: 8 digits long, containing only 0-9 or X in the last position
valid_issn=false; -- wrong length or improper character
else
valid_issn=is_valid_isxn(id, 8); -- validate issn
end
if true == valid_issn then
id = string.sub( id, 1, 4 ) .. "-" .. string.sub( id, 5 ); -- if valid, display correctly formatted version
else
id = issn_copy; -- if not valid, use the show the invalid issn with error message
end
text = externallinkid({link = handler.link, label = handler.label,
prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
if false == valid_issn then
text = text .. ' ' .. seterror( 'bad_issn' ) -- add an error message if the issn is invalid
end
return text
end
--[[--------------------------< M E S S A G E _ I D >----------------------------------------------------------
Validate and format a usenet message id. Simple error checking, looks for 'id-left@id-right' not enclosed in
'<' and/or '>' angle brackets.
]]
function message_id (id)
local handler = cfg.id_handlers['USENETID'];
text = externallinkid({link = handler.link, label = handler.label,
prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
if not id:match('^.+@.+$') or not id:match('^[^<].*[^>]$')then -- doesn't have '@' or has one or first or last character is '< or '>'
text = text .. ' ' .. seterror( 'bad_message_id' ) -- add an error message if the message id is invalid
end
return text
end
--[[--------------------------< S E T _ T I T L E T Y P E >----------------------------------------------------
This function sets default title types (equivalent to the citation including |type=<default value>) for those citations that have defaults.
Also handles the special case where it is desirable to omit the title type from the rendered citation (|type=none).
]]
function set_titletype(cite_class, title_type)
if is_set(title_type) then
if "none" == title_type then
title_type = ""; -- if |type=none then type parameter not displayed
end
return title_type; -- if |type= has been set to any other value use that value
end
if "AV-media-notes" == cite_class or "DVD-notes" == cite_class then -- if this citation is cite AV media notes or cite DVD notes
return "Media notes"; -- display AV media notes / DVD media notes annotation
elseif "mailinglist" == cite_class then -- if this citation is cite mailing list
return "Mailing list"; -- display mailing list annotation
elseif "podcast" == cite_class then -- if this citation is cite podcast
return "Podcast"; -- display podcast annotation
elseif "pressrelease" == cite_class then -- if this citation is cite press release
return "Press release"; -- display press release annotation
elseif "report" == cite_class then -- if this citation is cite report
return "Report"; -- display report annotation
elseif "techreport" == cite_class then -- if this citation is cite techreport
return "Technical report"; -- display techreport annotation
elseif "thesis" == cite_class then -- if this citation is cite thesis (degree option handled after this function returns)
return "Thesis"; -- display simple thesis annotation (without |degree= modification)
end
end
--[[
Determines whether a URL string is valid
At present the only check is whether the string appears to
be prefixed with a URI scheme. It is not determined whether
the URI scheme is valid or whether the URL is otherwise well
formed.
]]
function checkurl( url_str )
-- Protocol-relative or URL scheme
return url_str:sub(1,2) == "//" or url_str:match( "^[^/]*:" ) ~= nil;
end
-- Removes irrelevant text and dashes from ISBN number
-- Similar to that used for Special:BookSources
function cleanisbn( isbn_str )
return isbn_str:gsub( "[^-0-9X]", "" );
end
--[[--------------------------< E S C A P E _ L U A _ M A G I C _ C H A R S >----------------------------------
Returns a string where all of lua's magic characters have been escaped. This is important because functions like
string.gsub() treat their pattern and replace strings as patterns, not literal strings.
]]
function escape_lua_magic_chars (argument)
argument = argument:gsub("%%", "%%%%"); -- replace % with %%
argument = argument:gsub("([%^%$%(%)%.%[%]%*%+%-%?])", "%%%1"); -- replace all other lua magic pattern characters
return argument;
end
--[[--------------------------< S T R I P _ A P O S T R O P H E _ M A R K U P >--------------------------------
Strip wiki italic and bold markup from argument so that it doesn't contaminate COinS metadata.
This function strips common patterns of apostrophe markup. We presume that editors who have taken the time to
markup a title have, as a result, provided valid markup. When they don't, some single apostrophes are left behind.
]]
function strip_apostrophe_markup (argument)
if not is_set (argument) then return argument; end
while true do
if argument:match ("%'%'%'%'%'") then -- bold italic (5)
argument=argument:gsub("%'%'%'%'%'", ""); -- remove all instances of it
elseif argument:match ("%'%'%'%'") then -- italic start and end without content (4)
argument=argument:gsub("%'%'%'%'", "");
elseif argument:match ("%'%'%'") then -- bold (3)
argument=argument:gsub("%'%'%'", "");
elseif argument:match ("%'%'") then -- italic (2)
argument=argument:gsub("%'%'", "");
else
break;
end
end
return argument; -- done
end
--[[--------------------------< M A K E _ C O I N S _ T I T L E >----------------------------------------------
Makes a title for COinS from Title and / or ScriptTitle (or any other name-script pairs)
Apostrophe markup (bold, italics) is stripped from each value so that the COinS metadata isn't correupted with strings
of %27%27...
]]
function make_coins_title (title, script)
if is_set (title) then
title = strip_apostrophe_markup (title); -- strip any apostrophe markup
else
title=''; -- if not set, make sure title is an empty string
end
if is_set (script) then
script = script:gsub ('^%l%l%s*:%s*', ''); -- remove language prefix if present (script value may now be empty string)
script = strip_apostrophe_markup (script); -- strip any apostrophe markup
else
script=''; -- if not set, make sure script is an empty string
end
if is_set (title) and is_set (script) then
script = ' ' .. script; -- add a space before we concatenate
end
return title .. script; -- return the concatenation
end
--[[--------------------------< G E T _ C O I N S _ P A G E S >------------------------------------------------
Extract page numbers from external wikilinks in any of the |page=, |pages=, or |at= parameters for use in COinS.
]]
function get_coins_pages (pages)
local pattern;
if not is_set (pages) then return pages; end -- if no page numbers then we're done
while true do
pattern = pages:match("%[(%w*:?//[^ ]+%s+)[%w%d].*%]"); -- pattern is the opening bracket, the url and following space(s): "[url "
if nil == pattern then break; end -- no more urls
pattern = escape_lua_magic_chars (pattern); -- pattern is not a literal string; escape lua's magic pattern characters
pages = pages:gsub(pattern, ""); -- remove as many instances of pattern as possible
end
pages = pages:gsub("[%[%]]", ""); -- remove the brackets
pages = pages:gsub("–", "-" ); -- replace endashes with hyphens
pages = pages:gsub("&%w+;", "-" ); -- and replace html entities (– etc.) with hyphens; do we need to replace numerical entities like   and the like?
return pages;
end
--[[
ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit. ISBN-13 is checked in checkisbn().
If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length and stripped of dashes,
spaces and other non-isxn characters.
]]
function is_valid_isxn (isxn_str, len)
local temp = 0;
isxn_str = { isxn_str:byte(1, len) }; -- make a table of bytes
len = len+1; -- adjust to be a loop counter
for i, v in ipairs( isxn_str ) do -- loop through all of the bytes and calculate the checksum
if v == string.byte( "X" ) then -- if checkdigit is X
temp = temp + 10*( len - i ); -- it represents 10 decimal
else
temp = temp + tonumber( string.char(v) )*(len-i);
end
end
return temp % 11 == 0; -- returns true if calculation result is zero
end
-- Determines whether an ISBN string is valid
function checkisbn( isbn_str )
if nil ~= isbn_str:match("[^%s-0-9X]") then return false; end -- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
isbn_str = isbn_str:gsub( "-", "" ):gsub( " ", "" ); -- remove hyphens and spaces
local len = isbn_str:len();
if len ~= 10 and len ~= 13 then
return false;
end
if len == 10 then
if isbn_str:match( "^%d*X?$" ) == nil then return false; end
return is_valid_isxn(isbn_str, 10);
else
local temp = 0;
if isbn_str:match( "^97[89]%d*$" ) == nil then return false; end -- isbn13 begins with 978 or 979
isbn_str = { isbn_str:byte(1, len) };
for i, v in ipairs( isbn_str ) do
temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );
end
return temp % 10 == 0;
end
end
-- Gets the display text for a wikilink like [[A|B]] or [[B]] gives B
function removewikilink( str )
return (str:gsub( "%[%[([^%[%]]*)%]%]", function(l)
return l:gsub( "^[^|]*|(.*)$", "%1" ):gsub("^%s*(.-)%s*$", "%1");
end));
end
-- Escape sequences for content that will be used for URL descriptions
function safeforurl( str )
if str:match( "%[%[.-%]%]" ) ~= nil then
table.insert( z.message_tail, { seterror( 'wikilink_in_url', {}, true ) } );
end
return str:gsub( '[%[%]\n]', {
['['] = '[',
[']'] = ']',
['\n'] = ' ' } );
end
-- Converts a hyphen to a dash
function hyphentodash( str )
if not is_set(str) or str:match( "[%[%]{}<>]" ) ~= nil then
return str;
end
return str:gsub( '-', '–' );
end
-- Protects a string that will be wrapped in wiki italic markup '' ... ''
function safeforitalics( str )
--[[ Note: We cannot use <i> for italics, as the expected behavior for
italics specified by ''...'' in the title is that they will be inverted
(i.e. unitalicized) in the resulting references. In addition, <i> and ''
tend to interact poorly under Mediawiki's HTML tidy. ]]
if not is_set(str) then
return str;
else
if str:sub(1,1) == "'" then str = "<span></span>" .. str; end
if str:sub(-1,-1) == "'" then str = str .. "<span></span>"; end
-- Remove newlines as they break italics.
return str:gsub( '\n', ' ' );
end
end
--[[--------------------------< S A F E J O I N >--------------------------------------------------------------
Joins a sequence of strings together while checking for duplicate separation characters.
]]
function safejoin( tbl, duplicate_char )
--[[
Note: we use string functions here, rather than ustring functions.
This has considerably faster performance and should work correctly as
long as the duplicate_char is strict ASCII. The strings
in tbl may be ASCII or UTF8.
]]
local str = ''; -- the output string
local comp = ''; -- what does 'comp' mean?
local end_chr = '';
local trim;
for _, value in ipairs( tbl ) do
if value == nil then value = ''; end
if str == '' then -- if output string is empty
str = value; -- assign value to it (first time through the loop)
elseif value ~= '' then
if value:sub(1,1) == '<' then -- Special case of values enclosed in spans and other markup.
comp = value:gsub( "%b<>", "" ); -- remove html markup (<span>string</span> -> string)
else
comp = value;
end
-- typically duplicate_char is sepc
if comp:sub(1,1) == duplicate_char then -- is first charactier same as duplicate_char? why test first character?
-- Because individual string segments often (always?) begin with terminal punct for th
-- preceding segment: 'First element' .. 'sepc next element' .. etc?
trim = false;
end_chr = str:sub(-1,-1); -- get the last character of the output string
-- str = str .. "<HERE(enchr=" .. end_chr.. ")" -- debug stuff?
if end_chr == duplicate_char then -- if same as separator
str = str:sub(1,-2); -- remove it
elseif end_chr == "'" then -- if it might be wikimarkup
if str:sub(-3,-1) == duplicate_char .. "''" then -- if last three chars of str are sepc''
str = str:sub(1, -4) .. "''"; -- remove them and add back ''
elseif str:sub(-5,-1) == duplicate_char .. "]]''" then -- if last five chars of str are sepc]]''
trim = true; -- why? why do this and next differently from previous?
elseif str:sub(-4,-1) == duplicate_char .. "]''" then -- if last four chars of str are sepc]''
trim = true; -- same question
end
elseif end_chr == "]" then -- if it might be wikimarkup
if str:sub(-3,-1) == duplicate_char .. "]]" then -- if last three chars of str are sepc]] wikilink
trim = true;
elseif str:sub(-2,-1) == duplicate_char .. "]" then -- if last two chars of str are sepc] external link
trim = true;
elseif str:sub(-4,-1) == duplicate_char .. "'']" then -- normal case when |url=something & |title=Title.
trim = true;
end
elseif end_chr == " " then -- if last char of output string is a space
if str:sub(-2,-1) == duplicate_char .. " " then -- if last two chars of str are <sepc><space>
str = str:sub(1,-3); -- remove them both
end
end
if trim then
if value ~= comp then -- value does not equal comp when value contains html markup
local dup2 = duplicate_char;
if dup2:match( "%A" ) then dup2 = "%" .. dup2; end -- if duplicate_char not a letter then escape it
value = value:gsub( "(%b<>)" .. dup2, "%1", 1 ) -- remove duplicate_char if it follows html markup
else
value = value:sub( 2, -1 ); -- remove duplicate_char when it is first character
end
end
end
str = str .. value; --add it to the output string
end
end
return str;
end
-- Attempts to convert names to initials.
function reducetoinitials(first)
local initials = {}
local i = 0; -- counter for number of initials
for word in string.gmatch(first, "%S+") do
table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
i = i + 1; -- bump the counter
if 2 <= i then break; end -- only two initials allowed in Vancouver system; if 2, quit
end
return table.concat(initials) -- Vancouver format does not include spaces.
end
-- Formats a list of people (e.g. authors / editors)
function listpeople(control, people)
local sep;
local namesep;
local format = control.format
local maximum = control.maximum
local lastauthoramp = control.lastauthoramp;
local text = {}
local etal = false;
if 'vanc' == format then -- Vancouver-like author/editor name styling?
sep = ','; -- name-list separator between authors is a comma
namesep = ' '; -- last/first separator is a space
else
sep = ';' -- name-list separator between authors is a semicolon
namesep = ', ' -- last/first separator is <comma><space>
end
if sep:sub(-1,-1) ~= " " then sep = sep .. " " end
if maximum ~= nil and maximum < 1 then return "", 0; end
for i,person in ipairs(people) do
if is_set(person.last) then
local mask = person.mask
local one
local sep_one = sep;
if maximum ~= nil and i > maximum then
etal = true;
break;
elseif (mask ~= nil) then
local n = tonumber(mask)
if (n ~= nil) then
one = string.rep("—",n)
else
one = mask;
sep_one = " ";
end
else
one = person.last
local first = person.first
if is_set(first) then
if ( "vanc" == format ) then first = reducetoinitials(first) end
one = one .. namesep .. first
end
if is_set(person.link) and person.link ~= control.page_name then
one = "[[" .. person.link .. "|" .. one .. "]]" -- link author/editor if this page is not the author's/editor's page
end
if is_set(person.link) and ((nil ~= person.link:find("//")) or (nil ~= person.link:find("[%[%]]"))) then
one = one .. " " .. seterror( 'bad_authorlink' ) end -- url or wikilink in author link;
end
table.insert( text, one )
table.insert( text, sep_one )
end
end
local count = #text / 2;
if count > 0 then
if count > 1 and is_set(lastauthoramp) and not etal then
text[#text-2] = " & ";
end
text[#text] = nil;
end
local result = table.concat(text) -- construct list
if etal then
local etal_text = cfg.messages['et al'];
result = result .. " " .. etal_text;
end
return result, count
end
--[[--------------------------< A N C H O R I D >--------------------------------------------------------------
Generates a CITEREF anchor ID if we have at least one name or a date. Otherwise returns an empty string.
]]
function anchorid( options )
local id = table.concat( options ); -- concatenate names and year for CITEREF id
if is_set (id) then -- if concatenation is not an empty string
return "CITEREF" .. id; -- add the CITEREF portion
else
return ''; -- return an empty string; no reason to include CITEREF id in this citation
end
end
--[[
Gets name list from the input arguments
Searches through args in sequential order to find |lastn= and |firstn= parameters (or their aliases), and their matching link and mask parameters.
Stops searching when both |lastn= and |firstn= are not found in args after two sequential attempts: found |last1=, |last2=, and |last3= but doesn't
find |last4= and |last5= then the search is done.
This function emits an error message when there is a |firstn= without a matching |lastn=. When there are 'holes' in the list of last names, |last1= and |last3=
are present but |last2= is missing, an error message is emitted. |lastn= is not required to have a matching |firstn=.
]]
function extractnames(args, list_name)
local names = {}; -- table of names
local last; -- individual name components
local first;
local link;
local mask;
local i = 1; -- loop counter/indexer
local n = 1; -- output table indexer
local count = 0; -- used to count the number of times we haven't found a |last= (or alias for authors, |editor-last or alias for editors)
local err_msg_list_name = list_name:match ("(%w+)List") .. 's list'; -- modify AuthorList or EditorList for use in error messages if necessary
while true do
last = selectone( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', i ); -- search through args for name components beginning at 1
first = selectone( args, cfg.aliases[list_name .. '-First'], 'redundant_parameters', i );
link = selectone( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i );
mask = selectone( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );
if first and not last then -- if there is a firstn without a matching lastn
table.insert( z.message_tail, { seterror( 'first_missing_last', {err_msg_list_name, i}, true ) } ); -- add this error message
elseif not first and not last then -- if both firstn and lastn aren't found, are we done?
count = count + 1; -- number of times we haven't found last and first
if 2 == count then -- two missing names and we give up
break; -- normal exit or there is a two-name hole in the list; can't tell which
end
else -- we have last with or without a first
names[n] = {last = last, first = first, link = link, mask = mask}; -- add this name to our names list
n = n + 1; -- point to next location in the names table
if 1 == count then -- if the previous name was missing
table.insert( z.message_tail, { seterror( 'missing_name', {err_msg_list_name, i-1}, true ) } ); -- add this error message
end
count = 0; -- reset the counter, we're looking for two consecutive missing names
end
i = i + 1; -- point to next args location
end
return names; -- all done, return our list of names
end
-- Populates ID table from arguments using configuration settings
function extractids( args )
local id_list = {};
for k, v in pairs( cfg.id_handlers ) do
v = selectone( args, v.parameters, 'redundant_parameters' );
if is_set(v) then id_list[k] = v; end
end
return id_list;
end
--[[--------------------------< B U I L D I D L I S T >--------------------------------------------------------
Takes a table of IDs and turns it into a table of formatted ID outputs.
]]
function buildidlist( id_list, options )
local new_list, handler = {};
function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
for k, v in pairs( id_list ) do
-- fallback to read-only cfg
handler = setmetatable( { ['id'] = v }, fallback(k) );
if handler.mode == 'external' then
table.insert( new_list, {handler.label, externallinkid( handler ) } );
elseif handler.mode == 'internal' then
table.insert( new_list, {handler.label, internallinkid( handler ) } );
elseif handler.mode ~= 'manual' then
error( cfg.messages['unknown_ID_mode'] );
elseif k == 'DOI' then
table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
elseif k == 'ARXIV' then
table.insert( new_list, {handler.label, arxiv( v ) } );
elseif k == 'ASIN' then
table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } );
elseif k == 'LCCN' then
table.insert( new_list, {handler.label, lccn( v ) } );
elseif k == 'OL' then
table.insert( new_list, {handler.label, openlibrary( v ) } );
elseif k == 'PMC' then
table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
elseif k == 'PMID' then
table.insert( new_list, {handler.label, pmid( v ) } );
elseif k == 'ISSN' then
table.insert( new_list, {handler.label, issn( v ) } );
elseif k == 'ISBN' then
local ISBN = internallinkid( handler );
if not checkisbn( v ) and not is_set(options.IgnoreISBN) then
ISBN = ISBN .. seterror( 'bad_isbn', {}, false, " ", "" );
end
table.insert( new_list, {handler.label, ISBN } );
elseif k == 'USENETID' then
table.insert( new_list, {handler.label, message_id( v ) } );
else
error( cfg.messages['unknown_manual_ID'] );
end
end
function comp( a, b ) -- used in following table.sort()
return a[1] < b[1];
end
table.sort( new_list, comp );
for k, v in ipairs( new_list ) do
new_list[k] = v[2];
end
return new_list;
end
-- Chooses one matching parameter from a list of parameters to consider
-- Generates an error if more than one match is present.
function selectone( args, possible, error_condition, index )
local value = nil;
local selected = '';
local error_list = {};
if index ~= nil then index = tostring(index); end
-- Handle special case of "#" replaced by empty string
if index == '1' then
for _, v in ipairs( possible ) do
v = v:gsub( "#", "" );
if is_set(args[v]) then
if value ~= nil and selected ~= v then
table.insert( error_list, v );
else
value = args[v];
selected = v;
end
end
end
end
for _, v in ipairs( possible ) do
if index ~= nil then
v = v:gsub( "#", index );
end
if is_set(args[v]) then
if value ~= nil and selected ~= v then
table.insert( error_list, v );
else
value = args[v];
selected = v;
end
end
end
if #error_list > 0 then
local error_str = "";
for _, k in ipairs( error_list ) do
if error_str ~= "" then error_str = error_str .. cfg.messages['parameter-separator'] end
error_str = error_str .. wrap_style ('parameter', k);
end
if #error_list > 1 then
error_str = error_str .. cfg.messages['parameter-final-separator'];
else
error_str = error_str .. cfg.messages['parameter-pair-separator'];
end
error_str = error_str .. wrap_style ('parameter', selected);
table.insert( z.message_tail, { seterror( error_condition, {error_str}, true ) } );
end
return value, selected;
end
-- COinS metadata (see <http://ocoins.info/>) allows automated tools to parse
-- the citation information.
function COinS(data)
if 'table' ~= type(data) or nil == next(data) then
return '';
end
local ctx_ver = "Z39.88-2004";
-- treat table strictly as an array with only set values.
local OCinSoutput = setmetatable( {}, {
__newindex = function(self, key, value)
if is_set(value) then
rawset( self, #self+1, table.concat{ key, '=', mw.uri.encode( removewikilink( value ) ) } );
end
end
});
if is_set(data.Chapter) then
OCinSoutput.rft_val_fmt = "info:ofi/fmt:kev:mtx:book";
OCinSoutput["rft.genre"] = "bookitem";
OCinSoutput["rft.atitle"] = data.Chapter;
OCinSoutput["rft.btitle"] = data.Title;
elseif is_set(data.Periodical) then
OCinSoutput.rft_val_fmt = "info:ofi/fmt:kev:mtx:journal";
OCinSoutput["rft.genre"] = "article";
OCinSoutput["rft.jtitle"] = data.Periodical;
OCinSoutput["rft.atitle"] = data.Title;
else
OCinSoutput.rft_val_fmt = "info:ofi/fmt:kev:mtx:book";
OCinSoutput["rft.genre"] = "book"
OCinSoutput["rft.btitle"] = data.Title;
end
OCinSoutput["rft.place"] = data.PublicationPlace;
OCinSoutput["rft.date"] = data.Date;
OCinSoutput["rft.series"] = data.Series;
OCinSoutput["rft.volume"] = data.Volume;
OCinSoutput["rft.issue"] = data.Issue;
OCinSoutput["rft.pages"] = data.Pages;
OCinSoutput["rft.edition"] = data.Edition;
OCinSoutput["rft.pub"] = data.PublisherName;
for k, v in pairs( data.ID_list ) do
local id, value = cfg.id_handlers[k].COinS;
if k == 'ISBN' then value = cleanisbn( v ); else value = v; end
if string.sub( id or "", 1, 4 ) == 'info' then
OCinSoutput["rft_id"] = table.concat{ id, "/", v };
else
OCinSoutput[ id ] = value;
end
end
local last, first;
for k, v in ipairs( data.Authors ) do
last, first = v.last, v.first;
if k == 1 then
if is_set(last) then
OCinSoutput["rft.aulast"] = last;
end
if is_set(first) then
OCinSoutput["rft.aufirst"] = first;
end
end
if is_set(last) and is_set(first) then
OCinSoutput["rft.au"] = table.concat{ last, ", ", first };
elseif is_set(last) then
OCinSoutput["rft.au"] = last;
end
end
OCinSoutput.rft_id = data.URL;
OCinSoutput.rfr_id = table.concat{ "info:sid/", mw.site.server:match( "[^/]*$" ), ":", data.RawPage };
OCinSoutput = setmetatable( OCinSoutput, nil );
-- sort with version string always first, and combine.
table.sort( OCinSoutput );
table.insert( OCinSoutput, 1, "ctx_ver=" .. ctx_ver ); -- such as "Z39.88-2004"
return table.concat(OCinSoutput, "&");
end
--[[--------------------------< G E T _ I S O 6 3 9 _ C O D E >------------------------------------------------
Validates language names provided in |language= parameter if not an ISO639-1 code. Handles the special case that is Norwegian where
ISO639-1 code 'no' is mapped to language name 'Norwegian Bokmål' by Extention:CLDR.
Returns the language name and associated ISO639-1 code. Because case of the source may be incorrect or different from the case that Wikimedia
uses, the name comparisons are done in lower case and when a match is found, the Wikimedia version (assumed to be correct) is returned along
with the code. When there is no match, we return the original language name string.
mw.language.fetchLanguageNames() will return a list of languages that aren't part of ISO639-1. Names that aren't ISO639-1 but that are included
in the list will be found if that name is provided in the |language= parameter. For example, if |language=Samaritan Aramaic, that name will be
found with the associated code 'sam', not an ISO639-1 code. When names are found and the associated code is not two characters, this function
returns only the Wikimedia language name.
Adapted from code taken from Module:Check ISO 639-1.
]]
function get_iso639_code (lang)
if 'norwegian' == lang:lower() then -- special case related to Wikimedia remap of code 'no' at Extension:CLDR
return 'Norwegian', 'no'; -- Make sure rendered version is properly capitalized
end
local languages = mw.language.fetchLanguageNames('en', 'all') -- get a list of language names known to Wikimedia
-- ('all' is required for North Ndebele, South Ndebele, and Ojibwa)
local langlc = mw.ustring.lower(lang); -- lower case version for comparisons
for code, name in pairs(languages) do -- scan the list to see if we can find our language
if langlc == mw.ustring.lower(name) then
if 2 ~= code:len() then -- ISO639-1 codes only
return name; -- so return the name but not the code
end
return name, code; -- found it, return name to ensure proper capitalization and the ISO639-1 code
end
end
return lang; -- not valid language; return language in original case and nil for ISO639-1 code
end
--[[--------------------------< L A N G U A G E _ P A R A M E T E R >------------------------------------------
Get language name from ISO639-1 code value provided. If a code is valid use the returned name; if not, then use the value that was provided with the language parameter.
There is an exception. There are three ISO639-1 codes for Norewegian language variants. There are two official variants: Norwegian Bokmål (code 'nb') and
Norwegian Nynorsk (code 'nn'). The third, code 'no', is defined by ISO639-1 as 'Norwegian' though in Norway this is pretty much meaningless. However, it appears
that on enwiki, editors are for the most part unaware of the nb and nn variants (compare page counts for these variants at Category:Articles with non-English-language external links.
Because Norwegian Bokmål is the most common language variant, Media wiki has been modified to return Norwegian Bokmål for ISO639-1 code 'no'. Here we undo that and
return 'Norwegian' when editors use |language=no. We presume that editors don't know about the variants or can't descriminate between them.
See Help talk:Citation Style_1#An ISO 639-1 language name test
When |language= contains a valid ISO639-1 code, the page is assigned to the category for that code: Category:Norwegian-language sources (no) if
the page is a mainspace page and the ISO639-1 code is not 'en'. Similarly, if the parameter is |language=Norwegian, it will be categorized in the same way.
]]
function language_parameter (lang, namespace)
local code; -- the ISO639-1 two character code
local name; -- the language name
local test='';
if 0 == namespace and (('en' == lang:lower()) or ('english' == lang:lower())) then
table.insert (z.maintenance_cats, 'CS1 maint: English language specified'); -- add maintenance category if |language=English or |language=en in article space
end
if 2 == lang:len() then -- ISO639-1 language code are 2 characters (fetchLanguageName also supports 3 character codes)
name = mw.language.fetchLanguageName( lang:lower(), "en" ); -- get ISO 639-1 language name if Language is a proper code
end
if is_set (name) then -- if Language specified a valid ISO639-1 code
code = lang:lower(); -- save it
else
name, code = get_iso639_code (lang); -- attempt to get code from name (assign name here so that we are sure of proper capitalization)
end
if is_set (code) then
if 'no' == code then name = 'Norwegian' end; -- override wikimedia when code is 'no'
if 0 == namespace and 'en' ~= code then -- is this page main / article space and English not the language?
table.insert( z.properties_cats, 'CS1 ' .. name .. '-language sources (' .. code .. ')'); -- in main space and not English: categorize
end
else
table.insert (z.maintenance_cats, 'CS1 maint: Unrecognized language'); -- add maintenance category when |language= does not appear to be ISO 639-1 language
end
return (" " .. wrap_msg ('language', name)); -- wrap with '(in ...)'
end
--[[--------------------------< G E T _ S E T T I N G S _ F R O M _ C I T E _ C L A S S >----------------------
When |mode= is not set or when its value is invalid, use config.CitationClass and parameter values to establish
rendered style.
]]
function get_settings_from_cite_class (ps, ref, cite_class)
local sep;
if (cite_class == "citation") then -- for citation templates (CS2)
sep = ','; -- set citation separator to its default (comma)
if not is_set (ps) then -- if |postscript= has not been set, set cs2 default
ps = ''; -- make sure it isn't nil
end
if not is_set (ref) then -- if |ref= is not set
ref = "harv"; -- set default |ref=harv
end
else -- not a citation template so CS1
sep = '.'; -- set cite xxx separator to its default (period)
if not is_set (ps) then -- if |postscript= has not been set
ps = '.'; -- set cs1 default
end
end
return sep, ps, ref -- return them all
end
--[[--------------------------< S E T _ S T Y L E >------------------------------------------------------------
Establish basic style settings to be used when rendering the citation. Uses |mode= if set and valid or uses
config.CitationClass from the template's #invoke: to establish style.
]]
function set_style (mode, ps, ref, cite_class)
local sep;
if is_set (mode) then
if 'cs2' == mode then -- if this template is to be rendered in CS2 (citation) style
sep = ','; -- separate elements with a comma
if not is_set (ps) then -- unless explicitely set to something
ps = ''; -- make sure it isn't nil
end
if not is_set (ref) then -- unless explicitely set to something
ref = 'harv'; -- set so this template renders with CITEREF anchor id
end
elseif 'cs1' == mode then -- if this template is to be rendered in CS1 (cite xxx) style
sep = '.'; -- separate elements with a period
if not is_set (ps) then -- unless explicitely set to something
ps = '.'; -- terminate the rendered citation with a period
end
else -- anything but cs1 or cs2
table.insert( z.message_tail, { seterror( 'invalid_param_val', {'mode', mode}, true ) } ); -- add error message
sep, ps, ref = get_settings_from_cite_class (ps, ref, cite_class); -- get settings based on the template's CitationClass
end
else -- when |mode= empty or omitted
sep, ps, ref = get_settings_from_cite_class (ps, ref, cite_class); -- get settings based on the template's CitationClass
end
if 'none' == ps:lower() then -- if assigned value is 'none' then
ps = ''; -- set to empty string
end
return sep, ps, ref
end
--[[--------------------------< C I T A T I O N 0 >------------------------------------------------------------
This is the main function doing the majority of the citation
formatting.
]]
function citation0( config, args)
--[[
Load Input Parameters
The argument_wrapper facilitates the mapping of multiple
aliases to single internal variable.
]]
local A = argument_wrapper( args );
local i
local PPrefix = A['PPrefix']
local PPPrefix = A['PPPrefix']
if is_set( A['NoPP'] ) then PPPrefix = "" PPrefix = "" end
-- Pick out the relevant fields from the arguments. Different citation templates
-- define different field names for the same underlying things.
local Authors = A['Authors'];
local a = extractnames( args, 'AuthorList' );
local Coauthors = A['Coauthors'];
local Others = A['Others'];
local Editors = A['Editors'];
local e = extractnames( args, 'EditorList' );
local NameListFormat = A['NameListFormat']; -- replaces |author-format= and |editor-format=
if is_set (NameListFormat) and ('vanc' ~= NameListFormat) then -- only accepted value for this parameter is 'vanc'
table.insert( z.message_tail, { seterror( 'invalid_param_val', {'name-list-format', NameListFormat}, true ) } ); -- not vanc so add error message
NameListFormat = ''; -- set to empty string
end
local Year = A['Year'];
local PublicationDate = A['PublicationDate'];
local OrigYear = A['OrigYear'];
local Date = A['Date'];
local LayDate = A['LayDate'];
------------------------------------------------- Get title data
local Title = A['Title'];
local ScriptTitle = A['ScriptTitle'];
local BookTitle = A['BookTitle'];
local Conference = A['Conference'];
local TransTitle = A['TransTitle'];
local TitleNote = A['TitleNote'];
local TitleLink = A['TitleLink'];
local Chapter = A['Chapter'];
local ChapterLink = A['ChapterLink']; -- deprecated
local TransChapter = A['TransChapter'];
local TitleType = A['TitleType'];
local Degree = A['Degree'];
local Docket = A['Docket'];
local ArchiveURL = A['ArchiveURL'];
local URL = A['URL']
local URLorigin = A:ORIGIN('URL'); -- get name of parameter that holds URL
local ChapterURL = A['ChapterURL'];
local ChapterURLorigin = A:ORIGIN('ChapterURL'); -- get name of parameter that holds ChapterURL
local ConferenceURL = A['ConferenceURL'];
local ConferenceURLorigin = A:ORIGIN('ConferenceURL'); -- get name of parameter that holds ConferenceURL
local Periodical = A['Periodical'];
local Series = A['Series'];
local Volume = A['Volume'];
local Issue = A['Issue'];
local Position = '';
local Page = A['Page'];
local Pages = hyphentodash( A['Pages'] );
local At = A['At'];
local Edition = A['Edition'];
local PublicationPlace = A['PublicationPlace']
local Place = A['Place'];
local PublisherName = A['PublisherName'];
local RegistrationRequired = A['RegistrationRequired'];
local SubscriptionRequired = A['SubscriptionRequired'];
local Via = A['Via'];
local AccessDate = A['AccessDate'];
local ArchiveDate = A['ArchiveDate'];
local Agency = A['Agency'];
local DeadURL = A['DeadURL']
local Language = A['Language'];
local Format = A['Format'];
local ChapterFormat = A['ChapterFormat'];
local DoiBroken = A['DoiBroken'];
local ID = A['ID'];
local ASINTLD = A['ASINTLD'];
local IgnoreISBN = A['IgnoreISBN'];
local Embargo = A['Embargo'];
local ID_list = extractids( args );
local Quote = A['Quote'];
local LayURL = A['LayURL'];
local LaySource = A['LaySource'];
local Transcript = A['Transcript'];
local TranscriptURL = A['TranscriptURL']
local TranscriptURLorigin = A:ORIGIN('TranscriptURL'); -- get name of parameter that holds TranscriptURL
local LastAuthorAmp = A['LastAuthorAmp'];
local no_tracking_cats = A['NoTracking'];
--these are used by cite interview
local Callsign = A['Callsign'];
local City = A['City'];
local Program = A['Program'];
--local variables that are not cs1 parameters
local use_lowercase; -- controls capitalization of certain static text
local this_page = mw.title.getCurrentTitle(); -- also used for COinS and for language
local anchor_year; -- used in the CITEREF identifier
local COinS_date; -- used in the COinS metadata
-- set default parameter values defined by |mode= parameter. If |mode= is empty or omitted, use CitationClass to set these values
local sepc; -- separator between citation elements for CS1 a period, for CS2, a comma
local PostScript;
local Ref;
sepc, PostScript, Ref = set_style (A['Mode']:lower(), A['PostScript'], A['Ref'], config.CitationClass);
use_lowercase = ( sepc == ',' ); -- used to control capitalization for certain static text
--check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories.
if not is_set(no_tracking_cats) then -- ignore if we are already not going to categorize this page
if inArray (this_page.nsText, cfg.uncategorized_namespaces) then
no_tracking_cats = "true"; -- set no_tracking_cats
end
end
-- check for extra |page=, |pages= or |at= parameters.
if is_set(Page) then
if is_set(Pages) or is_set(At) then
Page = Page .. " " .. seterror('extra_pages'); -- add error message
Pages = ''; -- unset the others
At = '';
end
elseif is_set(Pages) then
if is_set(At) then
Pages = Pages .. " " .. seterror('extra_pages'); -- add error messages
At = ''; -- unset
end
end
-- both |publication-place= and |place= (|location=) allowed if different
if not is_set(PublicationPlace) and is_set(Place) then
PublicationPlace = Place; -- promote |place= (|location=) to |publication-place
end
if PublicationPlace == Place then Place = ''; end -- don't need both if they are the same
--[[
Parameter remapping for cite encyclopedia:
When the citation has these parameters:
|encyclopedia and |title then map |title to |article and |encyclopedia to |title
|encyclopedia and |article then map |encyclopedia to |title
|encyclopedia then map |encyclopedia to |title
|trans_title maps to |trans_chapter when |title is re-mapped
|url maps to |chapterurl when |title is remapped
All other combinations of |encyclopedia, |title, and |article are not modified
TODO: script-title to script-chapter if and when we support script-chapter
]]
local Encyclopedia = A['Encyclopedia'];
if ( config.CitationClass == "encyclopaedia" ) or ( config.CitationClass == "citation" and is_set (Encyclopedia)) then -- test code for citation
if is_set(Periodical) then -- Periodical is set when |encyclopedia is set
if is_set(Title) then
if not is_set(Chapter) then
Chapter = Title; -- |encyclopedia and |title are set so map |title to |article and |encyclopedia to |title
TransChapter = TransTitle;
ChapterURL = URL;
Title = Periodical;
ChapterFormat = Format;
Periodical = ''; -- redundant so unset
TransTitle = ''; -- redundant so unset
URL = ''; -- redundant so unset
Format = ''; -- redundant so unset
end
else -- |title not set
Title = Periodical; -- |encyclopedia set and |article set or not set so map |encyclopedia to |title
Periodical = ''; -- redundant so unset
end
end
end
-- Special case for cite techreport.
if (config.CitationClass == "techreport") then -- special case for cite techreport
if is_set(Issue) then -- cite techreport uses 'number', which other citations aliase to 'issue'
if not is_set(ID) then -- can we use ID for the "number"?
ID = Issue; -- yes, use it
Issue = ""; -- unset Issue so that "number" isn't duplicated in the rendered citation or COinS metadata
else -- can't use ID so emit error message
ID = ID .. " " .. seterror('redundant_parameters', '<code>|id=</code> and <code>|number=</code>');
end
end
end
-- special case for cite interview
if (config.CitationClass == "interview") then
if is_set(Program) then
ID = ' ' .. Program;
end
if is_set(Callsign) then
if is_set(ID) then
ID = ID .. sepc .. ' ' .. Callsign;
else
ID = ' ' .. Callsign;
end
end
if is_set(City) then
if is_set(ID) then
ID = ID .. sepc .. ' ' .. City;
else
ID = ' ' .. City;
end
end
if is_set(Others) then
if is_set(TitleType) then
Others = ' ' .. TitleType .. ' with ' .. Others;
TitleType = '';
else
Others = ' ' .. 'Interview with ' .. Others;
end
else
Others = '(Interview)';
end
end
-- special case for cite mailing list
if (config.CitationClass == "mailinglist") then
Periodical = A ['MailingList'];
end
--Account for the oddity that is {{cite journal}} with |pmc= set and |url= not set
if config.CitationClass == "journal" and not is_set(URL) and is_set(ID_list['PMC']) then
if not is_embargoed(Embargo) then
URL=cfg.id_handlers['PMC'].prefix .. ID_list['PMC']; -- set url to be the same as the PMC external link if not embargoed
URLorigin = cfg.id_handlers['PMC'].parameters[1]; -- set URLorigin to parameter name for use in error message if citation is missing a |title=
end
end
-- Account for the oddity that is {{cite conference}}, before generation of COinS data.
if 'conference' == config.CitationClass then
if is_set(BookTitle) then
Chapter = Title;
-- ChapterLink = TitleLink; -- |chapterlink= is deprecated
ChapterURL = URL;
ChapterURLorigin = URLorigin;
URLorigin = '';
ChapterFormat = Format;
TransChapter = TransTitle;
Title = BookTitle;
Format = '';
-- TitleLink = '';
TransTitle = '';
URL = '';
end
else
Conference = ''; -- not cite conference so make sure this is empty string
end
-- Account for the oddity that is {{cite episode}}, before generation of COinS data.
--[[ -- {{cite episode}} is not currently supported by this module
if config.CitationClass == "episode" then
local AirDate = A['AirDate'];
local SeriesLink = A['SeriesLink'];
local Season = A['Season'];
local SeriesNumber = A['SeriesNumber'];
local Network = A['Network'];
local Station = A['Station'];
local s, n = {}, {};
local Sep = (first_set(A["SeriesSeparator"], A["Separator"]) or "") .. " ";
if is_set(Issue) then table.insert(s, cfg.messages["episode"] .. " " .. Issue); Issue = ''; end
if is_set(Season) then table.insert(s, cfg.messages["season"] .. " " .. Season); end
if is_set(SeriesNumber) then table.insert(s, cfg.messages["series"] .. " " .. SeriesNumber); end
if is_set(Network) then table.insert(n, Network); end
if is_set(Station) then table.insert(n, Station); end
Date = Date or AirDate;
Chapter = Title;
ChapterLink = TitleLink;
TransChapter = TransTitle;
Title = Series;
TitleLink = SeriesLink;
TransTitle = '';
Series = table.concat(s, Sep);
ID = table.concat(n, Sep);
end
-- end of {{cite episode}} stuff]]
-- legacy: promote concatenation of |month=, and |year= to Date if Date not set; or, promote PublicationDate to Date if neither Date nor Year are set.
if is_set(Date) then
if is_set (Year) then
table.insert( z.maintenance_cats, "CS1 maint: Date and year"); -- add to maint category
end
else
Date = Year; -- promote Year to Date
Year = nil; -- make nil so Year as empty string isn't used for CITEREF
if is_set(Date) then
local Month = A['Month'];
if is_set(Month) then
Date = Month .. " " .. Date;
end
elseif is_set(PublicationDate) then -- use PublicationDate when |date= and |year= are not set
Date = PublicationDate; -- promote PublicationDate to Date
PublicationDate = ''; -- unset, no longer needed
end
end
if PublicationDate == Date then PublicationDate = ''; end -- if PublicationDate is same as Date, don't display in rendered citation
--[[
Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates. This must be done before we do COinS because here is where
we get the date used in the metadata.
Date validation supporting code is in Module:Citation/CS1/Date_validation
]]
anchor_year, COinS_date, error_message = dates({['accessdate']=AccessDate, ['airdate']=AirDate, ['archivedate']=ArchiveDate, ['date']=Date, ['doi_brokendate']=DoiBroken,
['embargo']=Embargo, ['laydate']=LayDate, ['publicationdate']=PublicationDate, ['year']=Year});
if is_set(error_message) then
table.insert( z.message_tail, { seterror( 'bad_date', {error_message}, true ) } ); -- add this error message
end
-- At this point fields may be nil if they weren't specified in the template use. We can use that fact.
-- Test if citation has no title
if not is_set(Title) and
-- not is_set(Periodical) and -- not a title
-- not is_set(Conference) and -- not a title
not is_set(TransTitle) and
not is_set(ScriptTitle) then
table.insert( z.message_tail, { seterror( 'citation_missing_title', {}, true ) } );
end
if 'none' == Title and is_set(Periodical) and not (( config.CitationClass == "encyclopaedia" ) or ( config.CitationClass == "citation" and is_set (Encyclopedia))) then -- special case
Title = ''; -- set title to empty string
table.insert( z.maintenance_cats, "CS1 maint: Untitled periodical"); -- add to maint category
end
-- COinS metadata (see <http://ocoins.info/>) for automated parsing of citation information.
-- handle the oddity that is cite encyclopedia and {{citation |encyclopedia=something}}. Here we presume that
-- when Periodical, Title, and Chapter are all set, then Periodical is the book (encyclopedia) title, Title
-- is the article title, and Chapter is a section within the article. So, we remap
local coins_chapter = Chapter; -- default assuming that remapping not required
local coins_title = Title; -- et tu
if 'encyclopaedia' == config.CitationClass or ('citation' == config.CitationClass and is_set (Encyclopedia)) then
if is_set (Chapter) and is_set (Title) and is_set (Periodical) then -- if all are used then
coins_chapter = Title; -- remap
coins_title = Periodical;
end
end
-- this is the function call to COinS()
local OCinSoutput = COinS{
['Periodical'] = Periodical,
['Chapter'] = strip_apostrophe_markup (coins_chapter), -- Chapter stripped of bold / italic wikimarkup
['Title'] = make_coins_title (coins_title, ScriptTitle), -- Title and ScriptTitle stripped of bold / italic wikimarkup
['PublicationPlace'] = PublicationPlace,
['Date'] = first_set(COinS_date, Date), -- COinS_date has correctly formatted date if Date is valid; any reason to keep Date here? Should we be including invalid dates in metadata?
['Series'] = Series,
['Volume'] = Volume,
['Issue'] = Issue,
['Pages'] = get_coins_pages (first_set(Page, Pages, At)), -- pages stripped of external links
['Edition'] = Edition,
['PublisherName'] = PublisherName,
['URL'] = first_set( URL, ChapterURL ),
['Authors'] = a,
['ID_list'] = ID_list,
['RawPage'] = this_page.prefixedText,
};
--[[Why is this here? Why are we mapping Title to Chapter when Periodical is set?
if is_set(Periodical) and not is_set(Chapter) and is_set(Title) then
Chapter = Title;
ChapterLink = TitleLink;
TransChapter = TransTitle;
Title = '';
TitleLink = '';
TransTitle = '';
end
]]
-- special case for cite newsgroup. Do this after COinS because we are modifying Publishername to include some static text
if 'newsgroup' == config.CitationClass then
if is_set (PublisherName) then
PublisherName = '[[Newsgroup]]: ' .. externallink( 'news:' .. PublisherName, PublisherName );
end
end
-- Now perform various field substitutions.
-- We also add leading spaces and surrounding markup and punctuation to the
-- various parts of the citation, but only when they are non-nil.
if not is_set(Authors) then
local Maximum = tonumber( A['DisplayAuthors'] );
if is_set (Maximum) then
if Maximum >= #a then -- if display-authors value greater than or equal to number of authors
table.insert( z.maintenance_cats, "CS1 maint: display-authors"); -- add maintenance category because display-authors parameter may be removed
end
else
Maximum = #a + 1; -- number of authors + 1
end
local control = {
format = NameListFormat, -- empty string or 'vanc'
maximum = Maximum,
lastauthoramp = LastAuthorAmp,
page_name = this_page.text -- get current page name so that we don't wikilink to it via authorlinkn
};
-- If the coauthor field is also used, prevent ampersand and et al. formatting.
if is_set(Coauthors) then
control.lastauthoramp = nil;
control.maximum = #a + 1;
end
Authors = listpeople(control, a)
end
if not is_set(Authors) and is_set(Coauthors) then -- coauthors aren't displayed if one of authors=, authorn=, or lastn= isn't specified
table.insert( z.message_tail, { seterror('coauthors_missing_author', {}, true) } ); -- emit error message
end
local EditorCount
if not is_set(Editors) then
local Maximum = tonumber( A['DisplayEditors'] );
-- Preserve old-style implicit et al.
if not is_set(Maximum) and #e == 4 then
Maximum = 3;
table.insert( z.message_tail, { seterror('implict_etal_editor', {}, true) } );
elseif not is_set(Maximum) then
Maximum = #e + 1;
end
local control = {
format = NameListFormat, -- empty string or 'vanc'
maximum = Maximum,
lastauthoramp = LastAuthorAmp,
page_name = this_page.text -- get current page name so that we don't wikilink to it via editorlinkn
};
Editors, EditorCount = listpeople(control, e);
else
EditorCount = 1;
end
local Cartography = "";
local Scale = "";
if config.CitationClass == "map" then
if not is_set( Authors ) and is_set( PublisherName ) then
Authors = PublisherName;
PublisherName = "";
end
Cartography = A['Cartography'];
if is_set( Cartography ) then
Cartography = sepc .. " " .. wrap_msg ('cartography', Cartography, use_lowercase);
end
Scale = A['Scale'];
if is_set( Scale ) then
Scale = sepc .. " " .. Scale;
end
end
Format = is_set(Format) and " (" .. Format .. ")" or "";
if not is_set(URL) and
not is_set(ArchiveURL) and
not is_set(ConferenceURL) and -- TODO: keep this here? conference as part of cite web or cite podcast?
not is_set(TranscriptURL) then
-- Test if cite web or cite podcast |url= is missing or empty
if inArray(config.CitationClass, {"web","podcast", "mailinglist"}) then
table.insert( z.message_tail, { seterror( 'cite_web_url', {}, true ) } );
end
-- Test if accessdate is given without giving a URL
if is_set(AccessDate) and not is_set(ChapterURL)then -- ChapterURL may be set when the others are not set; TODO: move this to a separate test?
table.insert( z.message_tail, { seterror( 'accessdate_missing_url', {}, true ) } );
AccessDate = '';
end
-- Test if format is given without giving a URL
if is_set(Format) then
Format = Format .. seterror( 'format_missing_url', {'format', 'url'} );
end
end
--[[
-- Test if citation has no title
if not is_set(Title) and
-- not is_set(Periodical) and -- not a title
-- not is_set(Conference) and -- not a title
not is_set(TransTitle) and
not is_set(ScriptTitle) then
table.insert( z.message_tail, { seterror( 'citation_missing_title', {}, true ) } );
end
if 'none' == Title and is_set(Periodical) then -- special case
Title = ''; -- set title to empty string
table.insert( z.maintenance_cats, "CS1 maint: Untitled periodical"); -- add to maint category
end
]]
local OriginalURL;
DeadURL = DeadURL:lower(); -- used later when assembling archived text
if is_set( ArchiveURL ) then
if is_set (URL) then
OriginalURL = URL; -- save copy of original source URL
if 'no' ~= DeadURL then -- if URL set then archive-url applies to it
URL = ArchiveURL -- swap-in the archive's url
URLorigin = A:ORIGIN('ArchiveURL') -- name of archive url parameter for error messages
end
elseif is_set (ChapterURL) then -- URL not set so if chapter-url is set apply archive url to it
OriginalURL = ChapterURL; -- save copy of source chapter's url for archive text
if 'no' ~= DeadURL then
ChapterURL = ArchiveURL -- swap-in the archive's url
URLorigin = A:ORIGIN('ArchiveURL') -- name of archive url parameter for error messages
end
end
end
if inArray(config.CitationClass, {"web","news","journal","pressrelease","podcast", "newsgroup"}) or
('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia)) then
if is_set (Chapter) or is_set (TransChapter) or is_set (ChapterURL)then -- chapter parameters not supported for these citation types
table.insert( z.message_tail, { seterror( 'chapter_ignored', {}, true ) } ); -- add error message
Chapter = ''; -- set to empty string to be safe with concatenation
TransChapter = '';
ChapterURL = '';
end
else -- otherwise, format chapter / article title
Chapter = format_chapter_title (Chapter, TransChapter, ChapterURL, ChapterURLorigin);
if is_set (Chapter) then
ChapterFormat = is_set(ChapterFormat) and " (" .. ChapterFormat .. ")" or "";
if is_set(ChapterFormat) and not is_set (ChapterURL) then -- Test if |chapter-format= is given without giving a |chapter-url=
ChapterFormat = ChapterFormat .. seterror( 'format_missing_url', {'chapter-format', 'chapter-url'} );
end
Chapter = Chapter .. ChapterFormat .. sepc .. ' ';
end
end
-- Format main title.
if is_set(TitleLink) and is_set(Title) then
Title = "[[" .. TitleLink .. "|" .. Title .. "]]"
end
if inArray(config.CitationClass, {"web","news","journal","pressrelease","podcast", "newsgroup", "mailinglist"}) or
('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia)) then
Title = kern_quotes (Title); -- if necessary, separate title's leading and trailing quote marks from Module provided quote marks
Title = wrap_style ('quoted-title', Title);
Title = script_concatenate (Title, ScriptTitle); -- <bdi> tags, lang atribute, categorization, etc; must be done after title is wrapped
TransTitle= wrap_style ('trans-quoted-title', TransTitle );
elseif 'report' == config.CitationClass then -- no styling for cite report
Title = script_concatenate (Title, ScriptTitle); -- <bdi> tags, lang atribute, categorization, etc; must be done after title is wrapped
TransTitle= wrap_style ('trans-quoted-title', TransTitle ); -- for cite report, use this form for trans-title
else
Title = wrap_style ('italic-title', Title);
Title = script_concatenate (Title, ScriptTitle); -- <bdi> tags, lang atribute, categorization, etc; must be done after title is wrapped
TransTitle = wrap_style ('trans-italic-title', TransTitle);
end
TransError = "";
if is_set(TransTitle) then
if is_set(Title) then
TransTitle = " " .. TransTitle;
else
TransError = " " .. seterror( 'trans_missing_title' );
end
end
Title = Title .. TransTitle;
if is_set(Title) then
if not is_set(TitleLink) and is_set(URL) then
Title = externallink( URL, Title ) .. TransError .. Format
URL = "";
Format = "";
else
Title = Title .. TransError;
end
end
if is_set(Place) then
Place = " " .. wrap_msg ('written', Place, use_lowercase) .. sepc .. " ";
end
if is_set(Conference) then
if is_set(ConferenceURL) then
Conference = externallink( ConferenceURL, Conference );
end
Conference = sepc .. " " .. Conference
elseif is_set(ConferenceURL) then
Conference = sepc .. " " .. externallink( ConferenceURL, nil, ConferenceURLorigin );
end
if not is_set(Position) then
local Minutes = A['Minutes'];
if is_set(Minutes) then
Position = " " .. Minutes .. " " .. cfg.messages['minutes'];
else
local Time = A['Time'];
if is_set(Time) then
local TimeCaption = A['TimeCaption']
if not is_set(TimeCaption) then
TimeCaption = cfg.messages['event'];
if sepc ~= '.' then
TimeCaption = TimeCaption:lower();
end
end
Position = " " .. TimeCaption .. " " .. Time;
end
end
else
Position = " " .. Position;
At = '';
end
if not is_set(Page) then
if is_set(Pages) then
if is_set(Periodical) and
not inArray(config.CitationClass, {"encyclopaedia","web","book","news","podcast"}) then
Pages = ": " .. Pages;
elseif tonumber(Pages) ~= nil then
Pages = sepc .." " .. PPrefix .. Pages;
else
Pages = sepc .." " .. PPPrefix .. Pages;
end
end
else
if is_set(Periodical) and
not inArray(config.CitationClass, {"encyclopaedia","web","book","news","podcast"}) then
Page = ": " .. Page;
else
Page = sepc .." " .. PPrefix .. Page;
end
end
At = is_set(At) and (sepc .. " " .. At) or "";
Position = is_set(Position) and (sepc .. " " .. Position) or "";
if config.CitationClass == 'map' then
local Section = A['Section'];
local Inset = A['Inset'];
if first_set( Pages, Page, At ) ~= nil or sepc ~= '.' then
if is_set( Section ) then
Section = ", " .. wrap_msg ('section', Section, true);
end
if is_set( Inset ) then
Inset = ", " .. wrap_msg ('inset', Inset, true);
end
else
if is_set( Section ) then
Section = sepc .. " " .. wrap_msg ('section', Section, use_lowercase);
if is_set( Inset ) then
Inset = ", " .. wrap_msg ('inset', Inset, true);
end
elseif is_set( Inset ) then
Inset = sepc .. " " .. wrap_msg ('inset', Inset, use_lowercase);
end
end
At = At .. Section .. Inset;
end
if is_set (Language) then
Language = language_parameter (Language, this_page.namespace); -- format, categories (article namespace only), name from ISO639-1, etc
else
Language=""; -- language not specified so make sure this is an empty string;
end
Others = is_set(Others) and (sepc .. " " .. Others) or "";
-- handle type parameter for those CS1 citations that have default values
if inArray(config.CitationClass, {"AV-media-notes", "DVD-notes", "mailinglist", "podcast", "pressrelease", "report", "techreport", "thesis"}) then
TitleType = set_titletype (config.CitationClass, TitleType);
if is_set(Degree) and "Thesis" == TitleType then -- special case for cite thesis
TitleType = Degree .. " thesis";
end
end
if is_set(TitleType) then -- if type parameter is specified
TitleType = " (" .. TitleType .. ")"; -- display it in parentheses
end
TitleNote = is_set(TitleNote) and (sepc .. " " .. TitleNote) or "";
Edition = is_set(Edition) and (" " .. wrap_msg ('edition', Edition)) or "";
Issue = is_set(Issue) and (" (" .. Issue .. ")") or "";
Series = is_set(Series) and (sepc .. " " .. Series) or "";
OrigYear = is_set(OrigYear) and (" [" .. OrigYear .. "]") or "";
Agency = is_set(Agency) and (sepc .. " " .. Agency) or "";
if is_set(Volume) then
if ( mw.ustring.len(Volume) > 4 )
then Volume = sepc .." " .. Volume;
else Volume = " <b>" .. hyphentodash(Volume) .. "</b>";
end
end
------------------------------------ totally unrelated data
if is_set(Via) then
Via = " " .. wrap_msg ('via', Via);
end
--[[
Subscription implies paywall; Registration does not. If both are used in a citation, the subscription required link
note is displayed. There are no error messages for this condition.
]]
if inArray(SubscriptionRequired:lower(), {'yes', 'true', 'y'}) then
SubscriptionRequired = sepc .. " " .. cfg.messages['subscription']; -- subscription required message
elseif inArray(RegistrationRequired:lower(), {'yes', 'true', 'y'}) then
SubscriptionRequired = sepc .. " " .. cfg.messages['registration']; -- registration required message
else
SubscriptionRequired = ''; -- either or both might be set to something other than yes true y
end
if is_set(AccessDate) then
local retrv_text = " " .. cfg.messages['retrieved']
AccessDate = nowrap_date (AccessDate); -- wrap in nowrap span if date in appropriate format
if (sepc ~= ".") then retrv_text = retrv_text:lower() end -- if 'citation', lower case
AccessDate = substitute (retrv_text, AccessDate); -- add retrieved text
-- neither of these work; don't know why; it seems that substitute() isn't being called
AccessDate = substitute (cfg.presentation['accessdate'], {sepc, AccessDate}); -- allow editors to hide accessdates
end
if is_set(ID) then ID = sepc .." ".. ID; end
if "thesis" == config.CitationClass and is_set(Docket) then
ID = sepc .." Docket ".. Docket .. ID;
end
if "report" == config.CitationClass and is_set(Docket) then -- for cite report when |docket= is set
ID = sepc .. ' ' .. Docket; -- overwrite ID even if |id= is set
end
ID_list = buildidlist( ID_list, {DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN, Embargo=Embargo} );
if is_set(URL) then
URL = " " .. externallink( URL, nil, URLorigin );
end
if is_set(Quote) then
if Quote:sub(1,1) == '"' and Quote:sub(-1,-1) == '"' then
Quote = Quote:sub(2,-2);
end
Quote = sepc .." " .. wrap_style ('quoted-text', Quote ); -- wrap in <q>...</q> tags
PostScript = ""; -- CS1 does not supply terminal punctuation when |quote= is set
end
local Archived
if is_set(ArchiveURL) then
if not is_set(ArchiveDate) then
ArchiveDate = seterror('archive_missing_date');
end
if "no" == DeadURL then
local arch_text = cfg.messages['archived'];
if sepc ~= "." then arch_text = arch_text:lower() end
Archived = sepc .. " " .. substitute( cfg.messages['archived-not-dead'],
{ externallink( ArchiveURL, arch_text ), ArchiveDate } );
if not is_set(OriginalURL) then
Archived = Archived .. " " .. seterror('archive_missing_url');
end
elseif is_set(OriginalURL) then
local arch_text = cfg.messages['archived-dead'];
if sepc ~= "." then arch_text = arch_text:lower() end
Archived = sepc .. " " .. substitute( arch_text,
{ externallink( OriginalURL, cfg.messages['original'] ), ArchiveDate } );
else
local arch_text = cfg.messages['archived-missing'];
if sepc ~= "." then arch_text = arch_text:lower() end
Archived = sepc .. " " .. substitute( arch_text,
{ seterror('archive_missing_url'), ArchiveDate } );
end
else
Archived = ""
end
local Lay
if is_set(LayURL) then
if is_set(LayDate) then LayDate = " (" .. LayDate .. ")" end
if is_set(LaySource) then
LaySource = " – ''" .. safeforitalics(LaySource) .. "''";
else
LaySource = "";
end
if sepc == '.' then
Lay = sepc .. " " .. externallink( LayURL, cfg.messages['lay summary'] ) .. LaySource .. LayDate
else
Lay = sepc .. " " .. externallink( LayURL, cfg.messages['lay summary']:lower() ) .. LaySource .. LayDate
end
else
Lay = "";
end
if is_set(Transcript) then
if is_set(TranscriptURL) then Transcript = externallink( TranscriptURL, Transcript ); end
elseif is_set(TranscriptURL) then
Transcript = externallink( TranscriptURL, nil, TranscriptURLorigin );
end
local Publisher;
if is_set(Periodical) and
not inArray(config.CitationClass, {"encyclopaedia","web","pressrelease","podcast"}) then
if is_set(PublisherName) then
if is_set(PublicationPlace) then
Publisher = PublicationPlace .. ": " .. PublisherName;
else
Publisher = PublisherName;
end
elseif is_set(PublicationPlace) then
Publisher= PublicationPlace;
else
Publisher = "";
end
if is_set(PublicationDate) then
if is_set(Publisher) then
Publisher = Publisher .. ", " .. wrap_msg ('published', PublicationDate);
else
Publisher = PublicationDate;
end
end
if is_set(Publisher) then
Publisher = " (" .. Publisher .. ")";
end
else
if is_set(PublicationDate) then
PublicationDate = " (" .. wrap_msg ('published', PublicationDate) .. ")";
end
if is_set(PublisherName) then
if is_set(PublicationPlace) then
Publisher = sepc .. " " .. PublicationPlace .. ": " .. PublisherName .. PublicationDate;
else
Publisher = sepc .. " " .. PublisherName .. PublicationDate;
end
elseif is_set(PublicationPlace) then
Publisher= sepc .. " " .. PublicationPlace .. PublicationDate;
else
Publisher = PublicationDate;
end
end
-- Several of the above rely upon detecting this as nil, so do it last.
if is_set(Periodical) then
if is_set(Title) or is_set(TitleNote) then
Periodical = sepc .. " " .. wrap_style ('italic-title', Periodical)
else
Periodical = wrap_style ('italic-title', Periodical)
end
end
--[[
Handle the oddity that is cite speech. This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be " (Speech)" so that
the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
]]
if "speech" == config.CitationClass then -- cite speech only
TitleNote = " (Speech)"; -- annotate the citation
if is_set (Periodical) then -- if Periodical, perhaps because of an included |website= or |journal= parameter
if is_set (Conference) then -- and if |event= is set
Conference = Conference .. sepc .. " "; -- then add appropriate punctuation to the end of the Conference variable before rendering
end
end
end
-- Piece all bits together at last. Here, all should be non-nil.
-- We build things this way because it is more efficient in LUA
-- not to keep reassigning to the same string variable over and over.
local tcommon
if inArray(config.CitationClass, {"journal","citation"}) and is_set(Periodical) then
if is_set(Others) then Others = Others .. sepc .. " " end
tcommon = safejoin( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Scale, Series,
Language, Cartography, Edition, Publisher, Agency, Volume, Issue}, sepc );
else
tcommon = safejoin( {Title, TitleNote, Conference, Periodical, Format, TitleType, Scale, Series, Language,
Volume, Issue, Others, Cartography, Edition, Publisher, Agency}, sepc );
end
if #ID_list > 0 then
ID_list = safejoin( { sepc .. " ", table.concat( ID_list, sepc .. " " ), ID }, sepc );
else
ID_list = ID;
end
local idcommon = safejoin( { ID_list, URL, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );
local text;
local pgtext = Position .. Page .. Pages .. At;
if is_set(Authors) then
if is_set(Coauthors) then
local sep = '; ';
if 'vanc' == NameListFormat then
sep = ', ';
end
Authors = Authors .. sep .. Coauthors;
end
if is_set(Date) then
Date = " ("..Date..")" .. OrigYear .. sepc .. " "
elseif string.sub(Authors,-1,-1) == sepc then
Authors = Authors .. " "
else
Authors = Authors .. sepc .. " "
end
if is_set(Editors) then
local in_text = " ";
local post_text = "";
if is_set(Chapter) then
in_text = in_text .. cfg.messages['in'] .. " "
else
if EditorCount <= 1 then
post_text = ", " .. cfg.messages['editor'];
else
post_text = ", " .. cfg.messages['editors'];
end
end
if (sepc ~= '.') then in_text = in_text:lower() end
Editors = in_text .. Editors .. post_text;
if (string.sub(Editors,-1,-1) == sepc)
then Editors = Editors .. " "
else Editors = Editors .. sepc .. " "
end
end
text = safejoin( {Authors, Date, Chapter, Place, Editors, tcommon }, sepc );
text = safejoin( {text, pgtext, idcommon}, sepc );
elseif is_set(Editors) then
if is_set(Date) then
if EditorCount <= 1 then
Editors = Editors .. ", " .. cfg.messages['editor'];
else
Editors = Editors .. ", " .. cfg.messages['editors'];
end
Date = " (" .. Date ..")" .. OrigYear .. sepc .. " "
else
if EditorCount <= 1 then
Editors = Editors .. " (" .. cfg.messages['editor'] .. ")" .. sepc .. " "
else
Editors = Editors .. " (" .. cfg.messages['editors'] .. ")" .. sepc .. " "
end
end
text = safejoin( {Editors, Date, Chapter, Place, tcommon}, sepc );
text = safejoin( {text, pgtext, idcommon}, sepc );
else
if is_set(Date) then
if ( string.sub(tcommon,-1,-1) ~= sepc )
then Date = sepc .." " .. Date .. OrigYear
else Date = " " .. Date .. OrigYear
end
end
if config.CitationClass=="journal" and is_set(Periodical) then
text = safejoin( {Chapter, Place, tcommon}, sepc );
text = safejoin( {text, pgtext, Date, idcommon}, sepc );
else
text = safejoin( {Chapter, Place, tcommon, Date}, sepc );
text = safejoin( {text, pgtext, idcommon}, sepc );
end
end
if is_set(PostScript) and PostScript ~= sepc then
text = safejoin( {text, sepc}, sepc ); --Deals with italics, spaces, etc.
text = text:sub(1,-sepc:len()-1);
-- text = text:sub(1,-2); --Remove final separator (assumes that sepc is only one character)
end
text = safejoin( {text, PostScript}, sepc );
-- Now enclose the whole thing in a <span/> element
local options = {};
if is_set(config.CitationClass) and config.CitationClass ~= "citation" then
options.class = "citation " .. config.CitationClass;
else
options.class = "citation";
end
if is_set(Ref) and Ref:lower() ~= "none" then
local id = Ref
if ( "harv" == Ref ) then
local names = {} --table of last names & year
if #a > 0 then
for i,v in ipairs(a) do
names[i] = v.last
if i == 4 then break end
end
elseif #e > 0 then
for i,v in ipairs(e) do
names[i] = v.last
if i == 4 then break end
end
end
names[ #names + 1 ] = first_set(Year, anchor_year); -- Year first for legacy citations and for YMD dates that require disambiguation
id = anchorid(names)
end
options.id = id;
end
if string.len(text:gsub("<span[^>/]*>.-</span>", ""):gsub("%b<>","")) <= 2 then
z.error_categories = {};
text = seterror('empty_citation');
z.message_tail = {};
end
if is_set(options.id) then
text = '<span id="' .. mw.uri.anchorEncode(options.id) ..'" class="' .. mw.text.nowiki(options.class) .. '">' .. text .. "</span>";
else
text = '<span class="' .. mw.text.nowiki(options.class) .. '">' .. text .. "</span>";
end
local empty_span = '<span style="display:none;"> </span>';
-- Note: Using display: none on then COinS span breaks some clients.
local OCinS = '<span title="' .. OCinSoutput .. '" class="Z3988">' .. empty_span .. '</span>';
text = text .. OCinS;
if #z.message_tail ~= 0 then
text = text .. " ";
for i,v in ipairs( z.message_tail ) do
if is_set(v[1]) then
if i == #z.message_tail then
text = text .. errorcomment( v[1], v[2] );
else
text = text .. errorcomment( v[1] .. "; ", v[2] );
end
end
end
end
no_tracking_cats = no_tracking_cats:lower();
if inArray(no_tracking_cats, {"", "no", "false", "n"}) then
for _, v in ipairs( z.error_categories ) do
text = text .. '[[Category:' .. v ..']]';
end
for _, v in ipairs( z.maintenance_cats ) do -- append maintenance categories
text = text .. '[[Category:' .. v ..']]';
end
for _, v in ipairs( z.properties_cats ) do -- append maintenance categories
text = text .. '[[Category:' .. v ..']]';
end
end
return text
end
-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
local pframe = frame:getParent()
if nil ~= string.find( frame:getTitle(), 'sandbox', 1, true ) then -- did the {{#invoke:}} use sandbox version?
cfg = mw.loadData( 'Module:Citation/CS1/Configuration/sandbox' ); -- load sandbox versions of Configuration and Whitelist and ...
whitelist = mw.loadData( 'Module:Citation/CS1/Whitelist/sandbox' );
dates = require('Module:Citation/CS1/Date_validation/sandbox').dates -- ... sandbox version of date validation code
else -- otherwise
cfg = mw.loadData( 'Module:Citation/CS1/Configuration' ); -- load live versions of Configuration and Whitelist and ...
whitelist = mw.loadData( 'Module:Citation/CS1/Whitelist' );
dates = require('Module:Citation/CS1/Date_validation').dates -- ... live version of date validation code
end
local args = {};
local suggestions = {};
local error_text, error_state;
local config = {};
for k, v in pairs( frame.args ) do
config[k] = v;
args[k] = v;
end
for k, v in pairs( pframe.args ) do
if v ~= '' then
if not validate( k ) then
error_text = "";
if type( k ) ~= 'string' then
-- Exclude empty numbered parameters
if v:match("%S+") ~= nil then
error_text, error_state = seterror( 'text_ignored', {v}, true );
end
elseif validate( k:lower() ) then
error_text, error_state = seterror( 'parameter_ignored_suggest', {k, k:lower()}, true );
else
if #suggestions == 0 then
suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );
end
if suggestions[ k:lower() ] ~= nil then
error_text, error_state = seterror( 'parameter_ignored_suggest', {k, suggestions[ k:lower() ]}, true );
else
error_text, error_state = seterror( 'parameter_ignored', {k}, true );
end
end
if error_text ~= '' then
table.insert( z.message_tail, {error_text, error_state} );
end
end
args[k] = v;
elseif args[k] ~= nil or (k == 'postscript') then
args[k] = v;
end
end
return citation0( config, args)
end
return z
nxx5xkgkqtad1cfa2vnlkq7s3kmefh6
189435
189420
2022-08-16T15:31:29Z
Venise12mai1834
8884
Scribunto
text/plain
local z = {
error_categories = {}; -- for categorizing citations that contain errors
error_ids = {};
message_tail = {};
maintenance_cats = {}; -- for categorizing citations that aren't erroneous per se, but could use a little work
properties_cats = {}; -- for categorizing citations based on certain properties, language of source for instance
}
-- Whether variable is set or not
function is_set( var )
return not (var == nil or var == '');
end
-- First set variable or nil if none
function first_set(...)
local list = {...};
for _, var in pairs(list) do
if is_set( var ) then
return var;
end
end
end
-- Whether needle is in haystack
function inArray( needle, haystack )
if needle == nil then
return false;
end
for n,v in ipairs( haystack ) do
if v == needle then
return n;
end
end
return false;
end
--[[
Categorize and emit an error message when the citation contains one or more deprecated parameters. Because deprecated parameters (currently |month=,
|coauthor=, and |coauthors=) aren't related to each other and because these parameters may be concatenated into the variables used by |date= and |author#= (and aliases)
details of which parameter caused the error message are not provided. Only one error message is emitted regardless of the number of deprecated parameters in the citation.
]]
function deprecated_parameter(name)
if true ~= Page_in_deprecated_cat then -- if we haven't been here before then set a
Page_in_deprecated_cat=true; -- sticky flag so that if there are more than one deprecated parameter the category is added only once
table.insert( z.message_tail, { seterror( 'deprecated_params', {name}, true ) } ); -- add error message
end
end
-- Populates numbered arguments in a message string using an argument table.
function substitute( msg, args )
return args and mw.message.newRawMessage( msg, args ):plain() or msg;
end
--[[--------------------------< K E R N _ Q U O T E S >--------------------------------------------------------
Apply kerning to open the space between the quote mark provided by the Module and a leading or trailing quote mark contained in a |title= or |chapter= parameter's value.
This function will positive kern either single or double quotes:
"'Unkerned title with leading and trailing single quote marks'"
" 'Kerned title with leading and trailing single quote marks' " (in real life the kerning isn't as wide as this example)
Double single quotes (italic or bold wikimarkup) are not kerned.
Call this function for chapter titles, for website titles, etc; not for book titles.
]]
function kern_quotes (str)
local cap='';
local cap2='';
cap, cap2 = str:match ("^([\"\'])([^\'].+)"); -- match leading double or single quote but not double single quotes
if is_set (cap) then
str = substitute (cfg.presentation['kern-left'], {cap, cap2});
end
cap, cap2 = str:match ("^(.+[^\'])([\"\'])$")
if is_set (cap) then
str = substitute (cfg.presentation['kern-right'], {cap, cap2});
end
return str;
end
--[[--------------------------< F O R M A T _ S C R I P T _ V A L U E >----------------------------------------
|script-title= holds title parameters that are not written in Latin based scripts: Chinese, Japanese, Arabic, Hebrew, etc. These scripts should
not be italicized and may be written right-to-left. The value supplied by |script-title= is concatenated onto Title after Title has been wrapped
in italic markup.
Regardless of language, all values provided by |script-title= are wrapped in <bdi>...</bdi> tags to isolate rtl languages from the English left to right.
|script-title= provides a unique feature. The value in |script-title= may be prefixed with a two-character ISO639 language code and a colon:
|script-title=ja:*** *** (where * represents a Japanese character)
Spaces between the two-character code and the colon and the colon and the first script character are allowed:
|script-title=ja : *** ***
|script-title=ja: *** ***
|script-title=ja :*** ***
Spaces preceding the prefix are allowed: |script-title = ja:*** ***
The prefix is checked for validity. If it is a valid ISO639 language code, the lang attribute (lang="ja") is added to the <bdi> tag so that browsers can
know the language the tag contains. This may help the browser render the script more correctly. If the prefix is invalid, the lang attribute
is not added. At this time there is no error message for this condition.
At this writing, only |script-title= is supported. It is anticipated that additional parameters will be created to use this function.
TODO: error messages when prefix is invalid ISO639 code; when script_value has prefix but no script;
]]
function format_script_value (script_value)
local lang=''; -- initialize to empty string
local name;
if script_value:match('^%l%l%s*:') then -- if first 3 non-space characters are script language prefix
lang = script_value:match('^(%l%l)%s*:%s*%S.*'); -- get the language prefix or nil if there is no script
if not is_set (lang) then
return ''; -- script_value was just the prefix so return empty string
end
-- if we get this far we have prefix and script
name = mw.language.fetchLanguageName( lang, "en" ); -- get language name so that we can use it to categorize
if is_set (name) then -- is prefix a proper ISO 639 language code?
script_value = script_value:gsub ('^%l%l%s*:%s*', ''); -- strip prefix from script
-- is prefix one of these language codes?
if inArray (lang, {'ar', 'bs', 'dv', 'el', 'fa', 'hy', 'ja', 'ko', 'ku', 'he', 'ps', 'ru', 'sd', 'sr', 'th', 'uk', 'ug', 'yi', 'zh'}) then
table.insert( z.properties_cats, 'CS1 uses ' .. name .. '-language script ('..lang..')'); -- categorize in language-specific categories
else
table.insert( z.properties_cats, 'CS1 uses foreign language script'); -- use this category as a catchall until language-specific category is available
end
lang = ' lang="' .. lang .. '" '; -- convert prefix into a lang attribute
else
lang = ''; -- invalid so set lang to empty string
end
end
script_value = substitute (cfg.presentation['bdi'], {lang, script_value}); -- isolate in case script is rtl
return script_value;
end
--[[--------------------------< S C R I P T _ C O N C A T E N A T E >------------------------------------------
Initially for |title= and |script-title=, this function concatenates those two parameter values after the script value has been
wrapped in <bdi> tags.
]]
function script_concatenate (title, script)
if is_set (script) then
script = format_script_value (script); -- <bdi> tags, lang atribute, categorization, etc; returns empty string on error
if is_set (script) then
title = title .. ' ' .. script; -- concatenate title and script title
end
end
return title;
end
--[[--------------------------< W R A P _ S T Y L E >----------------------------------------------------------
Applies styling to various parameters. Supplied string is wrapped using a message_list configuration taking one
argument; protects italic styled parameters. Additional text taken from citation_config.presentation - the reason
this function is similar to but separate from wrap_msg().
]]
function wrap_style (key, str)
if not is_set( str ) then
return "";
elseif inArray( key, { 'italic-title', 'trans-italic-title' } ) then
str = safeforitalics( str );
end
return substitute( cfg.presentation[key], {str} );
end
--[[--------------------------< W R A P _ M S G >--------------------------------------------------------------
Applies additional message text to various parameter values. Supplied string is wrapped using a message_list
configuration taking one argument. Supports lower case text for {{citation}} templates. Additional text taken
from citation_config.messages - the reason this function is similar to but separate from wrap_style().
]]
function wrap_msg (key, str, lower)
if not is_set( str ) then
return "";
end
if true == lower then
local msg;
msg = cfg.messages[key]:lower(); -- set the message to lower case before
str = substitute( msg, {str} ); -- including template text
return str;
else
return substitute( cfg.messages[key], {str} );
end
end
--[[--------------------------< F O R M A T _ C H A P T E R _ T I T L E >--------------------------------------
Format the three chapter parameters: |chapter=, |trans-chapter=, and |chapter-url= into a single Chapter meta-
parameter (chapter_url_source used for error messages).
]]
function format_chapter_title (chapter, transchapter, chapterurl, chapter_url_source)
local chapter_error = '';
if not is_set (chapter) then
chapter = ''; -- just to be safe for concatenation
if is_set (transchapter) then
chapter = wrap_style ('trans-quoted-title', transchapter);
chapter_error = " " .. seterror ('trans_missing_chapter');
end
if is_set (chapterurl) then
chapter = externallink (chapterurl, chapter, chapter_url_source); -- adds bare_url_missing_title error if appropriate
end
return chapter .. chapter_error;
else -- here when chapter is set
chapter = kern_quotes (chapter); -- if necessary, separate chapter title's leading and trailing quote marks from Module provided quote marks
chapter = wrap_style ('quoted-title', chapter);
if is_set (transchapter) then
transchapter = wrap_style ('trans-quoted-title', transchapter);
chapter = chapter .. ' ' .. transchapter;
end
if is_set (chapterurl) then
chapter = externallink (chapterurl, chapter); -- adds bare_url_missing_title error if appropriate
end
end
return chapter;
end
--[[
Argument wrapper. This function provides support for argument
mapping defined in the configuration file so that multiple names
can be transparently aliased to single internal variable.
]]
function argument_wrapper( args )
local origin = {};
return setmetatable({
ORIGIN = function( self, k )
local dummy = self[k]; --force the variable to be loaded.
return origin[k];
end
},
{
__index = function ( tbl, k )
if origin[k] ~= nil then
return nil;
end
local args, list, v = args, cfg.aliases[k];
if type( list ) == 'table' then
v, origin[k] = selectone( args, list, 'redundant_parameters' );
if origin[k] == nil then
origin[k] = ''; -- Empty string, not nil
end
elseif list ~= nil then
v, origin[k] = args[list], list;
else
-- maybe let through instead of raising an error?
-- v, origin[k] = args[k], k;
error( cfg.messages['unknown_argument_map'] );
end
-- Empty strings, not nil;
if v == nil then
v = cfg.defaults[k] or '';
origin[k] = '';
end
tbl = rawset( tbl, k, v );
return v;
end,
});
end
--[[
Looks for a parameter's name in the whitelist.
Parameters in the whitelist can have three values:
true - active, supported parameters
false - deprecated, supported parameters
nil - unsupported parameters
]]
function validate( name )
local name = tostring( name );
local state = whitelist.basic_arguments[ name ];
-- Normal arguments
if true == state then return true; end -- valid actively supported parameter
if false == state then
deprecated_parameter (name); -- parameter is deprecated but still supported
return true;
end
-- Arguments with numbers in them
name = name:gsub( "%d+", "#" ); -- replace digit(s) with # (last25 becomes last#
state = whitelist.numbered_arguments[ name ];
if true == state then return true; end -- valid actively supported parameter
if false == state then
deprecated_parameter (name); -- parameter is deprecated but still supported
return true;
end
return false; -- Not supported because not found or name is set to nil
end
--[[--------------------------< E R R O R C O M M E N T >------------------------------------------------------
Wraps error messages with css markup according to the state of hidden.
]]
function errorcomment( content, hidden )
return substitute( hidden and cfg.presentation['hidden-error'] or cfg.presentation['visible-error'], content );
end
--[[
Sets an error condition and returns the appropriate error message. The actual placement
of the error message in the output is the responsibility of the calling function.
]]
function seterror( error_id, arguments, raw, prefix, suffix )
local error_state = cfg.error_conditions[ error_id ];
prefix = prefix or "";
suffix = suffix or "";
if error_state == nil then
error( cfg.messages['undefined_error'] );
elseif is_set( error_state.category ) then
table.insert( z.error_categories, error_state.category );
end
local message = substitute( error_state.message, arguments );
message = message .. " ([[" .. cfg.messages['help page link'] ..
"#" .. error_state.anchor .. "|" ..
cfg.messages['help page label'] .. "]])";
z.error_ids[ error_id ] = true;
if inArray( error_id, { 'bare_url_missing_title', 'trans_missing_title' } )
and z.error_ids['citation_missing_title'] then
return '', false;
end
message = table.concat({ prefix, message, suffix });
if raw == true then
return message, error_state.hidden;
end
return errorcomment( message, error_state.hidden );
end
-- Formats a wiki style external link
function externallinkid(options)
local url_string = options.id;
if options.encode == true or options.encode == nil then
url_string = mw.uri.encode( url_string );
end
return mw.ustring.format( '[[%s|%s]]%s[%s%s%s %s]',
options.link, options.label, options.separator or " ",
options.prefix, url_string, options.suffix or "",
mw.text.nowiki(options.id)
);
end
-- Formats a wiki style internal link
function internallinkid(options)
return mw.ustring.format( '[[%s|%s]]%s[[%s%s%s|%s]]',
options.link, options.label, options.separator or " ",
options.prefix, options.id, options.suffix or "",
mw.text.nowiki(options.id)
);
end
-- Format an external link with error checking
function externallink( URL, label, source )
local error_str = "";
if not is_set( label ) then
label = URL;
if is_set( source ) then
error_str = seterror( 'bare_url_missing_title', { wrap_style ('parameter', source) }, false, " " );
else
error( cfg.messages["bare_url_no_origin"] );
end
end
if not checkurl( URL ) then
error_str = seterror( 'bad_url', {}, false, " " ) .. error_str;
end
return table.concat({ "[", URL, " ", safeforurl( label ), "]", error_str });
end
--[[--------------------------< N O W R A P _ D A T E >--------------------------------------------------------
When date is YYYY-MM-DD format wrap in nowrap span: <span ...>YYYY-MM-DD</span>. When date is DD MMMM YYYY or is
MMMM DD, YYYY then wrap in nowrap span: <span ...>DD MMMM</span> YYYY or <span ...>MMMM DD,</span> YYYY
DOES NOT yet support MMMM YYYY or any of the date ranges.
]]
function nowrap_date (date)
local cap='';
local cap2='';
if date:match("^%d%d%d%d%-%d%d%-%d%d$") then
date = substitute (cfg.presentation['nowrap1'], date);
elseif date:match("%a+%s*%d%d?,%s*%d%d%d%d") or date:match ("%d%d?%s*%a+%s*%d%d%d%d") then
cap, cap2 = string.match (date, "^(.*)%s+(%d%d%d%d)$");
date = substitute (cfg.presentation['nowrap2'], {cap, cap2});
end
return date;
end
--[[--------------------------< A M A Z O N >------------------------------------------------------------------
Formats a link to Amazon. Do simple error checking: asin must be mix of 10 numeric or uppercase alpha
characters. If a mix, first character must be uppercase alpha; if all numeric, asins must be 10-digit
isbn. If 10-digit isbn, add a maintenance category so a bot or awb script can replace |asin= with |isbn=.
Error message if not 10 characters, if not isbn10, if mixed and first character is a digit.
]]
function amazon(id, domain)
local err_cat = ""
if not id:match("^[%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u]$") then
err_cat = ' ' .. seterror ('bad_asin'); -- asin is not a mix of 10 uppercase alpha and numeric characters
else
if id:match("^%d%d%d%d%d%d%d%d%d[%dX]$") then -- if 10-digit numeric (or 9 digits with terminal X)
if checkisbn( id ) then -- see if asin value is isbn10
table.insert( z.maintenance_cats, "CS1 maint: ASIN uses ISBN"); -- add to maint category
elseif not is_set (err_cat) then
err_cat = ' ' .. seterror ('bad_asin'); -- asin is not isbn10
end
elseif not id:match("^%u[%d%u]+$") then
err_cat = ' ' .. seterror ('bad_asin'); -- asin doesn't begin with uppercase alpha
end
end
if not is_set(domain) then
domain = "com";
elseif inArray (domain, {'jp', 'uk'}) then -- Japan, United Kingdom
domain = "co." .. domain;
elseif inArray (domain, {'au', 'br', 'mx'}) then -- Australia, Brazil, Mexico
domain = "com." .. domain;
end
local handler = cfg.id_handlers['ASIN'];
return externallinkid({link = handler.link,
label=handler.label , prefix="//www.amazon."..domain.."/dp/",id=id,
encode=handler.encode, separator = handler.separator}) .. err_cat;
end
--[[--------------------------< A R X I V >--------------------------------------------------------------------
See: http://arxiv.org/help/arxiv_identifier
format and error check arXiv identifier. There are three valid forms of the identifier:
the first form, valid only between date codes 9108 and 0703 is:
arXiv:<archive>.<class>/<date code><number><version>
where:
<archive> is a string of alpha characters - may be hyphenated; no other punctuation
<class> is a string of alpha characters - may be hyphenated; no other punctuation
<date code> is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
first digit of YY for this form can only 9 and 0
<number> is a three-digit number
<version> is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
the second form, valid from April 2007 through December 2014 is:
arXiv:<date code>.<number><version>
where:
<date code> is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
<number> is a four-digit number
<version> is a 1 or more digit number preceded with a lowercase v; no spaces
the third form, valid from January 2015 is:
arXiv:<date code>.<number><version>
where:
<date code> and <version> are as defined for 0704-1412
<number> is a five-digit number
]]
function arxiv (id)
local handler = cfg.id_handlers['ARXIV'];
local year, month, version;
local err_cat = ""
if id:match("^%a[%a%.%-]+/[90]%d[01]%d%d%d%d$") or id:match("^%a[%a%.%-]+/[90]%d[01]%d%d%d%dv%d+$") then -- test for the 9108-0703 format w/ & w/o version
year, month = id:match("^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d[v%d]*$");
year = tonumber(year);
month = tonumber(month);
if ((not (90 < year or 8 > year)) or (1 > month or 12 < month)) or -- if invalid year or invalid month
((91 == year and 7 > month) or (7 == year and 3 < month)) then -- if years ok, are starting and ending months ok?
err_cat = ' ' .. seterror( 'bad_arxiv' ); -- set error message
end
elseif id:match("^%d%d[01]%d%.%d%d%d%d$") or id:match("^%d%d[01]%d%.%d%d%d%dv%d+$") then -- test for the 0704-1412 w/ & w/o version
year, month = id:match("^(%d%d)([01]%d)%.%d%d%d%d[v%d]*$");
year = tonumber(year);
month = tonumber(month);
if ((7 > year) or (14 < year) or (1 > month or 12 < month)) or -- is year invalid or is month invalid? (doesn't test for future years)
((7 == year) and (4 > month)) then --or -- when year is 07, is month invalid (before April)?
err_cat = ' ' .. seterror( 'bad_arxiv' ); -- set error message
end
elseif id:match("^%d%d[01]%d%.%d%d%d%d%d$") or id:match("^%d%d[01]%d%.%d%d%d%d%dv%d+$") then -- test for the 1501- format w/ & w/o version
year, month = id:match("^(%d%d)([01]%d)%.%d%d%d%d%d[v%d]*$");
year = tonumber(year);
month = tonumber(month);
if ((15 > year) or (1 > month or 12 < month)) then -- is year invalid or is month invalid? (doesn't test for future years)
err_cat = ' ' .. seterror( 'bad_arxiv' ); -- set error message
end
else
err_cat = ' ' .. seterror( 'bad_arxiv' ); -- arXiv id doesn't match any format
end
return externallinkid({link = handler.link, label = handler.label,
prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end
--[[
lccn normalization (http://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
a. Remove it.
b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
1. All these characters should be digits, and there should be six or less. (not done in this function)
2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.
Returns a normalized lccn for lccn() to validate. There is no error checking (step 3.b.1) performed in this function.
]]
function normalize_lccn (lccn)
lccn = lccn:gsub ("%s", ""); -- 1. strip whitespace
if nil ~= string.find (lccn,'/') then
lccn = lccn:match ("(.-)/"); -- 2. remove forward slash and all character to the right of it
end
local prefix
local suffix
prefix, suffix = lccn:match ("(.+)%-(.+)"); -- 3.a remove hyphen by splitting the string into prefix and suffix
if nil ~= suffix then -- if there was a hyphen
suffix=string.rep("0", 6-string.len (suffix)) .. suffix; -- 3.b.2 left fill the suffix with 0s if suffix length less than 6
lccn=prefix..suffix; -- reassemble the lccn
end
return lccn;
end
--[[
Format LCCN link and do simple error checking. LCCN is a character string 8-12 characters long. The length of the LCCN dictates the character type of the first 1-3 characters; the
rightmost eight are always digits. http://info-uri.info/registry/OAIHandler?verb=GetRecord&metadataPrefix=reg&identifier=info:lccn/
length = 8 then all digits
length = 9 then lccn[1] is lower case alpha
length = 10 then lccn[1] and lccn[2] are both lower case alpha or both digits
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lower case alpha or both digits
length = 12 then lccn[1] and lccn[2] are both lower case alpha
]]
function lccn(lccn)
local handler = cfg.id_handlers['LCCN'];
local err_cat = ''; -- presume that LCCN is valid
local id = lccn; -- local copy of the lccn
id = normalize_lccn (id); -- get canonical form (no whitespace, hyphens, forward slashes)
local len = id:len(); -- get the length of the lccn
if 8 == len then
if id:match("[^%d]") then -- if LCCN has anything but digits (nil if only digits)
err_cat = ' ' .. seterror( 'bad_lccn' ); -- set an error message
end
elseif 9 == len then -- LCCN should be adddddddd
if nil == id:match("%l%d%d%d%d%d%d%d%d") then -- does it match our pattern?
err_cat = ' ' .. seterror( 'bad_lccn' ); -- set an error message
end
elseif 10 == len then -- LCCN should be aadddddddd or dddddddddd
if id:match("[^%d]") then -- if LCCN has anything but digits (nil if only digits) ...
if nil == id:match("^%l%l%d%d%d%d%d%d%d%d") then -- ... see if it matches our pattern
err_cat = ' ' .. seterror( 'bad_lccn' ); -- no match, set an error message
end
end
elseif 11 == len then -- LCCN should be aaadddddddd or adddddddddd
if not (id:match("^%l%l%l%d%d%d%d%d%d%d%d") or id:match("^%l%d%d%d%d%d%d%d%d%d%d")) then -- see if it matches one of our patterns
err_cat = ' ' .. seterror( 'bad_lccn' ); -- no match, set an error message
end
elseif 12 == len then -- LCCN should be aadddddddddd
if not id:match("^%l%l%d%d%d%d%d%d%d%d%d%d") then -- see if it matches our pattern
err_cat = ' ' .. seterror( 'bad_lccn' ); -- no match, set an error message
end
else
err_cat = ' ' .. seterror( 'bad_lccn' ); -- wrong length, set an error message
end
if not is_set (err_cat) and nil ~= lccn:find ('%s') then
err_cat = ' ' .. seterror( 'bad_lccn' ); -- lccn contains a space, set an error message
end
return externallinkid({link = handler.link, label = handler.label,
prefix=handler.prefix,id=lccn,separator=handler.separator, encode=handler.encode}) .. err_cat;
end
--[[
Format PMID and do simple error checking. PMIDs are sequential numbers beginning at 1 and counting up. This code checks the PMID to see that it
contains only digits and is less than test_limit; the value in local variable test_limit will need to be updated periodically as more PMIDs are issued.
]]
function pmid(id)
local test_limit = 30000000; -- update this value as PMIDs approach
local handler = cfg.id_handlers['PMID'];
local err_cat = ''; -- presume that PMID is valid
if id:match("[^%d]") then -- if PMID has anything but digits
err_cat = ' ' .. seterror( 'bad_pmid' ); -- set an error message
else -- PMID is only digits
local id_num = tonumber(id); -- convert id to a number for range testing
if 1 > id_num or test_limit < id_num then -- if PMID is outside test limit boundaries
err_cat = ' ' .. seterror( 'bad_pmid' ); -- set an error message
end
end
return externallinkid({link = handler.link, label = handler.label,
prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end
--[[
Determines if a PMC identifier's online version is embargoed. Compares the date in |embargo= against today's date. If embargo date is
in the future, returns true; otherwise, returns false because the embargo has expired or |embargo= not set in this cite.
]]
function is_embargoed(embargo)
if is_set(embargo) then
local lang = mw.getContentLanguage();
local good1, embargo_date, good2, todays_date;
good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
good2, todays_date = pcall( lang.formatDate, lang, 'U' );
if good1 and good2 and tonumber( embargo_date ) >= tonumber( todays_date ) then --is embargo date is in the future?
return true; -- still embargoed
end
end
return false; -- embargo expired or |embargo= not set
end
--[[
Format a PMC, do simple error checking, and check for embargoed articles.
The embargo parameter takes a date for a value. If the embargo date is in the future
the PMC identifier will not be linked to the article. If the embargo specifies a date in the past, or if it is empty or omitted, then
the PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.
PMCs are sequential numbers beginning at 1 and counting up. This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.
]]
function pmc(id, embargo)
local test_limit = 5000000; -- update this value as PMCs approach
local handler = cfg.id_handlers['PMC'];
local err_cat = ''; -- presume that PMC is valid
local text;
if id:match("[^%d]") then -- if PMC has anything but digits
err_cat = ' ' .. seterror( 'bad_pmc' ); -- set an error message
else -- PMC is only digits
local id_num = tonumber(id); -- convert id to a number for range testing
if 1 > id_num or test_limit < id_num then -- if PMC is outside test limit boundaries
err_cat = ' ' .. seterror( 'bad_pmc' ); -- set an error message
end
end
if is_embargoed(embargo) then
text="[[" .. handler.link .. "|" .. handler.label .. "]]:" .. handler.separator .. id .. err_cat; --still embargoed so no external link
else
text = externallinkid({link = handler.link, label = handler.label, --no embargo date, ok to link to article
prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end
return text;
end
-- Formats a DOI and checks for DOI errors.
-- DOI names contain two parts: prefix and suffix separated by a forward slash.
-- Prefix: directory indicator '10.' followed by a registrant code
-- Suffix: character string of any length chosen by the registrant
-- This function checks a DOI name for: prefix/suffix. If the doi name contains spaces or endashes,
-- or, if it ends with a period or a comma, this function will emit a bad_doi error message.
-- DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
-- and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely if ever used in doi names.
function doi(id, inactive)
local cat = ""
local handler = cfg.id_handlers['DOI'];
local text;
if is_set(inactive) then
local inactive_year = inactive:match("%d%d%d%d") or ''; -- try to get the year portion from the inactive date
text = "[[" .. handler.link .. "|" .. handler.label .. "]]:" .. id;
if is_set(inactive_year) then
table.insert( z.error_categories, "Pages with DOIs inactive since " .. inactive_year );
else
table.insert( z.error_categories, "Pages with inactive DOIs" ); -- when inactive doesn't contain a recognizable year
end
inactive = " (" .. cfg.messages['inactive'] .. " " .. inactive .. ")"
else
text = externallinkid({link = handler.link, label = handler.label,
prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
inactive = ""
end
if nil == id:match("^10%.[^%s–]-/[^%s–]-[^%.,]$") then -- doi must begin with '10.', must contain a fwd slash, must not contain spaces or endashes, and must not end with period or comma
cat = ' ' .. seterror( 'bad_doi' );
end
return text .. inactive .. cat
end
-- Formats an OpenLibrary link, and checks for associated errors.
function openlibrary(id)
local code = id:match("^%d+([AMW])$"); -- only digits followed by 'A', 'M', or 'W'
local handler = cfg.id_handlers['OL'];
if ( code == "A" ) then
return externallinkid({link=handler.link, label=handler.label,
prefix="http://openlibrary.org/authors/OL",id=id, separator=handler.separator,
encode = handler.encode})
elseif ( code == "M" ) then
return externallinkid({link=handler.link, label=handler.label,
prefix="http://openlibrary.org/books/OL",id=id, separator=handler.separator,
encode = handler.encode})
elseif ( code == "W" ) then
return externallinkid({link=handler.link, label=handler.label,
prefix= "http://openlibrary.org/works/OL",id=id, separator=handler.separator,
encode = handler.encode})
else
return externallinkid({link=handler.link, label=handler.label,
prefix= "http://openlibrary.org/OL",id=id, separator=handler.separator,
encode = handler.encode}) ..
' ' .. seterror( 'bad_ol' );
end
end
--[[
Validate and format an issn. This code fixes the case where an editor has included an ISSN in the citation but has separated the two groups of four
digits with a space. When that condition occurred, the resulting link looked like this:
|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327] -- can't have spaces in an external link
This code now prevents that by inserting a hyphen at the issn midpoint. It also validates the issn for length and makes sure that the checkdigit agrees
with the calculated value. Incorrect length (8 digits), characters other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn
error message. The issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.
]]
function issn(id)
local issn_copy = id; -- save a copy of unadulterated issn; use this version for display if issn does not validate
local handler = cfg.id_handlers['ISSN'];
local text;
local valid_issn = true;
id=id:gsub( "[%s-–]", "" ); -- strip spaces, hyphens, and endashes from the issn
if 8 ~= id:len() or nil == id:match( "^%d*X?$" ) then -- validate the issn: 8 digits long, containing only 0-9 or X in the last position
valid_issn=false; -- wrong length or improper character
else
valid_issn=is_valid_isxn(id, 8); -- validate issn
end
if true == valid_issn then
id = string.sub( id, 1, 4 ) .. "-" .. string.sub( id, 5 ); -- if valid, display correctly formatted version
else
id = issn_copy; -- if not valid, use the show the invalid issn with error message
end
text = externallinkid({link = handler.link, label = handler.label,
prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
if false == valid_issn then
text = text .. ' ' .. seterror( 'bad_issn' ) -- add an error message if the issn is invalid
end
return text
end
--[[--------------------------< M E S S A G E _ I D >----------------------------------------------------------
Validate and format a usenet message id. Simple error checking, looks for 'id-left@id-right' not enclosed in
'<' and/or '>' angle brackets.
]]
function message_id (id)
local handler = cfg.id_handlers['USENETID'];
text = externallinkid({link = handler.link, label = handler.label,
prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
if not id:match('^.+@.+$') or not id:match('^[^<].*[^>]$')then -- doesn't have '@' or has one or first or last character is '< or '>'
text = text .. ' ' .. seterror( 'bad_message_id' ) -- add an error message if the message id is invalid
end
return text
end
--[[--------------------------< S E T _ T I T L E T Y P E >----------------------------------------------------
This function sets default title types (equivalent to the citation including |type=<default value>) for those citations that have defaults.
Also handles the special case where it is desirable to omit the title type from the rendered citation (|type=none).
]]
function set_titletype(cite_class, title_type)
if is_set(title_type) then
if "none" == title_type then
title_type = ""; -- if |type=none then type parameter not displayed
end
return title_type; -- if |type= has been set to any other value use that value
end
if "AV-media-notes" == cite_class or "DVD-notes" == cite_class then -- if this citation is cite AV media notes or cite DVD notes
return "Media notes"; -- display AV media notes / DVD media notes annotation
elseif "mailinglist" == cite_class then -- if this citation is cite mailing list
return "Mailing list"; -- display mailing list annotation
elseif "podcast" == cite_class then -- if this citation is cite podcast
return "Podcast"; -- display podcast annotation
elseif "pressrelease" == cite_class then -- if this citation is cite press release
return "Press release"; -- display press release annotation
elseif "report" == cite_class then -- if this citation is cite report
return "Report"; -- display report annotation
elseif "techreport" == cite_class then -- if this citation is cite techreport
return "Technical report"; -- display techreport annotation
elseif "thesis" == cite_class then -- if this citation is cite thesis (degree option handled after this function returns)
return "Thesis"; -- display simple thesis annotation (without |degree= modification)
end
end
--[[
Determines whether a URL string is valid
At present the only check is whether the string appears to
be prefixed with a URI scheme. It is not determined whether
the URI scheme is valid or whether the URL is otherwise well
formed.
]]
function checkurl( url_str )
-- Protocol-relative or URL scheme
return url_str:sub(1,2) == "//" or url_str:match( "^[^/]*:" ) ~= nil;
end
-- Removes irrelevant text and dashes from ISBN number
-- Similar to that used for Special:BookSources
function cleanisbn( isbn_str )
return isbn_str:gsub( "[^-0-9X]", "" );
end
--[[--------------------------< E S C A P E _ L U A _ M A G I C _ C H A R S >----------------------------------
Returns a string where all of lua's magic characters have been escaped. This is important because functions like
string.gsub() treat their pattern and replace strings as patterns, not literal strings.
]]
function escape_lua_magic_chars (argument)
argument = argument:gsub("%%", "%%%%"); -- replace % with %%
argument = argument:gsub("([%^%$%(%)%.%[%]%*%+%-%?])", "%%%1"); -- replace all other lua magic pattern characters
return argument;
end
--[[--------------------------< S T R I P _ A P O S T R O P H E _ M A R K U P >--------------------------------
Strip wiki italic and bold markup from argument so that it doesn't contaminate COinS metadata.
This function strips common patterns of apostrophe markup. We presume that editors who have taken the time to
markup a title have, as a result, provided valid markup. When they don't, some single apostrophes are left behind.
]]
function strip_apostrophe_markup (argument)
if not is_set (argument) then return argument; end
while true do
if argument:match ("%'%'%'%'%'") then -- bold italic (5)
argument=argument:gsub("%'%'%'%'%'", ""); -- remove all instances of it
elseif argument:match ("%'%'%'%'") then -- italic start and end without content (4)
argument=argument:gsub("%'%'%'%'", "");
elseif argument:match ("%'%'%'") then -- bold (3)
argument=argument:gsub("%'%'%'", "");
elseif argument:match ("%'%'") then -- italic (2)
argument=argument:gsub("%'%'", "");
else
break;
end
end
return argument; -- done
end
--[[--------------------------< M A K E _ C O I N S _ T I T L E >----------------------------------------------
Makes a title for COinS from Title and / or ScriptTitle (or any other name-script pairs)
Apostrophe markup (bold, italics) is stripped from each value so that the COinS metadata isn't correupted with strings
of %27%27...
]]
function make_coins_title (title, script)
if is_set (title) then
title = strip_apostrophe_markup (title); -- strip any apostrophe markup
else
title=''; -- if not set, make sure title is an empty string
end
if is_set (script) then
script = script:gsub ('^%l%l%s*:%s*', ''); -- remove language prefix if present (script value may now be empty string)
script = strip_apostrophe_markup (script); -- strip any apostrophe markup
else
script=''; -- if not set, make sure script is an empty string
end
if is_set (title) and is_set (script) then
script = ' ' .. script; -- add a space before we concatenate
end
return title .. script; -- return the concatenation
end
--[[--------------------------< G E T _ C O I N S _ P A G E S >------------------------------------------------
Extract page numbers from external wikilinks in any of the |page=, |pages=, or |at= parameters for use in COinS.
]]
function get_coins_pages (pages)
local pattern;
if not is_set (pages) then return pages; end -- if no page numbers then we're done
while true do
pattern = pages:match("%[(%w*:?//[^ ]+%s+)[%w%d].*%]"); -- pattern is the opening bracket, the url and following space(s): "[url "
if nil == pattern then break; end -- no more urls
pattern = escape_lua_magic_chars (pattern); -- pattern is not a literal string; escape lua's magic pattern characters
pages = pages:gsub(pattern, ""); -- remove as many instances of pattern as possible
end
pages = pages:gsub("[%[%]]", ""); -- remove the brackets
pages = pages:gsub("–", "-" ); -- replace endashes with hyphens
pages = pages:gsub("&%w+;", "-" ); -- and replace html entities (– etc.) with hyphens; do we need to replace numerical entities like   and the like?
return pages;
end
--[[
ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit. ISBN-13 is checked in checkisbn().
If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length and stripped of dashes,
spaces and other non-isxn characters.
]]
function is_valid_isxn (isxn_str, len)
local temp = 0;
isxn_str = { isxn_str:byte(1, len) }; -- make a table of bytes
len = len+1; -- adjust to be a loop counter
for i, v in ipairs( isxn_str ) do -- loop through all of the bytes and calculate the checksum
if v == string.byte( "X" ) then -- if checkdigit is X
temp = temp + 10*( len - i ); -- it represents 10 decimal
else
temp = temp + tonumber( string.char(v) )*(len-i);
end
end
return temp % 11 == 0; -- returns true if calculation result is zero
end
-- Determines whether an ISBN string is valid
function checkisbn( isbn_str )
if nil ~= isbn_str:match("[^%s-0-9X]") then return false; end -- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
isbn_str = isbn_str:gsub( "-", "" ):gsub( " ", "" ); -- remove hyphens and spaces
local len = isbn_str:len();
if len ~= 10 and len ~= 13 then
return false;
end
if len == 10 then
if isbn_str:match( "^%d*X?$" ) == nil then return false; end
return is_valid_isxn(isbn_str, 10);
else
local temp = 0;
if isbn_str:match( "^97[89]%d*$" ) == nil then return false; end -- isbn13 begins with 978 or 979
isbn_str = { isbn_str:byte(1, len) };
for i, v in ipairs( isbn_str ) do
temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );
end
return temp % 10 == 0;
end
end
-- Gets the display text for a wikilink like [[A|B]] or [[B]] gives B
function removewikilink( str )
return (str:gsub( "%[%[([^%[%]]*)%]%]", function(l)
return l:gsub( "^[^|]*|(.*)$", "%1" ):gsub("^%s*(.-)%s*$", "%1");
end));
end
-- Escape sequences for content that will be used for URL descriptions
function safeforurl( str )
if str:match( "%[%[.-%]%]" ) ~= nil then
table.insert( z.message_tail, { seterror( 'wikilink_in_url', {}, true ) } );
end
return str:gsub( '[%[%]\n]', {
['['] = '[',
[']'] = ']',
['\n'] = ' ' } );
end
-- Converts a hyphen to a dash
function hyphentodash( str )
if not is_set(str) or str:match( "[%[%]{}<>]" ) ~= nil then
return str;
end
return str:gsub( '-', '–' );
end
-- Protects a string that will be wrapped in wiki italic markup '' ... ''
function safeforitalics( str )
--[[ Note: We cannot use <i> for italics, as the expected behavior for
italics specified by ''...'' in the title is that they will be inverted
(i.e. unitalicized) in the resulting references. In addition, <i> and ''
tend to interact poorly under Mediawiki's HTML tidy. ]]
if not is_set(str) then
return str;
else
if str:sub(1,1) == "'" then str = "<span></span>" .. str; end
if str:sub(-1,-1) == "'" then str = str .. "<span></span>"; end
-- Remove newlines as they break italics.
return str:gsub( '\n', ' ' );
end
end
--[[--------------------------< S A F E J O I N >--------------------------------------------------------------
Joins a sequence of strings together while checking for duplicate separation characters.
]]
function safejoin( tbl, duplicate_char )
--[[
Note: we use string functions here, rather than ustring functions.
This has considerably faster performance and should work correctly as
long as the duplicate_char is strict ASCII. The strings
in tbl may be ASCII or UTF8.
]]
local str = ''; -- the output string
local comp = ''; -- what does 'comp' mean?
local end_chr = '';
local trim;
for _, value in ipairs( tbl ) do
if value == nil then value = ''; end
if str == '' then -- if output string is empty
str = value; -- assign value to it (first time through the loop)
elseif value ~= '' then
if value:sub(1,1) == '<' then -- Special case of values enclosed in spans and other markup.
comp = value:gsub( "%b<>", "" ); -- remove html markup (<span>string</span> -> string)
else
comp = value;
end
-- typically duplicate_char is sepc
if comp:sub(1,1) == duplicate_char then -- is first charactier same as duplicate_char? why test first character?
-- Because individual string segments often (always?) begin with terminal punct for th
-- preceding segment: 'First element' .. 'sepc next element' .. etc?
trim = false;
end_chr = str:sub(-1,-1); -- get the last character of the output string
-- str = str .. "<HERE(enchr=" .. end_chr.. ")" -- debug stuff?
if end_chr == duplicate_char then -- if same as separator
str = str:sub(1,-2); -- remove it
elseif end_chr == "'" then -- if it might be wikimarkup
if str:sub(-3,-1) == duplicate_char .. "''" then -- if last three chars of str are sepc''
str = str:sub(1, -4) .. "''"; -- remove them and add back ''
elseif str:sub(-5,-1) == duplicate_char .. "]]''" then -- if last five chars of str are sepc]]''
trim = true; -- why? why do this and next differently from previous?
elseif str:sub(-4,-1) == duplicate_char .. "]''" then -- if last four chars of str are sepc]''
trim = true; -- same question
end
elseif end_chr == "]" then -- if it might be wikimarkup
if str:sub(-3,-1) == duplicate_char .. "]]" then -- if last three chars of str are sepc]] wikilink
trim = true;
elseif str:sub(-2,-1) == duplicate_char .. "]" then -- if last two chars of str are sepc] external link
trim = true;
elseif str:sub(-4,-1) == duplicate_char .. "'']" then -- normal case when |url=something & |title=Title.
trim = true;
end
elseif end_chr == " " then -- if last char of output string is a space
if str:sub(-2,-1) == duplicate_char .. " " then -- if last two chars of str are <sepc><space>
str = str:sub(1,-3); -- remove them both
end
end
if trim then
if value ~= comp then -- value does not equal comp when value contains html markup
local dup2 = duplicate_char;
if dup2:match( "%A" ) then dup2 = "%" .. dup2; end -- if duplicate_char not a letter then escape it
value = value:gsub( "(%b<>)" .. dup2, "%1", 1 ) -- remove duplicate_char if it follows html markup
else
value = value:sub( 2, -1 ); -- remove duplicate_char when it is first character
end
end
end
str = str .. value; --add it to the output string
end
end
return str;
end
-- Attempts to convert names to initials.
function reducetoinitials(first)
local initials = {}
local i = 0; -- counter for number of initials
for word in string.gmatch(first, "%S+") do
table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
i = i + 1; -- bump the counter
if 2 <= i then break; end -- only two initials allowed in Vancouver system; if 2, quit
end
return table.concat(initials) -- Vancouver format does not include spaces.
end
-- Formats a list of people (e.g. authors / editors)
function listpeople(control, people)
local sep;
local namesep;
local format = control.format
local maximum = control.maximum
local lastauthoramp = control.lastauthoramp;
local text = {}
local etal = false;
if 'vanc' == format then -- Vancouver-like author/editor name styling?
sep = ','; -- name-list separator between authors is a comma
namesep = ' '; -- last/first separator is a space
else
sep = ';' -- name-list separator between authors is a semicolon
namesep = ', ' -- last/first separator is <comma><space>
end
if sep:sub(-1,-1) ~= " " then sep = sep .. " " end
if maximum ~= nil and maximum < 1 then return "", 0; end
for i,person in ipairs(people) do
if is_set(person.last) then
local mask = person.mask
local one
local sep_one = sep;
if maximum ~= nil and i > maximum then
etal = true;
break;
elseif (mask ~= nil) then
local n = tonumber(mask)
if (n ~= nil) then
one = string.rep("—",n)
else
one = mask;
sep_one = " ";
end
else
one = person.last
local first = person.first
if is_set(first) then
if ( "vanc" == format ) then first = reducetoinitials(first) end
one = one .. namesep .. first
end
if is_set(person.link) and person.link ~= control.page_name then
one = "[[" .. person.link .. "|" .. one .. "]]" -- link author/editor if this page is not the author's/editor's page
end
if is_set(person.link) and ((nil ~= person.link:find("//")) or (nil ~= person.link:find("[%[%]]"))) then
one = one .. " " .. seterror( 'bad_authorlink' ) end -- url or wikilink in author link;
end
table.insert( text, one )
table.insert( text, sep_one )
end
end
local count = #text / 2;
if count > 0 then
if count > 1 and is_set(lastauthoramp) and not etal then
text[#text-2] = " & ";
end
text[#text] = nil;
end
local result = table.concat(text) -- construct list
if etal then
local etal_text = cfg.messages['et al'];
result = result .. " " .. etal_text;
end
return result, count
end
--[[--------------------------< A N C H O R I D >--------------------------------------------------------------
Generates a CITEREF anchor ID if we have at least one name or a date. Otherwise returns an empty string.
]]
function anchorid( options )
local id = table.concat( options ); -- concatenate names and year for CITEREF id
if is_set (id) then -- if concatenation is not an empty string
return "CITEREF" .. id; -- add the CITEREF portion
else
return ''; -- return an empty string; no reason to include CITEREF id in this citation
end
end
--[[
Gets name list from the input arguments
Searches through args in sequential order to find |lastn= and |firstn= parameters (or their aliases), and their matching link and mask parameters.
Stops searching when both |lastn= and |firstn= are not found in args after two sequential attempts: found |last1=, |last2=, and |last3= but doesn't
find |last4= and |last5= then the search is done.
This function emits an error message when there is a |firstn= without a matching |lastn=. When there are 'holes' in the list of last names, |last1= and |last3=
are present but |last2= is missing, an error message is emitted. |lastn= is not required to have a matching |firstn=.
]]
function extractnames(args, list_name)
local names = {}; -- table of names
local last; -- individual name components
local first;
local link;
local mask;
local i = 1; -- loop counter/indexer
local n = 1; -- output table indexer
local count = 0; -- used to count the number of times we haven't found a |last= (or alias for authors, |editor-last or alias for editors)
local err_msg_list_name = list_name:match ("(%w+)List") .. 's list'; -- modify AuthorList or EditorList for use in error messages if necessary
while true do
last = selectone( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', i ); -- search through args for name components beginning at 1
first = selectone( args, cfg.aliases[list_name .. '-First'], 'redundant_parameters', i );
link = selectone( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i );
mask = selectone( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );
if first and not last then -- if there is a firstn without a matching lastn
table.insert( z.message_tail, { seterror( 'first_missing_last', {err_msg_list_name, i}, true ) } ); -- add this error message
elseif not first and not last then -- if both firstn and lastn aren't found, are we done?
count = count + 1; -- number of times we haven't found last and first
if 2 == count then -- two missing names and we give up
break; -- normal exit or there is a two-name hole in the list; can't tell which
end
else -- we have last with or without a first
names[n] = {last = last, first = first, link = link, mask = mask}; -- add this name to our names list
n = n + 1; -- point to next location in the names table
if 1 == count then -- if the previous name was missing
table.insert( z.message_tail, { seterror( 'missing_name', {err_msg_list_name, i-1}, true ) } ); -- add this error message
end
count = 0; -- reset the counter, we're looking for two consecutive missing names
end
i = i + 1; -- point to next args location
end
return names; -- all done, return our list of names
end
-- Populates ID table from arguments using configuration settings
function extractids( args )
local id_list = {};
for k, v in pairs( cfg.id_handlers ) do
v = selectone( args, v.parameters, 'redundant_parameters' );
if is_set(v) then id_list[k] = v; end
end
return id_list;
end
--[[--------------------------< B U I L D I D L I S T >--------------------------------------------------------
Takes a table of IDs and turns it into a table of formatted ID outputs.
]]
function buildidlist( id_list, options )
local new_list, handler = {};
function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
for k, v in pairs( id_list ) do
-- fallback to read-only cfg
handler = setmetatable( { ['id'] = v }, fallback(k) );
if handler.mode == 'external' then
table.insert( new_list, {handler.label, externallinkid( handler ) } );
elseif handler.mode == 'internal' then
table.insert( new_list, {handler.label, internallinkid( handler ) } );
elseif handler.mode ~= 'manual' then
error( cfg.messages['unknown_ID_mode'] );
elseif k == 'DOI' then
table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
elseif k == 'ARXIV' then
table.insert( new_list, {handler.label, arxiv( v ) } );
elseif k == 'ASIN' then
table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } );
elseif k == 'LCCN' then
table.insert( new_list, {handler.label, lccn( v ) } );
elseif k == 'OL' then
table.insert( new_list, {handler.label, openlibrary( v ) } );
elseif k == 'PMC' then
table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
elseif k == 'PMID' then
table.insert( new_list, {handler.label, pmid( v ) } );
elseif k == 'ISSN' then
table.insert( new_list, {handler.label, issn( v ) } );
elseif k == 'ISBN' then
local ISBN = internallinkid( handler );
if not checkisbn( v ) and not is_set(options.IgnoreISBN) then
ISBN = ISBN .. seterror( 'bad_isbn', {}, false, " ", "" );
end
table.insert( new_list, {handler.label, ISBN } );
elseif k == 'USENETID' then
table.insert( new_list, {handler.label, message_id( v ) } );
else
error( cfg.messages['unknown_manual_ID'] );
end
end
function comp( a, b ) -- used in following table.sort()
return a[1] < b[1];
end
table.sort( new_list, comp );
for k, v in ipairs( new_list ) do
new_list[k] = v[2];
end
return new_list;
end
-- Chooses one matching parameter from a list of parameters to consider
-- Generates an error if more than one match is present.
function selectone( args, possible, error_condition, index )
local value = nil;
local selected = '';
local error_list = {};
if index ~= nil then index = tostring(index); end
-- Handle special case of "#" replaced by empty string
if index == '1' then
for _, v in ipairs( possible ) do
v = v:gsub( "#", "" );
if is_set(args[v]) then
if value ~= nil and selected ~= v then
table.insert( error_list, v );
else
value = args[v];
selected = v;
end
end
end
end
for _, v in ipairs( possible ) do
if index ~= nil then
v = v:gsub( "#", index );
end
if is_set(args[v]) then
if value ~= nil and selected ~= v then
table.insert( error_list, v );
else
value = args[v];
selected = v;
end
end
end
if #error_list > 0 then
local error_str = "";
for _, k in ipairs( error_list ) do
if error_str ~= "" then error_str = error_str .. cfg.messages['parameter-separator'] end
error_str = error_str .. wrap_style ('parameter', k);
end
if #error_list > 1 then
error_str = error_str .. cfg.messages['parameter-final-separator'];
else
error_str = error_str .. cfg.messages['parameter-pair-separator'];
end
error_str = error_str .. wrap_style ('parameter', selected);
table.insert( z.message_tail, { seterror( error_condition, {error_str}, true ) } );
end
return value, selected;
end
-- COinS metadata (see <http://ocoins.info/>) allows automated tools to parse
-- the citation information.
function COinS(data)
if 'table' ~= type(data) or nil == next(data) then
return '';
end
local ctx_ver = "Z39.88-2004";
-- treat table strictly as an array with only set values.
local OCinSoutput = setmetatable( {}, {
__newindex = function(self, key, value)
if is_set(value) then
rawset( self, #self+1, table.concat{ key, '=', mw.uri.encode( removewikilink( value ) ) } );
end
end
});
if is_set(data.Chapter) then
OCinSoutput.rft_val_fmt = "info:ofi/fmt:kev:mtx:book";
OCinSoutput["rft.genre"] = "bookitem";
OCinSoutput["rft.atitle"] = data.Chapter;
OCinSoutput["rft.btitle"] = data.Title;
elseif is_set(data.Periodical) then
OCinSoutput.rft_val_fmt = "info:ofi/fmt:kev:mtx:journal";
OCinSoutput["rft.genre"] = "article";
OCinSoutput["rft.jtitle"] = data.Periodical;
OCinSoutput["rft.atitle"] = data.Title;
else
OCinSoutput.rft_val_fmt = "info:ofi/fmt:kev:mtx:book";
OCinSoutput["rft.genre"] = "book"
OCinSoutput["rft.btitle"] = data.Title;
end
OCinSoutput["rft.place"] = data.PublicationPlace;
OCinSoutput["rft.date"] = data.Date;
OCinSoutput["rft.series"] = data.Series;
OCinSoutput["rft.volume"] = data.Volume;
OCinSoutput["rft.issue"] = data.Issue;
OCinSoutput["rft.pages"] = data.Pages;
OCinSoutput["rft.edition"] = data.Edition;
OCinSoutput["rft.pub"] = data.PublisherName;
for k, v in pairs( data.ID_list ) do
local id, value = cfg.id_handlers[k].COinS;
if k == 'ISBN' then value = cleanisbn( v ); else value = v; end
if string.sub( id or "", 1, 4 ) == 'info' then
OCinSoutput["rft_id"] = table.concat{ id, "/", v };
else
OCinSoutput[ id ] = value;
end
end
local last, first;
for k, v in ipairs( data.Authors ) do
last, first = v.last, v.first;
if k == 1 then
if is_set(last) then
OCinSoutput["rft.aulast"] = last;
end
if is_set(first) then
OCinSoutput["rft.aufirst"] = first;
end
end
if is_set(last) and is_set(first) then
OCinSoutput["rft.au"] = table.concat{ last, ", ", first };
elseif is_set(last) then
OCinSoutput["rft.au"] = last;
end
end
OCinSoutput.rft_id = data.URL;
OCinSoutput.rfr_id = table.concat{ "info:sid/", mw.site.server:match( "[^/]*$" ), ":", data.RawPage };
OCinSoutput = setmetatable( OCinSoutput, nil );
-- sort with version string always first, and combine.
table.sort( OCinSoutput );
table.insert( OCinSoutput, 1, "ctx_ver=" .. ctx_ver ); -- such as "Z39.88-2004"
return table.concat(OCinSoutput, "&");
end
--[[--------------------------< G E T _ I S O 6 3 9 _ C O D E >------------------------------------------------
Validates language names provided in |language= parameter if not an ISO639 code. Handles the special case that is Norwegian where
ISO639 code 'no' is mapped to language name 'Norwegian Bokmål' by Extention:CLDR.
Returns the language name and associated ISO639 code. Because case of the source may be incorrect or different from the case that Wikimedia
uses, the name comparisons are done in lower case and when a match is found, the Wikimedia version (assumed to be correct) is returned along
with the code. When there is no match, we return the original language name string.
mw.language.fetchLanguageNames() will return a list of languages that aren't part of ISO639. Names that aren't ISO639 but that are included
in the list will be found if that name is provided in the |language= parameter. For example, if |language=Samaritan Aramaic, that name will be
found with the associated code 'sam', not an ISO639 code. When names are found and the associated code is not two characters, this function
returns only the Wikimedia language name.
Adapted from code taken from Module:Check ISO 639.
]]
function get_iso639_code (lang)
if 'norwegian' == lang:lower() then -- special case related to Wikimedia remap of code 'no' at Extension:CLDR
return 'Norwegian', 'no'; -- Make sure rendered version is properly capitalized
end
local languages = mw.language.fetchLanguageNames('en', 'all') -- get a list of language names known to Wikimedia
-- ('all' is required for North Ndebele, South Ndebele, and Ojibwa)
local langlc = mw.ustring.lower(lang); -- lower case version for comparisons
for code, name in pairs(languages) do -- scan the list to see if we can find our language
if langlc == mw.ustring.lower(name) then
if 2 ~= code:len() then -- ISO639 codes only
return name; -- so return the name but not the code
end
return name, code; -- found it, return name to ensure proper capitalization and the ISO639 code
end
end
return lang; -- not valid language; return language in original case and nil for ISO639 code
end
--[[--------------------------< L A N G U A G E _ P A R A M E T E R >------------------------------------------
Get language name from ISO639 code value provided. If a code is valid use the returned name; if not, then use the value that was provided with the language parameter.
There is an exception. There are three ISO639 codes for Norewegian language variants. There are two official variants: Norwegian Bokmål (code 'nb') and
Norwegian Nynorsk (code 'nn'). The third, code 'no', is defined by ISO639 as 'Norwegian' though in Norway this is pretty much meaningless. However, it appears
that on enwiki, editors are for the most part unaware of the nb and nn variants (compare page counts for these variants at Category:Articles with non-English-language external links.
Because Norwegian Bokmål is the most common language variant, Media wiki has been modified to return Norwegian Bokmål for ISO639 code 'no'. Here we undo that and
return 'Norwegian' when editors use |language=no. We presume that editors don't know about the variants or can't descriminate between them.
See Help talk:Citation Style_1#An ISO 639 language name test
When |language= contains a valid ISO639 code, the page is assigned to the category for that code: Category:Norwegian-language sources (no) if
the page is a mainspace page and the ISO639 code is not 'en'. Similarly, if the parameter is |language=Norwegian, it will be categorized in the same way.
]]
function language_parameter (lang, namespace)
local code; -- the ISO639 two character code
local name; -- the language name
local test='';
if 0 == namespace and (('en' == lang:lower()) or ('english' == lang:lower())) then
table.insert (z.maintenance_cats, 'CS1 maint: English language specified'); -- add maintenance category if |language=English or |language=en in article space
end
if 2 == lang:len() then -- ISO639 language code are 2 characters (fetchLanguageName also supports 3 character codes)
name = mw.language.fetchLanguageName( lang:lower(), "en" ); -- get ISO 639 language name if Language is a proper code
end
if is_set (name) then -- if Language specified a valid ISO639 code
code = lang:lower(); -- save it
else
name, code = get_iso639_code (lang); -- attempt to get code from name (assign name here so that we are sure of proper capitalization)
end
if is_set (code) then
if 'no' == code then name = 'Norwegian' end; -- override wikimedia when code is 'no'
if 0 == namespace and 'en' ~= code then -- is this page main / article space and English not the language?
table.insert( z.properties_cats, 'CS1 ' .. name .. '-language sources (' .. code .. ')'); -- in main space and not English: categorize
end
else
table.insert (z.maintenance_cats, 'CS1 maint: Unrecognized language'); -- add maintenance category when |language= does not appear to be ISO 639 language
end
return (" " .. wrap_msg ('language', name)); -- wrap with '(in ...)'
end
--[[--------------------------< G E T _ S E T T I N G S _ F R O M _ C I T E _ C L A S S >----------------------
When |mode= is not set or when its value is invalid, use config.CitationClass and parameter values to establish
rendered style.
]]
function get_settings_from_cite_class (ps, ref, cite_class)
local sep;
if (cite_class == "citation") then -- for citation templates (CS2)
sep = ','; -- set citation separator to its default (comma)
if not is_set (ps) then -- if |postscript= has not been set, set cs2 default
ps = ''; -- make sure it isn't nil
end
if not is_set (ref) then -- if |ref= is not set
ref = "harv"; -- set default |ref=harv
end
else -- not a citation template so CS1
sep = '.'; -- set cite xxx separator to its default (period)
if not is_set (ps) then -- if |postscript= has not been set
ps = '.'; -- set cs1 default
end
end
return sep, ps, ref -- return them all
end
--[[--------------------------< S E T _ S T Y L E >------------------------------------------------------------
Establish basic style settings to be used when rendering the citation. Uses |mode= if set and valid or uses
config.CitationClass from the template's #invoke: to establish style.
]]
function set_style (mode, ps, ref, cite_class)
local sep;
if is_set (mode) then
if 'cs2' == mode then -- if this template is to be rendered in CS2 (citation) style
sep = ','; -- separate elements with a comma
if not is_set (ps) then -- unless explicitely set to something
ps = ''; -- make sure it isn't nil
end
if not is_set (ref) then -- unless explicitely set to something
ref = 'harv'; -- set so this template renders with CITEREF anchor id
end
elseif 'cs1' == mode then -- if this template is to be rendered in CS1 (cite xxx) style
sep = '.'; -- separate elements with a period
if not is_set (ps) then -- unless explicitely set to something
ps = '.'; -- terminate the rendered citation with a period
end
else -- anything but cs1 or cs2
table.insert( z.message_tail, { seterror( 'invalid_param_val', {'mode', mode}, true ) } ); -- add error message
sep, ps, ref = get_settings_from_cite_class (ps, ref, cite_class); -- get settings based on the template's CitationClass
end
else -- when |mode= empty or omitted
sep, ps, ref = get_settings_from_cite_class (ps, ref, cite_class); -- get settings based on the template's CitationClass
end
if 'none' == ps:lower() then -- if assigned value is 'none' then
ps = ''; -- set to empty string
end
return sep, ps, ref
end
--[[--------------------------< C I T A T I O N 0 >------------------------------------------------------------
This is the main function doing the majority of the citation
formatting.
]]
function citation0( config, args)
--[[
Load Input Parameters
The argument_wrapper facilitates the mapping of multiple
aliases to single internal variable.
]]
local A = argument_wrapper( args );
local i
local PPrefix = A['PPrefix']
local PPPrefix = A['PPPrefix']
if is_set( A['NoPP'] ) then PPPrefix = "" PPrefix = "" end
-- Pick out the relevant fields from the arguments. Different citation templates
-- define different field names for the same underlying things.
local Authors = A['Authors'];
local a = extractnames( args, 'AuthorList' );
local Coauthors = A['Coauthors'];
local Others = A['Others'];
local Editors = A['Editors'];
local e = extractnames( args, 'EditorList' );
local NameListFormat = A['NameListFormat']; -- replaces |author-format= and |editor-format=
if is_set (NameListFormat) and ('vanc' ~= NameListFormat) then -- only accepted value for this parameter is 'vanc'
table.insert( z.message_tail, { seterror( 'invalid_param_val', {'name-list-format', NameListFormat}, true ) } ); -- not vanc so add error message
NameListFormat = ''; -- set to empty string
end
local Year = A['Year'];
local PublicationDate = A['PublicationDate'];
local OrigYear = A['OrigYear'];
local Date = A['Date'];
local LayDate = A['LayDate'];
------------------------------------------------- Get title data
local Title = A['Title'];
local ScriptTitle = A['ScriptTitle'];
local BookTitle = A['BookTitle'];
local Conference = A['Conference'];
local TransTitle = A['TransTitle'];
local TitleNote = A['TitleNote'];
local TitleLink = A['TitleLink'];
local Chapter = A['Chapter'];
local ChapterLink = A['ChapterLink']; -- deprecated
local TransChapter = A['TransChapter'];
local TitleType = A['TitleType'];
local Degree = A['Degree'];
local Docket = A['Docket'];
local ArchiveURL = A['ArchiveURL'];
local URL = A['URL']
local URLorigin = A:ORIGIN('URL'); -- get name of parameter that holds URL
local ChapterURL = A['ChapterURL'];
local ChapterURLorigin = A:ORIGIN('ChapterURL'); -- get name of parameter that holds ChapterURL
local ConferenceURL = A['ConferenceURL'];
local ConferenceURLorigin = A:ORIGIN('ConferenceURL'); -- get name of parameter that holds ConferenceURL
local Periodical = A['Periodical'];
local Series = A['Series'];
local Volume = A['Volume'];
local Issue = A['Issue'];
local Position = '';
local Page = A['Page'];
local Pages = hyphentodash( A['Pages'] );
local At = A['At'];
local Edition = A['Edition'];
local PublicationPlace = A['PublicationPlace']
local Place = A['Place'];
local PublisherName = A['PublisherName'];
local RegistrationRequired = A['RegistrationRequired'];
local SubscriptionRequired = A['SubscriptionRequired'];
local Via = A['Via'];
local AccessDate = A['AccessDate'];
local ArchiveDate = A['ArchiveDate'];
local Agency = A['Agency'];
local DeadURL = A['DeadURL']
local Language = A['Language'];
local Format = A['Format'];
local ChapterFormat = A['ChapterFormat'];
local DoiBroken = A['DoiBroken'];
local ID = A['ID'];
local ASINTLD = A['ASINTLD'];
local IgnoreISBN = A['IgnoreISBN'];
local Embargo = A['Embargo'];
local ID_list = extractids( args );
local Quote = A['Quote'];
local LayURL = A['LayURL'];
local LaySource = A['LaySource'];
local Transcript = A['Transcript'];
local TranscriptURL = A['TranscriptURL']
local TranscriptURLorigin = A:ORIGIN('TranscriptURL'); -- get name of parameter that holds TranscriptURL
local LastAuthorAmp = A['LastAuthorAmp'];
local no_tracking_cats = A['NoTracking'];
--these are used by cite interview
local Callsign = A['Callsign'];
local City = A['City'];
local Program = A['Program'];
--local variables that are not cs1 parameters
local use_lowercase; -- controls capitalization of certain static text
local this_page = mw.title.getCurrentTitle(); -- also used for COinS and for language
local anchor_year; -- used in the CITEREF identifier
local COinS_date; -- used in the COinS metadata
-- set default parameter values defined by |mode= parameter. If |mode= is empty or omitted, use CitationClass to set these values
local sepc; -- separator between citation elements for CS1 a period, for CS2, a comma
local PostScript;
local Ref;
sepc, PostScript, Ref = set_style (A['Mode']:lower(), A['PostScript'], A['Ref'], config.CitationClass);
use_lowercase = ( sepc == ',' ); -- used to control capitalization for certain static text
--check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories.
if not is_set(no_tracking_cats) then -- ignore if we are already not going to categorize this page
if inArray (this_page.nsText, cfg.uncategorized_namespaces) then
no_tracking_cats = "true"; -- set no_tracking_cats
end
end
-- check for extra |page=, |pages= or |at= parameters.
if is_set(Page) then
if is_set(Pages) or is_set(At) then
Page = Page .. " " .. seterror('extra_pages'); -- add error message
Pages = ''; -- unset the others
At = '';
end
elseif is_set(Pages) then
if is_set(At) then
Pages = Pages .. " " .. seterror('extra_pages'); -- add error messages
At = ''; -- unset
end
end
-- both |publication-place= and |place= (|location=) allowed if different
if not is_set(PublicationPlace) and is_set(Place) then
PublicationPlace = Place; -- promote |place= (|location=) to |publication-place
end
if PublicationPlace == Place then Place = ''; end -- don't need both if they are the same
--[[
Parameter remapping for cite encyclopedia:
When the citation has these parameters:
|encyclopedia and |title then map |title to |article and |encyclopedia to |title
|encyclopedia and |article then map |encyclopedia to |title
|encyclopedia then map |encyclopedia to |title
|trans_title maps to |trans_chapter when |title is re-mapped
|url maps to |chapterurl when |title is remapped
All other combinations of |encyclopedia, |title, and |article are not modified
TODO: script-title to script-chapter if and when we support script-chapter
]]
local Encyclopedia = A['Encyclopedia'];
if ( config.CitationClass == "encyclopaedia" ) or ( config.CitationClass == "citation" and is_set (Encyclopedia)) then -- test code for citation
if is_set(Periodical) then -- Periodical is set when |encyclopedia is set
if is_set(Title) then
if not is_set(Chapter) then
Chapter = Title; -- |encyclopedia and |title are set so map |title to |article and |encyclopedia to |title
TransChapter = TransTitle;
ChapterURL = URL;
Title = Periodical;
ChapterFormat = Format;
Periodical = ''; -- redundant so unset
TransTitle = ''; -- redundant so unset
URL = ''; -- redundant so unset
Format = ''; -- redundant so unset
end
else -- |title not set
Title = Periodical; -- |encyclopedia set and |article set or not set so map |encyclopedia to |title
Periodical = ''; -- redundant so unset
end
end
end
-- Special case for cite techreport.
if (config.CitationClass == "techreport") then -- special case for cite techreport
if is_set(Issue) then -- cite techreport uses 'number', which other citations aliase to 'issue'
if not is_set(ID) then -- can we use ID for the "number"?
ID = Issue; -- yes, use it
Issue = ""; -- unset Issue so that "number" isn't duplicated in the rendered citation or COinS metadata
else -- can't use ID so emit error message
ID = ID .. " " .. seterror('redundant_parameters', '<code>|id=</code> and <code>|number=</code>');
end
end
end
-- special case for cite interview
if (config.CitationClass == "interview") then
if is_set(Program) then
ID = ' ' .. Program;
end
if is_set(Callsign) then
if is_set(ID) then
ID = ID .. sepc .. ' ' .. Callsign;
else
ID = ' ' .. Callsign;
end
end
if is_set(City) then
if is_set(ID) then
ID = ID .. sepc .. ' ' .. City;
else
ID = ' ' .. City;
end
end
if is_set(Others) then
if is_set(TitleType) then
Others = ' ' .. TitleType .. ' with ' .. Others;
TitleType = '';
else
Others = ' ' .. 'Interview with ' .. Others;
end
else
Others = '(Interview)';
end
end
-- special case for cite mailing list
if (config.CitationClass == "mailinglist") then
Periodical = A ['MailingList'];
end
--Account for the oddity that is {{cite journal}} with |pmc= set and |url= not set
if config.CitationClass == "journal" and not is_set(URL) and is_set(ID_list['PMC']) then
if not is_embargoed(Embargo) then
URL=cfg.id_handlers['PMC'].prefix .. ID_list['PMC']; -- set url to be the same as the PMC external link if not embargoed
URLorigin = cfg.id_handlers['PMC'].parameters[1]; -- set URLorigin to parameter name for use in error message if citation is missing a |title=
end
end
-- Account for the oddity that is {{cite conference}}, before generation of COinS data.
if 'conference' == config.CitationClass then
if is_set(BookTitle) then
Chapter = Title;
-- ChapterLink = TitleLink; -- |chapterlink= is deprecated
ChapterURL = URL;
ChapterURLorigin = URLorigin;
URLorigin = '';
ChapterFormat = Format;
TransChapter = TransTitle;
Title = BookTitle;
Format = '';
-- TitleLink = '';
TransTitle = '';
URL = '';
end
else
Conference = ''; -- not cite conference so make sure this is empty string
end
-- Account for the oddity that is {{cite episode}}, before generation of COinS data.
--[[ -- {{cite episode}} is not currently supported by this module
if config.CitationClass == "episode" then
local AirDate = A['AirDate'];
local SeriesLink = A['SeriesLink'];
local Season = A['Season'];
local SeriesNumber = A['SeriesNumber'];
local Network = A['Network'];
local Station = A['Station'];
local s, n = {}, {};
local Sep = (first_set(A["SeriesSeparator"], A["Separator"]) or "") .. " ";
if is_set(Issue) then table.insert(s, cfg.messages["episode"] .. " " .. Issue); Issue = ''; end
if is_set(Season) then table.insert(s, cfg.messages["season"] .. " " .. Season); end
if is_set(SeriesNumber) then table.insert(s, cfg.messages["series"] .. " " .. SeriesNumber); end
if is_set(Network) then table.insert(n, Network); end
if is_set(Station) then table.insert(n, Station); end
Date = Date or AirDate;
Chapter = Title;
ChapterLink = TitleLink;
TransChapter = TransTitle;
Title = Series;
TitleLink = SeriesLink;
TransTitle = '';
Series = table.concat(s, Sep);
ID = table.concat(n, Sep);
end
-- end of {{cite episode}} stuff]]
-- legacy: promote concatenation of |month=, and |year= to Date if Date not set; or, promote PublicationDate to Date if neither Date nor Year are set.
if is_set(Date) then
if is_set (Year) then
table.insert( z.maintenance_cats, "CS1 maint: Date and year"); -- add to maint category
end
else
Date = Year; -- promote Year to Date
Year = nil; -- make nil so Year as empty string isn't used for CITEREF
if is_set(Date) then
local Month = A['Month'];
if is_set(Month) then
Date = Month .. " " .. Date;
end
elseif is_set(PublicationDate) then -- use PublicationDate when |date= and |year= are not set
Date = PublicationDate; -- promote PublicationDate to Date
PublicationDate = ''; -- unset, no longer needed
end
end
if PublicationDate == Date then PublicationDate = ''; end -- if PublicationDate is same as Date, don't display in rendered citation
--[[
Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates. This must be done before we do COinS because here is where
we get the date used in the metadata.
Date validation supporting code is in Module:Citation/CS1/Date_validation
]]
anchor_year, COinS_date, error_message = dates({['accessdate']=AccessDate, ['airdate']=AirDate, ['archivedate']=ArchiveDate, ['date']=Date, ['doi_brokendate']=DoiBroken,
['embargo']=Embargo, ['laydate']=LayDate, ['publicationdate']=PublicationDate, ['year']=Year});
if is_set(error_message) then
table.insert( z.message_tail, { seterror( 'bad_date', {error_message}, true ) } ); -- add this error message
end
-- At this point fields may be nil if they weren't specified in the template use. We can use that fact.
-- Test if citation has no title
if not is_set(Title) and
-- not is_set(Periodical) and -- not a title
-- not is_set(Conference) and -- not a title
not is_set(TransTitle) and
not is_set(ScriptTitle) then
table.insert( z.message_tail, { seterror( 'citation_missing_title', {}, true ) } );
end
if 'none' == Title and is_set(Periodical) and not (( config.CitationClass == "encyclopaedia" ) or ( config.CitationClass == "citation" and is_set (Encyclopedia))) then -- special case
Title = ''; -- set title to empty string
table.insert( z.maintenance_cats, "CS1 maint: Untitled periodical"); -- add to maint category
end
-- COinS metadata (see <http://ocoins.info/>) for automated parsing of citation information.
-- handle the oddity that is cite encyclopedia and {{citation |encyclopedia=something}}. Here we presume that
-- when Periodical, Title, and Chapter are all set, then Periodical is the book (encyclopedia) title, Title
-- is the article title, and Chapter is a section within the article. So, we remap
local coins_chapter = Chapter; -- default assuming that remapping not required
local coins_title = Title; -- et tu
if 'encyclopaedia' == config.CitationClass or ('citation' == config.CitationClass and is_set (Encyclopedia)) then
if is_set (Chapter) and is_set (Title) and is_set (Periodical) then -- if all are used then
coins_chapter = Title; -- remap
coins_title = Periodical;
end
end
-- this is the function call to COinS()
local OCinSoutput = COinS{
['Periodical'] = Periodical,
['Chapter'] = strip_apostrophe_markup (coins_chapter), -- Chapter stripped of bold / italic wikimarkup
['Title'] = make_coins_title (coins_title, ScriptTitle), -- Title and ScriptTitle stripped of bold / italic wikimarkup
['PublicationPlace'] = PublicationPlace,
['Date'] = first_set(COinS_date, Date), -- COinS_date has correctly formatted date if Date is valid; any reason to keep Date here? Should we be including invalid dates in metadata?
['Series'] = Series,
['Volume'] = Volume,
['Issue'] = Issue,
['Pages'] = get_coins_pages (first_set(Page, Pages, At)), -- pages stripped of external links
['Edition'] = Edition,
['PublisherName'] = PublisherName,
['URL'] = first_set( URL, ChapterURL ),
['Authors'] = a,
['ID_list'] = ID_list,
['RawPage'] = this_page.prefixedText,
};
--[[Why is this here? Why are we mapping Title to Chapter when Periodical is set?
if is_set(Periodical) and not is_set(Chapter) and is_set(Title) then
Chapter = Title;
ChapterLink = TitleLink;
TransChapter = TransTitle;
Title = '';
TitleLink = '';
TransTitle = '';
end
]]
-- special case for cite newsgroup. Do this after COinS because we are modifying Publishername to include some static text
if 'newsgroup' == config.CitationClass then
if is_set (PublisherName) then
PublisherName = '[[Newsgroup]]: ' .. externallink( 'news:' .. PublisherName, PublisherName );
end
end
-- Now perform various field substitutions.
-- We also add leading spaces and surrounding markup and punctuation to the
-- various parts of the citation, but only when they are non-nil.
if not is_set(Authors) then
local Maximum = tonumber( A['DisplayAuthors'] );
if is_set (Maximum) then
if Maximum >= #a then -- if display-authors value greater than or equal to number of authors
table.insert( z.maintenance_cats, "CS1 maint: display-authors"); -- add maintenance category because display-authors parameter may be removed
end
else
Maximum = #a + 1; -- number of authors + 1
end
local control = {
format = NameListFormat, -- empty string or 'vanc'
maximum = Maximum,
lastauthoramp = LastAuthorAmp,
page_name = this_page.text -- get current page name so that we don't wikilink to it via authorlinkn
};
-- If the coauthor field is also used, prevent ampersand and et al. formatting.
if is_set(Coauthors) then
control.lastauthoramp = nil;
control.maximum = #a + 1;
end
Authors = listpeople(control, a)
end
if not is_set(Authors) and is_set(Coauthors) then -- coauthors aren't displayed if one of authors=, authorn=, or lastn= isn't specified
table.insert( z.message_tail, { seterror('coauthors_missing_author', {}, true) } ); -- emit error message
end
local EditorCount
if not is_set(Editors) then
local Maximum = tonumber( A['DisplayEditors'] );
-- Preserve old-style implicit et al.
if not is_set(Maximum) and #e == 4 then
Maximum = 3;
table.insert( z.message_tail, { seterror('implict_etal_editor', {}, true) } );
elseif not is_set(Maximum) then
Maximum = #e + 1;
end
local control = {
format = NameListFormat, -- empty string or 'vanc'
maximum = Maximum,
lastauthoramp = LastAuthorAmp,
page_name = this_page.text -- get current page name so that we don't wikilink to it via editorlinkn
};
Editors, EditorCount = listpeople(control, e);
else
EditorCount = 1;
end
local Cartography = "";
local Scale = "";
if config.CitationClass == "map" then
if not is_set( Authors ) and is_set( PublisherName ) then
Authors = PublisherName;
PublisherName = "";
end
Cartography = A['Cartography'];
if is_set( Cartography ) then
Cartography = sepc .. " " .. wrap_msg ('cartography', Cartography, use_lowercase);
end
Scale = A['Scale'];
if is_set( Scale ) then
Scale = sepc .. " " .. Scale;
end
end
Format = is_set(Format) and " (" .. Format .. ")" or "";
if not is_set(URL) and
not is_set(ArchiveURL) and
not is_set(ConferenceURL) and -- TODO: keep this here? conference as part of cite web or cite podcast?
not is_set(TranscriptURL) then
-- Test if cite web or cite podcast |url= is missing or empty
if inArray(config.CitationClass, {"web","podcast", "mailinglist"}) then
table.insert( z.message_tail, { seterror( 'cite_web_url', {}, true ) } );
end
-- Test if accessdate is given without giving a URL
if is_set(AccessDate) and not is_set(ChapterURL)then -- ChapterURL may be set when the others are not set; TODO: move this to a separate test?
table.insert( z.message_tail, { seterror( 'accessdate_missing_url', {}, true ) } );
AccessDate = '';
end
-- Test if format is given without giving a URL
if is_set(Format) then
Format = Format .. seterror( 'format_missing_url', {'format', 'url'} );
end
end
--[[
-- Test if citation has no title
if not is_set(Title) and
-- not is_set(Periodical) and -- not a title
-- not is_set(Conference) and -- not a title
not is_set(TransTitle) and
not is_set(ScriptTitle) then
table.insert( z.message_tail, { seterror( 'citation_missing_title', {}, true ) } );
end
if 'none' == Title and is_set(Periodical) then -- special case
Title = ''; -- set title to empty string
table.insert( z.maintenance_cats, "CS1 maint: Untitled periodical"); -- add to maint category
end
]]
local OriginalURL;
DeadURL = DeadURL:lower(); -- used later when assembling archived text
if is_set( ArchiveURL ) then
if is_set (URL) then
OriginalURL = URL; -- save copy of original source URL
if 'no' ~= DeadURL then -- if URL set then archive-url applies to it
URL = ArchiveURL -- swap-in the archive's url
URLorigin = A:ORIGIN('ArchiveURL') -- name of archive url parameter for error messages
end
elseif is_set (ChapterURL) then -- URL not set so if chapter-url is set apply archive url to it
OriginalURL = ChapterURL; -- save copy of source chapter's url for archive text
if 'no' ~= DeadURL then
ChapterURL = ArchiveURL -- swap-in the archive's url
URLorigin = A:ORIGIN('ArchiveURL') -- name of archive url parameter for error messages
end
end
end
if inArray(config.CitationClass, {"web","news","journal","pressrelease","podcast", "newsgroup"}) or
('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia)) then
if is_set (Chapter) or is_set (TransChapter) or is_set (ChapterURL)then -- chapter parameters not supported for these citation types
table.insert( z.message_tail, { seterror( 'chapter_ignored', {}, true ) } ); -- add error message
Chapter = ''; -- set to empty string to be safe with concatenation
TransChapter = '';
ChapterURL = '';
end
else -- otherwise, format chapter / article title
Chapter = format_chapter_title (Chapter, TransChapter, ChapterURL, ChapterURLorigin);
if is_set (Chapter) then
ChapterFormat = is_set(ChapterFormat) and " (" .. ChapterFormat .. ")" or "";
if is_set(ChapterFormat) and not is_set (ChapterURL) then -- Test if |chapter-format= is given without giving a |chapter-url=
ChapterFormat = ChapterFormat .. seterror( 'format_missing_url', {'chapter-format', 'chapter-url'} );
end
Chapter = Chapter .. ChapterFormat .. sepc .. ' ';
end
end
-- Format main title.
if is_set(TitleLink) and is_set(Title) then
Title = "[[" .. TitleLink .. "|" .. Title .. "]]"
end
if inArray(config.CitationClass, {"web","news","journal","pressrelease","podcast", "newsgroup", "mailinglist"}) or
('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia)) then
Title = kern_quotes (Title); -- if necessary, separate title's leading and trailing quote marks from Module provided quote marks
Title = wrap_style ('quoted-title', Title);
Title = script_concatenate (Title, ScriptTitle); -- <bdi> tags, lang atribute, categorization, etc; must be done after title is wrapped
TransTitle= wrap_style ('trans-quoted-title', TransTitle );
elseif 'report' == config.CitationClass then -- no styling for cite report
Title = script_concatenate (Title, ScriptTitle); -- <bdi> tags, lang atribute, categorization, etc; must be done after title is wrapped
TransTitle= wrap_style ('trans-quoted-title', TransTitle ); -- for cite report, use this form for trans-title
else
Title = wrap_style ('italic-title', Title);
Title = script_concatenate (Title, ScriptTitle); -- <bdi> tags, lang atribute, categorization, etc; must be done after title is wrapped
TransTitle = wrap_style ('trans-italic-title', TransTitle);
end
TransError = "";
if is_set(TransTitle) then
if is_set(Title) then
TransTitle = " " .. TransTitle;
else
TransError = " " .. seterror( 'trans_missing_title' );
end
end
Title = Title .. TransTitle;
if is_set(Title) then
if not is_set(TitleLink) and is_set(URL) then
Title = externallink( URL, Title ) .. TransError .. Format
URL = "";
Format = "";
else
Title = Title .. TransError;
end
end
if is_set(Place) then
Place = " " .. wrap_msg ('written', Place, use_lowercase) .. sepc .. " ";
end
if is_set(Conference) then
if is_set(ConferenceURL) then
Conference = externallink( ConferenceURL, Conference );
end
Conference = sepc .. " " .. Conference
elseif is_set(ConferenceURL) then
Conference = sepc .. " " .. externallink( ConferenceURL, nil, ConferenceURLorigin );
end
if not is_set(Position) then
local Minutes = A['Minutes'];
if is_set(Minutes) then
Position = " " .. Minutes .. " " .. cfg.messages['minutes'];
else
local Time = A['Time'];
if is_set(Time) then
local TimeCaption = A['TimeCaption']
if not is_set(TimeCaption) then
TimeCaption = cfg.messages['event'];
if sepc ~= '.' then
TimeCaption = TimeCaption:lower();
end
end
Position = " " .. TimeCaption .. " " .. Time;
end
end
else
Position = " " .. Position;
At = '';
end
if not is_set(Page) then
if is_set(Pages) then
if is_set(Periodical) and
not inArray(config.CitationClass, {"encyclopaedia","web","book","news","podcast"}) then
Pages = ": " .. Pages;
elseif tonumber(Pages) ~= nil then
Pages = sepc .." " .. PPrefix .. Pages;
else
Pages = sepc .." " .. PPPrefix .. Pages;
end
end
else
if is_set(Periodical) and
not inArray(config.CitationClass, {"encyclopaedia","web","book","news","podcast"}) then
Page = ": " .. Page;
else
Page = sepc .." " .. PPrefix .. Page;
end
end
At = is_set(At) and (sepc .. " " .. At) or "";
Position = is_set(Position) and (sepc .. " " .. Position) or "";
if config.CitationClass == 'map' then
local Section = A['Section'];
local Inset = A['Inset'];
if first_set( Pages, Page, At ) ~= nil or sepc ~= '.' then
if is_set( Section ) then
Section = ", " .. wrap_msg ('section', Section, true);
end
if is_set( Inset ) then
Inset = ", " .. wrap_msg ('inset', Inset, true);
end
else
if is_set( Section ) then
Section = sepc .. " " .. wrap_msg ('section', Section, use_lowercase);
if is_set( Inset ) then
Inset = ", " .. wrap_msg ('inset', Inset, true);
end
elseif is_set( Inset ) then
Inset = sepc .. " " .. wrap_msg ('inset', Inset, use_lowercase);
end
end
At = At .. Section .. Inset;
end
if is_set (Language) then
Language = language_parameter (Language, this_page.namespace); -- format, categories (article namespace only), name from ISO639, etc
else
Language=""; -- language not specified so make sure this is an empty string;
end
Others = is_set(Others) and (sepc .. " " .. Others) or "";
-- handle type parameter for those CS1 citations that have default values
if inArray(config.CitationClass, {"AV-media-notes", "DVD-notes", "mailinglist", "podcast", "pressrelease", "report", "techreport", "thesis"}) then
TitleType = set_titletype (config.CitationClass, TitleType);
if is_set(Degree) and "Thesis" == TitleType then -- special case for cite thesis
TitleType = Degree .. " thesis";
end
end
if is_set(TitleType) then -- if type parameter is specified
TitleType = " (" .. TitleType .. ")"; -- display it in parentheses
end
TitleNote = is_set(TitleNote) and (sepc .. " " .. TitleNote) or "";
Edition = is_set(Edition) and (" " .. wrap_msg ('edition', Edition)) or "";
Issue = is_set(Issue) and (" (" .. Issue .. ")") or "";
Series = is_set(Series) and (sepc .. " " .. Series) or "";
OrigYear = is_set(OrigYear) and (" [" .. OrigYear .. "]") or "";
Agency = is_set(Agency) and (sepc .. " " .. Agency) or "";
if is_set(Volume) then
if ( mw.ustring.len(Volume) > 4 )
then Volume = sepc .." " .. Volume;
else Volume = " <b>" .. hyphentodash(Volume) .. "</b>";
end
end
------------------------------------ totally unrelated data
if is_set(Via) then
Via = " " .. wrap_msg ('via', Via);
end
--[[
Subscription implies paywall; Registration does not. If both are used in a citation, the subscription required link
note is displayed. There are no error messages for this condition.
]]
if inArray(SubscriptionRequired:lower(), {'yes', 'true', 'y'}) then
SubscriptionRequired = sepc .. " " .. cfg.messages['subscription']; -- subscription required message
elseif inArray(RegistrationRequired:lower(), {'yes', 'true', 'y'}) then
SubscriptionRequired = sepc .. " " .. cfg.messages['registration']; -- registration required message
else
SubscriptionRequired = ''; -- either or both might be set to something other than yes true y
end
if is_set(AccessDate) then
local retrv_text = " " .. cfg.messages['retrieved']
AccessDate = nowrap_date (AccessDate); -- wrap in nowrap span if date in appropriate format
if (sepc ~= ".") then retrv_text = retrv_text:lower() end -- if 'citation', lower case
AccessDate = substitute (retrv_text, AccessDate); -- add retrieved text
-- neither of these work; don't know why; it seems that substitute() isn't being called
AccessDate = substitute (cfg.presentation['accessdate'], {sepc, AccessDate}); -- allow editors to hide accessdates
end
if is_set(ID) then ID = sepc .." ".. ID; end
if "thesis" == config.CitationClass and is_set(Docket) then
ID = sepc .." Docket ".. Docket .. ID;
end
if "report" == config.CitationClass and is_set(Docket) then -- for cite report when |docket= is set
ID = sepc .. ' ' .. Docket; -- overwrite ID even if |id= is set
end
ID_list = buildidlist( ID_list, {DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN, Embargo=Embargo} );
if is_set(URL) then
URL = " " .. externallink( URL, nil, URLorigin );
end
if is_set(Quote) then
if Quote:sub(1,1) == '"' and Quote:sub(-1,-1) == '"' then
Quote = Quote:sub(2,-2);
end
Quote = sepc .." " .. wrap_style ('quoted-text', Quote ); -- wrap in <q>...</q> tags
PostScript = ""; -- CS1 does not supply terminal punctuation when |quote= is set
end
local Archived
if is_set(ArchiveURL) then
if not is_set(ArchiveDate) then
ArchiveDate = seterror('archive_missing_date');
end
if "no" == DeadURL then
local arch_text = cfg.messages['archived'];
if sepc ~= "." then arch_text = arch_text:lower() end
Archived = sepc .. " " .. substitute( cfg.messages['archived-not-dead'],
{ externallink( ArchiveURL, arch_text ), ArchiveDate } );
if not is_set(OriginalURL) then
Archived = Archived .. " " .. seterror('archive_missing_url');
end
elseif is_set(OriginalURL) then
local arch_text = cfg.messages['archived-dead'];
if sepc ~= "." then arch_text = arch_text:lower() end
Archived = sepc .. " " .. substitute( arch_text,
{ externallink( OriginalURL, cfg.messages['original'] ), ArchiveDate } );
else
local arch_text = cfg.messages['archived-missing'];
if sepc ~= "." then arch_text = arch_text:lower() end
Archived = sepc .. " " .. substitute( arch_text,
{ seterror('archive_missing_url'), ArchiveDate } );
end
else
Archived = ""
end
local Lay
if is_set(LayURL) then
if is_set(LayDate) then LayDate = " (" .. LayDate .. ")" end
if is_set(LaySource) then
LaySource = " – ''" .. safeforitalics(LaySource) .. "''";
else
LaySource = "";
end
if sepc == '.' then
Lay = sepc .. " " .. externallink( LayURL, cfg.messages['lay summary'] ) .. LaySource .. LayDate
else
Lay = sepc .. " " .. externallink( LayURL, cfg.messages['lay summary']:lower() ) .. LaySource .. LayDate
end
else
Lay = "";
end
if is_set(Transcript) then
if is_set(TranscriptURL) then Transcript = externallink( TranscriptURL, Transcript ); end
elseif is_set(TranscriptURL) then
Transcript = externallink( TranscriptURL, nil, TranscriptURLorigin );
end
local Publisher;
if is_set(Periodical) and
not inArray(config.CitationClass, {"encyclopaedia","web","pressrelease","podcast"}) then
if is_set(PublisherName) then
if is_set(PublicationPlace) then
Publisher = PublicationPlace .. ": " .. PublisherName;
else
Publisher = PublisherName;
end
elseif is_set(PublicationPlace) then
Publisher= PublicationPlace;
else
Publisher = "";
end
if is_set(PublicationDate) then
if is_set(Publisher) then
Publisher = Publisher .. ", " .. wrap_msg ('published', PublicationDate);
else
Publisher = PublicationDate;
end
end
if is_set(Publisher) then
Publisher = " (" .. Publisher .. ")";
end
else
if is_set(PublicationDate) then
PublicationDate = " (" .. wrap_msg ('published', PublicationDate) .. ")";
end
if is_set(PublisherName) then
if is_set(PublicationPlace) then
Publisher = sepc .. " " .. PublicationPlace .. ": " .. PublisherName .. PublicationDate;
else
Publisher = sepc .. " " .. PublisherName .. PublicationDate;
end
elseif is_set(PublicationPlace) then
Publisher= sepc .. " " .. PublicationPlace .. PublicationDate;
else
Publisher = PublicationDate;
end
end
-- Several of the above rely upon detecting this as nil, so do it last.
if is_set(Periodical) then
if is_set(Title) or is_set(TitleNote) then
Periodical = sepc .. " " .. wrap_style ('italic-title', Periodical)
else
Periodical = wrap_style ('italic-title', Periodical)
end
end
--[[
Handle the oddity that is cite speech. This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be " (Speech)" so that
the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
]]
if "speech" == config.CitationClass then -- cite speech only
TitleNote = " (Speech)"; -- annotate the citation
if is_set (Periodical) then -- if Periodical, perhaps because of an included |website= or |journal= parameter
if is_set (Conference) then -- and if |event= is set
Conference = Conference .. sepc .. " "; -- then add appropriate punctuation to the end of the Conference variable before rendering
end
end
end
-- Piece all bits together at last. Here, all should be non-nil.
-- We build things this way because it is more efficient in LUA
-- not to keep reassigning to the same string variable over and over.
local tcommon
if inArray(config.CitationClass, {"journal","citation"}) and is_set(Periodical) then
if is_set(Others) then Others = Others .. sepc .. " " end
tcommon = safejoin( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Scale, Series,
Language, Cartography, Edition, Publisher, Agency, Volume, Issue}, sepc );
else
tcommon = safejoin( {Title, TitleNote, Conference, Periodical, Format, TitleType, Scale, Series, Language,
Volume, Issue, Others, Cartography, Edition, Publisher, Agency}, sepc );
end
if #ID_list > 0 then
ID_list = safejoin( { sepc .. " ", table.concat( ID_list, sepc .. " " ), ID }, sepc );
else
ID_list = ID;
end
local idcommon = safejoin( { ID_list, URL, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );
local text;
local pgtext = Position .. Page .. Pages .. At;
if is_set(Authors) then
if is_set(Coauthors) then
local sep = '; ';
if 'vanc' == NameListFormat then
sep = ', ';
end
Authors = Authors .. sep .. Coauthors;
end
if is_set(Date) then
Date = " ("..Date..")" .. OrigYear .. sepc .. " "
elseif string.sub(Authors,-1,-1) == sepc then
Authors = Authors .. " "
else
Authors = Authors .. sepc .. " "
end
if is_set(Editors) then
local in_text = " ";
local post_text = "";
if is_set(Chapter) then
in_text = in_text .. cfg.messages['in'] .. " "
else
if EditorCount <= 1 then
post_text = ", " .. cfg.messages['editor'];
else
post_text = ", " .. cfg.messages['editors'];
end
end
if (sepc ~= '.') then in_text = in_text:lower() end
Editors = in_text .. Editors .. post_text;
if (string.sub(Editors,-1,-1) == sepc)
then Editors = Editors .. " "
else Editors = Editors .. sepc .. " "
end
end
text = safejoin( {Authors, Date, Chapter, Place, Editors, tcommon }, sepc );
text = safejoin( {text, pgtext, idcommon}, sepc );
elseif is_set(Editors) then
if is_set(Date) then
if EditorCount <= 1 then
Editors = Editors .. ", " .. cfg.messages['editor'];
else
Editors = Editors .. ", " .. cfg.messages['editors'];
end
Date = " (" .. Date ..")" .. OrigYear .. sepc .. " "
else
if EditorCount <= 1 then
Editors = Editors .. " (" .. cfg.messages['editor'] .. ")" .. sepc .. " "
else
Editors = Editors .. " (" .. cfg.messages['editors'] .. ")" .. sepc .. " "
end
end
text = safejoin( {Editors, Date, Chapter, Place, tcommon}, sepc );
text = safejoin( {text, pgtext, idcommon}, sepc );
else
if is_set(Date) then
if ( string.sub(tcommon,-1,-1) ~= sepc )
then Date = sepc .." " .. Date .. OrigYear
else Date = " " .. Date .. OrigYear
end
end
if config.CitationClass=="journal" and is_set(Periodical) then
text = safejoin( {Chapter, Place, tcommon}, sepc );
text = safejoin( {text, pgtext, Date, idcommon}, sepc );
else
text = safejoin( {Chapter, Place, tcommon, Date}, sepc );
text = safejoin( {text, pgtext, idcommon}, sepc );
end
end
if is_set(PostScript) and PostScript ~= sepc then
text = safejoin( {text, sepc}, sepc ); --Deals with italics, spaces, etc.
text = text:sub(1,-sepc:len()-1);
-- text = text:sub(1,-2); --Remove final separator (assumes that sepc is only one character)
end
text = safejoin( {text, PostScript}, sepc );
-- Now enclose the whole thing in a <span/> element
local options = {};
if is_set(config.CitationClass) and config.CitationClass ~= "citation" then
options.class = "citation " .. config.CitationClass;
else
options.class = "citation";
end
if is_set(Ref) and Ref:lower() ~= "none" then
local id = Ref
if ( "harv" == Ref ) then
local names = {} --table of last names & year
if #a > 0 then
for i,v in ipairs(a) do
names[i] = v.last
if i == 4 then break end
end
elseif #e > 0 then
for i,v in ipairs(e) do
names[i] = v.last
if i == 4 then break end
end
end
names[ #names + 1 ] = first_set(Year, anchor_year); -- Year first for legacy citations and for YMD dates that require disambiguation
id = anchorid(names)
end
options.id = id;
end
if string.len(text:gsub("<span[^>/]*>.-</span>", ""):gsub("%b<>","")) <= 2 then
z.error_categories = {};
text = seterror('empty_citation');
z.message_tail = {};
end
if is_set(options.id) then
text = '<span id="' .. mw.uri.anchorEncode(options.id) ..'" class="' .. mw.text.nowiki(options.class) .. '">' .. text .. "</span>";
else
text = '<span class="' .. mw.text.nowiki(options.class) .. '">' .. text .. "</span>";
end
local empty_span = '<span style="display:none;"> </span>';
-- Note: Using display: none on then COinS span breaks some clients.
local OCinS = '<span title="' .. OCinSoutput .. '" class="Z3988">' .. empty_span .. '</span>';
text = text .. OCinS;
if #z.message_tail ~= 0 then
text = text .. " ";
for i,v in ipairs( z.message_tail ) do
if is_set(v[1]) then
if i == #z.message_tail then
text = text .. errorcomment( v[1], v[2] );
else
text = text .. errorcomment( v[1] .. "; ", v[2] );
end
end
end
end
no_tracking_cats = no_tracking_cats:lower();
if inArray(no_tracking_cats, {"", "no", "false", "n"}) then
for _, v in ipairs( z.error_categories ) do
text = text .. '[[Category:' .. v ..']]';
end
for _, v in ipairs( z.maintenance_cats ) do -- append maintenance categories
text = text .. '[[Category:' .. v ..']]';
end
for _, v in ipairs( z.properties_cats ) do -- append maintenance categories
text = text .. '[[Category:' .. v ..']]';
end
end
return text
end
-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
local pframe = frame:getParent()
if nil ~= string.find( frame:getTitle(), 'sandbox', 1, true ) then -- did the {{#invoke:}} use sandbox version?
cfg = mw.loadData( 'Module:Citation/CS1/Configuration/sandbox' ); -- load sandbox versions of Configuration and Whitelist and ...
whitelist = mw.loadData( 'Module:Citation/CS1/Whitelist/sandbox' );
dates = require('Module:Citation/CS1/Date_validation/sandbox').dates -- ... sandbox version of date validation code
else -- otherwise
cfg = mw.loadData( 'Module:Citation/CS1/Configuration' ); -- load live versions of Configuration and Whitelist and ...
whitelist = mw.loadData( 'Module:Citation/CS1/Whitelist' );
dates = require('Module:Citation/CS1/Date_validation').dates -- ... live version of date validation code
end
local args = {};
local suggestions = {};
local error_text, error_state;
local config = {};
for k, v in pairs( frame.args ) do
config[k] = v;
args[k] = v;
end
for k, v in pairs( pframe.args ) do
if v ~= '' then
if not validate( k ) then
error_text = "";
if type( k ) ~= 'string' then
-- Exclude empty numbered parameters
if v:match("%S+") ~= nil then
error_text, error_state = seterror( 'text_ignored', {v}, true );
end
elseif validate( k:lower() ) then
error_text, error_state = seterror( 'parameter_ignored_suggest', {k, k:lower()}, true );
else
if #suggestions == 0 then
suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );
end
if suggestions[ k:lower() ] ~= nil then
error_text, error_state = seterror( 'parameter_ignored_suggest', {k, suggestions[ k:lower() ]}, true );
else
error_text, error_state = seterror( 'parameter_ignored', {k}, true );
end
end
if error_text ~= '' then
table.insert( z.message_tail, {error_text, error_state} );
end
end
args[k] = v;
elseif args[k] ~= nil or (k == 'postscript') then
args[k] = v;
end
end
return citation0( config, args)
end
return z
ouv67wgpu42jhpp9us6afp3wyk4jtbb
189436
189435
2022-08-16T15:32:06Z
Venise12mai1834
8884
ย้อนกลับไปรุ่นที่ 189420 โดย [[Special:Contributions/Venise12mai1834|Venise12mai1834]] ([[User talk:Venise12mai1834|พูดคุย]]) ด้วย[[WS:iScript|สจห.]]
Scribunto
text/plain
local z = {
error_categories = {}; -- for categorizing citations that contain errors
error_ids = {};
message_tail = {};
maintenance_cats = {}; -- for categorizing citations that aren't erroneous per se, but could use a little work
properties_cats = {}; -- for categorizing citations based on certain properties, language of source for instance
}
-- Whether variable is set or not
function is_set( var )
return not (var == nil or var == '');
end
-- First set variable or nil if none
function first_set(...)
local list = {...};
for _, var in pairs(list) do
if is_set( var ) then
return var;
end
end
end
-- Whether needle is in haystack
function inArray( needle, haystack )
if needle == nil then
return false;
end
for n,v in ipairs( haystack ) do
if v == needle then
return n;
end
end
return false;
end
--[[
Categorize and emit an error message when the citation contains one or more deprecated parameters. Because deprecated parameters (currently |month=,
|coauthor=, and |coauthors=) aren't related to each other and because these parameters may be concatenated into the variables used by |date= and |author#= (and aliases)
details of which parameter caused the error message are not provided. Only one error message is emitted regardless of the number of deprecated parameters in the citation.
]]
function deprecated_parameter(name)
if true ~= Page_in_deprecated_cat then -- if we haven't been here before then set a
Page_in_deprecated_cat=true; -- sticky flag so that if there are more than one deprecated parameter the category is added only once
table.insert( z.message_tail, { seterror( 'deprecated_params', {name}, true ) } ); -- add error message
end
end
-- Populates numbered arguments in a message string using an argument table.
function substitute( msg, args )
return args and mw.message.newRawMessage( msg, args ):plain() or msg;
end
--[[--------------------------< K E R N _ Q U O T E S >--------------------------------------------------------
Apply kerning to open the space between the quote mark provided by the Module and a leading or trailing quote mark contained in a |title= or |chapter= parameter's value.
This function will positive kern either single or double quotes:
"'Unkerned title with leading and trailing single quote marks'"
" 'Kerned title with leading and trailing single quote marks' " (in real life the kerning isn't as wide as this example)
Double single quotes (italic or bold wikimarkup) are not kerned.
Call this function for chapter titles, for website titles, etc; not for book titles.
]]
function kern_quotes (str)
local cap='';
local cap2='';
cap, cap2 = str:match ("^([\"\'])([^\'].+)"); -- match leading double or single quote but not double single quotes
if is_set (cap) then
str = substitute (cfg.presentation['kern-left'], {cap, cap2});
end
cap, cap2 = str:match ("^(.+[^\'])([\"\'])$")
if is_set (cap) then
str = substitute (cfg.presentation['kern-right'], {cap, cap2});
end
return str;
end
--[[--------------------------< F O R M A T _ S C R I P T _ V A L U E >----------------------------------------
|script-title= holds title parameters that are not written in Latin based scripts: Chinese, Japanese, Arabic, Hebrew, etc. These scripts should
not be italicized and may be written right-to-left. The value supplied by |script-title= is concatenated onto Title after Title has been wrapped
in italic markup.
Regardless of language, all values provided by |script-title= are wrapped in <bdi>...</bdi> tags to isolate rtl languages from the English left to right.
|script-title= provides a unique feature. The value in |script-title= may be prefixed with a two-character ISO639-1 language code and a colon:
|script-title=ja:*** *** (where * represents a Japanese character)
Spaces between the two-character code and the colon and the colon and the first script character are allowed:
|script-title=ja : *** ***
|script-title=ja: *** ***
|script-title=ja :*** ***
Spaces preceding the prefix are allowed: |script-title = ja:*** ***
The prefix is checked for validity. If it is a valid ISO639-1 language code, the lang attribute (lang="ja") is added to the <bdi> tag so that browsers can
know the language the tag contains. This may help the browser render the script more correctly. If the prefix is invalid, the lang attribute
is not added. At this time there is no error message for this condition.
At this writing, only |script-title= is supported. It is anticipated that additional parameters will be created to use this function.
TODO: error messages when prefix is invalid ISO639-1 code; when script_value has prefix but no script;
]]
function format_script_value (script_value)
local lang=''; -- initialize to empty string
local name;
if script_value:match('^%l%l%s*:') then -- if first 3 non-space characters are script language prefix
lang = script_value:match('^(%l%l)%s*:%s*%S.*'); -- get the language prefix or nil if there is no script
if not is_set (lang) then
return ''; -- script_value was just the prefix so return empty string
end
-- if we get this far we have prefix and script
name = mw.language.fetchLanguageName( lang, "en" ); -- get language name so that we can use it to categorize
if is_set (name) then -- is prefix a proper ISO 639-1 language code?
script_value = script_value:gsub ('^%l%l%s*:%s*', ''); -- strip prefix from script
-- is prefix one of these language codes?
if inArray (lang, {'ar', 'bs', 'dv', 'el', 'fa', 'hy', 'ja', 'ko', 'ku', 'he', 'ps', 'ru', 'sd', 'sr', 'th', 'uk', 'ug', 'yi', 'zh'}) then
table.insert( z.properties_cats, 'CS1 uses ' .. name .. '-language script ('..lang..')'); -- categorize in language-specific categories
else
table.insert( z.properties_cats, 'CS1 uses foreign language script'); -- use this category as a catchall until language-specific category is available
end
lang = ' lang="' .. lang .. '" '; -- convert prefix into a lang attribute
else
lang = ''; -- invalid so set lang to empty string
end
end
script_value = substitute (cfg.presentation['bdi'], {lang, script_value}); -- isolate in case script is rtl
return script_value;
end
--[[--------------------------< S C R I P T _ C O N C A T E N A T E >------------------------------------------
Initially for |title= and |script-title=, this function concatenates those two parameter values after the script value has been
wrapped in <bdi> tags.
]]
function script_concatenate (title, script)
if is_set (script) then
script = format_script_value (script); -- <bdi> tags, lang atribute, categorization, etc; returns empty string on error
if is_set (script) then
title = title .. ' ' .. script; -- concatenate title and script title
end
end
return title;
end
--[[--------------------------< W R A P _ S T Y L E >----------------------------------------------------------
Applies styling to various parameters. Supplied string is wrapped using a message_list configuration taking one
argument; protects italic styled parameters. Additional text taken from citation_config.presentation - the reason
this function is similar to but separate from wrap_msg().
]]
function wrap_style (key, str)
if not is_set( str ) then
return "";
elseif inArray( key, { 'italic-title', 'trans-italic-title' } ) then
str = safeforitalics( str );
end
return substitute( cfg.presentation[key], {str} );
end
--[[--------------------------< W R A P _ M S G >--------------------------------------------------------------
Applies additional message text to various parameter values. Supplied string is wrapped using a message_list
configuration taking one argument. Supports lower case text for {{citation}} templates. Additional text taken
from citation_config.messages - the reason this function is similar to but separate from wrap_style().
]]
function wrap_msg (key, str, lower)
if not is_set( str ) then
return "";
end
if true == lower then
local msg;
msg = cfg.messages[key]:lower(); -- set the message to lower case before
str = substitute( msg, {str} ); -- including template text
return str;
else
return substitute( cfg.messages[key], {str} );
end
end
--[[--------------------------< F O R M A T _ C H A P T E R _ T I T L E >--------------------------------------
Format the three chapter parameters: |chapter=, |trans-chapter=, and |chapter-url= into a single Chapter meta-
parameter (chapter_url_source used for error messages).
]]
function format_chapter_title (chapter, transchapter, chapterurl, chapter_url_source)
local chapter_error = '';
if not is_set (chapter) then
chapter = ''; -- just to be safe for concatenation
if is_set (transchapter) then
chapter = wrap_style ('trans-quoted-title', transchapter);
chapter_error = " " .. seterror ('trans_missing_chapter');
end
if is_set (chapterurl) then
chapter = externallink (chapterurl, chapter, chapter_url_source); -- adds bare_url_missing_title error if appropriate
end
return chapter .. chapter_error;
else -- here when chapter is set
chapter = kern_quotes (chapter); -- if necessary, separate chapter title's leading and trailing quote marks from Module provided quote marks
chapter = wrap_style ('quoted-title', chapter);
if is_set (transchapter) then
transchapter = wrap_style ('trans-quoted-title', transchapter);
chapter = chapter .. ' ' .. transchapter;
end
if is_set (chapterurl) then
chapter = externallink (chapterurl, chapter); -- adds bare_url_missing_title error if appropriate
end
end
return chapter;
end
--[[
Argument wrapper. This function provides support for argument
mapping defined in the configuration file so that multiple names
can be transparently aliased to single internal variable.
]]
function argument_wrapper( args )
local origin = {};
return setmetatable({
ORIGIN = function( self, k )
local dummy = self[k]; --force the variable to be loaded.
return origin[k];
end
},
{
__index = function ( tbl, k )
if origin[k] ~= nil then
return nil;
end
local args, list, v = args, cfg.aliases[k];
if type( list ) == 'table' then
v, origin[k] = selectone( args, list, 'redundant_parameters' );
if origin[k] == nil then
origin[k] = ''; -- Empty string, not nil
end
elseif list ~= nil then
v, origin[k] = args[list], list;
else
-- maybe let through instead of raising an error?
-- v, origin[k] = args[k], k;
error( cfg.messages['unknown_argument_map'] );
end
-- Empty strings, not nil;
if v == nil then
v = cfg.defaults[k] or '';
origin[k] = '';
end
tbl = rawset( tbl, k, v );
return v;
end,
});
end
--[[
Looks for a parameter's name in the whitelist.
Parameters in the whitelist can have three values:
true - active, supported parameters
false - deprecated, supported parameters
nil - unsupported parameters
]]
function validate( name )
local name = tostring( name );
local state = whitelist.basic_arguments[ name ];
-- Normal arguments
if true == state then return true; end -- valid actively supported parameter
if false == state then
deprecated_parameter (name); -- parameter is deprecated but still supported
return true;
end
-- Arguments with numbers in them
name = name:gsub( "%d+", "#" ); -- replace digit(s) with # (last25 becomes last#
state = whitelist.numbered_arguments[ name ];
if true == state then return true; end -- valid actively supported parameter
if false == state then
deprecated_parameter (name); -- parameter is deprecated but still supported
return true;
end
return false; -- Not supported because not found or name is set to nil
end
--[[--------------------------< E R R O R C O M M E N T >------------------------------------------------------
Wraps error messages with css markup according to the state of hidden.
]]
function errorcomment( content, hidden )
return substitute( hidden and cfg.presentation['hidden-error'] or cfg.presentation['visible-error'], content );
end
--[[
Sets an error condition and returns the appropriate error message. The actual placement
of the error message in the output is the responsibility of the calling function.
]]
function seterror( error_id, arguments, raw, prefix, suffix )
local error_state = cfg.error_conditions[ error_id ];
prefix = prefix or "";
suffix = suffix or "";
if error_state == nil then
error( cfg.messages['undefined_error'] );
elseif is_set( error_state.category ) then
table.insert( z.error_categories, error_state.category );
end
local message = substitute( error_state.message, arguments );
message = message .. " ([[" .. cfg.messages['help page link'] ..
"#" .. error_state.anchor .. "|" ..
cfg.messages['help page label'] .. "]])";
z.error_ids[ error_id ] = true;
if inArray( error_id, { 'bare_url_missing_title', 'trans_missing_title' } )
and z.error_ids['citation_missing_title'] then
return '', false;
end
message = table.concat({ prefix, message, suffix });
if raw == true then
return message, error_state.hidden;
end
return errorcomment( message, error_state.hidden );
end
-- Formats a wiki style external link
function externallinkid(options)
local url_string = options.id;
if options.encode == true or options.encode == nil then
url_string = mw.uri.encode( url_string );
end
return mw.ustring.format( '[[%s|%s]]%s[%s%s%s %s]',
options.link, options.label, options.separator or " ",
options.prefix, url_string, options.suffix or "",
mw.text.nowiki(options.id)
);
end
-- Formats a wiki style internal link
function internallinkid(options)
return mw.ustring.format( '[[%s|%s]]%s[[%s%s%s|%s]]',
options.link, options.label, options.separator or " ",
options.prefix, options.id, options.suffix or "",
mw.text.nowiki(options.id)
);
end
-- Format an external link with error checking
function externallink( URL, label, source )
local error_str = "";
if not is_set( label ) then
label = URL;
if is_set( source ) then
error_str = seterror( 'bare_url_missing_title', { wrap_style ('parameter', source) }, false, " " );
else
error( cfg.messages["bare_url_no_origin"] );
end
end
if not checkurl( URL ) then
error_str = seterror( 'bad_url', {}, false, " " ) .. error_str;
end
return table.concat({ "[", URL, " ", safeforurl( label ), "]", error_str });
end
--[[--------------------------< N O W R A P _ D A T E >--------------------------------------------------------
When date is YYYY-MM-DD format wrap in nowrap span: <span ...>YYYY-MM-DD</span>. When date is DD MMMM YYYY or is
MMMM DD, YYYY then wrap in nowrap span: <span ...>DD MMMM</span> YYYY or <span ...>MMMM DD,</span> YYYY
DOES NOT yet support MMMM YYYY or any of the date ranges.
]]
function nowrap_date (date)
local cap='';
local cap2='';
if date:match("^%d%d%d%d%-%d%d%-%d%d$") then
date = substitute (cfg.presentation['nowrap1'], date);
elseif date:match("%a+%s*%d%d?,%s*%d%d%d%d") or date:match ("%d%d?%s*%a+%s*%d%d%d%d") then
cap, cap2 = string.match (date, "^(.*)%s+(%d%d%d%d)$");
date = substitute (cfg.presentation['nowrap2'], {cap, cap2});
end
return date;
end
--[[--------------------------< A M A Z O N >------------------------------------------------------------------
Formats a link to Amazon. Do simple error checking: asin must be mix of 10 numeric or uppercase alpha
characters. If a mix, first character must be uppercase alpha; if all numeric, asins must be 10-digit
isbn. If 10-digit isbn, add a maintenance category so a bot or awb script can replace |asin= with |isbn=.
Error message if not 10 characters, if not isbn10, if mixed and first character is a digit.
]]
function amazon(id, domain)
local err_cat = ""
if not id:match("^[%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u]$") then
err_cat = ' ' .. seterror ('bad_asin'); -- asin is not a mix of 10 uppercase alpha and numeric characters
else
if id:match("^%d%d%d%d%d%d%d%d%d[%dX]$") then -- if 10-digit numeric (or 9 digits with terminal X)
if checkisbn( id ) then -- see if asin value is isbn10
table.insert( z.maintenance_cats, "CS1 maint: ASIN uses ISBN"); -- add to maint category
elseif not is_set (err_cat) then
err_cat = ' ' .. seterror ('bad_asin'); -- asin is not isbn10
end
elseif not id:match("^%u[%d%u]+$") then
err_cat = ' ' .. seterror ('bad_asin'); -- asin doesn't begin with uppercase alpha
end
end
if not is_set(domain) then
domain = "com";
elseif inArray (domain, {'jp', 'uk'}) then -- Japan, United Kingdom
domain = "co." .. domain;
elseif inArray (domain, {'au', 'br', 'mx'}) then -- Australia, Brazil, Mexico
domain = "com." .. domain;
end
local handler = cfg.id_handlers['ASIN'];
return externallinkid({link = handler.link,
label=handler.label , prefix="//www.amazon."..domain.."/dp/",id=id,
encode=handler.encode, separator = handler.separator}) .. err_cat;
end
--[[--------------------------< A R X I V >--------------------------------------------------------------------
See: http://arxiv.org/help/arxiv_identifier
format and error check arXiv identifier. There are three valid forms of the identifier:
the first form, valid only between date codes 9108 and 0703 is:
arXiv:<archive>.<class>/<date code><number><version>
where:
<archive> is a string of alpha characters - may be hyphenated; no other punctuation
<class> is a string of alpha characters - may be hyphenated; no other punctuation
<date code> is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
first digit of YY for this form can only 9 and 0
<number> is a three-digit number
<version> is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
the second form, valid from April 2007 through December 2014 is:
arXiv:<date code>.<number><version>
where:
<date code> is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
<number> is a four-digit number
<version> is a 1 or more digit number preceded with a lowercase v; no spaces
the third form, valid from January 2015 is:
arXiv:<date code>.<number><version>
where:
<date code> and <version> are as defined for 0704-1412
<number> is a five-digit number
]]
function arxiv (id)
local handler = cfg.id_handlers['ARXIV'];
local year, month, version;
local err_cat = ""
if id:match("^%a[%a%.%-]+/[90]%d[01]%d%d%d%d$") or id:match("^%a[%a%.%-]+/[90]%d[01]%d%d%d%dv%d+$") then -- test for the 9108-0703 format w/ & w/o version
year, month = id:match("^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d[v%d]*$");
year = tonumber(year);
month = tonumber(month);
if ((not (90 < year or 8 > year)) or (1 > month or 12 < month)) or -- if invalid year or invalid month
((91 == year and 7 > month) or (7 == year and 3 < month)) then -- if years ok, are starting and ending months ok?
err_cat = ' ' .. seterror( 'bad_arxiv' ); -- set error message
end
elseif id:match("^%d%d[01]%d%.%d%d%d%d$") or id:match("^%d%d[01]%d%.%d%d%d%dv%d+$") then -- test for the 0704-1412 w/ & w/o version
year, month = id:match("^(%d%d)([01]%d)%.%d%d%d%d[v%d]*$");
year = tonumber(year);
month = tonumber(month);
if ((7 > year) or (14 < year) or (1 > month or 12 < month)) or -- is year invalid or is month invalid? (doesn't test for future years)
((7 == year) and (4 > month)) then --or -- when year is 07, is month invalid (before April)?
err_cat = ' ' .. seterror( 'bad_arxiv' ); -- set error message
end
elseif id:match("^%d%d[01]%d%.%d%d%d%d%d$") or id:match("^%d%d[01]%d%.%d%d%d%d%dv%d+$") then -- test for the 1501- format w/ & w/o version
year, month = id:match("^(%d%d)([01]%d)%.%d%d%d%d%d[v%d]*$");
year = tonumber(year);
month = tonumber(month);
if ((15 > year) or (1 > month or 12 < month)) then -- is year invalid or is month invalid? (doesn't test for future years)
err_cat = ' ' .. seterror( 'bad_arxiv' ); -- set error message
end
else
err_cat = ' ' .. seterror( 'bad_arxiv' ); -- arXiv id doesn't match any format
end
return externallinkid({link = handler.link, label = handler.label,
prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end
--[[
lccn normalization (http://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
a. Remove it.
b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
1. All these characters should be digits, and there should be six or less. (not done in this function)
2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.
Returns a normalized lccn for lccn() to validate. There is no error checking (step 3.b.1) performed in this function.
]]
function normalize_lccn (lccn)
lccn = lccn:gsub ("%s", ""); -- 1. strip whitespace
if nil ~= string.find (lccn,'/') then
lccn = lccn:match ("(.-)/"); -- 2. remove forward slash and all character to the right of it
end
local prefix
local suffix
prefix, suffix = lccn:match ("(.+)%-(.+)"); -- 3.a remove hyphen by splitting the string into prefix and suffix
if nil ~= suffix then -- if there was a hyphen
suffix=string.rep("0", 6-string.len (suffix)) .. suffix; -- 3.b.2 left fill the suffix with 0s if suffix length less than 6
lccn=prefix..suffix; -- reassemble the lccn
end
return lccn;
end
--[[
Format LCCN link and do simple error checking. LCCN is a character string 8-12 characters long. The length of the LCCN dictates the character type of the first 1-3 characters; the
rightmost eight are always digits. http://info-uri.info/registry/OAIHandler?verb=GetRecord&metadataPrefix=reg&identifier=info:lccn/
length = 8 then all digits
length = 9 then lccn[1] is lower case alpha
length = 10 then lccn[1] and lccn[2] are both lower case alpha or both digits
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lower case alpha or both digits
length = 12 then lccn[1] and lccn[2] are both lower case alpha
]]
function lccn(lccn)
local handler = cfg.id_handlers['LCCN'];
local err_cat = ''; -- presume that LCCN is valid
local id = lccn; -- local copy of the lccn
id = normalize_lccn (id); -- get canonical form (no whitespace, hyphens, forward slashes)
local len = id:len(); -- get the length of the lccn
if 8 == len then
if id:match("[^%d]") then -- if LCCN has anything but digits (nil if only digits)
err_cat = ' ' .. seterror( 'bad_lccn' ); -- set an error message
end
elseif 9 == len then -- LCCN should be adddddddd
if nil == id:match("%l%d%d%d%d%d%d%d%d") then -- does it match our pattern?
err_cat = ' ' .. seterror( 'bad_lccn' ); -- set an error message
end
elseif 10 == len then -- LCCN should be aadddddddd or dddddddddd
if id:match("[^%d]") then -- if LCCN has anything but digits (nil if only digits) ...
if nil == id:match("^%l%l%d%d%d%d%d%d%d%d") then -- ... see if it matches our pattern
err_cat = ' ' .. seterror( 'bad_lccn' ); -- no match, set an error message
end
end
elseif 11 == len then -- LCCN should be aaadddddddd or adddddddddd
if not (id:match("^%l%l%l%d%d%d%d%d%d%d%d") or id:match("^%l%d%d%d%d%d%d%d%d%d%d")) then -- see if it matches one of our patterns
err_cat = ' ' .. seterror( 'bad_lccn' ); -- no match, set an error message
end
elseif 12 == len then -- LCCN should be aadddddddddd
if not id:match("^%l%l%d%d%d%d%d%d%d%d%d%d") then -- see if it matches our pattern
err_cat = ' ' .. seterror( 'bad_lccn' ); -- no match, set an error message
end
else
err_cat = ' ' .. seterror( 'bad_lccn' ); -- wrong length, set an error message
end
if not is_set (err_cat) and nil ~= lccn:find ('%s') then
err_cat = ' ' .. seterror( 'bad_lccn' ); -- lccn contains a space, set an error message
end
return externallinkid({link = handler.link, label = handler.label,
prefix=handler.prefix,id=lccn,separator=handler.separator, encode=handler.encode}) .. err_cat;
end
--[[
Format PMID and do simple error checking. PMIDs are sequential numbers beginning at 1 and counting up. This code checks the PMID to see that it
contains only digits and is less than test_limit; the value in local variable test_limit will need to be updated periodically as more PMIDs are issued.
]]
function pmid(id)
local test_limit = 30000000; -- update this value as PMIDs approach
local handler = cfg.id_handlers['PMID'];
local err_cat = ''; -- presume that PMID is valid
if id:match("[^%d]") then -- if PMID has anything but digits
err_cat = ' ' .. seterror( 'bad_pmid' ); -- set an error message
else -- PMID is only digits
local id_num = tonumber(id); -- convert id to a number for range testing
if 1 > id_num or test_limit < id_num then -- if PMID is outside test limit boundaries
err_cat = ' ' .. seterror( 'bad_pmid' ); -- set an error message
end
end
return externallinkid({link = handler.link, label = handler.label,
prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end
--[[
Determines if a PMC identifier's online version is embargoed. Compares the date in |embargo= against today's date. If embargo date is
in the future, returns true; otherwise, returns false because the embargo has expired or |embargo= not set in this cite.
]]
function is_embargoed(embargo)
if is_set(embargo) then
local lang = mw.getContentLanguage();
local good1, embargo_date, good2, todays_date;
good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
good2, todays_date = pcall( lang.formatDate, lang, 'U' );
if good1 and good2 and tonumber( embargo_date ) >= tonumber( todays_date ) then --is embargo date is in the future?
return true; -- still embargoed
end
end
return false; -- embargo expired or |embargo= not set
end
--[[
Format a PMC, do simple error checking, and check for embargoed articles.
The embargo parameter takes a date for a value. If the embargo date is in the future
the PMC identifier will not be linked to the article. If the embargo specifies a date in the past, or if it is empty or omitted, then
the PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.
PMCs are sequential numbers beginning at 1 and counting up. This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.
]]
function pmc(id, embargo)
local test_limit = 5000000; -- update this value as PMCs approach
local handler = cfg.id_handlers['PMC'];
local err_cat = ''; -- presume that PMC is valid
local text;
if id:match("[^%d]") then -- if PMC has anything but digits
err_cat = ' ' .. seterror( 'bad_pmc' ); -- set an error message
else -- PMC is only digits
local id_num = tonumber(id); -- convert id to a number for range testing
if 1 > id_num or test_limit < id_num then -- if PMC is outside test limit boundaries
err_cat = ' ' .. seterror( 'bad_pmc' ); -- set an error message
end
end
if is_embargoed(embargo) then
text="[[" .. handler.link .. "|" .. handler.label .. "]]:" .. handler.separator .. id .. err_cat; --still embargoed so no external link
else
text = externallinkid({link = handler.link, label = handler.label, --no embargo date, ok to link to article
prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end
return text;
end
-- Formats a DOI and checks for DOI errors.
-- DOI names contain two parts: prefix and suffix separated by a forward slash.
-- Prefix: directory indicator '10.' followed by a registrant code
-- Suffix: character string of any length chosen by the registrant
-- This function checks a DOI name for: prefix/suffix. If the doi name contains spaces or endashes,
-- or, if it ends with a period or a comma, this function will emit a bad_doi error message.
-- DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
-- and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely if ever used in doi names.
function doi(id, inactive)
local cat = ""
local handler = cfg.id_handlers['DOI'];
local text;
if is_set(inactive) then
local inactive_year = inactive:match("%d%d%d%d") or ''; -- try to get the year portion from the inactive date
text = "[[" .. handler.link .. "|" .. handler.label .. "]]:" .. id;
if is_set(inactive_year) then
table.insert( z.error_categories, "Pages with DOIs inactive since " .. inactive_year );
else
table.insert( z.error_categories, "Pages with inactive DOIs" ); -- when inactive doesn't contain a recognizable year
end
inactive = " (" .. cfg.messages['inactive'] .. " " .. inactive .. ")"
else
text = externallinkid({link = handler.link, label = handler.label,
prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
inactive = ""
end
if nil == id:match("^10%.[^%s–]-/[^%s–]-[^%.,]$") then -- doi must begin with '10.', must contain a fwd slash, must not contain spaces or endashes, and must not end with period or comma
cat = ' ' .. seterror( 'bad_doi' );
end
return text .. inactive .. cat
end
-- Formats an OpenLibrary link, and checks for associated errors.
function openlibrary(id)
local code = id:match("^%d+([AMW])$"); -- only digits followed by 'A', 'M', or 'W'
local handler = cfg.id_handlers['OL'];
if ( code == "A" ) then
return externallinkid({link=handler.link, label=handler.label,
prefix="http://openlibrary.org/authors/OL",id=id, separator=handler.separator,
encode = handler.encode})
elseif ( code == "M" ) then
return externallinkid({link=handler.link, label=handler.label,
prefix="http://openlibrary.org/books/OL",id=id, separator=handler.separator,
encode = handler.encode})
elseif ( code == "W" ) then
return externallinkid({link=handler.link, label=handler.label,
prefix= "http://openlibrary.org/works/OL",id=id, separator=handler.separator,
encode = handler.encode})
else
return externallinkid({link=handler.link, label=handler.label,
prefix= "http://openlibrary.org/OL",id=id, separator=handler.separator,
encode = handler.encode}) ..
' ' .. seterror( 'bad_ol' );
end
end
--[[
Validate and format an issn. This code fixes the case where an editor has included an ISSN in the citation but has separated the two groups of four
digits with a space. When that condition occurred, the resulting link looked like this:
|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327] -- can't have spaces in an external link
This code now prevents that by inserting a hyphen at the issn midpoint. It also validates the issn for length and makes sure that the checkdigit agrees
with the calculated value. Incorrect length (8 digits), characters other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn
error message. The issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.
]]
function issn(id)
local issn_copy = id; -- save a copy of unadulterated issn; use this version for display if issn does not validate
local handler = cfg.id_handlers['ISSN'];
local text;
local valid_issn = true;
id=id:gsub( "[%s-–]", "" ); -- strip spaces, hyphens, and endashes from the issn
if 8 ~= id:len() or nil == id:match( "^%d*X?$" ) then -- validate the issn: 8 digits long, containing only 0-9 or X in the last position
valid_issn=false; -- wrong length or improper character
else
valid_issn=is_valid_isxn(id, 8); -- validate issn
end
if true == valid_issn then
id = string.sub( id, 1, 4 ) .. "-" .. string.sub( id, 5 ); -- if valid, display correctly formatted version
else
id = issn_copy; -- if not valid, use the show the invalid issn with error message
end
text = externallinkid({link = handler.link, label = handler.label,
prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
if false == valid_issn then
text = text .. ' ' .. seterror( 'bad_issn' ) -- add an error message if the issn is invalid
end
return text
end
--[[--------------------------< M E S S A G E _ I D >----------------------------------------------------------
Validate and format a usenet message id. Simple error checking, looks for 'id-left@id-right' not enclosed in
'<' and/or '>' angle brackets.
]]
function message_id (id)
local handler = cfg.id_handlers['USENETID'];
text = externallinkid({link = handler.link, label = handler.label,
prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
if not id:match('^.+@.+$') or not id:match('^[^<].*[^>]$')then -- doesn't have '@' or has one or first or last character is '< or '>'
text = text .. ' ' .. seterror( 'bad_message_id' ) -- add an error message if the message id is invalid
end
return text
end
--[[--------------------------< S E T _ T I T L E T Y P E >----------------------------------------------------
This function sets default title types (equivalent to the citation including |type=<default value>) for those citations that have defaults.
Also handles the special case where it is desirable to omit the title type from the rendered citation (|type=none).
]]
function set_titletype(cite_class, title_type)
if is_set(title_type) then
if "none" == title_type then
title_type = ""; -- if |type=none then type parameter not displayed
end
return title_type; -- if |type= has been set to any other value use that value
end
if "AV-media-notes" == cite_class or "DVD-notes" == cite_class then -- if this citation is cite AV media notes or cite DVD notes
return "Media notes"; -- display AV media notes / DVD media notes annotation
elseif "mailinglist" == cite_class then -- if this citation is cite mailing list
return "Mailing list"; -- display mailing list annotation
elseif "podcast" == cite_class then -- if this citation is cite podcast
return "Podcast"; -- display podcast annotation
elseif "pressrelease" == cite_class then -- if this citation is cite press release
return "Press release"; -- display press release annotation
elseif "report" == cite_class then -- if this citation is cite report
return "Report"; -- display report annotation
elseif "techreport" == cite_class then -- if this citation is cite techreport
return "Technical report"; -- display techreport annotation
elseif "thesis" == cite_class then -- if this citation is cite thesis (degree option handled after this function returns)
return "Thesis"; -- display simple thesis annotation (without |degree= modification)
end
end
--[[
Determines whether a URL string is valid
At present the only check is whether the string appears to
be prefixed with a URI scheme. It is not determined whether
the URI scheme is valid or whether the URL is otherwise well
formed.
]]
function checkurl( url_str )
-- Protocol-relative or URL scheme
return url_str:sub(1,2) == "//" or url_str:match( "^[^/]*:" ) ~= nil;
end
-- Removes irrelevant text and dashes from ISBN number
-- Similar to that used for Special:BookSources
function cleanisbn( isbn_str )
return isbn_str:gsub( "[^-0-9X]", "" );
end
--[[--------------------------< E S C A P E _ L U A _ M A G I C _ C H A R S >----------------------------------
Returns a string where all of lua's magic characters have been escaped. This is important because functions like
string.gsub() treat their pattern and replace strings as patterns, not literal strings.
]]
function escape_lua_magic_chars (argument)
argument = argument:gsub("%%", "%%%%"); -- replace % with %%
argument = argument:gsub("([%^%$%(%)%.%[%]%*%+%-%?])", "%%%1"); -- replace all other lua magic pattern characters
return argument;
end
--[[--------------------------< S T R I P _ A P O S T R O P H E _ M A R K U P >--------------------------------
Strip wiki italic and bold markup from argument so that it doesn't contaminate COinS metadata.
This function strips common patterns of apostrophe markup. We presume that editors who have taken the time to
markup a title have, as a result, provided valid markup. When they don't, some single apostrophes are left behind.
]]
function strip_apostrophe_markup (argument)
if not is_set (argument) then return argument; end
while true do
if argument:match ("%'%'%'%'%'") then -- bold italic (5)
argument=argument:gsub("%'%'%'%'%'", ""); -- remove all instances of it
elseif argument:match ("%'%'%'%'") then -- italic start and end without content (4)
argument=argument:gsub("%'%'%'%'", "");
elseif argument:match ("%'%'%'") then -- bold (3)
argument=argument:gsub("%'%'%'", "");
elseif argument:match ("%'%'") then -- italic (2)
argument=argument:gsub("%'%'", "");
else
break;
end
end
return argument; -- done
end
--[[--------------------------< M A K E _ C O I N S _ T I T L E >----------------------------------------------
Makes a title for COinS from Title and / or ScriptTitle (or any other name-script pairs)
Apostrophe markup (bold, italics) is stripped from each value so that the COinS metadata isn't correupted with strings
of %27%27...
]]
function make_coins_title (title, script)
if is_set (title) then
title = strip_apostrophe_markup (title); -- strip any apostrophe markup
else
title=''; -- if not set, make sure title is an empty string
end
if is_set (script) then
script = script:gsub ('^%l%l%s*:%s*', ''); -- remove language prefix if present (script value may now be empty string)
script = strip_apostrophe_markup (script); -- strip any apostrophe markup
else
script=''; -- if not set, make sure script is an empty string
end
if is_set (title) and is_set (script) then
script = ' ' .. script; -- add a space before we concatenate
end
return title .. script; -- return the concatenation
end
--[[--------------------------< G E T _ C O I N S _ P A G E S >------------------------------------------------
Extract page numbers from external wikilinks in any of the |page=, |pages=, or |at= parameters for use in COinS.
]]
function get_coins_pages (pages)
local pattern;
if not is_set (pages) then return pages; end -- if no page numbers then we're done
while true do
pattern = pages:match("%[(%w*:?//[^ ]+%s+)[%w%d].*%]"); -- pattern is the opening bracket, the url and following space(s): "[url "
if nil == pattern then break; end -- no more urls
pattern = escape_lua_magic_chars (pattern); -- pattern is not a literal string; escape lua's magic pattern characters
pages = pages:gsub(pattern, ""); -- remove as many instances of pattern as possible
end
pages = pages:gsub("[%[%]]", ""); -- remove the brackets
pages = pages:gsub("–", "-" ); -- replace endashes with hyphens
pages = pages:gsub("&%w+;", "-" ); -- and replace html entities (– etc.) with hyphens; do we need to replace numerical entities like   and the like?
return pages;
end
--[[
ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit. ISBN-13 is checked in checkisbn().
If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length and stripped of dashes,
spaces and other non-isxn characters.
]]
function is_valid_isxn (isxn_str, len)
local temp = 0;
isxn_str = { isxn_str:byte(1, len) }; -- make a table of bytes
len = len+1; -- adjust to be a loop counter
for i, v in ipairs( isxn_str ) do -- loop through all of the bytes and calculate the checksum
if v == string.byte( "X" ) then -- if checkdigit is X
temp = temp + 10*( len - i ); -- it represents 10 decimal
else
temp = temp + tonumber( string.char(v) )*(len-i);
end
end
return temp % 11 == 0; -- returns true if calculation result is zero
end
-- Determines whether an ISBN string is valid
function checkisbn( isbn_str )
if nil ~= isbn_str:match("[^%s-0-9X]") then return false; end -- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
isbn_str = isbn_str:gsub( "-", "" ):gsub( " ", "" ); -- remove hyphens and spaces
local len = isbn_str:len();
if len ~= 10 and len ~= 13 then
return false;
end
if len == 10 then
if isbn_str:match( "^%d*X?$" ) == nil then return false; end
return is_valid_isxn(isbn_str, 10);
else
local temp = 0;
if isbn_str:match( "^97[89]%d*$" ) == nil then return false; end -- isbn13 begins with 978 or 979
isbn_str = { isbn_str:byte(1, len) };
for i, v in ipairs( isbn_str ) do
temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );
end
return temp % 10 == 0;
end
end
-- Gets the display text for a wikilink like [[A|B]] or [[B]] gives B
function removewikilink( str )
return (str:gsub( "%[%[([^%[%]]*)%]%]", function(l)
return l:gsub( "^[^|]*|(.*)$", "%1" ):gsub("^%s*(.-)%s*$", "%1");
end));
end
-- Escape sequences for content that will be used for URL descriptions
function safeforurl( str )
if str:match( "%[%[.-%]%]" ) ~= nil then
table.insert( z.message_tail, { seterror( 'wikilink_in_url', {}, true ) } );
end
return str:gsub( '[%[%]\n]', {
['['] = '[',
[']'] = ']',
['\n'] = ' ' } );
end
-- Converts a hyphen to a dash
function hyphentodash( str )
if not is_set(str) or str:match( "[%[%]{}<>]" ) ~= nil then
return str;
end
return str:gsub( '-', '–' );
end
-- Protects a string that will be wrapped in wiki italic markup '' ... ''
function safeforitalics( str )
--[[ Note: We cannot use <i> for italics, as the expected behavior for
italics specified by ''...'' in the title is that they will be inverted
(i.e. unitalicized) in the resulting references. In addition, <i> and ''
tend to interact poorly under Mediawiki's HTML tidy. ]]
if not is_set(str) then
return str;
else
if str:sub(1,1) == "'" then str = "<span></span>" .. str; end
if str:sub(-1,-1) == "'" then str = str .. "<span></span>"; end
-- Remove newlines as they break italics.
return str:gsub( '\n', ' ' );
end
end
--[[--------------------------< S A F E J O I N >--------------------------------------------------------------
Joins a sequence of strings together while checking for duplicate separation characters.
]]
function safejoin( tbl, duplicate_char )
--[[
Note: we use string functions here, rather than ustring functions.
This has considerably faster performance and should work correctly as
long as the duplicate_char is strict ASCII. The strings
in tbl may be ASCII or UTF8.
]]
local str = ''; -- the output string
local comp = ''; -- what does 'comp' mean?
local end_chr = '';
local trim;
for _, value in ipairs( tbl ) do
if value == nil then value = ''; end
if str == '' then -- if output string is empty
str = value; -- assign value to it (first time through the loop)
elseif value ~= '' then
if value:sub(1,1) == '<' then -- Special case of values enclosed in spans and other markup.
comp = value:gsub( "%b<>", "" ); -- remove html markup (<span>string</span> -> string)
else
comp = value;
end
-- typically duplicate_char is sepc
if comp:sub(1,1) == duplicate_char then -- is first charactier same as duplicate_char? why test first character?
-- Because individual string segments often (always?) begin with terminal punct for th
-- preceding segment: 'First element' .. 'sepc next element' .. etc?
trim = false;
end_chr = str:sub(-1,-1); -- get the last character of the output string
-- str = str .. "<HERE(enchr=" .. end_chr.. ")" -- debug stuff?
if end_chr == duplicate_char then -- if same as separator
str = str:sub(1,-2); -- remove it
elseif end_chr == "'" then -- if it might be wikimarkup
if str:sub(-3,-1) == duplicate_char .. "''" then -- if last three chars of str are sepc''
str = str:sub(1, -4) .. "''"; -- remove them and add back ''
elseif str:sub(-5,-1) == duplicate_char .. "]]''" then -- if last five chars of str are sepc]]''
trim = true; -- why? why do this and next differently from previous?
elseif str:sub(-4,-1) == duplicate_char .. "]''" then -- if last four chars of str are sepc]''
trim = true; -- same question
end
elseif end_chr == "]" then -- if it might be wikimarkup
if str:sub(-3,-1) == duplicate_char .. "]]" then -- if last three chars of str are sepc]] wikilink
trim = true;
elseif str:sub(-2,-1) == duplicate_char .. "]" then -- if last two chars of str are sepc] external link
trim = true;
elseif str:sub(-4,-1) == duplicate_char .. "'']" then -- normal case when |url=something & |title=Title.
trim = true;
end
elseif end_chr == " " then -- if last char of output string is a space
if str:sub(-2,-1) == duplicate_char .. " " then -- if last two chars of str are <sepc><space>
str = str:sub(1,-3); -- remove them both
end
end
if trim then
if value ~= comp then -- value does not equal comp when value contains html markup
local dup2 = duplicate_char;
if dup2:match( "%A" ) then dup2 = "%" .. dup2; end -- if duplicate_char not a letter then escape it
value = value:gsub( "(%b<>)" .. dup2, "%1", 1 ) -- remove duplicate_char if it follows html markup
else
value = value:sub( 2, -1 ); -- remove duplicate_char when it is first character
end
end
end
str = str .. value; --add it to the output string
end
end
return str;
end
-- Attempts to convert names to initials.
function reducetoinitials(first)
local initials = {}
local i = 0; -- counter for number of initials
for word in string.gmatch(first, "%S+") do
table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
i = i + 1; -- bump the counter
if 2 <= i then break; end -- only two initials allowed in Vancouver system; if 2, quit
end
return table.concat(initials) -- Vancouver format does not include spaces.
end
-- Formats a list of people (e.g. authors / editors)
function listpeople(control, people)
local sep;
local namesep;
local format = control.format
local maximum = control.maximum
local lastauthoramp = control.lastauthoramp;
local text = {}
local etal = false;
if 'vanc' == format then -- Vancouver-like author/editor name styling?
sep = ','; -- name-list separator between authors is a comma
namesep = ' '; -- last/first separator is a space
else
sep = ';' -- name-list separator between authors is a semicolon
namesep = ', ' -- last/first separator is <comma><space>
end
if sep:sub(-1,-1) ~= " " then sep = sep .. " " end
if maximum ~= nil and maximum < 1 then return "", 0; end
for i,person in ipairs(people) do
if is_set(person.last) then
local mask = person.mask
local one
local sep_one = sep;
if maximum ~= nil and i > maximum then
etal = true;
break;
elseif (mask ~= nil) then
local n = tonumber(mask)
if (n ~= nil) then
one = string.rep("—",n)
else
one = mask;
sep_one = " ";
end
else
one = person.last
local first = person.first
if is_set(first) then
if ( "vanc" == format ) then first = reducetoinitials(first) end
one = one .. namesep .. first
end
if is_set(person.link) and person.link ~= control.page_name then
one = "[[" .. person.link .. "|" .. one .. "]]" -- link author/editor if this page is not the author's/editor's page
end
if is_set(person.link) and ((nil ~= person.link:find("//")) or (nil ~= person.link:find("[%[%]]"))) then
one = one .. " " .. seterror( 'bad_authorlink' ) end -- url or wikilink in author link;
end
table.insert( text, one )
table.insert( text, sep_one )
end
end
local count = #text / 2;
if count > 0 then
if count > 1 and is_set(lastauthoramp) and not etal then
text[#text-2] = " & ";
end
text[#text] = nil;
end
local result = table.concat(text) -- construct list
if etal then
local etal_text = cfg.messages['et al'];
result = result .. " " .. etal_text;
end
return result, count
end
--[[--------------------------< A N C H O R I D >--------------------------------------------------------------
Generates a CITEREF anchor ID if we have at least one name or a date. Otherwise returns an empty string.
]]
function anchorid( options )
local id = table.concat( options ); -- concatenate names and year for CITEREF id
if is_set (id) then -- if concatenation is not an empty string
return "CITEREF" .. id; -- add the CITEREF portion
else
return ''; -- return an empty string; no reason to include CITEREF id in this citation
end
end
--[[
Gets name list from the input arguments
Searches through args in sequential order to find |lastn= and |firstn= parameters (or their aliases), and their matching link and mask parameters.
Stops searching when both |lastn= and |firstn= are not found in args after two sequential attempts: found |last1=, |last2=, and |last3= but doesn't
find |last4= and |last5= then the search is done.
This function emits an error message when there is a |firstn= without a matching |lastn=. When there are 'holes' in the list of last names, |last1= and |last3=
are present but |last2= is missing, an error message is emitted. |lastn= is not required to have a matching |firstn=.
]]
function extractnames(args, list_name)
local names = {}; -- table of names
local last; -- individual name components
local first;
local link;
local mask;
local i = 1; -- loop counter/indexer
local n = 1; -- output table indexer
local count = 0; -- used to count the number of times we haven't found a |last= (or alias for authors, |editor-last or alias for editors)
local err_msg_list_name = list_name:match ("(%w+)List") .. 's list'; -- modify AuthorList or EditorList for use in error messages if necessary
while true do
last = selectone( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', i ); -- search through args for name components beginning at 1
first = selectone( args, cfg.aliases[list_name .. '-First'], 'redundant_parameters', i );
link = selectone( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i );
mask = selectone( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );
if first and not last then -- if there is a firstn without a matching lastn
table.insert( z.message_tail, { seterror( 'first_missing_last', {err_msg_list_name, i}, true ) } ); -- add this error message
elseif not first and not last then -- if both firstn and lastn aren't found, are we done?
count = count + 1; -- number of times we haven't found last and first
if 2 == count then -- two missing names and we give up
break; -- normal exit or there is a two-name hole in the list; can't tell which
end
else -- we have last with or without a first
names[n] = {last = last, first = first, link = link, mask = mask}; -- add this name to our names list
n = n + 1; -- point to next location in the names table
if 1 == count then -- if the previous name was missing
table.insert( z.message_tail, { seterror( 'missing_name', {err_msg_list_name, i-1}, true ) } ); -- add this error message
end
count = 0; -- reset the counter, we're looking for two consecutive missing names
end
i = i + 1; -- point to next args location
end
return names; -- all done, return our list of names
end
-- Populates ID table from arguments using configuration settings
function extractids( args )
local id_list = {};
for k, v in pairs( cfg.id_handlers ) do
v = selectone( args, v.parameters, 'redundant_parameters' );
if is_set(v) then id_list[k] = v; end
end
return id_list;
end
--[[--------------------------< B U I L D I D L I S T >--------------------------------------------------------
Takes a table of IDs and turns it into a table of formatted ID outputs.
]]
function buildidlist( id_list, options )
local new_list, handler = {};
function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
for k, v in pairs( id_list ) do
-- fallback to read-only cfg
handler = setmetatable( { ['id'] = v }, fallback(k) );
if handler.mode == 'external' then
table.insert( new_list, {handler.label, externallinkid( handler ) } );
elseif handler.mode == 'internal' then
table.insert( new_list, {handler.label, internallinkid( handler ) } );
elseif handler.mode ~= 'manual' then
error( cfg.messages['unknown_ID_mode'] );
elseif k == 'DOI' then
table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
elseif k == 'ARXIV' then
table.insert( new_list, {handler.label, arxiv( v ) } );
elseif k == 'ASIN' then
table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } );
elseif k == 'LCCN' then
table.insert( new_list, {handler.label, lccn( v ) } );
elseif k == 'OL' then
table.insert( new_list, {handler.label, openlibrary( v ) } );
elseif k == 'PMC' then
table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
elseif k == 'PMID' then
table.insert( new_list, {handler.label, pmid( v ) } );
elseif k == 'ISSN' then
table.insert( new_list, {handler.label, issn( v ) } );
elseif k == 'ISBN' then
local ISBN = internallinkid( handler );
if not checkisbn( v ) and not is_set(options.IgnoreISBN) then
ISBN = ISBN .. seterror( 'bad_isbn', {}, false, " ", "" );
end
table.insert( new_list, {handler.label, ISBN } );
elseif k == 'USENETID' then
table.insert( new_list, {handler.label, message_id( v ) } );
else
error( cfg.messages['unknown_manual_ID'] );
end
end
function comp( a, b ) -- used in following table.sort()
return a[1] < b[1];
end
table.sort( new_list, comp );
for k, v in ipairs( new_list ) do
new_list[k] = v[2];
end
return new_list;
end
-- Chooses one matching parameter from a list of parameters to consider
-- Generates an error if more than one match is present.
function selectone( args, possible, error_condition, index )
local value = nil;
local selected = '';
local error_list = {};
if index ~= nil then index = tostring(index); end
-- Handle special case of "#" replaced by empty string
if index == '1' then
for _, v in ipairs( possible ) do
v = v:gsub( "#", "" );
if is_set(args[v]) then
if value ~= nil and selected ~= v then
table.insert( error_list, v );
else
value = args[v];
selected = v;
end
end
end
end
for _, v in ipairs( possible ) do
if index ~= nil then
v = v:gsub( "#", index );
end
if is_set(args[v]) then
if value ~= nil and selected ~= v then
table.insert( error_list, v );
else
value = args[v];
selected = v;
end
end
end
if #error_list > 0 then
local error_str = "";
for _, k in ipairs( error_list ) do
if error_str ~= "" then error_str = error_str .. cfg.messages['parameter-separator'] end
error_str = error_str .. wrap_style ('parameter', k);
end
if #error_list > 1 then
error_str = error_str .. cfg.messages['parameter-final-separator'];
else
error_str = error_str .. cfg.messages['parameter-pair-separator'];
end
error_str = error_str .. wrap_style ('parameter', selected);
table.insert( z.message_tail, { seterror( error_condition, {error_str}, true ) } );
end
return value, selected;
end
-- COinS metadata (see <http://ocoins.info/>) allows automated tools to parse
-- the citation information.
function COinS(data)
if 'table' ~= type(data) or nil == next(data) then
return '';
end
local ctx_ver = "Z39.88-2004";
-- treat table strictly as an array with only set values.
local OCinSoutput = setmetatable( {}, {
__newindex = function(self, key, value)
if is_set(value) then
rawset( self, #self+1, table.concat{ key, '=', mw.uri.encode( removewikilink( value ) ) } );
end
end
});
if is_set(data.Chapter) then
OCinSoutput.rft_val_fmt = "info:ofi/fmt:kev:mtx:book";
OCinSoutput["rft.genre"] = "bookitem";
OCinSoutput["rft.atitle"] = data.Chapter;
OCinSoutput["rft.btitle"] = data.Title;
elseif is_set(data.Periodical) then
OCinSoutput.rft_val_fmt = "info:ofi/fmt:kev:mtx:journal";
OCinSoutput["rft.genre"] = "article";
OCinSoutput["rft.jtitle"] = data.Periodical;
OCinSoutput["rft.atitle"] = data.Title;
else
OCinSoutput.rft_val_fmt = "info:ofi/fmt:kev:mtx:book";
OCinSoutput["rft.genre"] = "book"
OCinSoutput["rft.btitle"] = data.Title;
end
OCinSoutput["rft.place"] = data.PublicationPlace;
OCinSoutput["rft.date"] = data.Date;
OCinSoutput["rft.series"] = data.Series;
OCinSoutput["rft.volume"] = data.Volume;
OCinSoutput["rft.issue"] = data.Issue;
OCinSoutput["rft.pages"] = data.Pages;
OCinSoutput["rft.edition"] = data.Edition;
OCinSoutput["rft.pub"] = data.PublisherName;
for k, v in pairs( data.ID_list ) do
local id, value = cfg.id_handlers[k].COinS;
if k == 'ISBN' then value = cleanisbn( v ); else value = v; end
if string.sub( id or "", 1, 4 ) == 'info' then
OCinSoutput["rft_id"] = table.concat{ id, "/", v };
else
OCinSoutput[ id ] = value;
end
end
local last, first;
for k, v in ipairs( data.Authors ) do
last, first = v.last, v.first;
if k == 1 then
if is_set(last) then
OCinSoutput["rft.aulast"] = last;
end
if is_set(first) then
OCinSoutput["rft.aufirst"] = first;
end
end
if is_set(last) and is_set(first) then
OCinSoutput["rft.au"] = table.concat{ last, ", ", first };
elseif is_set(last) then
OCinSoutput["rft.au"] = last;
end
end
OCinSoutput.rft_id = data.URL;
OCinSoutput.rfr_id = table.concat{ "info:sid/", mw.site.server:match( "[^/]*$" ), ":", data.RawPage };
OCinSoutput = setmetatable( OCinSoutput, nil );
-- sort with version string always first, and combine.
table.sort( OCinSoutput );
table.insert( OCinSoutput, 1, "ctx_ver=" .. ctx_ver ); -- such as "Z39.88-2004"
return table.concat(OCinSoutput, "&");
end
--[[--------------------------< G E T _ I S O 6 3 9 _ C O D E >------------------------------------------------
Validates language names provided in |language= parameter if not an ISO639-1 code. Handles the special case that is Norwegian where
ISO639-1 code 'no' is mapped to language name 'Norwegian Bokmål' by Extention:CLDR.
Returns the language name and associated ISO639-1 code. Because case of the source may be incorrect or different from the case that Wikimedia
uses, the name comparisons are done in lower case and when a match is found, the Wikimedia version (assumed to be correct) is returned along
with the code. When there is no match, we return the original language name string.
mw.language.fetchLanguageNames() will return a list of languages that aren't part of ISO639-1. Names that aren't ISO639-1 but that are included
in the list will be found if that name is provided in the |language= parameter. For example, if |language=Samaritan Aramaic, that name will be
found with the associated code 'sam', not an ISO639-1 code. When names are found and the associated code is not two characters, this function
returns only the Wikimedia language name.
Adapted from code taken from Module:Check ISO 639-1.
]]
function get_iso639_code (lang)
if 'norwegian' == lang:lower() then -- special case related to Wikimedia remap of code 'no' at Extension:CLDR
return 'Norwegian', 'no'; -- Make sure rendered version is properly capitalized
end
local languages = mw.language.fetchLanguageNames('en', 'all') -- get a list of language names known to Wikimedia
-- ('all' is required for North Ndebele, South Ndebele, and Ojibwa)
local langlc = mw.ustring.lower(lang); -- lower case version for comparisons
for code, name in pairs(languages) do -- scan the list to see if we can find our language
if langlc == mw.ustring.lower(name) then
if 2 ~= code:len() then -- ISO639-1 codes only
return name; -- so return the name but not the code
end
return name, code; -- found it, return name to ensure proper capitalization and the ISO639-1 code
end
end
return lang; -- not valid language; return language in original case and nil for ISO639-1 code
end
--[[--------------------------< L A N G U A G E _ P A R A M E T E R >------------------------------------------
Get language name from ISO639-1 code value provided. If a code is valid use the returned name; if not, then use the value that was provided with the language parameter.
There is an exception. There are three ISO639-1 codes for Norewegian language variants. There are two official variants: Norwegian Bokmål (code 'nb') and
Norwegian Nynorsk (code 'nn'). The third, code 'no', is defined by ISO639-1 as 'Norwegian' though in Norway this is pretty much meaningless. However, it appears
that on enwiki, editors are for the most part unaware of the nb and nn variants (compare page counts for these variants at Category:Articles with non-English-language external links.
Because Norwegian Bokmål is the most common language variant, Media wiki has been modified to return Norwegian Bokmål for ISO639-1 code 'no'. Here we undo that and
return 'Norwegian' when editors use |language=no. We presume that editors don't know about the variants or can't descriminate between them.
See Help talk:Citation Style_1#An ISO 639-1 language name test
When |language= contains a valid ISO639-1 code, the page is assigned to the category for that code: Category:Norwegian-language sources (no) if
the page is a mainspace page and the ISO639-1 code is not 'en'. Similarly, if the parameter is |language=Norwegian, it will be categorized in the same way.
]]
function language_parameter (lang, namespace)
local code; -- the ISO639-1 two character code
local name; -- the language name
local test='';
if 0 == namespace and (('en' == lang:lower()) or ('english' == lang:lower())) then
table.insert (z.maintenance_cats, 'CS1 maint: English language specified'); -- add maintenance category if |language=English or |language=en in article space
end
if 2 == lang:len() then -- ISO639-1 language code are 2 characters (fetchLanguageName also supports 3 character codes)
name = mw.language.fetchLanguageName( lang:lower(), "en" ); -- get ISO 639-1 language name if Language is a proper code
end
if is_set (name) then -- if Language specified a valid ISO639-1 code
code = lang:lower(); -- save it
else
name, code = get_iso639_code (lang); -- attempt to get code from name (assign name here so that we are sure of proper capitalization)
end
if is_set (code) then
if 'no' == code then name = 'Norwegian' end; -- override wikimedia when code is 'no'
if 0 == namespace and 'en' ~= code then -- is this page main / article space and English not the language?
table.insert( z.properties_cats, 'CS1 ' .. name .. '-language sources (' .. code .. ')'); -- in main space and not English: categorize
end
else
table.insert (z.maintenance_cats, 'CS1 maint: Unrecognized language'); -- add maintenance category when |language= does not appear to be ISO 639-1 language
end
return (" " .. wrap_msg ('language', name)); -- wrap with '(in ...)'
end
--[[--------------------------< G E T _ S E T T I N G S _ F R O M _ C I T E _ C L A S S >----------------------
When |mode= is not set or when its value is invalid, use config.CitationClass and parameter values to establish
rendered style.
]]
function get_settings_from_cite_class (ps, ref, cite_class)
local sep;
if (cite_class == "citation") then -- for citation templates (CS2)
sep = ','; -- set citation separator to its default (comma)
if not is_set (ps) then -- if |postscript= has not been set, set cs2 default
ps = ''; -- make sure it isn't nil
end
if not is_set (ref) then -- if |ref= is not set
ref = "harv"; -- set default |ref=harv
end
else -- not a citation template so CS1
sep = '.'; -- set cite xxx separator to its default (period)
if not is_set (ps) then -- if |postscript= has not been set
ps = '.'; -- set cs1 default
end
end
return sep, ps, ref -- return them all
end
--[[--------------------------< S E T _ S T Y L E >------------------------------------------------------------
Establish basic style settings to be used when rendering the citation. Uses |mode= if set and valid or uses
config.CitationClass from the template's #invoke: to establish style.
]]
function set_style (mode, ps, ref, cite_class)
local sep;
if is_set (mode) then
if 'cs2' == mode then -- if this template is to be rendered in CS2 (citation) style
sep = ','; -- separate elements with a comma
if not is_set (ps) then -- unless explicitely set to something
ps = ''; -- make sure it isn't nil
end
if not is_set (ref) then -- unless explicitely set to something
ref = 'harv'; -- set so this template renders with CITEREF anchor id
end
elseif 'cs1' == mode then -- if this template is to be rendered in CS1 (cite xxx) style
sep = '.'; -- separate elements with a period
if not is_set (ps) then -- unless explicitely set to something
ps = '.'; -- terminate the rendered citation with a period
end
else -- anything but cs1 or cs2
table.insert( z.message_tail, { seterror( 'invalid_param_val', {'mode', mode}, true ) } ); -- add error message
sep, ps, ref = get_settings_from_cite_class (ps, ref, cite_class); -- get settings based on the template's CitationClass
end
else -- when |mode= empty or omitted
sep, ps, ref = get_settings_from_cite_class (ps, ref, cite_class); -- get settings based on the template's CitationClass
end
if 'none' == ps:lower() then -- if assigned value is 'none' then
ps = ''; -- set to empty string
end
return sep, ps, ref
end
--[[--------------------------< C I T A T I O N 0 >------------------------------------------------------------
This is the main function doing the majority of the citation
formatting.
]]
function citation0( config, args)
--[[
Load Input Parameters
The argument_wrapper facilitates the mapping of multiple
aliases to single internal variable.
]]
local A = argument_wrapper( args );
local i
local PPrefix = A['PPrefix']
local PPPrefix = A['PPPrefix']
if is_set( A['NoPP'] ) then PPPrefix = "" PPrefix = "" end
-- Pick out the relevant fields from the arguments. Different citation templates
-- define different field names for the same underlying things.
local Authors = A['Authors'];
local a = extractnames( args, 'AuthorList' );
local Coauthors = A['Coauthors'];
local Others = A['Others'];
local Editors = A['Editors'];
local e = extractnames( args, 'EditorList' );
local NameListFormat = A['NameListFormat']; -- replaces |author-format= and |editor-format=
if is_set (NameListFormat) and ('vanc' ~= NameListFormat) then -- only accepted value for this parameter is 'vanc'
table.insert( z.message_tail, { seterror( 'invalid_param_val', {'name-list-format', NameListFormat}, true ) } ); -- not vanc so add error message
NameListFormat = ''; -- set to empty string
end
local Year = A['Year'];
local PublicationDate = A['PublicationDate'];
local OrigYear = A['OrigYear'];
local Date = A['Date'];
local LayDate = A['LayDate'];
------------------------------------------------- Get title data
local Title = A['Title'];
local ScriptTitle = A['ScriptTitle'];
local BookTitle = A['BookTitle'];
local Conference = A['Conference'];
local TransTitle = A['TransTitle'];
local TitleNote = A['TitleNote'];
local TitleLink = A['TitleLink'];
local Chapter = A['Chapter'];
local ChapterLink = A['ChapterLink']; -- deprecated
local TransChapter = A['TransChapter'];
local TitleType = A['TitleType'];
local Degree = A['Degree'];
local Docket = A['Docket'];
local ArchiveURL = A['ArchiveURL'];
local URL = A['URL']
local URLorigin = A:ORIGIN('URL'); -- get name of parameter that holds URL
local ChapterURL = A['ChapterURL'];
local ChapterURLorigin = A:ORIGIN('ChapterURL'); -- get name of parameter that holds ChapterURL
local ConferenceURL = A['ConferenceURL'];
local ConferenceURLorigin = A:ORIGIN('ConferenceURL'); -- get name of parameter that holds ConferenceURL
local Periodical = A['Periodical'];
local Series = A['Series'];
local Volume = A['Volume'];
local Issue = A['Issue'];
local Position = '';
local Page = A['Page'];
local Pages = hyphentodash( A['Pages'] );
local At = A['At'];
local Edition = A['Edition'];
local PublicationPlace = A['PublicationPlace']
local Place = A['Place'];
local PublisherName = A['PublisherName'];
local RegistrationRequired = A['RegistrationRequired'];
local SubscriptionRequired = A['SubscriptionRequired'];
local Via = A['Via'];
local AccessDate = A['AccessDate'];
local ArchiveDate = A['ArchiveDate'];
local Agency = A['Agency'];
local DeadURL = A['DeadURL']
local Language = A['Language'];
local Format = A['Format'];
local ChapterFormat = A['ChapterFormat'];
local DoiBroken = A['DoiBroken'];
local ID = A['ID'];
local ASINTLD = A['ASINTLD'];
local IgnoreISBN = A['IgnoreISBN'];
local Embargo = A['Embargo'];
local ID_list = extractids( args );
local Quote = A['Quote'];
local LayURL = A['LayURL'];
local LaySource = A['LaySource'];
local Transcript = A['Transcript'];
local TranscriptURL = A['TranscriptURL']
local TranscriptURLorigin = A:ORIGIN('TranscriptURL'); -- get name of parameter that holds TranscriptURL
local LastAuthorAmp = A['LastAuthorAmp'];
local no_tracking_cats = A['NoTracking'];
--these are used by cite interview
local Callsign = A['Callsign'];
local City = A['City'];
local Program = A['Program'];
--local variables that are not cs1 parameters
local use_lowercase; -- controls capitalization of certain static text
local this_page = mw.title.getCurrentTitle(); -- also used for COinS and for language
local anchor_year; -- used in the CITEREF identifier
local COinS_date; -- used in the COinS metadata
-- set default parameter values defined by |mode= parameter. If |mode= is empty or omitted, use CitationClass to set these values
local sepc; -- separator between citation elements for CS1 a period, for CS2, a comma
local PostScript;
local Ref;
sepc, PostScript, Ref = set_style (A['Mode']:lower(), A['PostScript'], A['Ref'], config.CitationClass);
use_lowercase = ( sepc == ',' ); -- used to control capitalization for certain static text
--check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories.
if not is_set(no_tracking_cats) then -- ignore if we are already not going to categorize this page
if inArray (this_page.nsText, cfg.uncategorized_namespaces) then
no_tracking_cats = "true"; -- set no_tracking_cats
end
end
-- check for extra |page=, |pages= or |at= parameters.
if is_set(Page) then
if is_set(Pages) or is_set(At) then
Page = Page .. " " .. seterror('extra_pages'); -- add error message
Pages = ''; -- unset the others
At = '';
end
elseif is_set(Pages) then
if is_set(At) then
Pages = Pages .. " " .. seterror('extra_pages'); -- add error messages
At = ''; -- unset
end
end
-- both |publication-place= and |place= (|location=) allowed if different
if not is_set(PublicationPlace) and is_set(Place) then
PublicationPlace = Place; -- promote |place= (|location=) to |publication-place
end
if PublicationPlace == Place then Place = ''; end -- don't need both if they are the same
--[[
Parameter remapping for cite encyclopedia:
When the citation has these parameters:
|encyclopedia and |title then map |title to |article and |encyclopedia to |title
|encyclopedia and |article then map |encyclopedia to |title
|encyclopedia then map |encyclopedia to |title
|trans_title maps to |trans_chapter when |title is re-mapped
|url maps to |chapterurl when |title is remapped
All other combinations of |encyclopedia, |title, and |article are not modified
TODO: script-title to script-chapter if and when we support script-chapter
]]
local Encyclopedia = A['Encyclopedia'];
if ( config.CitationClass == "encyclopaedia" ) or ( config.CitationClass == "citation" and is_set (Encyclopedia)) then -- test code for citation
if is_set(Periodical) then -- Periodical is set when |encyclopedia is set
if is_set(Title) then
if not is_set(Chapter) then
Chapter = Title; -- |encyclopedia and |title are set so map |title to |article and |encyclopedia to |title
TransChapter = TransTitle;
ChapterURL = URL;
Title = Periodical;
ChapterFormat = Format;
Periodical = ''; -- redundant so unset
TransTitle = ''; -- redundant so unset
URL = ''; -- redundant so unset
Format = ''; -- redundant so unset
end
else -- |title not set
Title = Periodical; -- |encyclopedia set and |article set or not set so map |encyclopedia to |title
Periodical = ''; -- redundant so unset
end
end
end
-- Special case for cite techreport.
if (config.CitationClass == "techreport") then -- special case for cite techreport
if is_set(Issue) then -- cite techreport uses 'number', which other citations aliase to 'issue'
if not is_set(ID) then -- can we use ID for the "number"?
ID = Issue; -- yes, use it
Issue = ""; -- unset Issue so that "number" isn't duplicated in the rendered citation or COinS metadata
else -- can't use ID so emit error message
ID = ID .. " " .. seterror('redundant_parameters', '<code>|id=</code> and <code>|number=</code>');
end
end
end
-- special case for cite interview
if (config.CitationClass == "interview") then
if is_set(Program) then
ID = ' ' .. Program;
end
if is_set(Callsign) then
if is_set(ID) then
ID = ID .. sepc .. ' ' .. Callsign;
else
ID = ' ' .. Callsign;
end
end
if is_set(City) then
if is_set(ID) then
ID = ID .. sepc .. ' ' .. City;
else
ID = ' ' .. City;
end
end
if is_set(Others) then
if is_set(TitleType) then
Others = ' ' .. TitleType .. ' with ' .. Others;
TitleType = '';
else
Others = ' ' .. 'Interview with ' .. Others;
end
else
Others = '(Interview)';
end
end
-- special case for cite mailing list
if (config.CitationClass == "mailinglist") then
Periodical = A ['MailingList'];
end
--Account for the oddity that is {{cite journal}} with |pmc= set and |url= not set
if config.CitationClass == "journal" and not is_set(URL) and is_set(ID_list['PMC']) then
if not is_embargoed(Embargo) then
URL=cfg.id_handlers['PMC'].prefix .. ID_list['PMC']; -- set url to be the same as the PMC external link if not embargoed
URLorigin = cfg.id_handlers['PMC'].parameters[1]; -- set URLorigin to parameter name for use in error message if citation is missing a |title=
end
end
-- Account for the oddity that is {{cite conference}}, before generation of COinS data.
if 'conference' == config.CitationClass then
if is_set(BookTitle) then
Chapter = Title;
-- ChapterLink = TitleLink; -- |chapterlink= is deprecated
ChapterURL = URL;
ChapterURLorigin = URLorigin;
URLorigin = '';
ChapterFormat = Format;
TransChapter = TransTitle;
Title = BookTitle;
Format = '';
-- TitleLink = '';
TransTitle = '';
URL = '';
end
else
Conference = ''; -- not cite conference so make sure this is empty string
end
-- Account for the oddity that is {{cite episode}}, before generation of COinS data.
--[[ -- {{cite episode}} is not currently supported by this module
if config.CitationClass == "episode" then
local AirDate = A['AirDate'];
local SeriesLink = A['SeriesLink'];
local Season = A['Season'];
local SeriesNumber = A['SeriesNumber'];
local Network = A['Network'];
local Station = A['Station'];
local s, n = {}, {};
local Sep = (first_set(A["SeriesSeparator"], A["Separator"]) or "") .. " ";
if is_set(Issue) then table.insert(s, cfg.messages["episode"] .. " " .. Issue); Issue = ''; end
if is_set(Season) then table.insert(s, cfg.messages["season"] .. " " .. Season); end
if is_set(SeriesNumber) then table.insert(s, cfg.messages["series"] .. " " .. SeriesNumber); end
if is_set(Network) then table.insert(n, Network); end
if is_set(Station) then table.insert(n, Station); end
Date = Date or AirDate;
Chapter = Title;
ChapterLink = TitleLink;
TransChapter = TransTitle;
Title = Series;
TitleLink = SeriesLink;
TransTitle = '';
Series = table.concat(s, Sep);
ID = table.concat(n, Sep);
end
-- end of {{cite episode}} stuff]]
-- legacy: promote concatenation of |month=, and |year= to Date if Date not set; or, promote PublicationDate to Date if neither Date nor Year are set.
if is_set(Date) then
if is_set (Year) then
table.insert( z.maintenance_cats, "CS1 maint: Date and year"); -- add to maint category
end
else
Date = Year; -- promote Year to Date
Year = nil; -- make nil so Year as empty string isn't used for CITEREF
if is_set(Date) then
local Month = A['Month'];
if is_set(Month) then
Date = Month .. " " .. Date;
end
elseif is_set(PublicationDate) then -- use PublicationDate when |date= and |year= are not set
Date = PublicationDate; -- promote PublicationDate to Date
PublicationDate = ''; -- unset, no longer needed
end
end
if PublicationDate == Date then PublicationDate = ''; end -- if PublicationDate is same as Date, don't display in rendered citation
--[[
Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates. This must be done before we do COinS because here is where
we get the date used in the metadata.
Date validation supporting code is in Module:Citation/CS1/Date_validation
]]
anchor_year, COinS_date, error_message = dates({['accessdate']=AccessDate, ['airdate']=AirDate, ['archivedate']=ArchiveDate, ['date']=Date, ['doi_brokendate']=DoiBroken,
['embargo']=Embargo, ['laydate']=LayDate, ['publicationdate']=PublicationDate, ['year']=Year});
if is_set(error_message) then
table.insert( z.message_tail, { seterror( 'bad_date', {error_message}, true ) } ); -- add this error message
end
-- At this point fields may be nil if they weren't specified in the template use. We can use that fact.
-- Test if citation has no title
if not is_set(Title) and
-- not is_set(Periodical) and -- not a title
-- not is_set(Conference) and -- not a title
not is_set(TransTitle) and
not is_set(ScriptTitle) then
table.insert( z.message_tail, { seterror( 'citation_missing_title', {}, true ) } );
end
if 'none' == Title and is_set(Periodical) and not (( config.CitationClass == "encyclopaedia" ) or ( config.CitationClass == "citation" and is_set (Encyclopedia))) then -- special case
Title = ''; -- set title to empty string
table.insert( z.maintenance_cats, "CS1 maint: Untitled periodical"); -- add to maint category
end
-- COinS metadata (see <http://ocoins.info/>) for automated parsing of citation information.
-- handle the oddity that is cite encyclopedia and {{citation |encyclopedia=something}}. Here we presume that
-- when Periodical, Title, and Chapter are all set, then Periodical is the book (encyclopedia) title, Title
-- is the article title, and Chapter is a section within the article. So, we remap
local coins_chapter = Chapter; -- default assuming that remapping not required
local coins_title = Title; -- et tu
if 'encyclopaedia' == config.CitationClass or ('citation' == config.CitationClass and is_set (Encyclopedia)) then
if is_set (Chapter) and is_set (Title) and is_set (Periodical) then -- if all are used then
coins_chapter = Title; -- remap
coins_title = Periodical;
end
end
-- this is the function call to COinS()
local OCinSoutput = COinS{
['Periodical'] = Periodical,
['Chapter'] = strip_apostrophe_markup (coins_chapter), -- Chapter stripped of bold / italic wikimarkup
['Title'] = make_coins_title (coins_title, ScriptTitle), -- Title and ScriptTitle stripped of bold / italic wikimarkup
['PublicationPlace'] = PublicationPlace,
['Date'] = first_set(COinS_date, Date), -- COinS_date has correctly formatted date if Date is valid; any reason to keep Date here? Should we be including invalid dates in metadata?
['Series'] = Series,
['Volume'] = Volume,
['Issue'] = Issue,
['Pages'] = get_coins_pages (first_set(Page, Pages, At)), -- pages stripped of external links
['Edition'] = Edition,
['PublisherName'] = PublisherName,
['URL'] = first_set( URL, ChapterURL ),
['Authors'] = a,
['ID_list'] = ID_list,
['RawPage'] = this_page.prefixedText,
};
--[[Why is this here? Why are we mapping Title to Chapter when Periodical is set?
if is_set(Periodical) and not is_set(Chapter) and is_set(Title) then
Chapter = Title;
ChapterLink = TitleLink;
TransChapter = TransTitle;
Title = '';
TitleLink = '';
TransTitle = '';
end
]]
-- special case for cite newsgroup. Do this after COinS because we are modifying Publishername to include some static text
if 'newsgroup' == config.CitationClass then
if is_set (PublisherName) then
PublisherName = '[[Newsgroup]]: ' .. externallink( 'news:' .. PublisherName, PublisherName );
end
end
-- Now perform various field substitutions.
-- We also add leading spaces and surrounding markup and punctuation to the
-- various parts of the citation, but only when they are non-nil.
if not is_set(Authors) then
local Maximum = tonumber( A['DisplayAuthors'] );
if is_set (Maximum) then
if Maximum >= #a then -- if display-authors value greater than or equal to number of authors
table.insert( z.maintenance_cats, "CS1 maint: display-authors"); -- add maintenance category because display-authors parameter may be removed
end
else
Maximum = #a + 1; -- number of authors + 1
end
local control = {
format = NameListFormat, -- empty string or 'vanc'
maximum = Maximum,
lastauthoramp = LastAuthorAmp,
page_name = this_page.text -- get current page name so that we don't wikilink to it via authorlinkn
};
-- If the coauthor field is also used, prevent ampersand and et al. formatting.
if is_set(Coauthors) then
control.lastauthoramp = nil;
control.maximum = #a + 1;
end
Authors = listpeople(control, a)
end
if not is_set(Authors) and is_set(Coauthors) then -- coauthors aren't displayed if one of authors=, authorn=, or lastn= isn't specified
table.insert( z.message_tail, { seterror('coauthors_missing_author', {}, true) } ); -- emit error message
end
local EditorCount
if not is_set(Editors) then
local Maximum = tonumber( A['DisplayEditors'] );
-- Preserve old-style implicit et al.
if not is_set(Maximum) and #e == 4 then
Maximum = 3;
table.insert( z.message_tail, { seterror('implict_etal_editor', {}, true) } );
elseif not is_set(Maximum) then
Maximum = #e + 1;
end
local control = {
format = NameListFormat, -- empty string or 'vanc'
maximum = Maximum,
lastauthoramp = LastAuthorAmp,
page_name = this_page.text -- get current page name so that we don't wikilink to it via editorlinkn
};
Editors, EditorCount = listpeople(control, e);
else
EditorCount = 1;
end
local Cartography = "";
local Scale = "";
if config.CitationClass == "map" then
if not is_set( Authors ) and is_set( PublisherName ) then
Authors = PublisherName;
PublisherName = "";
end
Cartography = A['Cartography'];
if is_set( Cartography ) then
Cartography = sepc .. " " .. wrap_msg ('cartography', Cartography, use_lowercase);
end
Scale = A['Scale'];
if is_set( Scale ) then
Scale = sepc .. " " .. Scale;
end
end
Format = is_set(Format) and " (" .. Format .. ")" or "";
if not is_set(URL) and
not is_set(ArchiveURL) and
not is_set(ConferenceURL) and -- TODO: keep this here? conference as part of cite web or cite podcast?
not is_set(TranscriptURL) then
-- Test if cite web or cite podcast |url= is missing or empty
if inArray(config.CitationClass, {"web","podcast", "mailinglist"}) then
table.insert( z.message_tail, { seterror( 'cite_web_url', {}, true ) } );
end
-- Test if accessdate is given without giving a URL
if is_set(AccessDate) and not is_set(ChapterURL)then -- ChapterURL may be set when the others are not set; TODO: move this to a separate test?
table.insert( z.message_tail, { seterror( 'accessdate_missing_url', {}, true ) } );
AccessDate = '';
end
-- Test if format is given without giving a URL
if is_set(Format) then
Format = Format .. seterror( 'format_missing_url', {'format', 'url'} );
end
end
--[[
-- Test if citation has no title
if not is_set(Title) and
-- not is_set(Periodical) and -- not a title
-- not is_set(Conference) and -- not a title
not is_set(TransTitle) and
not is_set(ScriptTitle) then
table.insert( z.message_tail, { seterror( 'citation_missing_title', {}, true ) } );
end
if 'none' == Title and is_set(Periodical) then -- special case
Title = ''; -- set title to empty string
table.insert( z.maintenance_cats, "CS1 maint: Untitled periodical"); -- add to maint category
end
]]
local OriginalURL;
DeadURL = DeadURL:lower(); -- used later when assembling archived text
if is_set( ArchiveURL ) then
if is_set (URL) then
OriginalURL = URL; -- save copy of original source URL
if 'no' ~= DeadURL then -- if URL set then archive-url applies to it
URL = ArchiveURL -- swap-in the archive's url
URLorigin = A:ORIGIN('ArchiveURL') -- name of archive url parameter for error messages
end
elseif is_set (ChapterURL) then -- URL not set so if chapter-url is set apply archive url to it
OriginalURL = ChapterURL; -- save copy of source chapter's url for archive text
if 'no' ~= DeadURL then
ChapterURL = ArchiveURL -- swap-in the archive's url
URLorigin = A:ORIGIN('ArchiveURL') -- name of archive url parameter for error messages
end
end
end
if inArray(config.CitationClass, {"web","news","journal","pressrelease","podcast", "newsgroup"}) or
('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia)) then
if is_set (Chapter) or is_set (TransChapter) or is_set (ChapterURL)then -- chapter parameters not supported for these citation types
table.insert( z.message_tail, { seterror( 'chapter_ignored', {}, true ) } ); -- add error message
Chapter = ''; -- set to empty string to be safe with concatenation
TransChapter = '';
ChapterURL = '';
end
else -- otherwise, format chapter / article title
Chapter = format_chapter_title (Chapter, TransChapter, ChapterURL, ChapterURLorigin);
if is_set (Chapter) then
ChapterFormat = is_set(ChapterFormat) and " (" .. ChapterFormat .. ")" or "";
if is_set(ChapterFormat) and not is_set (ChapterURL) then -- Test if |chapter-format= is given without giving a |chapter-url=
ChapterFormat = ChapterFormat .. seterror( 'format_missing_url', {'chapter-format', 'chapter-url'} );
end
Chapter = Chapter .. ChapterFormat .. sepc .. ' ';
end
end
-- Format main title.
if is_set(TitleLink) and is_set(Title) then
Title = "[[" .. TitleLink .. "|" .. Title .. "]]"
end
if inArray(config.CitationClass, {"web","news","journal","pressrelease","podcast", "newsgroup", "mailinglist"}) or
('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia)) then
Title = kern_quotes (Title); -- if necessary, separate title's leading and trailing quote marks from Module provided quote marks
Title = wrap_style ('quoted-title', Title);
Title = script_concatenate (Title, ScriptTitle); -- <bdi> tags, lang atribute, categorization, etc; must be done after title is wrapped
TransTitle= wrap_style ('trans-quoted-title', TransTitle );
elseif 'report' == config.CitationClass then -- no styling for cite report
Title = script_concatenate (Title, ScriptTitle); -- <bdi> tags, lang atribute, categorization, etc; must be done after title is wrapped
TransTitle= wrap_style ('trans-quoted-title', TransTitle ); -- for cite report, use this form for trans-title
else
Title = wrap_style ('italic-title', Title);
Title = script_concatenate (Title, ScriptTitle); -- <bdi> tags, lang atribute, categorization, etc; must be done after title is wrapped
TransTitle = wrap_style ('trans-italic-title', TransTitle);
end
TransError = "";
if is_set(TransTitle) then
if is_set(Title) then
TransTitle = " " .. TransTitle;
else
TransError = " " .. seterror( 'trans_missing_title' );
end
end
Title = Title .. TransTitle;
if is_set(Title) then
if not is_set(TitleLink) and is_set(URL) then
Title = externallink( URL, Title ) .. TransError .. Format
URL = "";
Format = "";
else
Title = Title .. TransError;
end
end
if is_set(Place) then
Place = " " .. wrap_msg ('written', Place, use_lowercase) .. sepc .. " ";
end
if is_set(Conference) then
if is_set(ConferenceURL) then
Conference = externallink( ConferenceURL, Conference );
end
Conference = sepc .. " " .. Conference
elseif is_set(ConferenceURL) then
Conference = sepc .. " " .. externallink( ConferenceURL, nil, ConferenceURLorigin );
end
if not is_set(Position) then
local Minutes = A['Minutes'];
if is_set(Minutes) then
Position = " " .. Minutes .. " " .. cfg.messages['minutes'];
else
local Time = A['Time'];
if is_set(Time) then
local TimeCaption = A['TimeCaption']
if not is_set(TimeCaption) then
TimeCaption = cfg.messages['event'];
if sepc ~= '.' then
TimeCaption = TimeCaption:lower();
end
end
Position = " " .. TimeCaption .. " " .. Time;
end
end
else
Position = " " .. Position;
At = '';
end
if not is_set(Page) then
if is_set(Pages) then
if is_set(Periodical) and
not inArray(config.CitationClass, {"encyclopaedia","web","book","news","podcast"}) then
Pages = ": " .. Pages;
elseif tonumber(Pages) ~= nil then
Pages = sepc .." " .. PPrefix .. Pages;
else
Pages = sepc .." " .. PPPrefix .. Pages;
end
end
else
if is_set(Periodical) and
not inArray(config.CitationClass, {"encyclopaedia","web","book","news","podcast"}) then
Page = ": " .. Page;
else
Page = sepc .." " .. PPrefix .. Page;
end
end
At = is_set(At) and (sepc .. " " .. At) or "";
Position = is_set(Position) and (sepc .. " " .. Position) or "";
if config.CitationClass == 'map' then
local Section = A['Section'];
local Inset = A['Inset'];
if first_set( Pages, Page, At ) ~= nil or sepc ~= '.' then
if is_set( Section ) then
Section = ", " .. wrap_msg ('section', Section, true);
end
if is_set( Inset ) then
Inset = ", " .. wrap_msg ('inset', Inset, true);
end
else
if is_set( Section ) then
Section = sepc .. " " .. wrap_msg ('section', Section, use_lowercase);
if is_set( Inset ) then
Inset = ", " .. wrap_msg ('inset', Inset, true);
end
elseif is_set( Inset ) then
Inset = sepc .. " " .. wrap_msg ('inset', Inset, use_lowercase);
end
end
At = At .. Section .. Inset;
end
if is_set (Language) then
Language = language_parameter (Language, this_page.namespace); -- format, categories (article namespace only), name from ISO639-1, etc
else
Language=""; -- language not specified so make sure this is an empty string;
end
Others = is_set(Others) and (sepc .. " " .. Others) or "";
-- handle type parameter for those CS1 citations that have default values
if inArray(config.CitationClass, {"AV-media-notes", "DVD-notes", "mailinglist", "podcast", "pressrelease", "report", "techreport", "thesis"}) then
TitleType = set_titletype (config.CitationClass, TitleType);
if is_set(Degree) and "Thesis" == TitleType then -- special case for cite thesis
TitleType = Degree .. " thesis";
end
end
if is_set(TitleType) then -- if type parameter is specified
TitleType = " (" .. TitleType .. ")"; -- display it in parentheses
end
TitleNote = is_set(TitleNote) and (sepc .. " " .. TitleNote) or "";
Edition = is_set(Edition) and (" " .. wrap_msg ('edition', Edition)) or "";
Issue = is_set(Issue) and (" (" .. Issue .. ")") or "";
Series = is_set(Series) and (sepc .. " " .. Series) or "";
OrigYear = is_set(OrigYear) and (" [" .. OrigYear .. "]") or "";
Agency = is_set(Agency) and (sepc .. " " .. Agency) or "";
if is_set(Volume) then
if ( mw.ustring.len(Volume) > 4 )
then Volume = sepc .." " .. Volume;
else Volume = " <b>" .. hyphentodash(Volume) .. "</b>";
end
end
------------------------------------ totally unrelated data
if is_set(Via) then
Via = " " .. wrap_msg ('via', Via);
end
--[[
Subscription implies paywall; Registration does not. If both are used in a citation, the subscription required link
note is displayed. There are no error messages for this condition.
]]
if inArray(SubscriptionRequired:lower(), {'yes', 'true', 'y'}) then
SubscriptionRequired = sepc .. " " .. cfg.messages['subscription']; -- subscription required message
elseif inArray(RegistrationRequired:lower(), {'yes', 'true', 'y'}) then
SubscriptionRequired = sepc .. " " .. cfg.messages['registration']; -- registration required message
else
SubscriptionRequired = ''; -- either or both might be set to something other than yes true y
end
if is_set(AccessDate) then
local retrv_text = " " .. cfg.messages['retrieved']
AccessDate = nowrap_date (AccessDate); -- wrap in nowrap span if date in appropriate format
if (sepc ~= ".") then retrv_text = retrv_text:lower() end -- if 'citation', lower case
AccessDate = substitute (retrv_text, AccessDate); -- add retrieved text
-- neither of these work; don't know why; it seems that substitute() isn't being called
AccessDate = substitute (cfg.presentation['accessdate'], {sepc, AccessDate}); -- allow editors to hide accessdates
end
if is_set(ID) then ID = sepc .." ".. ID; end
if "thesis" == config.CitationClass and is_set(Docket) then
ID = sepc .." Docket ".. Docket .. ID;
end
if "report" == config.CitationClass and is_set(Docket) then -- for cite report when |docket= is set
ID = sepc .. ' ' .. Docket; -- overwrite ID even if |id= is set
end
ID_list = buildidlist( ID_list, {DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN, Embargo=Embargo} );
if is_set(URL) then
URL = " " .. externallink( URL, nil, URLorigin );
end
if is_set(Quote) then
if Quote:sub(1,1) == '"' and Quote:sub(-1,-1) == '"' then
Quote = Quote:sub(2,-2);
end
Quote = sepc .." " .. wrap_style ('quoted-text', Quote ); -- wrap in <q>...</q> tags
PostScript = ""; -- CS1 does not supply terminal punctuation when |quote= is set
end
local Archived
if is_set(ArchiveURL) then
if not is_set(ArchiveDate) then
ArchiveDate = seterror('archive_missing_date');
end
if "no" == DeadURL then
local arch_text = cfg.messages['archived'];
if sepc ~= "." then arch_text = arch_text:lower() end
Archived = sepc .. " " .. substitute( cfg.messages['archived-not-dead'],
{ externallink( ArchiveURL, arch_text ), ArchiveDate } );
if not is_set(OriginalURL) then
Archived = Archived .. " " .. seterror('archive_missing_url');
end
elseif is_set(OriginalURL) then
local arch_text = cfg.messages['archived-dead'];
if sepc ~= "." then arch_text = arch_text:lower() end
Archived = sepc .. " " .. substitute( arch_text,
{ externallink( OriginalURL, cfg.messages['original'] ), ArchiveDate } );
else
local arch_text = cfg.messages['archived-missing'];
if sepc ~= "." then arch_text = arch_text:lower() end
Archived = sepc .. " " .. substitute( arch_text,
{ seterror('archive_missing_url'), ArchiveDate } );
end
else
Archived = ""
end
local Lay
if is_set(LayURL) then
if is_set(LayDate) then LayDate = " (" .. LayDate .. ")" end
if is_set(LaySource) then
LaySource = " – ''" .. safeforitalics(LaySource) .. "''";
else
LaySource = "";
end
if sepc == '.' then
Lay = sepc .. " " .. externallink( LayURL, cfg.messages['lay summary'] ) .. LaySource .. LayDate
else
Lay = sepc .. " " .. externallink( LayURL, cfg.messages['lay summary']:lower() ) .. LaySource .. LayDate
end
else
Lay = "";
end
if is_set(Transcript) then
if is_set(TranscriptURL) then Transcript = externallink( TranscriptURL, Transcript ); end
elseif is_set(TranscriptURL) then
Transcript = externallink( TranscriptURL, nil, TranscriptURLorigin );
end
local Publisher;
if is_set(Periodical) and
not inArray(config.CitationClass, {"encyclopaedia","web","pressrelease","podcast"}) then
if is_set(PublisherName) then
if is_set(PublicationPlace) then
Publisher = PublicationPlace .. ": " .. PublisherName;
else
Publisher = PublisherName;
end
elseif is_set(PublicationPlace) then
Publisher= PublicationPlace;
else
Publisher = "";
end
if is_set(PublicationDate) then
if is_set(Publisher) then
Publisher = Publisher .. ", " .. wrap_msg ('published', PublicationDate);
else
Publisher = PublicationDate;
end
end
if is_set(Publisher) then
Publisher = " (" .. Publisher .. ")";
end
else
if is_set(PublicationDate) then
PublicationDate = " (" .. wrap_msg ('published', PublicationDate) .. ")";
end
if is_set(PublisherName) then
if is_set(PublicationPlace) then
Publisher = sepc .. " " .. PublicationPlace .. ": " .. PublisherName .. PublicationDate;
else
Publisher = sepc .. " " .. PublisherName .. PublicationDate;
end
elseif is_set(PublicationPlace) then
Publisher= sepc .. " " .. PublicationPlace .. PublicationDate;
else
Publisher = PublicationDate;
end
end
-- Several of the above rely upon detecting this as nil, so do it last.
if is_set(Periodical) then
if is_set(Title) or is_set(TitleNote) then
Periodical = sepc .. " " .. wrap_style ('italic-title', Periodical)
else
Periodical = wrap_style ('italic-title', Periodical)
end
end
--[[
Handle the oddity that is cite speech. This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be " (Speech)" so that
the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
]]
if "speech" == config.CitationClass then -- cite speech only
TitleNote = " (Speech)"; -- annotate the citation
if is_set (Periodical) then -- if Periodical, perhaps because of an included |website= or |journal= parameter
if is_set (Conference) then -- and if |event= is set
Conference = Conference .. sepc .. " "; -- then add appropriate punctuation to the end of the Conference variable before rendering
end
end
end
-- Piece all bits together at last. Here, all should be non-nil.
-- We build things this way because it is more efficient in LUA
-- not to keep reassigning to the same string variable over and over.
local tcommon
if inArray(config.CitationClass, {"journal","citation"}) and is_set(Periodical) then
if is_set(Others) then Others = Others .. sepc .. " " end
tcommon = safejoin( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Scale, Series,
Language, Cartography, Edition, Publisher, Agency, Volume, Issue}, sepc );
else
tcommon = safejoin( {Title, TitleNote, Conference, Periodical, Format, TitleType, Scale, Series, Language,
Volume, Issue, Others, Cartography, Edition, Publisher, Agency}, sepc );
end
if #ID_list > 0 then
ID_list = safejoin( { sepc .. " ", table.concat( ID_list, sepc .. " " ), ID }, sepc );
else
ID_list = ID;
end
local idcommon = safejoin( { ID_list, URL, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );
local text;
local pgtext = Position .. Page .. Pages .. At;
if is_set(Authors) then
if is_set(Coauthors) then
local sep = '; ';
if 'vanc' == NameListFormat then
sep = ', ';
end
Authors = Authors .. sep .. Coauthors;
end
if is_set(Date) then
Date = " ("..Date..")" .. OrigYear .. sepc .. " "
elseif string.sub(Authors,-1,-1) == sepc then
Authors = Authors .. " "
else
Authors = Authors .. sepc .. " "
end
if is_set(Editors) then
local in_text = " ";
local post_text = "";
if is_set(Chapter) then
in_text = in_text .. cfg.messages['in'] .. " "
else
if EditorCount <= 1 then
post_text = ", " .. cfg.messages['editor'];
else
post_text = ", " .. cfg.messages['editors'];
end
end
if (sepc ~= '.') then in_text = in_text:lower() end
Editors = in_text .. Editors .. post_text;
if (string.sub(Editors,-1,-1) == sepc)
then Editors = Editors .. " "
else Editors = Editors .. sepc .. " "
end
end
text = safejoin( {Authors, Date, Chapter, Place, Editors, tcommon }, sepc );
text = safejoin( {text, pgtext, idcommon}, sepc );
elseif is_set(Editors) then
if is_set(Date) then
if EditorCount <= 1 then
Editors = Editors .. ", " .. cfg.messages['editor'];
else
Editors = Editors .. ", " .. cfg.messages['editors'];
end
Date = " (" .. Date ..")" .. OrigYear .. sepc .. " "
else
if EditorCount <= 1 then
Editors = Editors .. " (" .. cfg.messages['editor'] .. ")" .. sepc .. " "
else
Editors = Editors .. " (" .. cfg.messages['editors'] .. ")" .. sepc .. " "
end
end
text = safejoin( {Editors, Date, Chapter, Place, tcommon}, sepc );
text = safejoin( {text, pgtext, idcommon}, sepc );
else
if is_set(Date) then
if ( string.sub(tcommon,-1,-1) ~= sepc )
then Date = sepc .." " .. Date .. OrigYear
else Date = " " .. Date .. OrigYear
end
end
if config.CitationClass=="journal" and is_set(Periodical) then
text = safejoin( {Chapter, Place, tcommon}, sepc );
text = safejoin( {text, pgtext, Date, idcommon}, sepc );
else
text = safejoin( {Chapter, Place, tcommon, Date}, sepc );
text = safejoin( {text, pgtext, idcommon}, sepc );
end
end
if is_set(PostScript) and PostScript ~= sepc then
text = safejoin( {text, sepc}, sepc ); --Deals with italics, spaces, etc.
text = text:sub(1,-sepc:len()-1);
-- text = text:sub(1,-2); --Remove final separator (assumes that sepc is only one character)
end
text = safejoin( {text, PostScript}, sepc );
-- Now enclose the whole thing in a <span/> element
local options = {};
if is_set(config.CitationClass) and config.CitationClass ~= "citation" then
options.class = "citation " .. config.CitationClass;
else
options.class = "citation";
end
if is_set(Ref) and Ref:lower() ~= "none" then
local id = Ref
if ( "harv" == Ref ) then
local names = {} --table of last names & year
if #a > 0 then
for i,v in ipairs(a) do
names[i] = v.last
if i == 4 then break end
end
elseif #e > 0 then
for i,v in ipairs(e) do
names[i] = v.last
if i == 4 then break end
end
end
names[ #names + 1 ] = first_set(Year, anchor_year); -- Year first for legacy citations and for YMD dates that require disambiguation
id = anchorid(names)
end
options.id = id;
end
if string.len(text:gsub("<span[^>/]*>.-</span>", ""):gsub("%b<>","")) <= 2 then
z.error_categories = {};
text = seterror('empty_citation');
z.message_tail = {};
end
if is_set(options.id) then
text = '<span id="' .. mw.uri.anchorEncode(options.id) ..'" class="' .. mw.text.nowiki(options.class) .. '">' .. text .. "</span>";
else
text = '<span class="' .. mw.text.nowiki(options.class) .. '">' .. text .. "</span>";
end
local empty_span = '<span style="display:none;"> </span>';
-- Note: Using display: none on then COinS span breaks some clients.
local OCinS = '<span title="' .. OCinSoutput .. '" class="Z3988">' .. empty_span .. '</span>';
text = text .. OCinS;
if #z.message_tail ~= 0 then
text = text .. " ";
for i,v in ipairs( z.message_tail ) do
if is_set(v[1]) then
if i == #z.message_tail then
text = text .. errorcomment( v[1], v[2] );
else
text = text .. errorcomment( v[1] .. "; ", v[2] );
end
end
end
end
no_tracking_cats = no_tracking_cats:lower();
if inArray(no_tracking_cats, {"", "no", "false", "n"}) then
for _, v in ipairs( z.error_categories ) do
text = text .. '[[Category:' .. v ..']]';
end
for _, v in ipairs( z.maintenance_cats ) do -- append maintenance categories
text = text .. '[[Category:' .. v ..']]';
end
for _, v in ipairs( z.properties_cats ) do -- append maintenance categories
text = text .. '[[Category:' .. v ..']]';
end
end
return text
end
-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
local pframe = frame:getParent()
if nil ~= string.find( frame:getTitle(), 'sandbox', 1, true ) then -- did the {{#invoke:}} use sandbox version?
cfg = mw.loadData( 'Module:Citation/CS1/Configuration/sandbox' ); -- load sandbox versions of Configuration and Whitelist and ...
whitelist = mw.loadData( 'Module:Citation/CS1/Whitelist/sandbox' );
dates = require('Module:Citation/CS1/Date_validation/sandbox').dates -- ... sandbox version of date validation code
else -- otherwise
cfg = mw.loadData( 'Module:Citation/CS1/Configuration' ); -- load live versions of Configuration and Whitelist and ...
whitelist = mw.loadData( 'Module:Citation/CS1/Whitelist' );
dates = require('Module:Citation/CS1/Date_validation').dates -- ... live version of date validation code
end
local args = {};
local suggestions = {};
local error_text, error_state;
local config = {};
for k, v in pairs( frame.args ) do
config[k] = v;
args[k] = v;
end
for k, v in pairs( pframe.args ) do
if v ~= '' then
if not validate( k ) then
error_text = "";
if type( k ) ~= 'string' then
-- Exclude empty numbered parameters
if v:match("%S+") ~= nil then
error_text, error_state = seterror( 'text_ignored', {v}, true );
end
elseif validate( k:lower() ) then
error_text, error_state = seterror( 'parameter_ignored_suggest', {k, k:lower()}, true );
else
if #suggestions == 0 then
suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );
end
if suggestions[ k:lower() ] ~= nil then
error_text, error_state = seterror( 'parameter_ignored_suggest', {k, suggestions[ k:lower() ]}, true );
else
error_text, error_state = seterror( 'parameter_ignored', {k}, true );
end
end
if error_text ~= '' then
table.insert( z.message_tail, {error_text, error_state} );
end
end
args[k] = v;
elseif args[k] ~= nil or (k == 'postscript') then
args[k] = v;
end
end
return citation0( config, args)
end
return z
nxx5xkgkqtad1cfa2vnlkq7s3kmefh6
มอดูล:Citation/CS1/Configuration
828
33554
189424
89007
2022-08-16T14:58:54Z
Venise12mai1834
8884
Scribunto
text/plain
citation_config = {};
-- override <code>...</code> styling to remove color, border, and padding. <code> css is specified here:
-- https://git.wikimedia.org/blob/mediawiki%2Fcore.git/69cd73811f7aadd093050dbf20ed70ef0b42a713/skins%2Fcommon%2FcommonElements.css#L199
local code_style="color:inherit; border:inherit; padding:inherit;";
--[[--------------------------< U N C A T E G O R I Z E D _ N A M E S P A C E S >------------------------------
List of namespaces that should not be included in citation error categories. Same as setting notracking = true by default
Note: Namespace names should use underscores instead of spaces.
]]
citation_config.uncategorized_namespaces = { 'User', 'Talk', 'User_talk', 'Wikisource_talk', 'File_talk', 'Template_talk',
'Help_talk', 'Category_talk', 'Portal_talk', 'Author_talk', 'Page_talk', 'Index_talk', 'Translation_talk',
'Module_talk', 'MediaWiki_talk' };
--[[--------------------------< M E S S A G E S >--------------------------------------------------------------
Translation table
The following contains fixed text that may be output as part of a citation.
This is separated from the main body to aid in future translations of this
module.
]]
citation_config.messages = {
['published'] = 'published $1',
['lay summary'] = 'Lay summary',
['retrieved'] = 'สืบค้นเมื่อ $1',
['inactive'] = 'inactive',
['archived-dead'] = 'Archived from $1 on $2',
['archived-not-dead'] = '$1 from the original on $2',
['archived-missing'] = 'Archived from the original$1 on $2',
['archived'] = 'Archived',
['original'] = 'the original',
['editor'] = 'บรรณาธิการ',
['editors'] = 'บรรณาธิการ',
['edition'] = '(พิมพ์ครั้งที่ $1)',
['episode'] = 'episode',
['season'] = 'season',
['series'] = 'series',
['cartography'] = 'Cartography by $1',
['section'] = 'Section $1',
['inset'] = '$1 inset',
['written'] = 'Written at $1',
['in'] = 'In',
['et al'] = 'และคณะ',
['subscription'] = '<span style="font-size:0.95em; font-size:90%; color:#555">(subscription required (<span title="Sources are not required to be available online. Online sources do not have to be freely available. The site may require a paid subscription." style="border-bottom:1px dotted;cursor:help">help</span>))</span>' ..
'[[Category:Pages containing links to subscription-only content]]',
['registration']='<span style="font-size:0.95em; font-size:90%; color:#555">(registration required (<span title="Sources are not required to be available online. Online sources do not have to be freely available. The site may require registration." style="border-bottom:1px dotted;cursor:help">help</span>))</span>' ..
'[[Category:Pages with login required references or sources]]',
['language'] = '(in $1)',
['via'] = " – โดยทาง $1",
['event'] = 'Event occurs at',
['minutes'] = 'minutes in',
['parameter-separator'] = ', ',
['parameter-final-separator'] = ', และ ',
['parameter-pair-separator'] = ' และ ',
-- Determines the location of the help page
['help page link'] = 'w:Help:CS1 errors',
['help page label'] = 'help',
-- Internal errors (should only occur if configuration is bad)
['undefined_error'] = 'Called with an undefined error condition',
['unknown_manual_ID'] = 'Unrecognized manual ID mode',
['unknown_ID_mode'] = 'Unrecognized ID mode',
['unknown_argument_map'] = 'Argument map not defined for this variable',
['bare_url_no_origin'] = 'Bare url found but origin indicator is nil or empty',
}
--[[--------------------------< P R E S E N T A T I O N >------------------------------------------------------
Fixed presentation markup. Originally part of citation_config.messages it has been moved into its own, more semantically
correct place.
]]
citation_config.presentation =
{
-- Error output
-- .error class is specified at https://git.wikimedia.org/blob/mediawiki%2Fcore.git/9553bd02a5595da05c184f7521721fb1b79b3935/skins%2Fcommon%2Fshared.css#L538
-- .citation-comment class is specified at Help:CS1_errors#Controlling_error_message_display
['hidden-error'] = '<span style="display:none;font-size:100%" class="error citation-comment">$1</span>',
['visible-error'] = '<span style="font-size:100%" class="error citation-comment">$1</span>',
['accessdate'] = '<span class="reference-accessdate">$1$2</span>', -- to allow editors to hide accessdate using personal css
['bdi'] = '<bdi$1>$2</bdi>', -- bidirectional isolation used with |script-title= and the like
['italic-title'] = "''$1''",
['kern-left'] = '<span style="padding-left:0.2em;">$1</span>$2', -- spacing to use when title contains leading single or double quote mark
['kern-right'] = '$1<span style="padding-right:0.2em;">$2</span>', -- spacing to use when title contains trailing single or double quote mark
['nowrap1'] = '<span class="nowrap">$1</span>', -- for nowrapping an item: <span ...>yyyy-mm-dd</span>
['nowrap2'] = '<span class="nowrap">$1</span> $2', -- for nowrapping portions of an item: <span ...>dd mmmm</span> yyyy (note white space)
['parameter'] = '<code style="'..code_style..'">|$1=</code>',
['quoted-text'] = '<q>$1</q>', -- for wrapping |quote= content
['quoted-title'] = '"$1"',
['trans-italic-title'] = "[''$1'']",
['trans-quoted-title'] = "[$1]",
}
--[[--------------------------< A L I A S E S >----------------------------------------------------------------
Aliases table for commonly passed parameters
]]
citation_config.aliases = {
['AccessDate'] = {'access-date', 'accessdate'},
['Agency'] = 'agency',
['AirDate'] = {'air-date', 'airdate'},
['ArchiveDate'] = {'archive-date', 'archivedate'},
['ArchiveURL'] = {'archive-url', 'archiveurl'},
['ASINTLD'] = {'ASIN-TLD', 'asin-tld'},
['At'] = 'at',
['Authors'] = {'authors', 'people', 'host'},
['AuthorFormat'] = {'author-format', 'authorformat'}, -- deprecated in favor of NameListFormat;
['AuthorSeparator'] = 'author-separator', -- deprecated
['AuthorNameSeparator'] = 'author-name-separator', -- deprecated
['BookTitle'] = {'book-title', 'booktitle'},
['Callsign'] = {'call-sign', 'callsign'}, -- cite interview
['Cartography'] = 'cartography',
['Chapter'] = {'chapter', 'contribution', 'entry', 'article', 'section'},
['ChapterFormat'] = 'chapter-format';
['ChapterLink'] = {'chapter-link', 'chapterlink'}, -- deprecated; remove after 1 January 2015?
['ChapterURL'] = {'chapter-url', 'chapterurl', 'contribution-url', 'contributionurl', 'section-url', 'sectionurl'},
['City'] = 'city', -- cite interview
['Coauthors'] = {'coauthors', 'coauthor'}, -- coauthor and coauthors are deprecated; remove after 1 January 2015?
['Conference'] = {'conference', 'event'},
['ConferenceURL'] = {'conference-url', 'conferenceurl', 'event-url', 'eventurl'},
['Date'] = 'date',
['Day'] = 'day', -- deprecated; remove after 1 January 2015?
['DeadURL'] = {'dead-url', 'deadurl'},
['Degree'] = 'degree',
['DisplayAuthors'] = {'display-authors', 'displayauthors'},
['DisplayEditors'] = {'display-editors', 'displayeditors'},
['Docket'] = 'docket',
['DoiBroken'] = {'doi-broken', 'doi-broken-date', 'doi-inactive-date', 'DoiBroken', 'doi_brokendate', 'doi_inactivedate'},
['Edition'] = 'edition',
['Editors'] = 'editors',
['EditorFormat'] = {'editor-format', 'editorformat'}, -- deprecated in favor of NameListFormat;
['EditorSeparator'] = 'editor-separator', -- deprecated
['EditorNameSeparator'] = 'editor-name-separator', -- deprecated
['Embargo'] = {'Embargo', 'embargo'},
['Encyclopedia'] = {'encyclopedia', 'encyclopaedia'}, -- this one only used by citation
['Format'] = 'format',
['ID'] = {'id', 'ID'},
['IgnoreISBN'] = {'ignore-isbn-error', 'ignoreisbnerror'},
['Inset'] = 'inset',
['Issue'] = {'issue', 'number'},
['Language'] = {'language', 'in'},
['LastAuthorAmp'] = {'last-author-amp', 'lastauthoramp'},
['LayDate'] = {'lay-date', 'laydate'},
['LaySource'] = {'lay-source', 'laysource'},
['LayURL'] = {'lay-url', 'lay-summary', 'layurl', 'laysummary'},
['MailingList'] = {'mailinglist', 'mailing-list'}, -- cite mailing list only
['MessageID'] = 'message-id',
['Minutes'] = 'minutes',
['Mode'] = 'mode',
['Month'] = 'month', -- deprecated; remove after 1 January 2015?
['NameListFormat'] = {'name-list-format', 'author-format', 'authorformat', 'editor-format', 'editorformat'},
['NameSeparator'] = 'name-separator', -- deprecated
['Network'] = 'network',
['NoPP'] = {'no-pp', 'nopp'},
['NoTracking'] = {'template-doc-demo', 'template doc demo', 'no-cat', 'nocat', 'no-tracking', 'notracking'},
['OrigYear'] = {'orig-year', 'origyear'},
['Others'] = {'others', 'interviewer', 'interviewers'},
['Page'] = {'p', 'page'},
['Pages'] = {'pp', 'pages'},
['Periodical'] = {'journal', 'newspaper', 'magazine', 'work', 'website', 'periodical', 'encyclopedia', 'encyclopaedia', 'dictionary'},
['Place'] = {'place', 'location'},
['PPrefix'] = {'p-prefix', 'PPrefix'},
['PPPrefix'] = {'pp-prefix', 'PPPrefix'},
['Program'] = 'program', -- cite interview
['PostScript'] = 'postscript',
['PublicationDate'] = {'publicationdate', 'publication-date'},
['PublicationPlace'] = {'publication-place', 'publicationplace'},
['PublisherName'] = {'publisher', 'distributor', 'institution', 'newsgroup'},
['Quote'] = {'quote', 'quotation'},
['Ref'] = {'ref', 'Ref'},
['RegistrationRequired'] = 'registration',
['Scale'] = 'scale',
['ScriptTitle'] = 'script-title',
['Section'] = 'section',
['Season'] = 'season',
['Separator'] = 'separator', -- deprecated in favor of Mode
['Series'] = {'series', 'version'},
['SeriesSeparator'] = 'series-separator',
['SeriesLink'] = {'series-link', 'serieslink'},
['SeriesNumber'] = {'series-number', 'series-no', 'seriesnumber', 'seriesno'},
['Station'] = 'station',
['SubscriptionRequired'] = 'subscription',
['Time'] = 'time',
['TimeCaption'] = {'time-caption', 'timecaption'},
['Title'] = 'title',
['TitleLink'] = {'title-link', 'episode-link', 'titlelink', 'episodelink'},
['TitleNote'] = 'department',
['TitleType'] = {'type', 'medium'},
['TransChapter'] = {'trans-chapter', 'trans_chapter'},
['Transcript'] = 'transcript',
['TranscriptURL'] = {'transcript-url', 'transcripturl'},
['TransTitle'] = {'trans-title', 'trans_title'},
['URL'] = {'url', 'URL'},
['Via'] = 'via',
['Volume'] = 'volume',
['Year'] = 'year',
['AuthorList-First'] = {"author#-first", "author-first#",
"first#", "given#"},
['AuthorList-Last'] = {"author#-last", "author-last#",
"last#", "surname#", "Author#", "author#", "authors#", "subject#"},
['AuthorList-Link'] = {"author#-link", "author-link#",
"author#link", "authorlink#", "subject-link#", "subject#link", "subject#-link", "subjectlink#"},
['AuthorList-Mask'] = {"author#-mask", "author-mask#",
"author#mask", "authormask#"},
['EditorList-First'] = {"editor#-first",
"editor-first#", "editor#-given", "editor-given#", "EditorGiven#"},
['EditorList-Last'] = {"editor#-last", "editor-last#",
"editor#-surname", "editor-surname#", "EditorSurname#", "Editor#", "editor#", "editors#"},
['EditorList-Link'] = {"editor#-link", "editor-link#",
"editor#link", "editorlink#"},
['EditorList-Mask'] = {"editor#-mask", "editor-mask#",
"editor#mask", "editormask#"},
}
-- Default parameter values
citation_config.defaults = {
['DeadURL'] = 'yes',
['PPrefix'] = "หน้า ",
['PPPrefix'] = "หน้า ",
}
--[[--------------------------< E R R O R _ C O N D I T I O N S >----------------------------------------------
Error condition table
The following contains a list of IDs for various error conditions defined in the
code. For each ID, we specify a text message to display, an error category to
include, and whether the error message should be wrapped as a hidden comment.
Anchor changes require identical changes to matching anchor in Help:CS1 errors
]]
citation_config.error_conditions = {
accessdate_missing_url = {
message = '<code style="'..code_style..'">|accessdate=</code> requires <code style="'..code_style..'">|url=</code>',
anchor = 'accessdate_missing_url',
category = 'หน้าที่มีอ้างอิงที่ขาด URL แต่กลับมีวันที่ในการเข้าถึง',
hidden = true },
archive_missing_date = {
message = '<code style="'..code_style..'">|archiveurl=</code> requires <code style="'..code_style..'">|archivedate=</code>',
anchor = 'archive_missing_date',
category = 'Pages with archiveurl citation errors',
hidden = false },
archive_missing_url = {
message = '<code style="'..code_style..'">|archiveurl=</code> requires <code style="'..code_style..'">|url=</code>',
anchor = 'archive_missing_url',
category = 'Pages with archiveurl citation errors',
hidden = false },
bad_arxiv = {
message = 'Check <code style="'..code_style..'">|arxiv=</code> value',
anchor = 'bad_arxiv',
category = 'CS1 errors: arXiv',
hidden = false },
bad_asin = {
message = 'Check <code style="'..code_style..'">|asin=</code> value',
anchor = 'bad_asin',
category ='CS1 errors: ASIN',
hidden = false },
bad_authorlink = {
message = 'Check <code style="'..code_style..'">|authorlink=</code> value',
anchor = 'bad_authorlink',
category = 'CS1 errors: authorlink',
hidden = false },
bad_date = {
message = 'Check date values in: <code style="'..code_style..'">$1</code>',
anchor = 'bad_date',
category = 'CS1 errors: dates',
hidden = false },
bad_doi = {
message = 'Check <code style="'..code_style..'">|doi=</code> value',
anchor = 'bad_doi',
category = 'หน้าที่มี DOI ผิดพลาด',
hidden = false },
bad_isbn = {
message = 'Check <code style="'..code_style..'">|isbn=</code> value',
anchor = 'bad_isbn',
category = 'หน้าที่มี ISBN ผิดพลาด',
hidden = false },
bad_issn = {
message = 'Check <code style="'..code_style..'">|issn=</code> value',
anchor = 'bad_issn',
category = 'CS1 errors: ISSN',
hidden = false },
bad_lccn = {
message = 'Check <code style="'..code_style..'">|lccn=</code> value',
anchor = 'bad_lccn',
category = 'CS1 errors: LCCN',
hidden = false },
bad_message_id = {
message = 'Check <code style="'..code_style..'">|message-id=</code> value',
anchor = 'bad_message_id',
category = 'CS1 errors: message-id',
hidden = false },
bad_ol = {
message = 'Check <code style="'..code_style..'">|ol=</code> value',
anchor = 'bad_ol',
category = 'หน้าที่มี OL ผิดพลาด',
hidden = false },
bad_pmc = {
message = 'Check <code style="'..code_style..'">|pmc=</code> value',
anchor = 'bad_pmc',
category = 'CS1 errors: PMC',
hidden = false },
bad_pmid = {
message = 'Check <code style="'..code_style..'">|pmid=</code> value',
anchor = 'bad_pmid',
category = 'CS1 errors: PMID',
hidden = false },
bad_url = {
message = 'Check <code style="'..code_style..'">|url=</code> scheme',
anchor = 'bad_url',
category = 'หน้าที่มี URL ผิดพลาด',
hidden = false },
bare_url_missing_title = {
message = '$1 missing title',
anchor = 'bare_url_missing_title',
category = 'Pages with citations having bare URLs',
hidden = false },
chapter_ignored = {
message = '<code style="'..code_style..'">|chapter=</code> ignored',
anchor = 'chapter_ignored',
category = 'CS1 errors: chapter ignored',
hidden = false },
citation_missing_title = {
message = 'Missing or empty <code style="'..code_style..'">|title=</code>',
anchor = 'citation_missing_title',
category = 'Pages with citations lacking titles',
hidden = false },
cite_web_url = { -- this error applies to cite web and to cite podcast
message = 'Missing or empty <code style="'..code_style..'">|url=</code>',
anchor = 'cite_web_url',
category = 'Pages using web citations with no URL',
hidden = true },
coauthors_missing_author = {
message = '<code style="'..code_style..'">|coauthors=</code> requires <code style="'..code_style..'">|author=</code>',
anchor = 'coauthors_missing_author',
category = 'CS1 errors: coauthors without author',
hidden = false },
deprecated_params = {
message = 'Cite uses deprecated parameter <code style="'..code_style..'">|$1=</code>',
anchor = 'deprecated_params',
category = 'หน้าที่ใช้แม่แบบอ้างอิงที่มีพารามิเตอร์ล้าสมัย',
hidden = true },
empty_citation = {
message = 'Empty citation',
anchor = 'empty_citation',
category = 'หน้าที่มีอ้างอิงว่าง',
hidden = false },
extra_pages = {
message = 'Extra <code style="'..code_style..'">|pages=</code> or <code style="'..code_style..'">|at=</code>',
anchor = 'extra_pages',
category = 'Pages with citations using conflicting page specifications',
hidden = false },
first_missing_last = {
message = '<code style="'..code_style..'">|first$2=</code> missing <code style="'..code_style..'">|last$2=</code> in $1',
anchor = 'first_missing_last',
category = 'CS1 errors: missing author or editor',
hidden = false },
format_missing_url = {
message = '<code style="'..code_style..'">|$1=</code> requires <code style="'..code_style..'">|$2=</code>',
anchor = 'format_missing_url',
category = 'Pages using citations with format and no URL',
hidden = true },
implict_etal_editor = {
message = '<code style="'..code_style..'">|displayeditors=</code> suggested',
anchor = 'displayeditors',
category = 'Pages using citations with old-style implicit et al. in editors',
hidden = true },
invalid_param_val = {
message = 'Invalid <code style="'..code_style..'">|$1=$2</code>',
anchor = 'invalid_param_val',
category = 'CS1 errors: invalid mode',
hidden = false },
missing_name = {
message = 'Missing <code style="'..code_style..'">|last$2=</code> in $1',
anchor = 'missing_name',
category = 'CS1 errors: missing author or editor',
hidden = false },
parameter_ignored = {
message = 'Unknown parameter <code style="'..code_style..'">|$1=</code> ignored',
anchor = 'parameter_ignored',
category = 'หน้าที่มีอ้างอิงที่ใช้พารามิเตอร์ไม่สนับสนุน',
hidden = false },
parameter_ignored_suggest = {
message = 'Unknown parameter <code style="'..code_style..'">|$1=</code> ignored (<code style="'..code_style..'">|$2=</code> suggested)',
anchor = 'parameter_ignored_suggest',
category = 'หน้าที่มีอ้างอิงที่ใช้พารามิเตอร์ไม่สนับสนุน',
hidden = false },
redundant_parameters = {
message = 'More than one of $1 specified',
anchor = 'redundant_parameters',
category = 'หน้าที่มีอ้างอิงที่ใช้พารามิเตอร์ซ้ำซ้อน',
hidden = false },
text_ignored = {
message = 'Text "$1" ignored',
anchor = 'text_ignored',
category = 'หน้าที่มีอ้างอิงที่ใช้พารามิเตอร์ไม่มีชื่อ',
hidden = false },
trans_missing_chapter = {
message = '<code style="'..code_style..'">|trans-chapter=</code> requires <code style="'..code_style..'">|chapter=</code>',
anchor = 'trans_missing_chapter',
category = 'Pages with citations using translated terms without the original',
hidden = false },
trans_missing_title = {
message = '<code style="'..code_style..'">|trans-title=</code> requires <code style="'..code_style..'">|title=</code>',
anchor = 'trans_missing_title',
category = 'Pages with citations using translated terms without the original',
hidden = false },
wikilink_in_url = {
message = 'Wikilink embedded in URL title',
anchor = 'wikilink_in_url',
category = 'Pages with citations having wikilinks embedded in URL titles',
hidden = false },
}
citation_config.id_handlers = {
['ARXIV'] = {
parameters = {'arxiv', 'ARXIV'},
link = 'w:arXiv',
label = 'arXiv',
mode = 'manual',
prefix = '//arxiv.org/abs/', -- protocol relative tested 2013-09-04
encode = false,
COinS = 'info:arxiv',
separator = ':',
},
['ASIN'] = {
parameters = { 'asin', 'ASIN' },
link = 'w:Amazon Standard Identification Number',
label = 'ASIN',
mode = 'manual',
COinS = 'info:asin',
separator = ' ',
encode = false;
},
['BIBCODE'] = {
parameters = {'bibcode', 'BIBCODE'},
link = 'w:Bibcode',
label = 'Bibcode',
mode = 'external',
prefix = 'http://adsabs.harvard.edu/abs/',
encode = false,
COinS = 'info:bibcode',
separator = ':',
},
['DOI'] = {
parameters = { 'doi', 'DOI' },
link = 'w:Digital object identifier',
label = 'doi',
mode = 'manual',
prefix = '//dx.doi.org/',
COinS = 'info:doi',
separator = ':',
encode = true,
},
['ISBN'] = {
parameters = {'isbn', 'ISBN', 'isbn13', 'ISBN13'},
link = 'w:International Standard Book Number',
label = 'ISBN',
mode = 'manual',
prefix = 'Special:BookSources/',
COinS = 'rft.isbn',
separator = ' ',
},
['ISSN'] = {
parameters = {'issn', 'ISSN'},
link = 'w:International Standard Serial Number',
label = 'ISSN',
mode = 'manual',
prefix = '//www.worldcat.org/issn/',
COinS = 'rft.issn',
encode = false,
separator = ' ',
},
['JFM'] = {
parameters = {'jfm', 'JFM'},
link = 'w:Jahrbuch über die Fortschritte der Mathematik',
label = 'JFM',
mode = 'external',
prefix = '//zbmath.org/?format=complete&q=an:',
COinS = 'rft.jfm',
encode = true,
separator = ' ',
},
['JSTOR'] = {
parameters = {'jstor', 'JSTOR'},
link = 'w:JSTOR',
label = 'JSTOR',
mode = 'external',
prefix = '//www.jstor.org/stable/', -- protocol relative tested 2013-09-04
COinS = 'rft.jstor',
-- encode = true,
encode = false,
separator = ' ',
},
['LCCN'] = {
parameters = {'LCCN', 'lccn'},
link = 'w:Library of Congress Control Number',
label = 'LCCN',
mode = 'manual',
prefix = 'http://lccn.loc.gov/',
COinS = 'rft.lccn',
encode = false,
separator = ' ',
},
['MR'] = {
parameters = {'MR', 'mr'},
link = 'w:Mathematical Reviews',
label = 'MR',
mode = 'external',
prefix = '//www.ams.org/mathscinet-getitem?mr=', -- protocol relative tested 2013-09-04
COinS = 'rft.mr',
encode = true,
separator = ' ',
},
['OCLC'] = {
parameters = {'OCLC', 'oclc'},
link = 'w:OCLC',
label = 'OCLC',
mode = 'external',
prefix = '//www.worldcat.org/oclc/',
COinS = 'info:oclcnum',
encode = true,
separator = ' ',
},
['OL'] = {
parameters = { 'ol', 'OL' },
link = 'w:Open Library',
label = 'OL',
mode = 'manual',
COinS = 'info:olnum',
separator = ' ',
endode = true,
},
['OSTI'] = {
parameters = {'OSTI', 'osti'},
link = 'w:Office of Scientific and Technical Information',
label = 'OSTI',
mode = 'external',
prefix = '//www.osti.gov/energycitations/product.biblio.jsp?osti_id=', -- protocol relative tested 2013-09-04
COinS = 'info:osti',
encode = true,
separator = ' ',
},
['PMC'] = {
parameters = {'PMC', 'pmc'},
link = 'w:PubMed Central',
label = 'PMC',
mode = 'manual', -- changed to support unlinking of PMC identifier when article is embargoed
prefix = '//www.ncbi.nlm.nih.gov/pmc/articles/PMC',
suffix = " ",
COinS = 'info:pmc',
encode = true,
separator = ' ',
},
['PMID'] = {
parameters = {'PMID', 'pmid'},
link = 'w:PubMed Identifier',
label = 'PMID',
mode = 'manual', -- changed from external manual to support PMID validation
prefix = '//www.ncbi.nlm.nih.gov/pubmed/',
COinS = 'info:pmid',
encode = false,
separator = ' ',
},
['RFC'] = {
parameters = {'RFC', 'rfc'},
link = 'w:Request for Comments',
label = 'RFC',
mode = 'external',
prefix = '//tools.ietf.org/html/rfc',
COinS = 'info:rfc',
encode = false,
separator = ' ',
},
['SSRN'] = {
parameters = {'SSRN', 'ssrn'},
link = 'w:Social Science Research Network',
label = 'SSRN',
mode = 'external',
prefix = '//ssrn.com/abstract=', -- protocol relative tested 2013-09-04
COinS = 'info:ssrn',
encode = true,
separator = ' ',
},
['USENETID'] = {
parameters = {'message-id'},
link = 'w:Usenet',
label = 'Usenet:',
mode = 'manual',
prefix = 'news:',
encode = false,
COinS = 'info:usenet',
separator = ' ',
},
['ZBL'] = {
parameters = {'ZBL', 'zbl'},
link = 'w:Zentralblatt MATH',
label = 'Zbl',
mode = 'external',
prefix = '//zbmath.org/?format=complete&q=an:',
COinS = 'info:zbl',
encode = true,
separator = ' ',
},
}
return citation_config;
32z7ma4tupmjaj5rucm8jcbxkfx5opn
189433
189424
2022-08-16T15:27:14Z
Venise12mai1834
8884
Scribunto
text/plain
citation_config = {};
-- override <code>...</code> styling to remove color, border, and padding. <code> css is specified here:
-- https://git.wikimedia.org/blob/mediawiki%2Fcore.git/69cd73811f7aadd093050dbf20ed70ef0b42a713/skins%2Fcommon%2FcommonElements.css#L199
local code_style="color:inherit; border:inherit; padding:inherit;";
--[[--------------------------< U N C A T E G O R I Z E D _ N A M E S P A C E S >------------------------------
List of namespaces that should not be included in citation error categories. Same as setting notracking = true by default
Note: Namespace names should use underscores instead of spaces.
]]
citation_config.uncategorized_namespaces = { 'User', 'Talk', 'User_talk', 'Wikisource_talk', 'File_talk', 'Template_talk',
'Help_talk', 'Category_talk', 'Portal_talk', 'Author_talk', 'Page_talk', 'Index_talk', 'Translation_talk',
'Module_talk', 'MediaWiki_talk' };
--[[--------------------------< M E S S A G E S >--------------------------------------------------------------
Translation table
The following contains fixed text that may be output as part of a citation.
This is separated from the main body to aid in future translations of this
module.
]]
citation_config.messages = {
['published'] = 'published $1',
['lay summary'] = 'Lay summary',
['retrieved'] = 'สืบค้นเมื่อ $1',
['inactive'] = 'inactive',
['archived-dead'] = 'Archived from $1 on $2',
['archived-not-dead'] = '$1 from the original on $2',
['archived-missing'] = 'Archived from the original$1 on $2',
['archived'] = 'Archived',
['original'] = 'the original',
['editor'] = 'บรรณาธิการ',
['editors'] = 'บรรณาธิการ',
['edition'] = '(พิมพ์ครั้งที่ $1)',
['episode'] = 'episode',
['season'] = 'season',
['series'] = 'series',
['cartography'] = 'Cartography by $1',
['section'] = 'Section $1',
['inset'] = '$1 inset',
['written'] = 'Written at $1',
['in'] = 'In',
['et al'] = 'และคนอื่น ๆ',
['subscription'] = '<span style="font-size:0.95em; font-size:90%; color:#555">(subscription required (<span title="Sources are not required to be available online. Online sources do not have to be freely available. The site may require a paid subscription." style="border-bottom:1px dotted;cursor:help">help</span>))</span>' ..
'[[Category:Pages containing links to subscription-only content]]',
['registration']='<span style="font-size:0.95em; font-size:90%; color:#555">(registration required (<span title="Sources are not required to be available online. Online sources do not have to be freely available. The site may require registration." style="border-bottom:1px dotted;cursor:help">help</span>))</span>' ..
'[[Category:Pages with login required references or sources]]',
['language'] = '(ภาษา$1)',
['via'] = " – โดยทาง $1",
['event'] = 'Event occurs at',
['minutes'] = 'minutes in',
['parameter-separator'] = ', ',
['parameter-final-separator'] = ', และ ',
['parameter-pair-separator'] = ' และ ',
-- Determines the location of the help page
['help page link'] = 'w:Help:CS1 errors',
['help page label'] = 'help',
-- Internal errors (should only occur if configuration is bad)
['undefined_error'] = 'Called with an undefined error condition',
['unknown_manual_ID'] = 'Unrecognized manual ID mode',
['unknown_ID_mode'] = 'Unrecognized ID mode',
['unknown_argument_map'] = 'Argument map not defined for this variable',
['bare_url_no_origin'] = 'Bare url found but origin indicator is nil or empty',
}
--[[--------------------------< P R E S E N T A T I O N >------------------------------------------------------
Fixed presentation markup. Originally part of citation_config.messages it has been moved into its own, more semantically
correct place.
]]
citation_config.presentation =
{
-- Error output
-- .error class is specified at https://git.wikimedia.org/blob/mediawiki%2Fcore.git/9553bd02a5595da05c184f7521721fb1b79b3935/skins%2Fcommon%2Fshared.css#L538
-- .citation-comment class is specified at Help:CS1_errors#Controlling_error_message_display
['hidden-error'] = '<span style="display:none;font-size:100%" class="error citation-comment">$1</span>',
['visible-error'] = '<span style="font-size:100%" class="error citation-comment">$1</span>',
['accessdate'] = '<span class="reference-accessdate">$1$2</span>', -- to allow editors to hide accessdate using personal css
['bdi'] = '<bdi$1>$2</bdi>', -- bidirectional isolation used with |script-title= and the like
['italic-title'] = "''$1''",
['kern-left'] = '<span style="padding-left:0.2em;">$1</span>$2', -- spacing to use when title contains leading single or double quote mark
['kern-right'] = '$1<span style="padding-right:0.2em;">$2</span>', -- spacing to use when title contains trailing single or double quote mark
['nowrap1'] = '<span class="nowrap">$1</span>', -- for nowrapping an item: <span ...>yyyy-mm-dd</span>
['nowrap2'] = '<span class="nowrap">$1</span> $2', -- for nowrapping portions of an item: <span ...>dd mmmm</span> yyyy (note white space)
['parameter'] = '<code style="'..code_style..'">|$1=</code>',
['quoted-text'] = '<q>$1</q>', -- for wrapping |quote= content
['quoted-title'] = '"$1"',
['trans-italic-title'] = "[''$1'']",
['trans-quoted-title'] = "[$1]",
}
--[[--------------------------< A L I A S E S >----------------------------------------------------------------
Aliases table for commonly passed parameters
]]
citation_config.aliases = {
['AccessDate'] = {'access-date', 'accessdate'},
['Agency'] = 'agency',
['AirDate'] = {'air-date', 'airdate'},
['ArchiveDate'] = {'archive-date', 'archivedate'},
['ArchiveURL'] = {'archive-url', 'archiveurl'},
['ASINTLD'] = {'ASIN-TLD', 'asin-tld'},
['At'] = 'at',
['Authors'] = {'authors', 'people', 'host'},
['AuthorFormat'] = {'author-format', 'authorformat'}, -- deprecated in favor of NameListFormat;
['AuthorSeparator'] = 'author-separator', -- deprecated
['AuthorNameSeparator'] = 'author-name-separator', -- deprecated
['BookTitle'] = {'book-title', 'booktitle'},
['Callsign'] = {'call-sign', 'callsign'}, -- cite interview
['Cartography'] = 'cartography',
['Chapter'] = {'chapter', 'contribution', 'entry', 'article', 'section'},
['ChapterFormat'] = 'chapter-format';
['ChapterLink'] = {'chapter-link', 'chapterlink'}, -- deprecated; remove after 1 January 2015?
['ChapterURL'] = {'chapter-url', 'chapterurl', 'contribution-url', 'contributionurl', 'section-url', 'sectionurl'},
['City'] = 'city', -- cite interview
['Coauthors'] = {'coauthors', 'coauthor'}, -- coauthor and coauthors are deprecated; remove after 1 January 2015?
['Conference'] = {'conference', 'event'},
['ConferenceURL'] = {'conference-url', 'conferenceurl', 'event-url', 'eventurl'},
['Date'] = 'date',
['Day'] = 'day', -- deprecated; remove after 1 January 2015?
['DeadURL'] = {'dead-url', 'deadurl'},
['Degree'] = 'degree',
['DisplayAuthors'] = {'display-authors', 'displayauthors'},
['DisplayEditors'] = {'display-editors', 'displayeditors'},
['Docket'] = 'docket',
['DoiBroken'] = {'doi-broken', 'doi-broken-date', 'doi-inactive-date', 'DoiBroken', 'doi_brokendate', 'doi_inactivedate'},
['Edition'] = 'edition',
['Editors'] = 'editors',
['EditorFormat'] = {'editor-format', 'editorformat'}, -- deprecated in favor of NameListFormat;
['EditorSeparator'] = 'editor-separator', -- deprecated
['EditorNameSeparator'] = 'editor-name-separator', -- deprecated
['Embargo'] = {'Embargo', 'embargo'},
['Encyclopedia'] = {'encyclopedia', 'encyclopaedia'}, -- this one only used by citation
['Format'] = 'format',
['ID'] = {'id', 'ID'},
['IgnoreISBN'] = {'ignore-isbn-error', 'ignoreisbnerror'},
['Inset'] = 'inset',
['Issue'] = {'issue', 'number'},
['Language'] = {'language', 'in'},
['LastAuthorAmp'] = {'last-author-amp', 'lastauthoramp'},
['LayDate'] = {'lay-date', 'laydate'},
['LaySource'] = {'lay-source', 'laysource'},
['LayURL'] = {'lay-url', 'lay-summary', 'layurl', 'laysummary'},
['MailingList'] = {'mailinglist', 'mailing-list'}, -- cite mailing list only
['MessageID'] = 'message-id',
['Minutes'] = 'minutes',
['Mode'] = 'mode',
['Month'] = 'month', -- deprecated; remove after 1 January 2015?
['NameListFormat'] = {'name-list-format', 'author-format', 'authorformat', 'editor-format', 'editorformat'},
['NameSeparator'] = 'name-separator', -- deprecated
['Network'] = 'network',
['NoPP'] = {'no-pp', 'nopp'},
['NoTracking'] = {'template-doc-demo', 'template doc demo', 'no-cat', 'nocat', 'no-tracking', 'notracking'},
['OrigYear'] = {'orig-year', 'origyear'},
['Others'] = {'others', 'interviewer', 'interviewers'},
['Page'] = {'p', 'page'},
['Pages'] = {'pp', 'pages'},
['Periodical'] = {'journal', 'newspaper', 'magazine', 'work', 'website', 'periodical', 'encyclopedia', 'encyclopaedia', 'dictionary'},
['Place'] = {'place', 'location'},
['PPrefix'] = {'p-prefix', 'PPrefix'},
['PPPrefix'] = {'pp-prefix', 'PPPrefix'},
['Program'] = 'program', -- cite interview
['PostScript'] = 'postscript',
['PublicationDate'] = {'publicationdate', 'publication-date'},
['PublicationPlace'] = {'publication-place', 'publicationplace'},
['PublisherName'] = {'publisher', 'distributor', 'institution', 'newsgroup'},
['Quote'] = {'quote', 'quotation'},
['Ref'] = {'ref', 'Ref'},
['RegistrationRequired'] = 'registration',
['Scale'] = 'scale',
['ScriptTitle'] = 'script-title',
['Section'] = 'section',
['Season'] = 'season',
['Separator'] = 'separator', -- deprecated in favor of Mode
['Series'] = {'series', 'version'},
['SeriesSeparator'] = 'series-separator',
['SeriesLink'] = {'series-link', 'serieslink'},
['SeriesNumber'] = {'series-number', 'series-no', 'seriesnumber', 'seriesno'},
['Station'] = 'station',
['SubscriptionRequired'] = 'subscription',
['Time'] = 'time',
['TimeCaption'] = {'time-caption', 'timecaption'},
['Title'] = 'title',
['TitleLink'] = {'title-link', 'episode-link', 'titlelink', 'episodelink'},
['TitleNote'] = 'department',
['TitleType'] = {'type', 'medium'},
['TransChapter'] = {'trans-chapter', 'trans_chapter'},
['Transcript'] = 'transcript',
['TranscriptURL'] = {'transcript-url', 'transcripturl'},
['TransTitle'] = {'trans-title', 'trans_title'},
['URL'] = {'url', 'URL'},
['Via'] = 'via',
['Volume'] = 'volume',
['Year'] = 'year',
['AuthorList-First'] = {"author#-first", "author-first#",
"first#", "given#"},
['AuthorList-Last'] = {"author#-last", "author-last#",
"last#", "surname#", "Author#", "author#", "authors#", "subject#"},
['AuthorList-Link'] = {"author#-link", "author-link#",
"author#link", "authorlink#", "subject-link#", "subject#link", "subject#-link", "subjectlink#"},
['AuthorList-Mask'] = {"author#-mask", "author-mask#",
"author#mask", "authormask#"},
['EditorList-First'] = {"editor#-first",
"editor-first#", "editor#-given", "editor-given#", "EditorGiven#"},
['EditorList-Last'] = {"editor#-last", "editor-last#",
"editor#-surname", "editor-surname#", "EditorSurname#", "Editor#", "editor#", "editors#"},
['EditorList-Link'] = {"editor#-link", "editor-link#",
"editor#link", "editorlink#"},
['EditorList-Mask'] = {"editor#-mask", "editor-mask#",
"editor#mask", "editormask#"},
}
-- Default parameter values
citation_config.defaults = {
['DeadURL'] = 'yes',
['PPrefix'] = "หน้า ",
['PPPrefix'] = "หน้า ",
}
--[[--------------------------< E R R O R _ C O N D I T I O N S >----------------------------------------------
Error condition table
The following contains a list of IDs for various error conditions defined in the
code. For each ID, we specify a text message to display, an error category to
include, and whether the error message should be wrapped as a hidden comment.
Anchor changes require identical changes to matching anchor in Help:CS1 errors
]]
citation_config.error_conditions = {
accessdate_missing_url = {
message = '<code style="'..code_style..'">|accessdate=</code> requires <code style="'..code_style..'">|url=</code>',
anchor = 'accessdate_missing_url',
category = 'หน้าที่มีอ้างอิงที่ขาด URL แต่กลับมีวันที่ในการเข้าถึง',
hidden = true },
archive_missing_date = {
message = '<code style="'..code_style..'">|archiveurl=</code> requires <code style="'..code_style..'">|archivedate=</code>',
anchor = 'archive_missing_date',
category = 'Pages with archiveurl citation errors',
hidden = false },
archive_missing_url = {
message = '<code style="'..code_style..'">|archiveurl=</code> requires <code style="'..code_style..'">|url=</code>',
anchor = 'archive_missing_url',
category = 'Pages with archiveurl citation errors',
hidden = false },
bad_arxiv = {
message = 'Check <code style="'..code_style..'">|arxiv=</code> value',
anchor = 'bad_arxiv',
category = 'CS1 errors: arXiv',
hidden = false },
bad_asin = {
message = 'Check <code style="'..code_style..'">|asin=</code> value',
anchor = 'bad_asin',
category ='CS1 errors: ASIN',
hidden = false },
bad_authorlink = {
message = 'Check <code style="'..code_style..'">|authorlink=</code> value',
anchor = 'bad_authorlink',
category = 'CS1 errors: authorlink',
hidden = false },
bad_date = {
message = 'Check date values in: <code style="'..code_style..'">$1</code>',
anchor = 'bad_date',
category = 'CS1 errors: dates',
hidden = false },
bad_doi = {
message = 'Check <code style="'..code_style..'">|doi=</code> value',
anchor = 'bad_doi',
category = 'หน้าที่มี DOI ผิดพลาด',
hidden = false },
bad_isbn = {
message = 'Check <code style="'..code_style..'">|isbn=</code> value',
anchor = 'bad_isbn',
category = 'หน้าที่มี ISBN ผิดพลาด',
hidden = false },
bad_issn = {
message = 'Check <code style="'..code_style..'">|issn=</code> value',
anchor = 'bad_issn',
category = 'CS1 errors: ISSN',
hidden = false },
bad_lccn = {
message = 'Check <code style="'..code_style..'">|lccn=</code> value',
anchor = 'bad_lccn',
category = 'CS1 errors: LCCN',
hidden = false },
bad_message_id = {
message = 'Check <code style="'..code_style..'">|message-id=</code> value',
anchor = 'bad_message_id',
category = 'CS1 errors: message-id',
hidden = false },
bad_ol = {
message = 'Check <code style="'..code_style..'">|ol=</code> value',
anchor = 'bad_ol',
category = 'หน้าที่มี OL ผิดพลาด',
hidden = false },
bad_pmc = {
message = 'Check <code style="'..code_style..'">|pmc=</code> value',
anchor = 'bad_pmc',
category = 'CS1 errors: PMC',
hidden = false },
bad_pmid = {
message = 'Check <code style="'..code_style..'">|pmid=</code> value',
anchor = 'bad_pmid',
category = 'CS1 errors: PMID',
hidden = false },
bad_url = {
message = 'Check <code style="'..code_style..'">|url=</code> scheme',
anchor = 'bad_url',
category = 'หน้าที่มี URL ผิดพลาด',
hidden = false },
bare_url_missing_title = {
message = '$1 missing title',
anchor = 'bare_url_missing_title',
category = 'Pages with citations having bare URLs',
hidden = false },
chapter_ignored = {
message = '<code style="'..code_style..'">|chapter=</code> ignored',
anchor = 'chapter_ignored',
category = 'CS1 errors: chapter ignored',
hidden = false },
citation_missing_title = {
message = 'Missing or empty <code style="'..code_style..'">|title=</code>',
anchor = 'citation_missing_title',
category = 'Pages with citations lacking titles',
hidden = false },
cite_web_url = { -- this error applies to cite web and to cite podcast
message = 'Missing or empty <code style="'..code_style..'">|url=</code>',
anchor = 'cite_web_url',
category = 'Pages using web citations with no URL',
hidden = true },
coauthors_missing_author = {
message = '<code style="'..code_style..'">|coauthors=</code> requires <code style="'..code_style..'">|author=</code>',
anchor = 'coauthors_missing_author',
category = 'CS1 errors: coauthors without author',
hidden = false },
deprecated_params = {
message = 'Cite uses deprecated parameter <code style="'..code_style..'">|$1=</code>',
anchor = 'deprecated_params',
category = 'หน้าที่ใช้แม่แบบอ้างอิงที่มีพารามิเตอร์ล้าสมัย',
hidden = true },
empty_citation = {
message = 'Empty citation',
anchor = 'empty_citation',
category = 'หน้าที่มีอ้างอิงว่าง',
hidden = false },
extra_pages = {
message = 'Extra <code style="'..code_style..'">|pages=</code> or <code style="'..code_style..'">|at=</code>',
anchor = 'extra_pages',
category = 'Pages with citations using conflicting page specifications',
hidden = false },
first_missing_last = {
message = '<code style="'..code_style..'">|first$2=</code> missing <code style="'..code_style..'">|last$2=</code> in $1',
anchor = 'first_missing_last',
category = 'CS1 errors: missing author or editor',
hidden = false },
format_missing_url = {
message = '<code style="'..code_style..'">|$1=</code> requires <code style="'..code_style..'">|$2=</code>',
anchor = 'format_missing_url',
category = 'Pages using citations with format and no URL',
hidden = true },
implict_etal_editor = {
message = '<code style="'..code_style..'">|displayeditors=</code> suggested',
anchor = 'displayeditors',
category = 'Pages using citations with old-style implicit et al. in editors',
hidden = true },
invalid_param_val = {
message = 'Invalid <code style="'..code_style..'">|$1=$2</code>',
anchor = 'invalid_param_val',
category = 'CS1 errors: invalid mode',
hidden = false },
missing_name = {
message = 'Missing <code style="'..code_style..'">|last$2=</code> in $1',
anchor = 'missing_name',
category = 'CS1 errors: missing author or editor',
hidden = false },
parameter_ignored = {
message = 'Unknown parameter <code style="'..code_style..'">|$1=</code> ignored',
anchor = 'parameter_ignored',
category = 'หน้าที่มีอ้างอิงที่ใช้พารามิเตอร์ไม่สนับสนุน',
hidden = false },
parameter_ignored_suggest = {
message = 'Unknown parameter <code style="'..code_style..'">|$1=</code> ignored (<code style="'..code_style..'">|$2=</code> suggested)',
anchor = 'parameter_ignored_suggest',
category = 'หน้าที่มีอ้างอิงที่ใช้พารามิเตอร์ไม่สนับสนุน',
hidden = false },
redundant_parameters = {
message = 'More than one of $1 specified',
anchor = 'redundant_parameters',
category = 'หน้าที่มีอ้างอิงที่ใช้พารามิเตอร์ซ้ำซ้อน',
hidden = false },
text_ignored = {
message = 'Text "$1" ignored',
anchor = 'text_ignored',
category = 'หน้าที่มีอ้างอิงที่ใช้พารามิเตอร์ไม่มีชื่อ',
hidden = false },
trans_missing_chapter = {
message = '<code style="'..code_style..'">|trans-chapter=</code> requires <code style="'..code_style..'">|chapter=</code>',
anchor = 'trans_missing_chapter',
category = 'Pages with citations using translated terms without the original',
hidden = false },
trans_missing_title = {
message = '<code style="'..code_style..'">|trans-title=</code> requires <code style="'..code_style..'">|title=</code>',
anchor = 'trans_missing_title',
category = 'Pages with citations using translated terms without the original',
hidden = false },
wikilink_in_url = {
message = 'Wikilink embedded in URL title',
anchor = 'wikilink_in_url',
category = 'Pages with citations having wikilinks embedded in URL titles',
hidden = false },
}
citation_config.id_handlers = {
['ARXIV'] = {
parameters = {'arxiv', 'ARXIV'},
link = 'w:arXiv',
label = 'arXiv',
mode = 'manual',
prefix = '//arxiv.org/abs/', -- protocol relative tested 2013-09-04
encode = false,
COinS = 'info:arxiv',
separator = ':',
},
['ASIN'] = {
parameters = { 'asin', 'ASIN' },
link = 'w:Amazon Standard Identification Number',
label = 'ASIN',
mode = 'manual',
COinS = 'info:asin',
separator = ' ',
encode = false;
},
['BIBCODE'] = {
parameters = {'bibcode', 'BIBCODE'},
link = 'w:Bibcode',
label = 'Bibcode',
mode = 'external',
prefix = 'http://adsabs.harvard.edu/abs/',
encode = false,
COinS = 'info:bibcode',
separator = ':',
},
['DOI'] = {
parameters = { 'doi', 'DOI' },
link = 'w:Digital object identifier',
label = 'doi',
mode = 'manual',
prefix = '//dx.doi.org/',
COinS = 'info:doi',
separator = ':',
encode = true,
},
['ISBN'] = {
parameters = {'isbn', 'ISBN', 'isbn13', 'ISBN13'},
link = 'w:International Standard Book Number',
label = 'ISBN',
mode = 'manual',
prefix = 'Special:BookSources/',
COinS = 'rft.isbn',
separator = ' ',
},
['ISSN'] = {
parameters = {'issn', 'ISSN'},
link = 'w:International Standard Serial Number',
label = 'ISSN',
mode = 'manual',
prefix = '//www.worldcat.org/issn/',
COinS = 'rft.issn',
encode = false,
separator = ' ',
},
['JFM'] = {
parameters = {'jfm', 'JFM'},
link = 'w:Jahrbuch über die Fortschritte der Mathematik',
label = 'JFM',
mode = 'external',
prefix = '//zbmath.org/?format=complete&q=an:',
COinS = 'rft.jfm',
encode = true,
separator = ' ',
},
['JSTOR'] = {
parameters = {'jstor', 'JSTOR'},
link = 'w:JSTOR',
label = 'JSTOR',
mode = 'external',
prefix = '//www.jstor.org/stable/', -- protocol relative tested 2013-09-04
COinS = 'rft.jstor',
-- encode = true,
encode = false,
separator = ' ',
},
['LCCN'] = {
parameters = {'LCCN', 'lccn'},
link = 'w:Library of Congress Control Number',
label = 'LCCN',
mode = 'manual',
prefix = 'http://lccn.loc.gov/',
COinS = 'rft.lccn',
encode = false,
separator = ' ',
},
['MR'] = {
parameters = {'MR', 'mr'},
link = 'w:Mathematical Reviews',
label = 'MR',
mode = 'external',
prefix = '//www.ams.org/mathscinet-getitem?mr=', -- protocol relative tested 2013-09-04
COinS = 'rft.mr',
encode = true,
separator = ' ',
},
['OCLC'] = {
parameters = {'OCLC', 'oclc'},
link = 'w:OCLC',
label = 'OCLC',
mode = 'external',
prefix = '//www.worldcat.org/oclc/',
COinS = 'info:oclcnum',
encode = true,
separator = ' ',
},
['OL'] = {
parameters = { 'ol', 'OL' },
link = 'w:Open Library',
label = 'OL',
mode = 'manual',
COinS = 'info:olnum',
separator = ' ',
endode = true,
},
['OSTI'] = {
parameters = {'OSTI', 'osti'},
link = 'w:Office of Scientific and Technical Information',
label = 'OSTI',
mode = 'external',
prefix = '//www.osti.gov/energycitations/product.biblio.jsp?osti_id=', -- protocol relative tested 2013-09-04
COinS = 'info:osti',
encode = true,
separator = ' ',
},
['PMC'] = {
parameters = {'PMC', 'pmc'},
link = 'w:PubMed Central',
label = 'PMC',
mode = 'manual', -- changed to support unlinking of PMC identifier when article is embargoed
prefix = '//www.ncbi.nlm.nih.gov/pmc/articles/PMC',
suffix = " ",
COinS = 'info:pmc',
encode = true,
separator = ' ',
},
['PMID'] = {
parameters = {'PMID', 'pmid'},
link = 'w:PubMed Identifier',
label = 'PMID',
mode = 'manual', -- changed from external manual to support PMID validation
prefix = '//www.ncbi.nlm.nih.gov/pubmed/',
COinS = 'info:pmid',
encode = false,
separator = ' ',
},
['RFC'] = {
parameters = {'RFC', 'rfc'},
link = 'w:Request for Comments',
label = 'RFC',
mode = 'external',
prefix = '//tools.ietf.org/html/rfc',
COinS = 'info:rfc',
encode = false,
separator = ' ',
},
['SSRN'] = {
parameters = {'SSRN', 'ssrn'},
link = 'w:Social Science Research Network',
label = 'SSRN',
mode = 'external',
prefix = '//ssrn.com/abstract=', -- protocol relative tested 2013-09-04
COinS = 'info:ssrn',
encode = true,
separator = ' ',
},
['USENETID'] = {
parameters = {'message-id'},
link = 'w:Usenet',
label = 'Usenet:',
mode = 'manual',
prefix = 'news:',
encode = false,
COinS = 'info:usenet',
separator = ' ',
},
['ZBL'] = {
parameters = {'ZBL', 'zbl'},
link = 'w:Zentralblatt MATH',
label = 'Zbl',
mode = 'external',
prefix = '//zbmath.org/?format=complete&q=an:',
COinS = 'info:zbl',
encode = true,
separator = ' ',
},
}
return citation_config;
adtktzso6e8sjcuec6slmrnxkryuxiz
189487
189433
2022-08-16T16:52:34Z
Venise12mai1834
8884
Scribunto
text/plain
citation_config = {};
-- override <code>...</code> styling to remove color, border, and padding. <code> css is specified here:
-- https://git.wikimedia.org/blob/mediawiki%2Fcore.git/69cd73811f7aadd093050dbf20ed70ef0b42a713/skins%2Fcommon%2FcommonElements.css#L199
local code_style="color:inherit; border:inherit; padding:inherit;";
--[[--------------------------< U N C A T E G O R I Z E D _ N A M E S P A C E S >------------------------------
List of namespaces that should not be included in citation error categories. Same as setting notracking = true by default
Note: Namespace names should use underscores instead of spaces.
]]
citation_config.uncategorized_namespaces = { 'User', 'Talk', 'User_talk', 'Wikisource_talk', 'File_talk', 'Template_talk',
'Help_talk', 'Category_talk', 'Portal_talk', 'Author_talk', 'Page_talk', 'Index_talk', 'Translation_talk',
'Module_talk', 'MediaWiki_talk' };
--[[--------------------------< M E S S A G E S >--------------------------------------------------------------
Translation table
The following contains fixed text that may be output as part of a citation.
This is separated from the main body to aid in future translations of this
module.
]]
citation_config.messages = {
['published'] = 'published $1',
['lay summary'] = 'Lay summary',
['retrieved'] = 'สืบค้นเมื่อ $1',
['inactive'] = 'inactive',
['archived-dead'] = 'Archived from $1 on $2',
['archived-not-dead'] = '$1 from the original on $2',
['archived-missing'] = 'Archived from the original$1 on $2',
['archived'] = 'Archived',
['original'] = 'the original',
['editor'] = 'บรรณาธิการ',
['editors'] = 'บรรณาธิการ',
['edition'] = '(พิมพ์ครั้งที่ $1)',
['episode'] = 'episode',
['season'] = 'season',
['series'] = 'series',
['cartography'] = 'Cartography by $1',
['section'] = 'Section $1',
['inset'] = '$1 inset',
['written'] = 'Written at $1',
['in'] = 'In',
['et al'] = 'และคนอื่น ๆ',
['subscription'] = '<span style="font-size:0.95em; font-size:90%; color:#555">(subscription required (<span title="Sources are not required to be available online. Online sources do not have to be freely available. The site may require a paid subscription." style="border-bottom:1px dotted;cursor:help">help</span>))</span>' ..
'[[Category:Pages containing links to subscription-only content]]',
['registration']='<span style="font-size:0.95em; font-size:90%; color:#555">(registration required (<span title="Sources are not required to be available online. Online sources do not have to be freely available. The site may require registration." style="border-bottom:1px dotted;cursor:help">help</span>))</span>' ..
'[[Category:Pages with login required references or sources]]',
['language'] = '(ภาษา$1)',
['via'] = " – โดยทาง $1",
['event'] = 'Event occurs at',
['minutes'] = 'minutes in',
['parameter-separator'] = ', ',
['parameter-final-separator'] = ', และ ',
['parameter-pair-separator'] = ' และ ',
-- Determines the location of the help page
['help page link'] = 'w:Help:CS1 errors',
['help page label'] = 'help',
-- Internal errors (should only occur if configuration is bad)
['undefined_error'] = 'Called with an undefined error condition',
['unknown_manual_ID'] = 'Unrecognized manual ID mode',
['unknown_ID_mode'] = 'Unrecognized ID mode',
['unknown_argument_map'] = 'Argument map not defined for this variable',
['bare_url_no_origin'] = 'Bare url found but origin indicator is nil or empty',
}
--[[--------------------------< P R E S E N T A T I O N >------------------------------------------------------
Fixed presentation markup. Originally part of citation_config.messages it has been moved into its own, more semantically
correct place.
]]
citation_config.presentation =
{
-- Error output
-- .error class is specified at https://git.wikimedia.org/blob/mediawiki%2Fcore.git/9553bd02a5595da05c184f7521721fb1b79b3935/skins%2Fcommon%2Fshared.css#L538
-- .citation-comment class is specified at Help:CS1_errors#Controlling_error_message_display
['hidden-error'] = '<span style="display:none;font-size:100%" class="error citation-comment">$1</span>',
['visible-error'] = '<span style="font-size:100%" class="error citation-comment">$1</span>',
['accessdate'] = '<span class="reference-accessdate">$1$2</span>', -- to allow editors to hide accessdate using personal css
['bdi'] = '<bdi$1>$2</bdi>', -- bidirectional isolation used with |script-title= and the like
['italic-title'] = "''$1''",
['kern-left'] = '<span style="padding-left:0.2em;">$1</span>$2', -- spacing to use when title contains leading single or double quote mark
['kern-right'] = '$1<span style="padding-right:0.2em;">$2</span>', -- spacing to use when title contains trailing single or double quote mark
['nowrap1'] = '<span class="nowrap">$1</span>', -- for nowrapping an item: <span ...>yyyy-mm-dd</span>
['nowrap2'] = '<span class="nowrap">$1</span> $2', -- for nowrapping portions of an item: <span ...>dd mmmm</span> yyyy (note white space)
['parameter'] = '<code style="'..code_style..'">|$1=</code>',
['quoted-text'] = '<q>$1</q>', -- for wrapping |quote= content
['quoted-title'] = '"$1"',
['trans-italic-title'] = "[''$1'']",
['trans-quoted-title'] = "[$1]",
}
--[[--------------------------< A L I A S E S >----------------------------------------------------------------
Aliases table for commonly passed parameters
]]
citation_config.aliases = {
['AccessDate'] = {'access-date', 'accessdate'},
['Agency'] = 'agency',
['AirDate'] = {'air-date', 'airdate'},
['ArchiveDate'] = {'archive-date', 'archivedate'},
['ArchiveURL'] = {'archive-url', 'archiveurl'},
['ASINTLD'] = {'ASIN-TLD', 'asin-tld'},
['At'] = 'at',
['Authors'] = {'authors', 'people', 'host'},
['AuthorFormat'] = {'author-format', 'authorformat'}, -- deprecated in favor of NameListFormat;
['AuthorSeparator'] = 'author-separator', -- deprecated
['AuthorNameSeparator'] = 'author-name-separator', -- deprecated
['BookTitle'] = {'book-title', 'booktitle'},
['Callsign'] = {'call-sign', 'callsign'}, -- cite interview
['Cartography'] = 'cartography',
['Chapter'] = {'chapter', 'contribution', 'entry', 'article', 'section'},
['ChapterFormat'] = 'chapter-format';
['ChapterLink'] = {'chapter-link', 'chapterlink'}, -- deprecated; remove after 1 January 2015?
['ChapterURL'] = {'chapter-url', 'chapterurl', 'contribution-url', 'contributionurl', 'section-url', 'sectionurl'},
['City'] = 'city', -- cite interview
['Coauthors'] = {'coauthors', 'coauthor'}, -- coauthor and coauthors are deprecated; remove after 1 January 2015?
['Conference'] = {'conference', 'event'},
['ConferenceURL'] = {'conference-url', 'conferenceurl', 'event-url', 'eventurl'},
['Date'] = 'date',
['Day'] = 'day', -- deprecated; remove after 1 January 2015?
['DeadURL'] = {'dead-url', 'deadurl'},
['Degree'] = 'degree',
['DisplayAuthors'] = {'display-authors', 'displayauthors'},
['DisplayEditors'] = {'display-editors', 'displayeditors'},
['Docket'] = 'docket',
['DoiBroken'] = {'doi-broken', 'doi-broken-date', 'doi-inactive-date', 'DoiBroken', 'doi_brokendate', 'doi_inactivedate'},
['Edition'] = 'edition',
['Editors'] = 'editors',
['EditorFormat'] = {'editor-format', 'editorformat'}, -- deprecated in favor of NameListFormat;
['EditorSeparator'] = 'editor-separator', -- deprecated
['EditorNameSeparator'] = 'editor-name-separator', -- deprecated
['Embargo'] = {'Embargo', 'embargo'},
['Encyclopedia'] = {'encyclopedia', 'encyclopaedia'}, -- this one only used by citation
['Format'] = 'format',
['ID'] = {'id', 'ID'},
['IgnoreISBN'] = {'ignore-isbn-error', 'ignoreisbnerror'},
['Inset'] = 'inset',
['Issue'] = {'issue', 'number'},
['Language'] = {'language', 'in'},
['LastAuthorAmp'] = {'last-author-amp', 'lastauthoramp'},
['LayDate'] = {'lay-date', 'laydate'},
['LaySource'] = {'lay-source', 'laysource'},
['LayURL'] = {'lay-url', 'lay-summary', 'layurl', 'laysummary'},
['MailingList'] = {'mailinglist', 'mailing-list'}, -- cite mailing list only
['MessageID'] = 'message-id',
['Minutes'] = 'minutes',
['Mode'] = 'mode',
['Month'] = 'month', -- deprecated; remove after 1 January 2015?
['NameListFormat'] = {'name-list-format', 'author-format', 'authorformat', 'editor-format', 'editorformat'},
['NameSeparator'] = 'name-separator', -- deprecated
['Network'] = 'network',
['NoPP'] = {'no-pp', 'nopp'},
['NoTracking'] = {'template-doc-demo', 'template doc demo', 'no-cat', 'nocat', 'no-tracking', 'notracking'},
['OrigYear'] = {'orig-year', 'origyear'},
['Others'] = {'others', 'interviewer', 'interviewers'},
['Page'] = {'p', 'page'},
['Pages'] = {'pp', 'pages'},
['Periodical'] = {'journal', 'newspaper', 'magazine', 'work', 'website', 'periodical', 'encyclopedia', 'encyclopaedia', 'dictionary'},
['Place'] = {'place', 'location'},
['PPrefix'] = {'p-prefix', 'PPrefix'},
['PPPrefix'] = {'pp-prefix', 'PPPrefix'},
['Program'] = 'program', -- cite interview
['PostScript'] = 'postscript',
['PublicationDate'] = {'publicationdate', 'publication-date'},
['PublicationPlace'] = {'publication-place', 'publicationplace'},
['PublisherName'] = {'publisher', 'distributor', 'institution', 'newsgroup'},
['Quote'] = {'quote', 'quotation'},
['Ref'] = {'ref', 'Ref'},
['RegistrationRequired'] = 'registration',
['Scale'] = 'scale',
['ScriptTitle'] = 'script-title',
['Section'] = 'section',
['Season'] = 'season',
['Separator'] = 'separator', -- deprecated in favor of Mode
['Series'] = {'series', 'version'},
['SeriesSeparator'] = 'series-separator',
['SeriesLink'] = {'series-link', 'serieslink'},
['SeriesNumber'] = {'series-number', 'series-no', 'seriesnumber', 'seriesno'},
['Station'] = 'station',
['SubscriptionRequired'] = 'subscription',
['Time'] = 'time',
['TimeCaption'] = {'time-caption', 'timecaption'},
['Title'] = 'title',
['TitleLink'] = {'title-link', 'episode-link', 'titlelink', 'episodelink'},
['TitleNote'] = 'department',
['TitleType'] = {'type', 'medium'},
['TransChapter'] = {'trans-chapter', 'trans_chapter'},
['Transcript'] = 'transcript',
['TranscriptURL'] = {'transcript-url', 'transcripturl'},
['TransTitle'] = {'trans-title', 'trans_title'},
['URL'] = {'url', 'URL'},
['Via'] = 'via',
['Volume'] = 'volume',
['Year'] = 'year',
['AuthorList-First'] = {"author#-first", "author-first#",
"first#", "given#"},
['AuthorList-Last'] = {"author#-last", "author-last#",
"last#", "surname#", "Author#", "author#", "authors#", "subject#"},
['AuthorList-Link'] = {"author#-link", "author-link#",
"author#link", "authorlink#", "subject-link#", "subject#link", "subject#-link", "subjectlink#"},
['AuthorList-Mask'] = {"author#-mask", "author-mask#",
"author#mask", "authormask#"},
['EditorList-First'] = {"editor#-first",
"editor-first#", "editor#-given", "editor-given#", "EditorGiven#"},
['EditorList-Last'] = {"editor#-last", "editor-last#",
"editor#-surname", "editor-surname#", "EditorSurname#", "Editor#", "editor#", "editors#"},
['EditorList-Link'] = {"editor#-link", "editor-link#",
"editor#link", "editorlink#"},
['EditorList-Mask'] = {"editor#-mask", "editor-mask#",
"editor#mask", "editormask#"},
}
-- Default parameter values
citation_config.defaults = {
['DeadURL'] = 'yes',
['PPrefix'] = "น. ",
['PPPrefix'] = "น. ",
}
--[[--------------------------< E R R O R _ C O N D I T I O N S >----------------------------------------------
Error condition table
The following contains a list of IDs for various error conditions defined in the
code. For each ID, we specify a text message to display, an error category to
include, and whether the error message should be wrapped as a hidden comment.
Anchor changes require identical changes to matching anchor in Help:CS1 errors
]]
citation_config.error_conditions = {
accessdate_missing_url = {
message = '<code style="'..code_style..'">|accessdate=</code> requires <code style="'..code_style..'">|url=</code>',
anchor = 'accessdate_missing_url',
category = 'หน้าที่มีอ้างอิงที่ขาด URL แต่กลับมีวันที่ในการเข้าถึง',
hidden = true },
archive_missing_date = {
message = '<code style="'..code_style..'">|archiveurl=</code> requires <code style="'..code_style..'">|archivedate=</code>',
anchor = 'archive_missing_date',
category = 'Pages with archiveurl citation errors',
hidden = false },
archive_missing_url = {
message = '<code style="'..code_style..'">|archiveurl=</code> requires <code style="'..code_style..'">|url=</code>',
anchor = 'archive_missing_url',
category = 'Pages with archiveurl citation errors',
hidden = false },
bad_arxiv = {
message = 'Check <code style="'..code_style..'">|arxiv=</code> value',
anchor = 'bad_arxiv',
category = 'CS1 errors: arXiv',
hidden = false },
bad_asin = {
message = 'Check <code style="'..code_style..'">|asin=</code> value',
anchor = 'bad_asin',
category ='CS1 errors: ASIN',
hidden = false },
bad_authorlink = {
message = 'Check <code style="'..code_style..'">|authorlink=</code> value',
anchor = 'bad_authorlink',
category = 'CS1 errors: authorlink',
hidden = false },
bad_date = {
message = 'Check date values in: <code style="'..code_style..'">$1</code>',
anchor = 'bad_date',
category = 'CS1 errors: dates',
hidden = false },
bad_doi = {
message = 'Check <code style="'..code_style..'">|doi=</code> value',
anchor = 'bad_doi',
category = 'หน้าที่มี DOI ผิดพลาด',
hidden = false },
bad_isbn = {
message = 'Check <code style="'..code_style..'">|isbn=</code> value',
anchor = 'bad_isbn',
category = 'หน้าที่มี ISBN ผิดพลาด',
hidden = false },
bad_issn = {
message = 'Check <code style="'..code_style..'">|issn=</code> value',
anchor = 'bad_issn',
category = 'CS1 errors: ISSN',
hidden = false },
bad_lccn = {
message = 'Check <code style="'..code_style..'">|lccn=</code> value',
anchor = 'bad_lccn',
category = 'CS1 errors: LCCN',
hidden = false },
bad_message_id = {
message = 'Check <code style="'..code_style..'">|message-id=</code> value',
anchor = 'bad_message_id',
category = 'CS1 errors: message-id',
hidden = false },
bad_ol = {
message = 'Check <code style="'..code_style..'">|ol=</code> value',
anchor = 'bad_ol',
category = 'หน้าที่มี OL ผิดพลาด',
hidden = false },
bad_pmc = {
message = 'Check <code style="'..code_style..'">|pmc=</code> value',
anchor = 'bad_pmc',
category = 'CS1 errors: PMC',
hidden = false },
bad_pmid = {
message = 'Check <code style="'..code_style..'">|pmid=</code> value',
anchor = 'bad_pmid',
category = 'CS1 errors: PMID',
hidden = false },
bad_url = {
message = 'Check <code style="'..code_style..'">|url=</code> scheme',
anchor = 'bad_url',
category = 'หน้าที่มี URL ผิดพลาด',
hidden = false },
bare_url_missing_title = {
message = '$1 missing title',
anchor = 'bare_url_missing_title',
category = 'Pages with citations having bare URLs',
hidden = false },
chapter_ignored = {
message = '<code style="'..code_style..'">|chapter=</code> ignored',
anchor = 'chapter_ignored',
category = 'CS1 errors: chapter ignored',
hidden = false },
citation_missing_title = {
message = 'Missing or empty <code style="'..code_style..'">|title=</code>',
anchor = 'citation_missing_title',
category = 'Pages with citations lacking titles',
hidden = false },
cite_web_url = { -- this error applies to cite web and to cite podcast
message = 'Missing or empty <code style="'..code_style..'">|url=</code>',
anchor = 'cite_web_url',
category = 'Pages using web citations with no URL',
hidden = true },
coauthors_missing_author = {
message = '<code style="'..code_style..'">|coauthors=</code> requires <code style="'..code_style..'">|author=</code>',
anchor = 'coauthors_missing_author',
category = 'CS1 errors: coauthors without author',
hidden = false },
deprecated_params = {
message = 'Cite uses deprecated parameter <code style="'..code_style..'">|$1=</code>',
anchor = 'deprecated_params',
category = 'น.ที่ใช้แม่แบบอ้างอิงที่มีพารามิเตอร์ล้าสมัย',
hidden = true },
empty_citation = {
message = 'Empty citation',
anchor = 'empty_citation',
category = 'หน้าที่มีอ้างอิงว่าง',
hidden = false },
extra_pages = {
message = 'Extra <code style="'..code_style..'">|pages=</code> or <code style="'..code_style..'">|at=</code>',
anchor = 'extra_pages',
category = 'Pages with citations using conflicting page specifications',
hidden = false },
first_missing_last = {
message = '<code style="'..code_style..'">|first$2=</code> missing <code style="'..code_style..'">|last$2=</code> in $1',
anchor = 'first_missing_last',
category = 'CS1 errors: missing author or editor',
hidden = false },
format_missing_url = {
message = '<code style="'..code_style..'">|$1=</code> requires <code style="'..code_style..'">|$2=</code>',
anchor = 'format_missing_url',
category = 'Pages using citations with format and no URL',
hidden = true },
implict_etal_editor = {
message = '<code style="'..code_style..'">|displayeditors=</code> suggested',
anchor = 'displayeditors',
category = 'Pages using citations with old-style implicit et al. in editors',
hidden = true },
invalid_param_val = {
message = 'Invalid <code style="'..code_style..'">|$1=$2</code>',
anchor = 'invalid_param_val',
category = 'CS1 errors: invalid mode',
hidden = false },
missing_name = {
message = 'Missing <code style="'..code_style..'">|last$2=</code> in $1',
anchor = 'missing_name',
category = 'CS1 errors: missing author or editor',
hidden = false },
parameter_ignored = {
message = 'Unknown parameter <code style="'..code_style..'">|$1=</code> ignored',
anchor = 'parameter_ignored',
category = 'หน้าที่มีอ้างอิงที่ใช้พารามิเตอร์ไม่สนับสนุน',
hidden = false },
parameter_ignored_suggest = {
message = 'Unknown parameter <code style="'..code_style..'">|$1=</code> ignored (<code style="'..code_style..'">|$2=</code> suggested)',
anchor = 'parameter_ignored_suggest',
category = 'หน้าที่มีอ้างอิงที่ใช้พารามิเตอร์ไม่สนับสนุน',
hidden = false },
redundant_parameters = {
message = 'More than one of $1 specified',
anchor = 'redundant_parameters',
category = 'หน้าที่มีอ้างอิงที่ใช้พารามิเตอร์ซ้ำซ้อน',
hidden = false },
text_ignored = {
message = 'Text "$1" ignored',
anchor = 'text_ignored',
category = 'หน้าที่มีอ้างอิงที่ใช้พารามิเตอร์ไม่มีชื่อ',
hidden = false },
trans_missing_chapter = {
message = '<code style="'..code_style..'">|trans-chapter=</code> requires <code style="'..code_style..'">|chapter=</code>',
anchor = 'trans_missing_chapter',
category = 'Pages with citations using translated terms without the original',
hidden = false },
trans_missing_title = {
message = '<code style="'..code_style..'">|trans-title=</code> requires <code style="'..code_style..'">|title=</code>',
anchor = 'trans_missing_title',
category = 'Pages with citations using translated terms without the original',
hidden = false },
wikilink_in_url = {
message = 'Wikilink embedded in URL title',
anchor = 'wikilink_in_url',
category = 'Pages with citations having wikilinks embedded in URL titles',
hidden = false },
}
citation_config.id_handlers = {
['ARXIV'] = {
parameters = {'arxiv', 'ARXIV'},
link = 'w:arXiv',
label = 'arXiv',
mode = 'manual',
prefix = '//arxiv.org/abs/', -- protocol relative tested 2013-09-04
encode = false,
COinS = 'info:arxiv',
separator = ':',
},
['ASIN'] = {
parameters = { 'asin', 'ASIN' },
link = 'w:Amazon Standard Identification Number',
label = 'ASIN',
mode = 'manual',
COinS = 'info:asin',
separator = ' ',
encode = false;
},
['BIBCODE'] = {
parameters = {'bibcode', 'BIBCODE'},
link = 'w:Bibcode',
label = 'Bibcode',
mode = 'external',
prefix = 'http://adsabs.harvard.edu/abs/',
encode = false,
COinS = 'info:bibcode',
separator = ':',
},
['DOI'] = {
parameters = { 'doi', 'DOI' },
link = 'w:Digital object identifier',
label = 'doi',
mode = 'manual',
prefix = '//dx.doi.org/',
COinS = 'info:doi',
separator = ':',
encode = true,
},
['ISBN'] = {
parameters = {'isbn', 'ISBN', 'isbn13', 'ISBN13'},
link = 'w:International Standard Book Number',
label = 'ISBN',
mode = 'manual',
prefix = 'Special:BookSources/',
COinS = 'rft.isbn',
separator = ' ',
},
['ISSN'] = {
parameters = {'issn', 'ISSN'},
link = 'w:International Standard Serial Number',
label = 'ISSN',
mode = 'manual',
prefix = '//www.worldcat.org/issn/',
COinS = 'rft.issn',
encode = false,
separator = ' ',
},
['JFM'] = {
parameters = {'jfm', 'JFM'},
link = 'w:Jahrbuch über die Fortschritte der Mathematik',
label = 'JFM',
mode = 'external',
prefix = '//zbmath.org/?format=complete&q=an:',
COinS = 'rft.jfm',
encode = true,
separator = ' ',
},
['JSTOR'] = {
parameters = {'jstor', 'JSTOR'},
link = 'w:JSTOR',
label = 'JSTOR',
mode = 'external',
prefix = '//www.jstor.org/stable/', -- protocol relative tested 2013-09-04
COinS = 'rft.jstor',
-- encode = true,
encode = false,
separator = ' ',
},
['LCCN'] = {
parameters = {'LCCN', 'lccn'},
link = 'w:Library of Congress Control Number',
label = 'LCCN',
mode = 'manual',
prefix = 'http://lccn.loc.gov/',
COinS = 'rft.lccn',
encode = false,
separator = ' ',
},
['MR'] = {
parameters = {'MR', 'mr'},
link = 'w:Mathematical Reviews',
label = 'MR',
mode = 'external',
prefix = '//www.ams.org/mathscinet-getitem?mr=', -- protocol relative tested 2013-09-04
COinS = 'rft.mr',
encode = true,
separator = ' ',
},
['OCLC'] = {
parameters = {'OCLC', 'oclc'},
link = 'w:OCLC',
label = 'OCLC',
mode = 'external',
prefix = '//www.worldcat.org/oclc/',
COinS = 'info:oclcnum',
encode = true,
separator = ' ',
},
['OL'] = {
parameters = { 'ol', 'OL' },
link = 'w:Open Library',
label = 'OL',
mode = 'manual',
COinS = 'info:olnum',
separator = ' ',
endode = true,
},
['OSTI'] = {
parameters = {'OSTI', 'osti'},
link = 'w:Office of Scientific and Technical Information',
label = 'OSTI',
mode = 'external',
prefix = '//www.osti.gov/energycitations/product.biblio.jsp?osti_id=', -- protocol relative tested 2013-09-04
COinS = 'info:osti',
encode = true,
separator = ' ',
},
['PMC'] = {
parameters = {'PMC', 'pmc'},
link = 'w:PubMed Central',
label = 'PMC',
mode = 'manual', -- changed to support unlinking of PMC identifier when article is embargoed
prefix = '//www.ncbi.nlm.nih.gov/pmc/articles/PMC',
suffix = " ",
COinS = 'info:pmc',
encode = true,
separator = ' ',
},
['PMID'] = {
parameters = {'PMID', 'pmid'},
link = 'w:PubMed Identifier',
label = 'PMID',
mode = 'manual', -- changed from external manual to support PMID validation
prefix = '//www.ncbi.nlm.nih.gov/pubmed/',
COinS = 'info:pmid',
encode = false,
separator = ' ',
},
['RFC'] = {
parameters = {'RFC', 'rfc'},
link = 'w:Request for Comments',
label = 'RFC',
mode = 'external',
prefix = '//tools.ietf.org/html/rfc',
COinS = 'info:rfc',
encode = false,
separator = ' ',
},
['SSRN'] = {
parameters = {'SSRN', 'ssrn'},
link = 'w:Social Science Research Network',
label = 'SSRN',
mode = 'external',
prefix = '//ssrn.com/abstract=', -- protocol relative tested 2013-09-04
COinS = 'info:ssrn',
encode = true,
separator = ' ',
},
['USENETID'] = {
parameters = {'message-id'},
link = 'w:Usenet',
label = 'Usenet:',
mode = 'manual',
prefix = 'news:',
encode = false,
COinS = 'info:usenet',
separator = ' ',
},
['ZBL'] = {
parameters = {'ZBL', 'zbl'},
link = 'w:Zentralblatt MATH',
label = 'Zbl',
mode = 'external',
prefix = '//zbmath.org/?format=complete&q=an:',
COinS = 'info:zbl',
encode = true,
separator = ' ',
},
}
return citation_config;
pki44pter8w0r9hpzbctthve47f63p3
189488
189487
2022-08-16T16:53:16Z
Venise12mai1834
8884
Scribunto
text/plain
citation_config = {};
-- override <code>...</code> styling to remove color, border, and padding. <code> css is specified here:
-- https://git.wikimedia.org/blob/mediawiki%2Fcore.git/69cd73811f7aadd093050dbf20ed70ef0b42a713/skins%2Fcommon%2FcommonElements.css#L199
local code_style="color:inherit; border:inherit; padding:inherit;";
--[[--------------------------< U N C A T E G O R I Z E D _ N A M E S P A C E S >------------------------------
List of namespaces that should not be included in citation error categories. Same as setting notracking = true by default
Note: Namespace names should use underscores instead of spaces.
]]
citation_config.uncategorized_namespaces = { 'User', 'Talk', 'User_talk', 'Wikisource_talk', 'File_talk', 'Template_talk',
'Help_talk', 'Category_talk', 'Portal_talk', 'Author_talk', 'Page_talk', 'Index_talk', 'Translation_talk',
'Module_talk', 'MediaWiki_talk' };
--[[--------------------------< M E S S A G E S >--------------------------------------------------------------
Translation table
The following contains fixed text that may be output as part of a citation.
This is separated from the main body to aid in future translations of this
module.
]]
citation_config.messages = {
['published'] = 'published $1',
['lay summary'] = 'Lay summary',
['retrieved'] = 'สืบค้นเมื่อ $1',
['inactive'] = 'inactive',
['archived-dead'] = 'Archived from $1 on $2',
['archived-not-dead'] = '$1 from the original on $2',
['archived-missing'] = 'Archived from the original$1 on $2',
['archived'] = 'Archived',
['original'] = 'the original',
['editor'] = 'บรรณาธิการ',
['editors'] = 'บรรณาธิการ',
['edition'] = '(พิมพ์ครั้งที่ $1)',
['episode'] = 'episode',
['season'] = 'season',
['series'] = 'series',
['cartography'] = 'Cartography by $1',
['section'] = 'Section $1',
['inset'] = '$1 inset',
['written'] = 'Written at $1',
['in'] = 'In',
['et al'] = 'และคนอื่น ๆ',
['subscription'] = '<span style="font-size:0.95em; font-size:90%; color:#555">(subscription required (<span title="Sources are not required to be available online. Online sources do not have to be freely available. The site may require a paid subscription." style="border-bottom:1px dotted;cursor:help">help</span>))</span>' ..
'[[Category:Pages containing links to subscription-only content]]',
['registration']='<span style="font-size:0.95em; font-size:90%; color:#555">(registration required (<span title="Sources are not required to be available online. Online sources do not have to be freely available. The site may require registration." style="border-bottom:1px dotted;cursor:help">help</span>))</span>' ..
'[[Category:Pages with login required references or sources]]',
['language'] = '(ภาษา$1)',
['via'] = " – โดยทาง $1",
['event'] = 'Event occurs at',
['minutes'] = 'minutes in',
['parameter-separator'] = ', ',
['parameter-final-separator'] = ', และ ',
['parameter-pair-separator'] = ' และ ',
-- Determines the location of the help page
['help page link'] = 'w:Help:CS1 errors',
['help page label'] = 'help',
-- Internal errors (should only occur if configuration is bad)
['undefined_error'] = 'Called with an undefined error condition',
['unknown_manual_ID'] = 'Unrecognized manual ID mode',
['unknown_ID_mode'] = 'Unrecognized ID mode',
['unknown_argument_map'] = 'Argument map not defined for this variable',
['bare_url_no_origin'] = 'Bare url found but origin indicator is nil or empty',
}
--[[--------------------------< P R E S E N T A T I O N >------------------------------------------------------
Fixed presentation markup. Originally part of citation_config.messages it has been moved into its own, more semantically
correct place.
]]
citation_config.presentation =
{
-- Error output
-- .error class is specified at https://git.wikimedia.org/blob/mediawiki%2Fcore.git/9553bd02a5595da05c184f7521721fb1b79b3935/skins%2Fcommon%2Fshared.css#L538
-- .citation-comment class is specified at Help:CS1_errors#Controlling_error_message_display
['hidden-error'] = '<span style="display:none;font-size:100%" class="error citation-comment">$1</span>',
['visible-error'] = '<span style="font-size:100%" class="error citation-comment">$1</span>',
['accessdate'] = '<span class="reference-accessdate">$1$2</span>', -- to allow editors to hide accessdate using personal css
['bdi'] = '<bdi$1>$2</bdi>', -- bidirectional isolation used with |script-title= and the like
['italic-title'] = "''$1''",
['kern-left'] = '<span style="padding-left:0.2em;">$1</span>$2', -- spacing to use when title contains leading single or double quote mark
['kern-right'] = '$1<span style="padding-right:0.2em;">$2</span>', -- spacing to use when title contains trailing single or double quote mark
['nowrap1'] = '<span class="nowrap">$1</span>', -- for nowrapping an item: <span ...>yyyy-mm-dd</span>
['nowrap2'] = '<span class="nowrap">$1</span> $2', -- for nowrapping portions of an item: <span ...>dd mmmm</span> yyyy (note white space)
['parameter'] = '<code style="'..code_style..'">|$1=</code>',
['quoted-text'] = '<q>$1</q>', -- for wrapping |quote= content
['quoted-title'] = '"$1"',
['trans-italic-title'] = "[''$1'']",
['trans-quoted-title'] = "[$1]",
}
--[[--------------------------< A L I A S E S >----------------------------------------------------------------
Aliases table for commonly passed parameters
]]
citation_config.aliases = {
['AccessDate'] = {'access-date', 'accessdate'},
['Agency'] = 'agency',
['AirDate'] = {'air-date', 'airdate'},
['ArchiveDate'] = {'archive-date', 'archivedate'},
['ArchiveURL'] = {'archive-url', 'archiveurl'},
['ASINTLD'] = {'ASIN-TLD', 'asin-tld'},
['At'] = 'at',
['Authors'] = {'authors', 'people', 'host'},
['AuthorFormat'] = {'author-format', 'authorformat'}, -- deprecated in favor of NameListFormat;
['AuthorSeparator'] = 'author-separator', -- deprecated
['AuthorNameSeparator'] = 'author-name-separator', -- deprecated
['BookTitle'] = {'book-title', 'booktitle'},
['Callsign'] = {'call-sign', 'callsign'}, -- cite interview
['Cartography'] = 'cartography',
['Chapter'] = {'chapter', 'contribution', 'entry', 'article', 'section'},
['ChapterFormat'] = 'chapter-format';
['ChapterLink'] = {'chapter-link', 'chapterlink'}, -- deprecated; remove after 1 January 2015?
['ChapterURL'] = {'chapter-url', 'chapterurl', 'contribution-url', 'contributionurl', 'section-url', 'sectionurl'},
['City'] = 'city', -- cite interview
['Coauthors'] = {'coauthors', 'coauthor'}, -- coauthor and coauthors are deprecated; remove after 1 January 2015?
['Conference'] = {'conference', 'event'},
['ConferenceURL'] = {'conference-url', 'conferenceurl', 'event-url', 'eventurl'},
['Date'] = 'date',
['Day'] = 'day', -- deprecated; remove after 1 January 2015?
['DeadURL'] = {'dead-url', 'deadurl'},
['Degree'] = 'degree',
['DisplayAuthors'] = {'display-authors', 'displayauthors'},
['DisplayEditors'] = {'display-editors', 'displayeditors'},
['Docket'] = 'docket',
['DoiBroken'] = {'doi-broken', 'doi-broken-date', 'doi-inactive-date', 'DoiBroken', 'doi_brokendate', 'doi_inactivedate'},
['Edition'] = 'edition',
['Editors'] = 'editors',
['EditorFormat'] = {'editor-format', 'editorformat'}, -- deprecated in favor of NameListFormat;
['EditorSeparator'] = 'editor-separator', -- deprecated
['EditorNameSeparator'] = 'editor-name-separator', -- deprecated
['Embargo'] = {'Embargo', 'embargo'},
['Encyclopedia'] = {'encyclopedia', 'encyclopaedia'}, -- this one only used by citation
['Format'] = 'format',
['ID'] = {'id', 'ID'},
['IgnoreISBN'] = {'ignore-isbn-error', 'ignoreisbnerror'},
['Inset'] = 'inset',
['Issue'] = {'issue', 'number'},
['Language'] = {'language', 'in'},
['LastAuthorAmp'] = {'last-author-amp', 'lastauthoramp'},
['LayDate'] = {'lay-date', 'laydate'},
['LaySource'] = {'lay-source', 'laysource'},
['LayURL'] = {'lay-url', 'lay-summary', 'layurl', 'laysummary'},
['MailingList'] = {'mailinglist', 'mailing-list'}, -- cite mailing list only
['MessageID'] = 'message-id',
['Minutes'] = 'minutes',
['Mode'] = 'mode',
['Month'] = 'month', -- deprecated; remove after 1 January 2015?
['NameListFormat'] = {'name-list-format', 'author-format', 'authorformat', 'editor-format', 'editorformat'},
['NameSeparator'] = 'name-separator', -- deprecated
['Network'] = 'network',
['NoPP'] = {'no-pp', 'nopp'},
['NoTracking'] = {'template-doc-demo', 'template doc demo', 'no-cat', 'nocat', 'no-tracking', 'notracking'},
['OrigYear'] = {'orig-year', 'origyear'},
['Others'] = {'others', 'interviewer', 'interviewers'},
['Page'] = {'p', 'page'},
['Pages'] = {'pp', 'pages'},
['Periodical'] = {'journal', 'newspaper', 'magazine', 'work', 'website', 'periodical', 'encyclopedia', 'encyclopaedia', 'dictionary'},
['Place'] = {'place', 'location'},
['PPrefix'] = {'p-prefix', 'PPrefix'},
['PPPrefix'] = {'pp-prefix', 'PPPrefix'},
['Program'] = 'program', -- cite interview
['PostScript'] = 'postscript',
['PublicationDate'] = {'publicationdate', 'publication-date'},
['PublicationPlace'] = {'publication-place', 'publicationplace'},
['PublisherName'] = {'publisher', 'distributor', 'institution', 'newsgroup'},
['Quote'] = {'quote', 'quotation'},
['Ref'] = {'ref', 'Ref'},
['RegistrationRequired'] = 'registration',
['Scale'] = 'scale',
['ScriptTitle'] = 'script-title',
['Section'] = 'section',
['Season'] = 'season',
['Separator'] = 'separator', -- deprecated in favor of Mode
['Series'] = {'series', 'version'},
['SeriesSeparator'] = 'series-separator',
['SeriesLink'] = {'series-link', 'serieslink'},
['SeriesNumber'] = {'series-number', 'series-no', 'seriesnumber', 'seriesno'},
['Station'] = 'station',
['SubscriptionRequired'] = 'subscription',
['Time'] = 'time',
['TimeCaption'] = {'time-caption', 'timecaption'},
['Title'] = 'title',
['TitleLink'] = {'title-link', 'episode-link', 'titlelink', 'episodelink'},
['TitleNote'] = 'department',
['TitleType'] = {'type', 'medium'},
['TransChapter'] = {'trans-chapter', 'trans_chapter'},
['Transcript'] = 'transcript',
['TranscriptURL'] = {'transcript-url', 'transcripturl'},
['TransTitle'] = {'trans-title', 'trans_title'},
['URL'] = {'url', 'URL'},
['Via'] = 'via',
['Volume'] = 'volume',
['Year'] = 'year',
['AuthorList-First'] = {"author#-first", "author-first#",
"first#", "given#"},
['AuthorList-Last'] = {"author#-last", "author-last#",
"last#", "surname#", "Author#", "author#", "authors#", "subject#"},
['AuthorList-Link'] = {"author#-link", "author-link#",
"author#link", "authorlink#", "subject-link#", "subject#link", "subject#-link", "subjectlink#"},
['AuthorList-Mask'] = {"author#-mask", "author-mask#",
"author#mask", "authormask#"},
['EditorList-First'] = {"editor#-first",
"editor-first#", "editor#-given", "editor-given#", "EditorGiven#"},
['EditorList-Last'] = {"editor#-last", "editor-last#",
"editor#-surname", "editor-surname#", "EditorSurname#", "Editor#", "editor#", "editors#"},
['EditorList-Link'] = {"editor#-link", "editor-link#",
"editor#link", "editorlink#"},
['EditorList-Mask'] = {"editor#-mask", "editor-mask#",
"editor#mask", "editormask#"},
}
-- Default parameter values
citation_config.defaults = {
['DeadURL'] = 'yes',
['PPrefix'] = "น. ",
['PPPrefix'] = "น. ",
}
--[[--------------------------< E R R O R _ C O N D I T I O N S >----------------------------------------------
Error condition table
The following contains a list of IDs for various error conditions defined in the
code. For each ID, we specify a text message to display, an error category to
include, and whether the error message should be wrapped as a hidden comment.
Anchor changes require identical changes to matching anchor in Help:CS1 errors
]]
citation_config.error_conditions = {
accessdate_missing_url = {
message = '<code style="'..code_style..'">|accessdate=</code> requires <code style="'..code_style..'">|url=</code>',
anchor = 'accessdate_missing_url',
category = 'หน้าที่มีอ้างอิงที่ขาด URL แต่กลับมีวันที่ในการเข้าถึง',
hidden = true },
archive_missing_date = {
message = '<code style="'..code_style..'">|archiveurl=</code> requires <code style="'..code_style..'">|archivedate=</code>',
anchor = 'archive_missing_date',
category = 'Pages with archiveurl citation errors',
hidden = false },
archive_missing_url = {
message = '<code style="'..code_style..'">|archiveurl=</code> requires <code style="'..code_style..'">|url=</code>',
anchor = 'archive_missing_url',
category = 'Pages with archiveurl citation errors',
hidden = false },
bad_arxiv = {
message = 'Check <code style="'..code_style..'">|arxiv=</code> value',
anchor = 'bad_arxiv',
category = 'CS1 errors: arXiv',
hidden = false },
bad_asin = {
message = 'Check <code style="'..code_style..'">|asin=</code> value',
anchor = 'bad_asin',
category ='CS1 errors: ASIN',
hidden = false },
bad_authorlink = {
message = 'Check <code style="'..code_style..'">|authorlink=</code> value',
anchor = 'bad_authorlink',
category = 'CS1 errors: authorlink',
hidden = false },
bad_date = {
message = 'Check date values in: <code style="'..code_style..'">$1</code>',
anchor = 'bad_date',
category = 'CS1 errors: dates',
hidden = false },
bad_doi = {
message = 'Check <code style="'..code_style..'">|doi=</code> value',
anchor = 'bad_doi',
category = 'หน้าที่มี DOI ผิดพลาด',
hidden = false },
bad_isbn = {
message = 'Check <code style="'..code_style..'">|isbn=</code> value',
anchor = 'bad_isbn',
category = 'หน้าที่มี ISBN ผิดพลาด',
hidden = false },
bad_issn = {
message = 'Check <code style="'..code_style..'">|issn=</code> value',
anchor = 'bad_issn',
category = 'CS1 errors: ISSN',
hidden = false },
bad_lccn = {
message = 'Check <code style="'..code_style..'">|lccn=</code> value',
anchor = 'bad_lccn',
category = 'CS1 errors: LCCN',
hidden = false },
bad_message_id = {
message = 'Check <code style="'..code_style..'">|message-id=</code> value',
anchor = 'bad_message_id',
category = 'CS1 errors: message-id',
hidden = false },
bad_ol = {
message = 'Check <code style="'..code_style..'">|ol=</code> value',
anchor = 'bad_ol',
category = 'หน้าที่มี OL ผิดพลาด',
hidden = false },
bad_pmc = {
message = 'Check <code style="'..code_style..'">|pmc=</code> value',
anchor = 'bad_pmc',
category = 'CS1 errors: PMC',
hidden = false },
bad_pmid = {
message = 'Check <code style="'..code_style..'">|pmid=</code> value',
anchor = 'bad_pmid',
category = 'CS1 errors: PMID',
hidden = false },
bad_url = {
message = 'Check <code style="'..code_style..'">|url=</code> scheme',
anchor = 'bad_url',
category = 'หน้าที่มี URL ผิดพลาด',
hidden = false },
bare_url_missing_title = {
message = '$1 missing title',
anchor = 'bare_url_missing_title',
category = 'Pages with citations having bare URLs',
hidden = false },
chapter_ignored = {
message = '<code style="'..code_style..'">|chapter=</code> ignored',
anchor = 'chapter_ignored',
category = 'CS1 errors: chapter ignored',
hidden = false },
citation_missing_title = {
message = 'Missing or empty <code style="'..code_style..'">|title=</code>',
anchor = 'citation_missing_title',
category = 'Pages with citations lacking titles',
hidden = false },
cite_web_url = { -- this error applies to cite web and to cite podcast
message = 'Missing or empty <code style="'..code_style..'">|url=</code>',
anchor = 'cite_web_url',
category = 'Pages using web citations with no URL',
hidden = true },
coauthors_missing_author = {
message = '<code style="'..code_style..'">|coauthors=</code> requires <code style="'..code_style..'">|author=</code>',
anchor = 'coauthors_missing_author',
category = 'CS1 errors: coauthors without author',
hidden = false },
deprecated_params = {
message = 'Cite uses deprecated parameter <code style="'..code_style..'">|$1=</code>',
anchor = 'deprecated_params',
category = 'หน้าที่ใช้แม่แบบอ้างอิงที่มีพารามิเตอร์ล้าสมัย',
hidden = true },
empty_citation = {
message = 'Empty citation',
anchor = 'empty_citation',
category = 'หน้าที่มีอ้างอิงว่าง',
hidden = false },
extra_pages = {
message = 'Extra <code style="'..code_style..'">|pages=</code> or <code style="'..code_style..'">|at=</code>',
anchor = 'extra_pages',
category = 'Pages with citations using conflicting page specifications',
hidden = false },
first_missing_last = {
message = '<code style="'..code_style..'">|first$2=</code> missing <code style="'..code_style..'">|last$2=</code> in $1',
anchor = 'first_missing_last',
category = 'CS1 errors: missing author or editor',
hidden = false },
format_missing_url = {
message = '<code style="'..code_style..'">|$1=</code> requires <code style="'..code_style..'">|$2=</code>',
anchor = 'format_missing_url',
category = 'Pages using citations with format and no URL',
hidden = true },
implict_etal_editor = {
message = '<code style="'..code_style..'">|displayeditors=</code> suggested',
anchor = 'displayeditors',
category = 'Pages using citations with old-style implicit et al. in editors',
hidden = true },
invalid_param_val = {
message = 'Invalid <code style="'..code_style..'">|$1=$2</code>',
anchor = 'invalid_param_val',
category = 'CS1 errors: invalid mode',
hidden = false },
missing_name = {
message = 'Missing <code style="'..code_style..'">|last$2=</code> in $1',
anchor = 'missing_name',
category = 'CS1 errors: missing author or editor',
hidden = false },
parameter_ignored = {
message = 'Unknown parameter <code style="'..code_style..'">|$1=</code> ignored',
anchor = 'parameter_ignored',
category = 'หน้าที่มีอ้างอิงที่ใช้พารามิเตอร์ไม่สนับสนุน',
hidden = false },
parameter_ignored_suggest = {
message = 'Unknown parameter <code style="'..code_style..'">|$1=</code> ignored (<code style="'..code_style..'">|$2=</code> suggested)',
anchor = 'parameter_ignored_suggest',
category = 'หน้าที่มีอ้างอิงที่ใช้พารามิเตอร์ไม่สนับสนุน',
hidden = false },
redundant_parameters = {
message = 'More than one of $1 specified',
anchor = 'redundant_parameters',
category = 'หน้าที่มีอ้างอิงที่ใช้พารามิเตอร์ซ้ำซ้อน',
hidden = false },
text_ignored = {
message = 'Text "$1" ignored',
anchor = 'text_ignored',
category = 'หน้าที่มีอ้างอิงที่ใช้พารามิเตอร์ไม่มีชื่อ',
hidden = false },
trans_missing_chapter = {
message = '<code style="'..code_style..'">|trans-chapter=</code> requires <code style="'..code_style..'">|chapter=</code>',
anchor = 'trans_missing_chapter',
category = 'Pages with citations using translated terms without the original',
hidden = false },
trans_missing_title = {
message = '<code style="'..code_style..'">|trans-title=</code> requires <code style="'..code_style..'">|title=</code>',
anchor = 'trans_missing_title',
category = 'Pages with citations using translated terms without the original',
hidden = false },
wikilink_in_url = {
message = 'Wikilink embedded in URL title',
anchor = 'wikilink_in_url',
category = 'Pages with citations having wikilinks embedded in URL titles',
hidden = false },
}
citation_config.id_handlers = {
['ARXIV'] = {
parameters = {'arxiv', 'ARXIV'},
link = 'w:arXiv',
label = 'arXiv',
mode = 'manual',
prefix = '//arxiv.org/abs/', -- protocol relative tested 2013-09-04
encode = false,
COinS = 'info:arxiv',
separator = ':',
},
['ASIN'] = {
parameters = { 'asin', 'ASIN' },
link = 'w:Amazon Standard Identification Number',
label = 'ASIN',
mode = 'manual',
COinS = 'info:asin',
separator = ' ',
encode = false;
},
['BIBCODE'] = {
parameters = {'bibcode', 'BIBCODE'},
link = 'w:Bibcode',
label = 'Bibcode',
mode = 'external',
prefix = 'http://adsabs.harvard.edu/abs/',
encode = false,
COinS = 'info:bibcode',
separator = ':',
},
['DOI'] = {
parameters = { 'doi', 'DOI' },
link = 'w:Digital object identifier',
label = 'doi',
mode = 'manual',
prefix = '//dx.doi.org/',
COinS = 'info:doi',
separator = ':',
encode = true,
},
['ISBN'] = {
parameters = {'isbn', 'ISBN', 'isbn13', 'ISBN13'},
link = 'w:International Standard Book Number',
label = 'ISBN',
mode = 'manual',
prefix = 'Special:BookSources/',
COinS = 'rft.isbn',
separator = ' ',
},
['ISSN'] = {
parameters = {'issn', 'ISSN'},
link = 'w:International Standard Serial Number',
label = 'ISSN',
mode = 'manual',
prefix = '//www.worldcat.org/issn/',
COinS = 'rft.issn',
encode = false,
separator = ' ',
},
['JFM'] = {
parameters = {'jfm', 'JFM'},
link = 'w:Jahrbuch über die Fortschritte der Mathematik',
label = 'JFM',
mode = 'external',
prefix = '//zbmath.org/?format=complete&q=an:',
COinS = 'rft.jfm',
encode = true,
separator = ' ',
},
['JSTOR'] = {
parameters = {'jstor', 'JSTOR'},
link = 'w:JSTOR',
label = 'JSTOR',
mode = 'external',
prefix = '//www.jstor.org/stable/', -- protocol relative tested 2013-09-04
COinS = 'rft.jstor',
-- encode = true,
encode = false,
separator = ' ',
},
['LCCN'] = {
parameters = {'LCCN', 'lccn'},
link = 'w:Library of Congress Control Number',
label = 'LCCN',
mode = 'manual',
prefix = 'http://lccn.loc.gov/',
COinS = 'rft.lccn',
encode = false,
separator = ' ',
},
['MR'] = {
parameters = {'MR', 'mr'},
link = 'w:Mathematical Reviews',
label = 'MR',
mode = 'external',
prefix = '//www.ams.org/mathscinet-getitem?mr=', -- protocol relative tested 2013-09-04
COinS = 'rft.mr',
encode = true,
separator = ' ',
},
['OCLC'] = {
parameters = {'OCLC', 'oclc'},
link = 'w:OCLC',
label = 'OCLC',
mode = 'external',
prefix = '//www.worldcat.org/oclc/',
COinS = 'info:oclcnum',
encode = true,
separator = ' ',
},
['OL'] = {
parameters = { 'ol', 'OL' },
link = 'w:Open Library',
label = 'OL',
mode = 'manual',
COinS = 'info:olnum',
separator = ' ',
endode = true,
},
['OSTI'] = {
parameters = {'OSTI', 'osti'},
link = 'w:Office of Scientific and Technical Information',
label = 'OSTI',
mode = 'external',
prefix = '//www.osti.gov/energycitations/product.biblio.jsp?osti_id=', -- protocol relative tested 2013-09-04
COinS = 'info:osti',
encode = true,
separator = ' ',
},
['PMC'] = {
parameters = {'PMC', 'pmc'},
link = 'w:PubMed Central',
label = 'PMC',
mode = 'manual', -- changed to support unlinking of PMC identifier when article is embargoed
prefix = '//www.ncbi.nlm.nih.gov/pmc/articles/PMC',
suffix = " ",
COinS = 'info:pmc',
encode = true,
separator = ' ',
},
['PMID'] = {
parameters = {'PMID', 'pmid'},
link = 'w:PubMed Identifier',
label = 'PMID',
mode = 'manual', -- changed from external manual to support PMID validation
prefix = '//www.ncbi.nlm.nih.gov/pubmed/',
COinS = 'info:pmid',
encode = false,
separator = ' ',
},
['RFC'] = {
parameters = {'RFC', 'rfc'},
link = 'w:Request for Comments',
label = 'RFC',
mode = 'external',
prefix = '//tools.ietf.org/html/rfc',
COinS = 'info:rfc',
encode = false,
separator = ' ',
},
['SSRN'] = {
parameters = {'SSRN', 'ssrn'},
link = 'w:Social Science Research Network',
label = 'SSRN',
mode = 'external',
prefix = '//ssrn.com/abstract=', -- protocol relative tested 2013-09-04
COinS = 'info:ssrn',
encode = true,
separator = ' ',
},
['USENETID'] = {
parameters = {'message-id'},
link = 'w:Usenet',
label = 'Usenet:',
mode = 'manual',
prefix = 'news:',
encode = false,
COinS = 'info:usenet',
separator = ' ',
},
['ZBL'] = {
parameters = {'ZBL', 'zbl'},
link = 'w:Zentralblatt MATH',
label = 'Zbl',
mode = 'external',
prefix = '//zbmath.org/?format=complete&q=an:',
COinS = 'info:zbl',
encode = true,
separator = ' ',
},
}
return citation_config;
01137bysjlcrie0koq8820i8zyts5z9
มอดูล:Citation/CS1/Date validation
828
33555
189403
89011
2022-08-16T14:00:29Z
Venise12mai1834
8884
อัปเดต
Scribunto
text/plain
--[[--------------------------< F O R W A R D D E C L A R A T I O N S >--------------------------------------
]]
local add_prop_cat, is_set, in_array, set_message, substitute, wrap_style; -- imported functions from selected Module:Citation/CS1/Utilities
local cfg; -- table of tables imported from selected Module:Citation/CS1/Configuration
--[[--------------------------< F I L E - S C O P E D E C L A R A T I O N S >--------------------------------
File-scope variables are declared here
]]
local lang_object = mw.getContentLanguage(); -- used by is_valid_accessdate(), is_valid_year(), date_name_xlate(); TODO: move to ~/Configuration?
local year_limit; -- used by is_valid_year()
--[=[-------------------------< I S _ V A L I D _ A C C E S S D A T E >----------------------------------------
returns true if:
Wikipedia start date <= accessdate < today + 2 days
Wikipedia start date is 2001-01-15T00:00:00 UTC which is 979516800 seconds after 1970-01-01T00:00:00 UTC (the start of Unix time)
accessdate is the date provided in |access-date= at time 00:00:00 UTC
today is the current date at time 00:00:00 UTC plus 48 hours
if today is 2015-01-01T00:00:00 then
adding 24 hours gives 2015-01-02T00:00:00 – one second more than today
adding 24 hours gives 2015-01-03T00:00:00 – one second more than tomorrow
This function does not work if it is fed month names for languages other than English. Wikimedia #time: parser
apparently doesn't understand non-English date month names. This function will always return false when the date
contains a non-English month name because good1 is false after the call to lang.formatDate(). To get around that
call this function with YYYY-MM-DD format dates.
]=]
local function is_valid_accessdate (accessdate)
local good1, good2;
local access_ts, tomorrow_ts; -- to hold Unix time stamps representing the dates
good1, access_ts = pcall (lang_object.formatDate, lang_object, 'U', accessdate ); -- convert accessdate value to Unix timestamp
good2, tomorrow_ts = pcall (lang_object.formatDate, lang_object, 'U', 'today + 2 days' ); -- today midnight + 2 days is one second more than all day tomorrow
if good1 and good2 then -- lang.formatDate() returns a timestamp in the local script which which tonumber() may not understand
access_ts = tonumber (access_ts) or lang_object:parseFormattedNumber (access_ts); -- convert to numbers for the comparison;
tomorrow_ts = tonumber (tomorrow_ts) or lang_object:parseFormattedNumber (tomorrow_ts);
else
return false; -- one or both failed to convert to Unix time stamp
end
if 979516800 <= access_ts and access_ts < tomorrow_ts then -- Wikipedia start date <= accessdate < tomorrow's date
return true;
else
return false; -- accessdate out of range
end
end
--[[--------------------------< G E T _ M O N T H _ N U M B E R >----------------------------------------------
returns a number according to the month in a date: 1 for January, etc. Capitalization and spelling must be correct.
If not a valid month, returns 0
]]
local function get_month_number (month)
return cfg.date_names['local'].long[month] or cfg.date_names['local'].short[month] or -- look for local names first
cfg.date_names['en'].long[month] or cfg.date_names['en'].short[month] or -- failing that, look for English names
0; -- not a recognized month name
end
--[[--------------------------< G E T _ S E A S O N _ N U M B E R >--------------------------------------------
returns a number according to the sequence of seasons in a year: 21 for Spring, etc. Capitalization and spelling
must be correct. If not a valid season, returns 0.
21-24 = Spring, Summer, Autumn, Winter, independent of “Hemisphere”
returns 0 when <param> is not |date=
Season numbering is defined by Extended Date/Time Format (EDTF) specification (https://www.loc.gov/standards/datetime/)
which became part of ISO 8601 in 2019. See '§Sub-year groupings'. The standard defines various divisions using
numbers 21-41. cs1|2 only supports generic seasons. EDTF does support the distinction between north and south
hemisphere seasons but cs1|2 has no way to make that distinction.
These additional divisions not currently supported:
25-28 = Spring - Northern Hemisphere, Summer- Northern Hemisphere, Autumn - Northern Hemisphere, Winter - Northern Hemisphere
29-32 = Spring – Southern Hemisphere, Summer– Southern Hemisphere, Autumn – Southern Hemisphere, Winter - Southern Hemisphere
33-36 = Quarter 1, Quarter 2, Quarter 3, Quarter 4 (3 months each)
37-39 = Quadrimester 1, Quadrimester 2, Quadrimester 3 (4 months each)
40-41 = Semestral 1, Semestral-2 (6 months each)
]]
local function get_season_number (season, param)
if 'date' ~= param then
return 0; -- season dates only supported by |date=
end
return cfg.date_names['local'].season[season] or -- look for local names first
cfg.date_names['en'].season[season] or -- failing that, look for English names
0; -- not a recognized season name
end
--[[--------------------------< G E T _ Q U A R T E R _ N U M B E R >------------------------------------------
returns a number according to the sequence of quarters in a year: 33 for first quarter, etc. Capitalization and spelling
must be correct. If not a valid quarter, returns 0.
33-36 = Quarter 1, Quarter 2, Quarter 3, Quarter 4 (3 months each)
returns 0 when <param> is not |date=
Quarter numbering is defined by Extended Date/Time Format (EDTF) specification (https://www.loc.gov/standards/datetime/)
which became part of ISO 8601 in 2019. See '§Sub-year groupings'. The standard defines various divisions using
numbers 21-41. cs1|2 only supports generic seasons and quarters.
These additional divisions not currently supported:
37-39 = Quadrimester 1, Quadrimester 2, Quadrimester 3 (4 months each)
40-41 = Semestral 1, Semestral-2 (6 months each)
]]
local function get_quarter_number (quarter, param)
if 'date' ~= param then
return 0; -- quarter dates only supported by |date=
end
quarter = mw.ustring.gsub (quarter, ' +', ' '); -- special case replace multiple space chars with a single space char
return cfg.date_names['local'].quarter[quarter] or -- look for local names first
cfg.date_names['en'].quarter[quarter] or -- failing that, look for English names
0; -- not a recognized quarter name
end
--[[--------------------------< G E T _ P R O P E R _ N A M E _ N U M B E R >----------------------------------
returns a non-zero number if date contains a recognized proper-name. Capitalization and spelling must be correct.
returns 0 when <param> is not |date=
]]
local function get_proper_name_number (name, param)
if 'date' ~= param then
return 0; -- proper-name dates only supported by |date=
end
return cfg.date_names['local'].named[name] or -- look for local names dates first
cfg.date_names['en'].named[name] or -- failing that, look for English names
0; -- not a recognized named date
end
--[[--------------------------< G E T _ E L E M E N T _ N U M B E R <------------------------------------------
returns true if month or season or quarter or proper name is valid (properly spelled, capitalized, abbreviated)
]]
local function get_element_number (element, param)
local num;
local funcs = {get_month_number, get_season_number, get_quarter_number, get_proper_name_number}; -- list of functions to execute in order
for _, func in ipairs (funcs) do -- spin through the function list
num = func (element, param); -- call the function and get the returned number
if 0 ~= num then -- non-zero when valid month season quarter
return num; -- return that number
end
end
return nil; -- not valid
end
--[[--------------------------< I S _ V A L I D _ Y E A R >----------------------------------------------------
Function gets current year from the server and compares it to year from a citation parameter. Years more than one
year in the future are not acceptable.
Special case for |pmc-embargo-date=: years more than two years in the future are not acceptable
]]
local function is_valid_year (year, param)
if not is_set (year_limit) then
year_limit = tonumber(os.date("%Y"))+1; -- global variable so we only have to fetch it once
end
year = tonumber (year) or lang_object:parseFormattedNumber (year); -- convert to number for the comparison;
if 'pmc-embargo-date' == param then -- special case for |pmc-embargo-date=
return year and (year <= tonumber(os.date("%Y"))+2) or false; -- years more than two years in the future are not accepted
end
return year and (year <= year_limit) or false;
end
--[[--------------------------< I S _ V A L I D _ D A T E >----------------------------------------------------
Returns true if day is less than or equal to the number of days in month and year is no farther into the future
than next year; else returns false.
Assumes Julian calendar prior to year 1582 and Gregorian calendar thereafter. Accounts for Julian calendar leap
years before 1582 and Gregorian leap years after 1582. Where the two calendars overlap (1582 to approximately
1923) dates are assumed to be Gregorian.
]]
local function is_valid_date (year, month, day, param)
local days_in_month = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
local month_length;
if not is_valid_year (year, param) then -- no farther into the future than next year except |pmc-embargo-date= no more than two years in the future
return false;
end
month = tonumber (month); -- required for YYYY-MM-DD dates
if (2 == month) then -- if February
month_length = 28; -- then 28 days unless
if 1582 > tonumber(year) then -- Julian calendar
if 0 == (year%4) then -- is a leap year?
month_length = 29; -- if leap year then 29 days in February
end
else -- Gregorian calendar
if (0 == (year%4) and (0 ~= (year%100) or 0 == (year%400))) then -- is a leap year?
month_length = 29; -- if leap year then 29 days in February
end
end
else
month_length = days_in_month[month];
end
if tonumber (day) > month_length then
return false;
end
return true;
end
--[[--------------------------< I S _ V A L I D _ M O N T H _ R A N G E _ S T Y L E >--------------------------
Months in a range are expected to have the same style: Jan–Mar or October–December but not February–Mar or Jul–August.
This function looks in cfg.date_names{} to see if both month names are listed in the long subtable or both are
listed in the short subtable. When both have the same style (both are listed in the same table), returns true; false else
]]
local function is_valid_month_range_style (month1, month2)
if (cfg.date_names.en.long[month1] and cfg.date_names.en.long[month2]) or -- are both English names listed in the long subtable?
(cfg.date_names.en.short[month1] and cfg.date_names.en.short[month2]) or -- are both English names listed in the short subtable?
(cfg.date_names['local'].long[month1] and cfg.date_names['local'].long[month2]) or -- are both local names listed in the long subtable?
(cfg.date_names['local'].short[month1] and cfg.date_names['local'].short[month2]) then -- are both local names listed in the short subtable?
return true;
end
return false; -- names are mixed
end
--[[--------------------------< I S _ V A L I D _ M O N T H _ S E A S O N _ R A N G E >------------------------
Check a pair of months or seasons to see if both are valid members of a month or season pair.
Month pairs are expected to be left to right, earliest to latest in time.
All season ranges are accepted as valid because there are publishers out there who have published a Summer–Spring YYYY issue, hence treat as ok
]]
local function is_valid_month_season_range(range_start, range_end, param)
local range_start_number = get_month_number (range_start);
local range_end_number;
if 0 == range_start_number then -- is this a month range?
range_start_number = get_season_number (range_start, param); -- not a month; is it a season? get start season number
range_end_number = get_season_number (range_end, param); -- get end season number
if (0 ~= range_start_number) and (0 ~= range_end_number) and (range_start_number ~= range_end_number) then
return true; -- any season pairing is accepted except when both are the same
end
return false; -- range_start and/or range_end is not a season
end
-- here when range_start is a month
range_end_number = get_month_number (range_end); -- get end month number
if range_start_number < range_end_number and -- range_start is a month; does range_start precede range_end?
is_valid_month_range_style (range_start, range_end) then -- do months have the same style?
return true; -- proper order and same style
end
return false; -- range_start month number is greater than or equal to range end number; or range end isn't a month
end
--[[--------------------------< M A K E _ C O I N S _ D A T E >------------------------------------------------
This function receives a table of date parts for one or two dates and an empty table reference declared in
Module:Citation/CS1. The function is called only for |date= parameters and only if the |date=<value> is
determined to be a valid date format. The question of what to do with invalid date formats is not answered here.
The date parts in the input table are converted to an ISO 8601 conforming date string:
single whole dates: yyyy-mm-dd
month and year dates: yyyy-mm
year dates: yyyy
ranges: yyyy-mm-dd/yyyy-mm-dd
yyyy-mm/yyyy-mm
yyyy/yyyy
Dates in the Julian calendar are reduced to year or year/year so that we don't have to do calendar conversion from
Julian to Proleptic Gregorian.
The input table has:
year, year2 – always present; if before 1582, ignore months and days if present
month, month2 – 0 if not provided, 1-12 for months, 21-24 for seasons; 99 Christmas
day, day2 – 0 if not provided, 1-31 for days
the output table receives:
rftdate: an ISO 8601 formatted date
rftchron: a free-form version of the date, usually without year which is in rftdate (season ranges and proper-name dates)
rftssn: one of four season keywords: winter, spring, summer, fall (lowercase)
rftquarter: one of four values: 1, 2, 3, 4
]]
local function make_COinS_date (input, tCOinS_date)
local date; -- one date or first date in a range
local date2 = ''; -- end of range date
-- start temporary Julian / Gregorian calendar uncertainty detection
local year = tonumber(input.year); -- this temporary code to determine the extent of sources dated to the Julian/Gregorian
local month = tonumber(input.month); -- interstice 1 October 1582 – 1 January 1926
local day = tonumber (input.day);
if (0 ~= day) and -- day must have a value for this to be a whole date
(((1582 == year) and (10 <= month) and (12 >= month)) or -- any whole 1582 date from 1 October to 31 December or
((1926 == year) and (1 == month) and (1 == input.day)) or -- 1 January 1926 or
((1582 < year) and (1925 >= year))) then -- any date 1 January 1583 – 31 December 1925
tCOinS_date.inter_cal_cat = true; -- set category flag true
end
-- end temporary Julian / Gregorian calendar uncertainty detection
if 1582 > tonumber(input.year) or 20 < tonumber(input.month) then -- Julian calendar or season so &rft.date gets year only
date = input.year;
if 0 ~= input.year2 and input.year ~= input.year2 then -- if a range, only the second year portion when not the same as range start year
date = string.format ('%.4d/%.4d', tonumber(input.year), tonumber(input.year2)) -- assemble the date range
end
if 20 < tonumber(input.month) then -- if season or proper-name date
local season = {[24] = 'winter', [21] = 'spring', [22] = 'summer', [23] = 'fall', [33] = '1', [34] = '2', [35] = '3', [36] = '4', [98] = 'Easter', [99] = 'Christmas'}; -- seasons lowercase, no autumn; proper-names use title case
if 0 == input.month2 then -- single season date
if 40 < tonumber(input.month) then
tCOinS_date.rftchron = season[input.month]; -- proper-name dates
elseif 30 < tonumber(input.month) then
tCOinS_date.rftquarter = season[input.month]; -- quarters
else
tCOinS_date.rftssn = season[input.month]; -- seasons
end
else -- season range with a second season specified
if input.year ~= input.year2 then -- season year – season year range or season year–year
tCOinS_date.rftssn = season[input.month]; -- start of range season; keep this?
if 0~= input.month2 then
tCOinS_date.rftchron = string.format ('%s %s – %s %s', season[input.month], input.year, season[input.month2], input.year2);
end
else -- season–season year range
tCOinS_date.rftssn = season[input.month]; -- start of range season; keep this?
tCOinS_date.rftchron = season[input.month] .. '–' .. season[input.month2]; -- season–season year range
end
end
end
tCOinS_date.rftdate = date;
return; -- done
end
if 0 ~= input.day then
date = string.format ('%s-%.2d-%.2d', input.year, tonumber(input.month), tonumber(input.day)); -- whole date
elseif 0 ~= input.month then
date = string.format ('%s-%.2d', input.year, tonumber(input.month)); -- year and month
else
date = string.format ('%s', input.year); -- just year
end
if 0 ~= input.year2 then
if 0 ~= input.day2 then
date2 = string.format ('/%s-%.2d-%.2d', input.year2, tonumber(input.month2), tonumber(input.day2)); -- whole date
elseif 0 ~= input.month2 then
date2 = string.format ('/%s-%.2d', input.year2, tonumber(input.month2)); -- year and month
else
date2 = string.format ('/%s', input.year2); -- just year
end
end
tCOinS_date.rftdate = date .. date2; -- date2 has the '/' separator
return;
end
--[[--------------------------< P A T T E R N S >--------------------------------------------------------------
this is the list of patterns for date formats that this module recognizes. Approximately the first half of these
patterns represent formats that might be reformatted into another format. Those that might be reformatted have
'indicator' letters that identify the content of the matching capture: 'd' (day), 'm' (month), 'a' (anchor year),
'y' (year); second day, month, year have a '2' suffix.
These patterns are used for both date validation and for reformatting. This table should not be moved to ~/Configuration
because changes to this table require changes to check_date() and to reformatter() and reformat_date()
]]
local patterns = {
-- year-initial numerical year-month-day
['ymd'] = {'^(%d%d%d%d)%-(%d%d)%-(%d%d)$', 'y', 'm', 'd'},
-- month-initial: month day, year
['Mdy'] = {'^(%D-) +([1-9]%d?), +((%d%d%d%d?)%a?)$', 'm', 'd', 'a', 'y'},
-- month-initial day range: month day–day, year; days are separated by endash
['Md-dy'] = {'^(%D-) +([1-9]%d?)[%-–]([1-9]%d?), +((%d%d%d%d)%a?)$', 'm', 'd', 'd2', 'a', 'y'},
-- day-initial: day month year
['dMy'] = {'^([1-9]%d?) +(%D-) +((%d%d%d%d?)%a?)$', 'd', 'm', 'a', 'y'},
-- year-initial: year month day; day: 1 or 2 two digits, leading zero allowed; not supported at en.wiki
-- ['yMd'] = {'^((%d%d%d%d?)%a?) +(%D-) +(%d%d?)$', 'a', 'y', 'm', 'd'},
-- day-range-initial: day–day month year; days are separated by endash
['d-dMy'] = {'^([1-9]%d?)[%-–]([1-9]%d?) +(%D-) +((%d%d%d%d)%a?)$', 'd', 'd2', 'm', 'a', 'y'},
-- day initial month-day-range: day month - day month year; uses spaced endash
['dM-dMy'] = {'^([1-9]%d?) +(%D-) +[%-–] +([1-9]%d?) +(%D-) +((%d%d%d%d)%a?)$', 'd', 'm', 'd2', 'm2', 'a', 'y'},
-- month initial month-day-range: month day – month day, year; uses spaced endash
['Md-Mdy'] = {'^(%D-) +([1-9]%d?) +[%-–] +(%D-) +([1-9]%d?), +((%d%d%d%d)%a?)$','m', 'd', 'm2', 'd2', 'a', 'y'},
-- day initial month-day-year-range: day month year - day month year; uses spaced endash
['dMy-dMy'] = {'^([1-9]%d?) +(%D-) +(%d%d%d%d) +[%-–] +([1-9]%d?) +(%D-) +((%d%d%d%d)%a?)$', 'd', 'm', 'y', 'd2', 'm2', 'a', 'y2'},
-- month initial month-day-year-range: month day, year – month day, year; uses spaced endash
['Mdy-Mdy'] = {'^(%D-) +([1-9]%d?), +(%d%d%d%d) +[%-–] +(%D-) +([1-9]%d?), +((%d%d%d%d)%a?)$', 'm', 'd', 'y', 'm2', 'd2', 'a', 'y2'},
-- these date formats cannot be converted, per se, but month name can be rendered short or long
-- month/season year - month/season year; separated by spaced endash
['My-My'] = {'^(%D-) +(%d%d%d%d) +[%-–] +(%D-) +((%d%d%d%d)%a?)$', 'm', 'y', 'm2', 'a', 'y2'},
-- month/season range year; months separated by endash
['M-My'] = {'^(%D-)[%-–](%D-) +((%d%d%d%d)%a?)$', 'm', 'm2', 'a', 'y'},
-- month/season year or proper-name year; quarter year when First Quarter YYYY etc.
['My'] = {'^([^%d–]-) +((%d%d%d%d)%a?)$', 'm', 'a', 'y'}, -- this way because endash is a member of %D; %D- will match January–March 2019 when it shouldn't
-- these date formats cannot be converted
['Sy4-y2'] = {'^(%D-) +((%d%d)%d%d)[%-–]((%d%d)%a?)$'}, -- special case Winter/Summer year-year (YYYY-YY); year separated with unspaced endash
['Sy-y'] = {'^(%D-) +(%d%d%d%d)[%-–]((%d%d%d%d)%a?)$'}, -- special case Winter/Summer year-year; year separated with unspaced endash
['y-y'] = {'^(%d%d%d%d?)[%-–]((%d%d%d%d?)%a?)$'}, -- year range: YYY-YYY or YYY-YYYY or YYYY–YYYY; separated by unspaced endash; 100-9999
['y4-y2'] = {'^((%d%d)%d%d)[%-–]((%d%d)%a?)$'}, -- year range: YYYY–YY; separated by unspaced endash
['y'] = {'^((%d%d%d%d?)%a?)$'}, -- year; here accept either YYY or YYYY
}
--[[--------------------------< I S _ V A L I D _ E M B A R G O _ D A T E >------------------------------------
returns true and date value if that value has proper dmy, mdy, ymd format.
returns false and 9999 (embargoed forever) when date value is not proper format; assumes that when |pmc-embargo-date= is
set, the editor intended to embargo a PMC but |pmc-embargo-date= does not hold a single date.
]]
local function is_valid_embargo_date (v)
if v:match (patterns['ymd'][1]) or -- ymd
v:match (patterns['Mdy'][1]) or -- dmy
v:match (patterns['dMy'][1]) then -- mdy
return true, v;
end
return false, '9999'; -- if here not good date so return false and set embargo date to long time in future
end
--[[--------------------------< C H E C K _ D A T E >----------------------------------------------------------
Check date format to see that it is one of the formats approved by WP:DATESNO or WP:DATERANGE. Exception: only
allowed range separator is endash. Additionally, check the date to see that it is a real date: no 31 in 30-day
months; no 29 February when not a leap year. Months, both long-form and three character abbreviations, and seasons
must be spelled correctly. Future years beyond next year are not allowed.
If the date fails the format tests, this function returns false and does not return values for anchor_year and
COinS_date. When this happens, the date parameter is (DEBUG: not?) used in the COinS metadata and the CITEREF identifier gets
its year from the year parameter if present otherwise CITEREF does not get a date value.
Inputs:
date_string - date string from date-holding parameters (date, year, publication-date, access-date, pmc-embargo-date, archive-date, lay-date)
Returns:
false if date string is not a real date; else
true, anchor_year, COinS_date
anchor_year can be used in CITEREF anchors
COinS_date is ISO 8601 format date; see make_COInS_date()
]]
local function check_date (date_string, param, tCOinS_date)
local year; -- assume that year2, months, and days are not used;
local year2 = 0; -- second year in a year range
local month = 0;
local month2 = 0; -- second month in a month range
local day = 0;
local day2 = 0; -- second day in a day range
local anchor_year;
local coins_date;
if date_string:match (patterns['ymd'][1]) then -- year-initial numerical year month day format
year, month, day = date_string:match (patterns['ymd'][1]);
if 12 < tonumber(month) or 1 > tonumber(month) or 1582 > tonumber(year) or 0 == tonumber(day) then return false; end -- month or day number not valid or not Gregorian calendar
anchor_year = year;
elseif mw.ustring.match(date_string, patterns['Mdy'][1]) then -- month-initial: month day, year
month, day, anchor_year, year = mw.ustring.match(date_string, patterns['Mdy'][1]);
month = get_month_number (month);
if 0 == month then return false; end -- return false if month text isn't one of the twelve months
elseif mw.ustring.match(date_string, patterns['Md-dy'][1]) then -- month-initial day range: month day–day, year; days are separated by endash
month, day, day2, anchor_year, year = mw.ustring.match(date_string, patterns['Md-dy'][1]);
if tonumber(day) >= tonumber(day2) then return false; end -- date range order is left to right: earlier to later; dates may not be the same;
month = get_month_number (month);
if 0 == month then return false; end -- return false if month text isn't one of the twelve months
month2=month; -- for metadata
year2 = year;
elseif mw.ustring.match(date_string, patterns['dMy'][1]) then -- day-initial: day month year
day, month, anchor_year, year = mw.ustring.match(date_string, patterns['dMy'][1]);
month = get_month_number (month);
if 0 == month then return false; end -- return false if month text isn't one of the twelve months
--[[ NOT supported at en.wiki
elseif mw.ustring.match(date_string, patterns['yMd'][1]) then -- year-initial: year month day; day: 1 or 2 two digits, leading zero allowed
anchor_year, year, month, day = mw.ustring.match(date_string, patterns['yMd'][1]);
month = get_month_number (month);
if 0 == month then return false; end -- return false if month text isn't one of the twelve months
-- end NOT supported at en.wiki ]]
elseif mw.ustring.match(date_string, patterns['d-dMy'][1]) then -- day-range-initial: day–day month year; days are separated by endash
day, day2, month, anchor_year, year = mw.ustring.match(date_string, patterns['d-dMy'][1]);
if tonumber(day) >= tonumber(day2) then return false; end -- date range order is left to right: earlier to later; dates may not be the same;
month = get_month_number (month);
if 0 == month then return false; end -- return false if month text isn't one of the twelve months
month2 = month; -- for metadata
year2 = year;
elseif mw.ustring.match(date_string, patterns['dM-dMy'][1]) then -- day initial month-day-range: day month - day month year; uses spaced endash
day, month, day2, month2, anchor_year, year = mw.ustring.match(date_string, patterns['dM-dMy'][1]);
if (not is_valid_month_season_range(month, month2)) or not is_valid_year(year) then return false; end -- date range order is left to right: earlier to later;
month = get_month_number (month); -- for metadata
month2 = get_month_number (month2);
year2 = year;
elseif mw.ustring.match(date_string, patterns['Md-Mdy'][1]) then -- month initial month-day-range: month day – month day, year; uses spaced endash
month, day, month2, day2, anchor_year, year = mw.ustring.match(date_string, patterns['Md-Mdy'][1]);
if (not is_valid_month_season_range(month, month2, param)) or not is_valid_year(year) then return false; end
month = get_month_number (month); -- for metadata
month2 = get_month_number (month2);
year2 = year;
elseif mw.ustring.match(date_string, patterns['dMy-dMy'][1]) then -- day initial month-day-year-range: day month year - day month year; uses spaced endash
day, month, year, day2, month2, anchor_year, year2 = mw.ustring.match(date_string, patterns['dMy-dMy'][1]);
if tonumber(year2) <= tonumber(year) then return false; end -- must be sequential years, left to right, earlier to later
if not is_valid_year(year2) or not is_valid_month_range_style(month, month2) then return false; end -- year2 no more than one year in the future; months same style
month = get_month_number (month); -- for metadata
month2 = get_month_number (month2);
if 0 == month or 0 == month2 then return false; end -- both must be valid
elseif mw.ustring.match(date_string, patterns['Mdy-Mdy'][1]) then -- month initial month-day-year-range: month day, year – month day, year; uses spaced endash
month, day, year, month2, day2, anchor_year, year2 = mw.ustring.match(date_string, patterns['Mdy-Mdy'][1]);
if tonumber(year2) <= tonumber(year) then return false; end -- must be sequential years, left to right, earlier to later
if not is_valid_year(year2) or not is_valid_month_range_style(month, month2) then return false; end -- year2 no more than one year in the future; months same style
month = get_month_number (month); -- for metadata
month2 = get_month_number(month2);
if 0 == month or 0 == month2 then return false; end -- both must be valid
elseif mw.ustring.match(date_string, patterns['Sy4-y2'][1]) then -- special case Winter/Summer year-year (YYYY-YY); year separated with unspaced endash
local century;
month, year, century, anchor_year, year2 = mw.ustring.match(date_string, patterns['Sy4-y2'][1]);
if 'Winter' ~= month and 'Summer' ~= month then return false end; -- 'month' can only be Winter or Summer
anchor_year = year .. '–' .. anchor_year; -- assemble anchor_year from both years
year2 = century..year2; -- add the century to year2 for comparisons
if 1 ~= tonumber(year2) - tonumber(year) then return false; end -- must be sequential years, left to right, earlier to later
if not is_valid_year(year2) then return false; end -- no year farther in the future than next year
month = get_season_number(month, param);
elseif mw.ustring.match(date_string, patterns['Sy-y'][1]) then -- special case Winter/Summer year-year; year separated with unspaced endash
month, year, anchor_year, year2 = mw.ustring.match(date_string, patterns['Sy-y'][1]);
month = get_season_number (month, param); -- <month> can only be winter or summer; also for metadata
if (month ~= cfg.date_names['en'].season['Winter']) and (month ~= cfg.date_names['en'].season['Summer']) then
return false; -- not Summer or Winter; abandon
end
anchor_year = year .. '–' .. anchor_year; -- assemble anchor_year from both years
if 1 ~= tonumber(year2) - tonumber(year) then return false; end -- must be sequential years, left to right, earlier to later
if not is_valid_year(year2) then return false; end -- no year farther in the future than next year
elseif mw.ustring.match(date_string, patterns['My-My'][1]) then -- month/season year - month/season year; separated by spaced endash
month, year, month2, anchor_year, year2 = mw.ustring.match(date_string, patterns['My-My'][1]);
anchor_year = year .. '–' .. anchor_year; -- assemble anchor_year from both years
if tonumber(year) >= tonumber(year2) then return false; end -- left to right, earlier to later, not the same
if not is_valid_year(year2) then return false; end -- no year farther in the future than next year
if 0 ~= get_month_number(month) and 0 ~= get_month_number(month2) and is_valid_month_range_style(month, month2) then -- both must be month year, same month style
month = get_month_number(month);
month2 = get_month_number(month2);
elseif 0 ~= get_season_number(month, param) and 0 ~= get_season_number(month2, param) then -- both must be season year, not mixed
month = get_season_number(month, param);
month2 = get_season_number(month2, param);
else
return false;
end
elseif mw.ustring.match(date_string, patterns['M-My'][1]) then -- month/season range year; months separated by endash
month, month2, anchor_year, year = mw.ustring.match(date_string, patterns['M-My'][1]);
if (not is_valid_month_season_range(month, month2, param)) or (not is_valid_year(year)) then return false; end
if 0 ~= get_month_number(month) then -- determined to be a valid range so just check this one to know if month or season
month = get_month_number(month);
month2 = get_month_number(month2);
if 0 == month or 0 == month2 then return false; end
else
month = get_season_number(month, param);
month2 = get_season_number(month2, param);
end
year2 = year;
elseif mw.ustring.match(date_string, patterns['My'][1]) then -- month/season/quarter/proper-name year
month, anchor_year, year = mw.ustring.match(date_string, patterns['My'][1]);
if not is_valid_year(year) then return false; end
month = get_element_number(month, param); -- get month season quarter proper-name number or nil
if not month then return false; end -- not valid whatever it is
elseif mw.ustring.match(date_string, patterns['y-y'][1]) then -- Year range: YYY-YYY or YYY-YYYY or YYYY–YYYY; separated by unspaced endash; 100-9999
year, anchor_year, year2 = mw.ustring.match(date_string, patterns['y-y'][1]);
anchor_year = year .. '–' .. anchor_year; -- assemble anchor year from both years
if tonumber(year) >= tonumber(year2) then return false; end -- left to right, earlier to later, not the same
if not is_valid_year(year2) then return false; end -- no year farther in the future than next year
elseif mw.ustring.match(date_string, patterns['y4-y2'][1]) then -- Year range: YYYY–YY; separated by unspaced endash
local century;
year, century, anchor_year, year2 = mw.ustring.match(date_string, patterns['y4-y2'][1]);
anchor_year = year .. '–' .. anchor_year; -- assemble anchor year from both years
if in_array (param, {'date', 'publication-date', 'year'}) then
add_prop_cat ('year-range-abbreviated');
end
if 13 > tonumber(year2) then return false; end -- don't allow 2003-05 which might be May 2003
year2 = century .. year2; -- add the century to year2 for comparisons
if tonumber(year) >= tonumber(year2) then return false; end -- left to right, earlier to later, not the same
if not is_valid_year(year2) then return false; end -- no year farther in the future than next year
elseif mw.ustring.match(date_string, patterns['y'][1]) then -- year; here accept either YYY or YYYY
anchor_year, year = mw.ustring.match(date_string, patterns['y'][1]);
if false == is_valid_year(year) then
return false;
end
else
return false; -- date format not one of the MOS:DATE approved formats
end
if 'access-date' == param then -- test accessdate here because we have numerical date parts
if 0 ~= year and 0 ~= month and 0 ~= day and -- all parts of a single date required
0 == year2 and 0 == month2 and 0 == day2 then -- none of these; accessdate must not be a range
if not is_valid_accessdate(year .. '-' .. month .. '-' .. day) then
return false; -- return false when accessdate out of bounds
end
else
return false; -- return false when accessdate is a range of two dates
end
end
local result=true; -- check whole dates for validity; assume true because not all dates will go through this test
if 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 == month2 and 0 == day2 then -- YMD (simple whole date)
result = is_valid_date (year, month, day, param); -- <param> for |pmc-embargo-date=
elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 == month2 and 0 ~= day2 then -- YMD-d (day range)
result = is_valid_date (year, month, day);
result = result and is_valid_date (year, month, day2);
elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 ~= month2 and 0 ~= day2 then -- YMD-md (day month range)
result = is_valid_date (year, month, day);
result = result and is_valid_date (year, month2, day2);
elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 ~= year2 and 0 ~= month2 and 0 ~= day2 then -- YMD-ymd (day month year range)
result = is_valid_date(year, month, day);
result = result and is_valid_date(year2, month2, day2);
end
if false == result then return false; end
if nil ~= tCOinS_date then -- this table only passed into this function when testing |date= parameter values
make_COinS_date ({year = year, month = month, day = day, year2 = year2, month2 = month2, day2 = day2}, tCOinS_date); -- make an ISO 8601 date string for COinS
end
return true, anchor_year; -- format is good and date string represents a real date
end
--[[--------------------------< D A T E S >--------------------------------------------------------------------
Cycle the date-holding parameters in passed table date_parameters_list through check_date() to check compliance with MOS:DATE. For all valid dates, check_date() returns
true. The |date= parameter test is unique, it is the only date holding parameter from which values for anchor_year (used in CITEREF identifiers) and COinS_date (used in
the COinS metadata) are derived. The |date= parameter is the only date-holding parameter that is allowed to contain the no-date keywords "n.d." or "nd" (without quotes).
Unlike most error messages created in this module, only one error message is created by this function. Because all of the date holding parameters are processed serially,
parameters with errors are added to the <error_list> sequence table as the dates are tested.
]]
local function dates(date_parameters_list, tCOinS_date, error_list)
local anchor_year; -- will return as nil if the date being tested is not |date=
local COinS_date; -- will return as nil if the date being tested is not |date=
local embargo_date; -- if embargo date is a good dmy, mdy, ymd date then holds original value else reset to 9999
local good_date = false;
for k, v in pairs(date_parameters_list) do -- for each date-holding parameter in the list
if is_set(v.val) then -- if the parameter has a value
v.val = mw.ustring.gsub(v.val, '%d', cfg.date_names.local_digits); -- translate 'local' digits to Western 0-9
if v.val:match("^c%. [1-9]%d%d%d?%a?$") then -- special case for c. year or with or without CITEREF disambiguator - only |date= and |year=
local year = v.val:match("c%. ([1-9]%d%d%d?)%a?"); -- get the year portion so it can be tested
if 'date' == k then
anchor_year, COinS_date = v.val:match("((c%. [1-9]%d%d%d?)%a?)"); -- anchor year and COinS_date only from |date= parameter
good_date = is_valid_year(year);
elseif 'year' == k then
good_date = is_valid_year(year);
end
elseif 'date' == k then -- if the parameter is |date=
if v.val:match("^n%.d%.%a?$") then -- ToDo: I18N -- if |date=n.d. with or without a CITEREF disambiguator
good_date, anchor_year, COinS_date = true, v.val:match("((n%.d%.)%a?)"); -- ToDo: I18N -- "n.d."; no error when date parameter is set to no date
elseif v.val:match("^nd%a?$") then -- ToDo: I18N -- if |date=nd with or without a CITEREF disambiguator
good_date, anchor_year, COinS_date = true, v.val:match("((nd)%a?)"); -- ToDo: I18N -- "nd"; no error when date parameter is set to no date
else
good_date, anchor_year, COinS_date = check_date (v.val, k, tCOinS_date); -- go test the date
end
elseif 'year' == k then -- if the parameter is |year= it should hold only a year value
if v.val:match("^[1-9]%d%d%d?%a?$") then -- if |year = 3 or 4 digits only with or without a CITEREF disambiguator
good_date, anchor_year, COinS_date = true, v.val:match("((%d+)%a?)");
end
elseif 'pmc-embargo-date' == k then -- if the parameter is |pmc-embargo-date=
good_date = check_date (v.val, k); -- go test the date
if true == good_date then -- if the date is a valid date
good_date, embargo_date = is_valid_embargo_date (v.val); -- is |pmc-embargo-date= date a single dmy, mdy, or ymd formatted date? yes: returns embargo date; no: returns 9999
end
else -- any other date-holding parameter
good_date = check_date (v.val, k); -- go test the date
end
if false == good_date then -- assemble one error message so we don't add the tracking category multiple times
table.insert (error_list, wrap_style ('parameter', v.name)); -- make parameter name suitable for error message list
end
end
end
return anchor_year, embargo_date; -- and done
end
--[[--------------------------< Y E A R _ D A T E _ C H E C K >------------------------------------------------
Compare the value provided in |year= with the year value(s) provided in |date=. This function sets a local numeric value:
0 - year value does not match the year value in date
1 - (default) year value matches the year value in date or one of the year values when date contains two years
2 - year value matches the year value in date when date is in the form YYYY-MM-DD and year is disambiguated (|year=YYYYx)
the numeric value in <result> determines the 'output' if any from this function:
0 – adds error message to error_list sequence table
1 – adds maint cat
2 – does nothing
]]
local function year_date_check (year_string, year_origin, date_string, date_origin, error_list)
local year;
local date1;
local date2;
local result = 1; -- result of the test; assume that the test passes
year = year_string:match ('(%d%d%d%d?)');
if date_string:match ('%d%d%d%d%-%d%d%-%d%d') and year_string:match ('%d%d%d%d%a') then --special case where both date and year are required YYYY-MM-DD and YYYYx
date1 = date_string:match ('(%d%d%d%d)');
year = year_string:match ('(%d%d%d%d)');
if year ~= date1 then
result = 0; -- years don't match
else
result = 2; -- years match; but because disambiguated, don't add to maint cat
end
elseif date_string:match ("%d%d%d%d?.-%d%d%d%d?") then -- any of the standard range formats of date with two three- or four-digit years
date1, date2 = date_string:match ("(%d%d%d%d?).-(%d%d%d%d?)");
if year ~= date1 and year ~= date2 then
result = 0;
end
elseif mw.ustring.match(date_string, "%d%d%d%d[%-–]%d%d") then -- YYYY-YY date ranges
local century;
date1, century, date2 = mw.ustring.match(date_string, "((%d%d)%d%d)[%-–]+(%d%d)");
date2 = century..date2; -- convert YY to YYYY
if year ~= date1 and year ~= date2 then
result = 0;
end
elseif date_string:match ("%d%d%d%d?") then -- any of the standard formats of date with one year
date1 = date_string:match ("(%d%d%d%d?)");
if year ~= date1 then
result = 0;
end
else -- should never get here; this function called only when no other date errors
result = 0; -- no recognizable year in date
end
if 0 == result then -- year / date mismatch
table.insert (error_list, substitute (cfg.messages['mismatch'], {year_origin, date_origin})); -- add error message to error_list sequence table
elseif 1 == result then -- redundant year / date
set_message ('maint_date_year'); -- add a maint cat
end
end
--[[--------------------------< R E F O R M A T T E R >--------------------------------------------------------
reformat 'date' into new format specified by format_param if pattern_idx (the current format of 'date') can be
reformatted. Does the grunt work for reformat_dates().
The table re_formats maps pattern_idx (current format) and format_param (desired format) to a table that holds:
format string used by string.format()
identifier letters ('d', 'm', 'y', 'd2', 'm2', 'y2') that serve as indexes into a table t{} that holds captures
from mw.ustring.match() for the various date parts specified by patterns[pattern_idx][1]
Items in patterns{} have the general form:
['ymd'] = {'^(%d%d%d%d)%-(%d%d)%-(%d%d)$', 'y', 'm', 'd'}, where:
['ymd'] is pattern_idx
patterns['ymd'][1] is the match pattern with captures for mw.ustring.match()
patterns['ymd'][2] is an indicator letter identifying the content of the first capture
patterns['ymd'][3] ... the second capture etc.
when a pattern matches a date, the captures are loaded into table t{} in capture order using the idemtifier
characters as indexes into t{} For the above, a ymd date is in t{} as:
t.y = first capture (year), t.m = second capture (month), t.d = third capture (day)
To reformat, this function is called with the pattern_idx that matches the current format of the date and with
format_param set to the desired format. This function loads table t{} as described and then calls string.format()
with the format string specified by re_format[pattern_idx][format_param][1] using values taken from t{} according
to the capture identifier letters specified by patterns[pattern_idx][format_param][n] where n is 2..
]]
local re_formats = {
['ymd'] = { -- date format is ymd; reformat to:
['mdy'] = {'%s %s, %s', 'm', 'd', 'y'}, -- |df=mdy
['dmy'] = {'%s %s %s', 'd', 'm', 'y'}, -- |df=dmy
-- ['yMd'] = {'%s %s %s', 'y', 'm', 'd'}, -- |df=yMd; not supported at en.wiki
},
['Mdy'] = { -- date format is Mdy; reformat to:
['mdy'] = {'%s %s, %s', 'm', 'd', 'y'}, -- for long/short reformatting
['dmy'] = {'%s %s %s', 'd', 'm', 'y'}, -- |df=dmy
['ymd'] = {'%s-%s-%s', 'y', 'm', 'd'}, -- |df=ymd
-- ['yMd'] = {'%s %s %s', 'y', 'm', 'd'}, -- |df=yMd; not supported at en.wiki
},
['dMy'] = { -- date format is dMy; reformat to:
['dmy'] = {'%s %s %s', 'd', 'm', 'y'}, -- for long/short reformatting
['mdy'] = {'%s %s, %s', 'm', 'd', 'y'}, -- |df=mdy
['ymd'] = {'%s-%s-%s', 'y', 'm', 'd'}, -- |df=ymd
-- ['yMd'] = {'%s %s %s', 'y', 'm', 'd'}, -- |df=yMd; not supported at en.wiki
},
['Md-dy'] = { -- date format is Md-dy; reformat to:
['mdy'] = {'%s %s–%s, %s', 'm', 'd', 'd2', 'y'}, -- for long/short reformatting
['dmy'] = {'%s–%s %s %s', 'd', 'd2', 'm', 'y'}, -- |df=dmy -> d-dMy
},
['d-dMy'] = { -- date format is d-d>y; reformat to:
['dmy'] = {'%s–%s %s %s', 'd', 'd2', 'm', 'y'}, -- for long/short reformatting
['mdy'] = {'%s %s–%s, %s', 'm', 'd', 'd2', 'y'}, -- |df=mdy -> Md-dy
},
['dM-dMy'] = { -- date format is dM-dMy; reformat to:
['dmy'] = {'%s %s – %s %s %s', 'd', 'm', 'd2', 'm2', 'y'}, -- for long/short reformatting
['mdy'] = {'%s %s – %s %s, %s', 'm', 'd', 'm2', 'd2', 'y'}, -- |df=mdy -> Md-Mdy
},
['Md-Mdy'] = { -- date format is Md-Mdy; reformat to:
['mdy'] = {'%s %s – %s %s, %s', 'm', 'd', 'm2', 'd2', 'y'}, -- for long/short reformatting
['dmy'] = {'%s %s – %s %s %s', 'd', 'm', 'd2', 'm2', 'y'}, -- |df=dmy -> dM-dMy
},
['dMy-dMy'] = { -- date format is dMy-dMy; reformat to:
['dmy'] = {'%s %s %s – %s %s %s', 'd', 'm', 'y', 'd2', 'm2', 'y2'}, -- for long/short reformatting
['mdy'] = {'%s %s, %s – %s %s, %s', 'm', 'd', 'y', 'm2', 'd2', 'y2'}, -- |df=mdy -> Mdy-Mdy
},
['Mdy-Mdy'] = { -- date format is Mdy-Mdy; reformat to:
['mdy'] = {'%s %s, %s – %s %s, %s', 'm', 'd', 'y', 'm2', 'd2', 'y2'}, -- for long/short reformatting
['dmy'] = {'%s %s %s – %s %s %s', 'd', 'm', 'y', 'd2', 'm2', 'y2'}, -- |df=dmy -> dMy-dMy
},
['My-My'] = { -- these for long/short reformatting
['any'] = {'%s %s – %s %s', 'm', 'y', 'm2', 'y2'}, -- dmy/mdy agnostic
},
['M-My'] = { -- these for long/short reformatting
['any'] = {'%s–%s %s', 'm', 'm2', 'y'}, -- dmy/mdy agnostic
},
['My'] = { -- these for long/short reformatting
['any'] = {'%s %s', 'm', 'y'}, -- dmy/mdy agnostic
},
-- ['yMd'] = { -- not supported at en.wiki
-- ['mdy'] = {'%s %s, %s', 'm', 'd', 'y'}, -- |df=mdy
-- ['dmy'] = {'%s %s %s', 'd', 'm', 'y'}, -- |df=dmy
-- ['ymd'] = {'%s-%s-%s', 'y', 'm', 'd'}, -- |df=ymd
-- },
}
local function reformatter (date, pattern_idx, format_param, mon_len)
if not in_array (pattern_idx, {'ymd', 'Mdy', 'Md-dy', 'dMy', 'yMd', 'd-dMy', 'dM-dMy', 'Md-Mdy', 'dMy-dMy', 'Mdy-Mdy', 'My-My', 'M-My', 'My'}) then
return; -- not in this set of date format patterns then not a reformattable date
end
if 'ymd' == format_param and in_array (pattern_idx, {'ymd', 'Md-dy', 'd-dMy', 'dM-dMy', 'Md-Mdy', 'dMy-dMy', 'Mdy-Mdy', 'My-My', 'M-My', 'My'}) then
return; -- ymd date ranges not supported at en.wiki; no point in reformatting ymd to ymd
end
if in_array (pattern_idx, {'My', 'M-My', 'My-My'}) then -- these are not dmy/mdy so can't be 'reformatted' into either
format_param = 'any'; -- so format-agnostic
end
-- yMd is not supported at en.wiki; when yMd is supported at your wiki, uncomment the next line
-- if 'yMd' == format_param and in_array (pattern_idx, {'yMd', 'Md-dy', 'd-dMy', 'dM-dMy', 'Md-Mdy', 'dMy-dMy', 'Mdy-Mdy'}) then -- these formats not convertable; yMd not supported at en.wiki
if 'yMd' == format_param then -- yMd not supported at en.wiki; when yMd is supported at your wiki, remove or comment-out this line
return; -- not a reformattable date
end
local c1, c2, c3, c4, c5, c6, c7; -- these hold the captures specified in patterns[pattern_idx][1]
c1, c2, c3, c4, c5, c6, c7 = mw.ustring.match (date, patterns[pattern_idx][1]); -- get the captures
local t = { -- table that holds k/v pairs of date parts from the captures and patterns[pattern_idx][2..]
[patterns[pattern_idx][2]] = c1; -- at minimum there is always one capture with a matching indicator letter
[patterns[pattern_idx][3] or 'x'] = c2; -- patterns can have a variable number of captures; each capture requires an indicator letter;
[patterns[pattern_idx][4] or 'x'] = c3; -- where there is no capture, there is no indicator letter so n in patterns[pattern_idx][n] will be nil;
[patterns[pattern_idx][5] or 'x'] = c4; -- the 'x' here spoofs an indicator letter to prevent 'table index is nil' error
[patterns[pattern_idx][6] or 'x'] = c5;
[patterns[pattern_idx][7] or 'x'] = c6;
[patterns[pattern_idx][8] or 'x'] = c7;
};
if t.a then -- if this date has an anchor year capture (all convertable date formats except ymd)
if t.y2 then -- for year range date formats
t.y2 = t.a; -- use the anchor year capture when reassembling the date
else -- here for single date formats (except ymd)
t.y = t.a; -- use the anchor year capture when reassembling the date
end
end
if tonumber(t.m) then -- if raw month is a number (converting from ymd)
if 's' == mon_len then -- if we are to use abbreviated month names
t.m = cfg.date_names['inv_local_short'][tonumber(t.m)]; -- convert it to a month name
else
t.m = cfg.date_names['inv_local_long'][tonumber(t.m)]; -- convert it to a month name
end
t.d = t.d:gsub ('0(%d)', '%1'); -- strip leading '0' from day if present
elseif 'ymd' == format_param then -- when converting to ymd
t.y = t.y:gsub ('%a', ''); -- strip CITREF disambiguator if present; anchor year already known so process can proceed; TODO: maint message?
if 1582 > tonumber (t.y) then -- ymd format dates not allowed before 1582
return;
end
t.m = string.format ('%02d', get_month_number (t.m)); -- make sure that month and day are two digits
t.d = string.format ('%02d', t.d);
elseif mon_len then -- if mon_len is set to either 'short' or 'long'
for _, mon in ipairs ({'m', 'm2'}) do -- because there can be two month names, check both
if t[mon] then
t[mon] = get_month_number (t[mon]); -- get the month number for this month (is length agnostic)
if 0 == t[mon] then return; end -- seasons and named dates can't be converted
t[mon] = (('s' == mon_len) and cfg.date_names['inv_local_short'][t[mon]]) or cfg.date_names['inv_local_long'][t[mon]]; -- fetch month name according to length
end
end
end
local new_date = string.format (re_formats[pattern_idx][format_param][1], -- format string
t[re_formats[pattern_idx][format_param][2]], -- named captures from t{}
t[re_formats[pattern_idx][format_param][3]],
t[re_formats[pattern_idx][format_param][4]],
t[re_formats[pattern_idx][format_param][5]],
t[re_formats[pattern_idx][format_param][6]],
t[re_formats[pattern_idx][format_param][7]],
t[re_formats[pattern_idx][format_param][8]]
);
return new_date;
end
--[[-------------------------< R E F O R M A T _ D A T E S >--------------------------------------------------
Reformats existing dates into the format specified by format.
format is one of several manual keywords: dmy, dmy-all, mdy, mdy-all, ymd, ymd-all. The -all version includes
access- and archive-dates; otherwise these dates are not reformatted.
This function allows automatic date formatting. In ~/Configuration, the article source is searched for one of
the {{use xxx dates}} templates. If found, xxx becomes the global date format as xxx-all. If |cs1-dates= in
{{use xxx dates}} has legitimate value then that value determines how cs1|2 dates will be rendered. Legitimate
values for |cs1-dates= are:
l - all dates are rendered with long month names
ls - publication dates use long month names; access-/archive-dates use abbreviated month names
ly - publication dates use long month names; access-/archive-dates rendered in ymd format
s - all dates are rendered with abbreviated (short) month names
sy - publication dates use abbreviated month names; access-/archive-dates rendered in ymd format
y - all dates are rendered in ymd format
the format argument for automatic date formatting will be the format specified by {{use xxx dates}} with the
value supplied by |cs1-dates so one of: xxx-l, xxx-ls, xxx-ly, xxx-s, xxx-sy, xxx-y, or simply xxx (|cs1-dates=
empty, omitted, or invalid) where xxx shall be either of dmy or mdy.
dates are extracted from date_parameters_list, reformatted (if appropriate), and then written back into the
list in the new format. Dates in date_parameters_list are presumed here to be valid (no errors). This function
returns true when a date has been reformatted, false else. Actual reformatting is done by reformatter().
]]
local function reformat_dates (date_parameters_list, format)
local all = false; -- set to false to skip access- and archive-dates
local len_p = 'l'; -- default publication date length shall be long
local len_a = 'l'; -- default access-/archive-date length shall be long
local result = false;
local new_date;
if format:match('%a+%-all') then -- manual df keyword; auto df keyword when length not specified in {{use xxx dates}};
format = format:match('(%a+)%-all'); -- extract the format
all = true; -- all dates are long format dates because this keyword doesn't specify length
elseif format:match('%a+%-[lsy][sy]?') then -- auto df keywords; internal only
all = true; -- auto df applies to all dates; use length specified by capture len_p for all dates
format, len_p, len_a = format:match('(%a+)%-([lsy])([sy]?)'); -- extract the format and length keywords
if 'y' == len_p then -- because allowed by MOS:DATEUNIFY (sort of) range dates and My dates not reformatted
format = 'ymd'; -- override {{use xxx dates}}
elseif (not is_set(len_a)) or (len_p == len_a) then -- no access-/archive-date length specified or same length as publication dates then
len_a = len_p; -- in case len_a not set
end
end -- else only publication dates and they are long
for param_name, param_val in pairs (date_parameters_list) do -- for each date-holding parameter in the list
if is_set (param_val.val) then -- if the parameter has a value
if not (not all and in_array (param_name, {'access-date', 'archive-date'})) then -- skip access- or archive-date unless format is xxx-all; yeah, ugly; TODO: find a better way
for pattern_idx, pattern in pairs (patterns) do
if mw.ustring.match (param_val.val, pattern[1]) then
if all and in_array (param_name, {'access-date', 'archive-date'}) then -- if this date is an access- or archive-date
new_date = reformatter (param_val.val, pattern_idx, (('y' == len_a) and 'ymd') or format, len_a); -- choose ymd or dmy/mdy according to len_a setting
else -- all other dates
new_date = reformatter (param_val.val, pattern_idx, format, len_p);
end
if new_date then -- set when date was reformatted
date_parameters_list[param_name].val = new_date; -- update date in date list
result = true; -- and announce that changes have been made
end
end -- if
end -- for
end -- if
end -- if
end -- for
return result; -- declare boolean result and done
end
--[[--------------------------< D A T E _ H Y P H E N _ T O _ D A S H >----------------------------------------
Loops through the list of date-holding parameters and converts any hyphen to an ndash. Not called if the cs1|2
template has any date errors.
Modifies the date_parameters_list and returns true if hyphens are replaced, else returns false.
]]
local function date_hyphen_to_dash (date_parameters_list)
local result = false;
local n;
for param_name, param_val in pairs(date_parameters_list) do -- for each date-holding parameter in the list
if is_set (param_val.val) and
not mw.ustring.match (param_val.val, patterns.ymd[1]) then -- for those that are not ymd dates (ustring because here digits may not be Western)
param_val.val, n = param_val.val:gsub ('%-', '–'); -- replace any hyphen with ndash
if 0 ~= n then
date_parameters_list[param_name].val = param_val.val; -- update the list
result = true;
end
end
end
return result; -- so we know if any hyphens were replaced
end
--[[-------------------------< D A T E _ N A M E _ X L A T E >------------------------------------------------
Attempts to translate English date names to local-language date names using names supplied by MediaWiki's
date parser function. This is simple name-for-name replacement and may not work for all languages.
if xlat_dig is true, this function will also translate Western (English) digits to the local language's digits.
This will also translate ymd dates.
]]
local function date_name_xlate (date_parameters_list, xlt_dig)
local xlate;
local mode; -- long or short month names
local modified = false;
local date;
local sources_t = {
{cfg.date_names.en.long, cfg.date_names.inv_local_long}, -- for translating long English month names to long local month names
{cfg.date_names.en.short, cfg.date_names.inv_local_short}, -- short month names
{cfg.date_names.en.quarter, cfg.date_names.inv_local_quarter}, -- quarter date names
{cfg.date_names.en.season, cfg.date_names.inv_local_season}, -- season date nam
{cfg.date_names.en.named, cfg.date_names.inv_local_named}, -- named dates
}
local function is_xlateable (month) -- local function to get local date name that replaces existing English-language date name
for _, date_names_t in ipairs (sources_t) do -- for each sequence table in date_names_t
if date_names_t[1][month] then -- if date name is English month (long or short), quarter, season or named and
if date_names_t[2][date_names_t[1][month]] then -- if there is a matching local date name
return date_names_t[2][date_names_t[1][month]]; -- return the local date name
end
end
end
end
for param_name, param_val in pairs(date_parameters_list) do -- for each date-holding parameter in the list
if is_set(param_val.val) then -- if the parameter has a value
date = param_val.val;
for month in mw.ustring.gmatch (date, '[%a ]+') do -- iterate through all date names in the date (single date or date range)
month = mw.text.trim (month); -- this because quarterly dates contain whitespace
xlate = is_xlateable (month); -- get translate <month>; returns translation or nil
-- if cfg.date_names.en.long[month] then -- long month dates
-- if cfg.date_names.inv_local_long[cfg.date_names.en.long[month]] then
-- xlate = cfg.date_names.inv_local_long[cfg.date_names.en.long[month]];
-- end
---- mode = 'F'; -- English name is long so use long local name
-- elseif cfg.date_names.en.short[month] then -- short month dates
-- if cfg.date_names.inv_local_short[cfg.date_names.en.short[month]] then
-- xlate = cfg.date_names.inv_local_short[cfg.date_names.en.short[month]];
-- end
---- mode = 'M'; -- English name is short so use short local name
-- elseif cfg.date_names.en.quarter[month] then -- quarter dates
-- if cfg.date_names.inv_local_quarter[cfg.date_names.en.quarter[month]] then
-- xlate = cfg.date_names.inv_local_quarter[cfg.date_names.en.quarter[month]];
-- end
-- elseif cfg.date_names.en.season[month] then -- season dates
-- if cfg.date_names.inv_local_season[cfg.date_names.en.season[month]] then
-- xlate = cfg.date_names.inv_local_season[cfg.date_names.en.season[month]];
-- end
-- elseif cfg.date_names.en.named[month] then -- named dates
-- if cfg.date_names.inv_local_named[cfg.date_names.en.named[month]] then
-- xlate = cfg.date_names.inv_local_named[cfg.date_names.en.named[month]];
-- end
-- else
-- xlate=nil; -- not an English month name; could be local language month name
---- mode = nil; -- not an English month name; could be local language month name or an English season name
-- end
if xlate then
-- if mode then -- might be a season
-- xlate = lang_object:formatDate(mode, '1' .. month); -- translate the month name to this local language
date = mw.ustring.gsub (date, month, xlate); -- replace the English with the translation
date_parameters_list[param_name].val = date; -- save the translated date
modified = true;
end
end
if xlt_dig then -- shall we also translate digits?
date = date:gsub ('%d', cfg.date_names.xlate_digits); -- translate digits from Western to 'local digits'
date_parameters_list[param_name].val = date; -- save the translated date
modified = true;
end
end
end
return modified;
end
--[[--------------------------< S E T _ S E L E C T E D _ M O D U L E S >--------------------------------------
Sets local imported functions table to same (live or sandbox) as that used by the other modules.
]]
local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
add_prop_cat = utilities_page_ptr.add_prop_cat ; -- import functions from selected Module:Citation/CS1/Utilities module
is_set = utilities_page_ptr.is_set;
in_array = utilities_page_ptr.in_array;
set_message = utilities_page_ptr.set_message;
substitute = utilities_page_ptr.substitute;
wrap_style = utilities_page_ptr.wrap_style;
cfg = cfg_table_ptr; -- import tables from selected Module:Citation/CS1/Configuration
end
--[[--------------------------< E X P O R T E D F U N C T I O N S >------------------------------------------
]]
return { -- return exported functions
dates = dates,
year_date_check = year_date_check,
reformat_dates = reformat_dates,
date_hyphen_to_dash = date_hyphen_to_dash,
date_name_xlate = date_name_xlate,
set_selected_modules = set_selected_modules
}
obboarlfkmx4zbge5gqjllttddlxljn
189421
189403
2022-08-16T14:49:35Z
Venise12mai1834
8884
Scribunto
text/plain
local p = {}
-- returns a number according to the month in a date: 1 for January, etc. Capitalization and spelling must be correct. If not a valid month, returns 0
function get_month_number (month)
local long_months = {['January']=1, ['February']=2, ['March']=3, ['April']=4, ['May']=5, ['June']=6, ['July']=7, ['August']=8, ['September']=9, ['October']=10, ['November']=11, ['December']=12};
local short_months = {['Jan']=1, ['Feb']=2, ['Mar']=3, ['Apr']=4, ['May']=5, ['Jun']=6, ['Jul']=7, ['Aug']=8, ['Sep']=9, ['Oct']=10, ['Nov']=11, ['Dec']=12};
local temp;
temp=long_months[month];
if temp then return temp; end -- if month is the long-form name
temp=short_months[month];
if temp then return temp; end -- if month is the short-form name
return 0; -- misspelled, improper case, or not a month name
end
-- returns a number according to the sequence of seasons in a year: 1 for Winter, etc. Capitalization and spelling must be correct. If not a valid season, returns 0
function get_season_number (season)
local season_list = {['Winter']=1, ['Spring']=2, ['Summer']=3, ['Fall']=4, ['Autumn']=4}
local temp;
temp=season_list[season];
if temp then return temp; end -- if season is a valid name return its number
return 0; -- misspelled, improper case, or not a season name
end
--returns true if month or season is valid (properly spelled, capitalized, abbreviated)
function is_valid_month_or_season (month_season)
if 0 == get_month_number (month_season) then -- if month text isn't one of the twelve months, might be a season
if 0 == get_season_number (month_season) then -- not a month, is it a season?
return false; -- return false not a month or one of the five seasons
end
end
return true;
end
--[[--------------------------< I S _ V A L I D _ Y E A R >----------------------------------------------------
Function gets current year from the server and compares it to year from a citation parameter. Years more than one year in the future are not acceptable.
]]
function is_valid_year(year)
if not is_set(year_limit) then
year_limit = tonumber(os.date("%Y"))+1; -- global variable so we only have to fetch it once
end
return tonumber(year) <= year_limit; -- false if year is in the future more than one year
end
--[[
Returns true if day is less than or equal to the number of days in month and year is no farther into the future than next year; else returns false.
Assumes Julian calendar prior to year 1582 and Gregorian calendar thereafter. Accounts for Julian calendar leap years before 1582 and Gregorian leap years after 1582.
Where the two calendars overlap (1582 to approximately 1923) dates are assumed to be Gregorian.
]]
function is_valid_date (year, month, day)
local days_in_month = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
local month_length;
if not is_valid_year(year) then -- no farther into the future than next year
return false;
end
if (2==month) then -- if February
month_length = 28; -- then 28 days unless
if 1582 > tonumber(year) then -- Julian calendar
if 0==(year%4) then
month_length = 29;
end
else -- Gregorian calendar
if (0==(year%4) and (0~=(year%100) or 0==(year%400))) then -- is a leap year?
month_length = 29; -- if leap year then 29 days in February
end
end
else
month_length=days_in_month[month];
end
if tonumber (day) > month_length then
return false;
end
return true;
end
--[[
Check a pair of months or seasons to see if both are valid members of a month or season pair.
Month pairs are expected to be left to right, earliest to latest in time. Similarly, seasons are also left to right, earliest to latest in time. There is
an oddity with seasons. Winter is assigned a value of 1, spring 2, ..., fall and autumn 4. Because winter can follow fall/autumn at the end of a calender year, a special test
is made to see if |date=Fall-Winter yyyy (4-1) is the date.
]]
function is_valid_month_season_range(range_start, range_end)
local range_start_number = get_month_number (range_start);
if 0 == range_start_number then -- is this a month range?
local range_start_number = get_season_number (range_start); -- not a month; is it a season? get start season number
local range_end_number = get_season_number (range_end); -- get end season number
if 0 ~= range_start_number then -- is start of range a season?
if range_start_number < range_end_number then -- range_start is a season
return true; -- return true when range_end is also a season and follows start season; else false
end
if 4 == range_start_number and 1 == range_end_number then -- special case when range is Fall-Winter or Autumn-Winter
return true;
end
end
return false; -- range_start is not a month or a season; or range_start is a season and range_end is not; or improper season sequence
end
local range_end_number = get_month_number (range_end); -- get end month number
if range_start_number < range_end_number then -- range_start is a month; does range_start precede range_end?
return true; -- if yes, return true
end
return false; -- range_start month number is greater than or equal to range end number; or range end isn't a month
end
--[[
Check date format to see that it is one of the formats approved by WP:DATESNO or WP:DATERANGE. Exception: only allowed range separator is endash.
Additionally, check the date to see that it is a real date: no 31 in 30-day months; no 29 February when not a leap year. Months, both long-form and three
character abbreviations, and seasons must be spelled correctly. Future years beyond next year are not allowed.
If the date fails the format tests, this function returns false and does not return values for anchor_year and COinS_date. When this happens, the date parameter is
used in the COinS metadata and the CITEREF identifier gets its year from the year parameter if present otherwise CITEREF does not get a date value.
Inputs:
date_string - date string from date-holding parameters (date, year, accessdate, embargo, archivedate, etc.)
Returns:
false if date string is not a real date; else
true, anchor_year, COinS_date
anchor_year can be used in CITEREF anchors
COinS_date is date_string without anchor_year disambiguator if any
]]
function check_date (date_string)
local year; -- assume that year2, months, and days are not used;
local year2=0; -- second year in a year range
local month=0;
local month2=0; -- second month in a month range
local day=0;
local day2=0; -- second day in a day range
local anchor_year;
local coins_date;
if date_string:match("^%d%d%d%d%-%d%d%-%d%d$") then -- year-initial numerical year month day format
year, month, day=string.match(date_string, "(%d%d%d%d)%-(%d%d)%-(%d%d)");
month=tonumber(month);
if 12 < month or 1 > month or 1583 > tonumber(year) then return false; end -- month number not valid or not Gregorian calendar
anchor_year = year;
elseif date_string:match("^%a+ +[1-9]%d?, +[1-9]%d%d%d%a?$") then -- month-initial: month day, year
month, day, anchor_year, year=string.match(date_string, "(%a+)%s*(%d%d?),%s*((%d%d%d%d)%a?)");
month = get_month_number (month);
if 0 == month then return false; end -- return false if month text isn't one of the twelve months
elseif date_string:match("^%a+ +[1-9]%d?–[1-9]%d?, +[1-9]%d%d%d%a?$") then -- month-initial day range: month day–day, year; days are separated by endash
month, day, day2, anchor_year, year=string.match(date_string, "(%a+) +(%d%d?)–(%d%d?), +((%d%d%d%d)%a?)");
if tonumber(day) >= tonumber(day2) then return false; end -- date range order is left to right: earlier to later; dates may not be the same;
month = get_month_number (month);
if 0 == month then return false; end -- return false if month text isn't one of the twelve months
elseif date_string:match("^[1-9]%d? +%a+ +[1-9]%d%d%d%a?$") then -- day-initial: day month year
day, month, anchor_year, year=string.match(date_string, "(%d%d*)%s*(%a+)%s*((%d%d%d%d)%a?)");
month = get_month_number (month);
if 0 == month then return false; end -- return false if month text isn't one of the twelve months
elseif date_string:match("^[1-9]%d?–[1-9]%d? +%a+ +[1-9]%d%d%d%a?$") then -- day-range-initial: day–day month year; days are separated by endash
day, day2, month, anchor_year, year=string.match(date_string, "(%d%d?)–(%d%d?) +(%a+) +((%d%d%d%d)%a?)");
if tonumber(day) >= tonumber(day2) then return false; end -- date range order is left to right: earlier to later; dates may not be the same;
month = get_month_number (month);
if 0 == month then return false; end -- return false if month text isn't one of the twelve months
elseif date_string:match("^[1-9]%d? +%a+ – [1-9]%d? +%a+ +[1-9]%d%d%d%a?$") then -- day initial month-day-range: day month - day month year; uses spaced endash
day, month, day2, month2, anchor_year, year=date_string:match("(%d%d?) +(%a+) – (%d%d?) +(%a+) +((%d%d%d%d)%a?)");
if (not is_valid_month_season_range(month, month2)) or not is_valid_year(year) then return false; end -- date range order is left to right: earlier to later;
month = get_month_number (month);
month2 = get_month_number (month2);
elseif date_string:match("^%a+ +[1-9]%d? – %a+ +[1-9]%d?, +[1-9]%d%d%d?%a?$") then -- month initial month-day-range: month day – month day, year; uses spaced endash
month, day, month2, day2, anchor_year, year=date_string:match("(%a+) +(%d%d?) – (%a+) +(%d%d?), +((%d%d%d%d)%a?)");
if (not is_valid_month_season_range(month, month2)) or not is_valid_year(year) then return false; end
month = get_month_number (month);
month2 = get_month_number (month2);
elseif date_string:match("^[1-9]%d? +%a+ +[1-9]%d%d%d – [1-9]%d? +%a+ +[1-9]%d%d%d%a?$") then -- day initial month-day-year-range: day month year - day month year; uses spaced endash
day, month, year, day2, month2, anchor_year, year2=date_string:match("(%d%d?) +(%a+) +(%d%d%d%d?) – (%d%d?) +(%a+) +((%d%d%d%d?)%a?)");
if tonumber(year2) <= tonumber(year) then return false; end -- must be sequential years, left to right, earlier to later
if not is_valid_year(year2) then return false; end -- year2 no more than one year in the future
month = get_month_number (month);
month2 = get_month_number (month2);
elseif date_string:match("^%a+ +[1-9]%d?, +[1-9]%d%d%d – %a+ +[1-9]%d?, +[1-9]%d%d%d%a?$") then -- month initial month-day-year-range: month day, year – month day, year; uses spaced endash
month, day, year, month2, day2, anchor_year, year2=date_string:match("(%a+) +(%d%d?), +(%d%d%d%d) – (%a+) +(%d%d?), +((%d%d%d%d)%a?)");
if tonumber(year2) <= tonumber(year) then return false; end -- must be sequential years, left to right, earlier to later
if not is_valid_year(year2) then return false; end -- year2 no more than one year in the future
month = get_month_number (month);
month2 = get_month_number (month2);
elseif date_string:match("^%a+ +[1-9]%d%d%d–%d%d%a?$") then -- special case Winter/Summer year-year (YYYY-YY); year separated with unspaced endash
if nil == date_string:match("^Winter") and nil == date_string:match("^Summer") then return false end; -- 'month' can only be Winter or Summer
local century;
year, century, anchor_year, year2=date_string:match("%a+ +((%d%d)%d%d)–((%d%d)%a?)");
anchor_year=year..'–'..anchor_year; -- assemble anchor_year from both years
year2 = century..year2; -- add the century to year2 for comparisons
if 1 ~= tonumber(year2) - tonumber(year) then return false; end -- must be sequential years, left to right, earlier to later
if not is_valid_year(year2) then return false; end -- no year farther in the future than next year
elseif date_string:match("^%a+ +[1-9]%d%d%d–[1-9]%d%d%d%a?$") then -- special case Winter/Summer year-year; year separated with unspaced endash
if nil == date_string:match("^Winter") and nil == date_string:match("^Summer") then return false end; -- 'month' can only be Winter or Summer
year, anchor_year, year2=date_string:match("%a+ +(%d%d%d%d)–((%d%d%d%d)%a?)");
anchor_year=year..'–'..anchor_year; -- assemble anchor_year from both years
if 1 ~= tonumber(year2) - tonumber(year) then return false; end -- must be sequential years, left to right, earlier to later
if not is_valid_year(year2) then return false; end -- no year farther in the future than next year
elseif date_string:match("^%a+ +[1-9]%d%d%d% – %a+ +[1-9]%d%d%d%a?$") then -- month/season year - month/season year; separated by spaced endash
month, year, month2, anchor_year, year2=date_string:match("(%a+) +(%d%d%d%d) – (%a+) +((%d%d%d%d)%a?)");
anchor_year=year..'–'..anchor_year; -- assemble anchor_year from both years
if tonumber(year) >= tonumber(year2) then return false; end -- left to right, earlier to later, not the same
if not is_valid_year(year2) then return false; end -- no year farther in the future than next year
if not((0 ~= get_month_number(month) and 0 ~= get_month_number(month2)) or -- both must be month year or season year, not mixed
(0 ~= get_season_number(month) and 0 ~= get_season_number(month2))) then return false; end
elseif date_string:match ("^%a+–%a+ +[1-9]%d%d%d%a?$") then -- month/season range year; months separated by endash
month, month2, anchor_year, year=date_string:match ("(%a+)–(%a+)%s*((%d%d%d%d)%a?)");
if (not is_valid_month_season_range(month, month2)) or (not is_valid_year(year)) then
return false;
end
elseif date_string:match("^%a+ +%d%d%d%d%a?$") then -- month/season year
month, anchor_year, year=date_string:match("(%a+)%s*((%d%d%d%d)%a?)");
if not is_valid_year(year) then return false; end
if not is_valid_month_or_season (month) then return false; end
elseif date_string:match("^[1-9]%d%d%d?–[1-9]%d%d%d?%a?$") then -- Year range: YYY-YYY or YYY-YYYY or YYYY–YYYY; separated by unspaced endash; 100-9999
year, anchor_year, year2=date_string:match("(%d%d%d%d?)–((%d%d%d%d?)%a?)");
anchor_year=year..'–'..anchor_year; -- assemble anchor year from both years
if tonumber(year) >= tonumber(year2) then return false; end -- left to right, earlier to later, not the same
if not is_valid_year(year2) then return false; end -- no year farther in the future than next year
elseif date_string:match("^[1-9]%d%d%d–%d%d%a?$") then -- Year range: YYYY–YY; separated by unspaced endash
local century;
year, century, anchor_year, year2=date_string:match("((%d%d)%d%d)–((%d%d)%a?)");
anchor_year=year..'–'..anchor_year; -- assemble anchor year from both years
if 13 > tonumber(year2) then return false; end -- don't allow 2003-05 which might be May 2003
year2 = century..year2; -- add the century to year2 for comparisons
if tonumber(year) >= tonumber(year2) then return false; end -- left to right, earlier to later, not the same
if not is_valid_year(year2) then return false; end -- no year farther in the future than next year
elseif date_string:match("^[1-9]%d%d%d?%a?$") then -- year; here accept either YYY or YYYY
anchor_year, year=date_string:match("((%d%d%d%d?)%a?)");
if false == is_valid_year(year) then
return false;
end
else
return false; -- date format not one of the MOS:DATE approved formats
end
local result=true; -- check whole dates for validity; assume true because not all dates will go through this test
if 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 == month2 and 0 == day2 then -- YMD (simple whole date)
result=is_valid_date(year,month,day);
elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 == month2 and 0 ~= day2 then -- YMD-d (day range)
result=is_valid_date(year,month,day);
result=result and is_valid_date(year,month,day2);
elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 ~= month2 and 0 ~= day2 then -- YMD-md (day month range)
result=is_valid_date(year,month,day);
result=result and is_valid_date(year,month2,day2);
elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 ~= year2 and 0 ~= month2 and 0 ~= day2 then -- YMD-ymd (day month year range)
result=is_valid_date(year,month,day);
result=result and is_valid_date(year2,month2,day2);
end
if false == result then return false; end
-- if here, then date_string is valid; get coins_date from date_string (leave CITEREF disambiguator) ...
coins_date=date_string:match("^(.+%d)%a?$"); -- last character of valid disambiguatable date is always a digit
coins_date= mw.ustring.gsub(coins_date, "–", "-" ); -- ... and replace any ndash with a hyphen
return true, anchor_year, coins_date; -- format is good and date string represents a real date
end
--[[--------------------------< D A T E S >--------------------------------------------------------------------
Cycle the date-holding parameters in passed table date_parameters_list through check_date() to check compliance with MOS:DATE. For all valid dates, check_date() returns
true. The |date= parameter test is unique, it is the only date holding parameter from which values for anchor_year (used in CITEREF identifiers) and COinS_date (used in
the COinS metadata) are derived. The |date= parameter is the only date-holding parameter that is allowed to contain the no-date keywords "n.d." or "nd" (without quotes).
Unlike most error messages created in this module, only one error message is created by this function. Because all of the date holding parameters are processed serially,
a single error message is created as the dates are tested.
]]
function p.dates(date_parameters_list)
local anchor_year; -- will return as nil if the date being tested is not |date=
local COinS_date; -- will return as nil if the date being tested is not |date=
local error_message ="";
local good_date=false;
for k, v in pairs(date_parameters_list) do -- for each date-holding parameter in the list
if is_set(v) then -- if the parameter has a value
if v:match("^c%. [1-9]%d%d%d?%a?$") then -- special case for c. year or with or without CITEREF disambiguator - only |date= and |year=
local year = v:match("c%. ([1-9]%d%d%d?)%a?"); -- get the year portion so it can be tested
if 'date'==k then
anchor_year, COinS_date = v:match("((c%. [1-9]%d%d%d?)%a?)"); -- anchor year and COinS_date only from |date= parameter
good_date = is_valid_year(year);
elseif 'year'==k then
good_date = is_valid_year(year);
end
elseif 'date'==k then -- if the parameter is |date=
if v:match("^n%.d%.%a?") then -- if |date=n.d. with or without a CITEREF disambiguator
good_date, anchor_year, COinS_date = true, v:match("((n%.d%.)%a?)"); --"n.d."; no error when date parameter is set to no date
elseif v:match("^nd%a?$") then -- if |date=nd with or without a CITEREF disambiguator
good_date, anchor_year, COinS_date = true, v:match("((nd)%a?)"); --"nd"; no error when date parameter is set to no date
else
good_date, anchor_year, COinS_date = check_date (v); -- go test the date
end
else -- any other date-holding parameter
good_date = check_date (v); -- go test the date
end
if false==good_date then -- assemble one error message so we don't add the tracking category multiple times
if is_set(error_message) then -- once we've added the first portion of the error message ...
error_message=error_message .. ", "; -- ... add a comma space separator
end
error_message=error_message .. "|" .. k .. "="; -- add the failed parameter
end
end
end
return anchor_year, COinS_date, error_message; -- and done
end
return p;
q07f5ywg7wdwcj2xfvzzp6zwc4a77lh
หมวดหมู่:งานที่ต้นฉบับเป็นภาษาอังกฤษ
14
39377
189445
117022
2022-08-16T15:38:22Z
Venise12mai1834
8884
wikitext
text/x-wiki
[[หมวดหมู่:งานแปลแบ่งตามภาษาต้นฉบับ|อังกฤษ]]
[[หมวดหมู่:ภาษาอังกฤษ]]
c4n0c5j2i7am0k4tgxscedi70j3ptmk
หมวดหมู่:งานที่ต้นฉบับเป็นภาษาเขมร
14
39379
189440
117024
2022-08-16T15:36:32Z
Venise12mai1834
8884
wikitext
text/x-wiki
[[หมวดหมู่:งานแปลแบ่งตามภาษาต้นฉบับ|เขมร]]
[[หมวดหมู่:ภาษาเขมร]]
j8yns0mol7mf0ziq37sgfjahvvlf2nt
หมวดหมู่:งานที่ต้นฉบับเป็นภาษาพม่า
14
39380
189446
117027
2022-08-16T15:38:28Z
Venise12mai1834
8884
wikitext
text/x-wiki
[[หมวดหมู่:งานแปลแบ่งตามภาษาต้นฉบับ|พม่า]]
[[หมวดหมู่:ภาษาพม่า]]
6q8bpoxj3chdr9htdzuio64wg6gxtku
หมวดหมู่:งานที่ต้นฉบับเป็นภาษาบาลี
14
39381
189442
117032
2022-08-16T15:36:43Z
Venise12mai1834
8884
wikitext
text/x-wiki
[[หมวดหมู่:งานแปลแบ่งตามภาษาต้นฉบับ|บาลี]]
[[หมวดหมู่:ภาษาบาลี]]
1fkd7b1jn0qa2dvyblvmua69rrqa9ur
หมวดหมู่:งานที่ต้นฉบับเป็นภาษาอาหรับ
14
40059
189444
120537
2022-08-16T15:38:03Z
Venise12mai1834
8884
wikitext
text/x-wiki
[[หมวดหมู่:งานแปลแบ่งตามภาษาต้นฉบับ|อาหรับ]]
[[หมวดหมู่:ภาษาอาหรับ]]
ce7s5lco6zk1zcgvhssd8iev5mrl10h
หมวดหมู่:งานที่ต้นฉบับเป็นภาษาอิตาลี
14
40295
189443
122040
2022-08-16T15:37:44Z
Venise12mai1834
8884
wikitext
text/x-wiki
[[หมวดหมู่:งานแปลแบ่งตามภาษาต้นฉบับ|อิตาลี]]
[[หมวดหมู่:ภาษาอิตาลี]]
4aphcg9qjr6c40oinhzoigxu47ek8l9
หน้า:2482-278 (Ministry of Finance v. Prajadhipok & Rambai Barni).pdf/3
250
41837
189499
167698
2022-08-17T08:40:01Z
Venise12mai1834
8884
proofread-page
text/x-wiki
<noinclude><pagequality level="3" user="Bitterschoko" />{{หว|๔||ข่าวโฆษณาการ}}{{สต}}</noinclude>โดยอ้างเหตุว่า เมื่อวันที่ ๑๑ กรกฎาคม พ.ศ. ๒๔๘๒ จำเลยที่ ๑ ได้โอนขายที่ดินโฉนดที่ ๕๕๓๒ ของจำเลยที่ ๑ ให้แก่หม่อมเจ้ารัตยากรวิสุทธิ์ไปเป็นเงิน ๕,๐๐๐ บาท และในวันที่ ๑๒ เดือนเดียวกัน จำเลยที่ ๑ ได้ให้ผู้แทนมาขอต่อเจ้าพนักงานทะเบียนที่ดินและโลหะกิจ จังหวัดพระนครและธนบุรี เพื่อทำนีติกรรมโอนขายที่ดินอีก ๘ แปลง ตามบัญชีท้ายคำร้อง ให้แก่หม่อมเจ้ากมลีสาณ ชุมพล เป็นราคา ๑๒๘,๓๒๐ บาท การกระทำของจำเลยที่ ๑ ดั่งกล่าวนี้ เป็นการที่จำเลยตั้งใจจะโอนขายทรัพย์สินของจำเลยไปให้พ้นอำนาจศาลซึ่งอาจจะออกบังคับเอาแก่จำเลย และเพื่อฉ้อโกงโจทก์ และนอกจากนั้น ตัวจำเลยอยู่นอกอำนาจศาลด้วย
ศาลแพ่งได้ไต่สวนคำร้องฉะบับนี้แล้วมีคำสั่งให้ยกเสีย
โจทก์อุทธรณ์ต่อมา
คณะผู้พิพากษาศาลอุทธรณ์ได้ตรวจสำนวนและประชุมปรึกษาแล้ว
ตามประมวลกฎหมายวิธีพิจารณาความแพ่ง มาตรา ๒๕๕ การที่ศาลจะอนุญาตตามคำขอของโจทก์ ศาลจะต้องพอใจจากพะยานที่โจทก์นำมาสืบหรือที่ศาลได้เรียกมาสืบว่า
(๑){{ชว|1em}}คำฟ้องที่ผู้ขอยื่นและในโอกาสที่ยื่นคำขอนั้นมีเหตุสมควร และ
(๒){{ชว|1em}}มีเหตุเพียงพอที่จะนำวิธีคุ้มครองตามที่ขอนั้นมาใช้ได้ กล่าวคือ
{{ชว}}(ก){{ชว|1em}}จำเลยตั้งใจจะโอนขายหรือจำหน่ายทรัพย์สินของตนเสียทั้งหมดหรือแต่บางส่วน หรือยักย้ายไปเสียให้พ้นจากอำนาจศาล เพื่อประวิงหรือขัดขวางต่อการบังคับตามคำบังคับอย่างใดซึ่งอาจจะออกบังคับเอาแก่จำเลย หรือเพื่อจะฉ้อโกงโจทก์ หรือ
{{ชว}}(ข){{ชว|1em}}มีเหตุอื่นใดในการยึดหรืออายัดทรัพย์สินนั้น ตามที่ศาลจะพิเคราะห์เห็นเป็นการยุติธรรมและสมควร
ในข้อ (๑) นั้น โจทก์ได้นำหลวงกาจสงคราม ซึ่งได้รับแต่งตั้งให้เป็นประธานในคณะกรรมการตรวจรับทรัพย์สินพระมหากษัตริย์เมื่อประมาณ ๕ เดือนมานี้ และหลวงดำริอิศรานุวรรต ซึ่งเป็นกรรมการร่วมอยู่ในขณะนี้ และเป็นประธานกรรมการตรวจเงินแผ่นดิน มีหน้าที่ตรวจบัญชีของสำนักงานพระคลังข้างที่ มาเบิกความเป็นพะยาน ได้ความว่า ในการตรวจรับทรัพย์สินพระมหากษัตริย์ ปรากฏตามบัญชีว่า จำเลยได้โอนทรัพย์สินฝ่ายพระมหากษัตริย์เป็นทรัพย์สินส่วนตัวของจำเลยเป็นจำนวนดั่งที่โจทก์กล่าวไว้ในฟ้อง การที่พะยานยืนยันว่า เป็นทรัพย์สินฝ่ายพระมหากษัตริย์ ก็โดยพะยานตรวจทราบจากบัญชีของสำนักงานพระคลังข้างที่ เพราะมีการแยกบัญชีไว้เป็น ๒ ประเภท คือ ประเภทหนึ่ง ทรัพย์สินฝ่ายพระมหากษัตริย์ อีกประเภทหนึ่ง ทรัพย์สินส่วนพระองค์ เงินที่จ่ายและโอนไปนั้นจ่ายและโอนไปจากบัญชีทรัพย์สินฝ่ายพระมหากษัตริย์ทั้งสิ้น
อนึ่ง หลวงกาจสงครามได้เบิกความด้วยว่า ได้ตรวจพบเอกสารซึ่งจำเลยที่ ๑ สั่งให้กรมพระกำแพงเพ็ชร์ฯ เสนอโครงการณ์ส่งเงินทรัพย์สินพระมหากษัตริย์ไปต่างประเทศ โครงการณ์ที่เสนอมานั้น<noinclude></noinclude><noinclude></noinclude>
egmxsxug9z5nq9v7neszhaox7p0renr
หมวดหมู่:งานที่ต้นฉบับเป็นภาษาฝรั่งเศส
14
43232
189447
135928
2022-08-16T15:38:50Z
Venise12mai1834
8884
wikitext
text/x-wiki
[[หมวดหมู่:งานแปลแบ่งตามภาษาต้นฉบับ|ฝรั่งเศส]]
[[หมวดหมู่:ภาษาฝรั่งเศส]]
knbbx2fq2qp28pnkbxnfig3yfhqahv8
งานแปล:กฎอัยการศึก ลงวันที่ 21 ตุลาคม ค.ศ. 1789
114
44052
189449
168333
2022-08-16T15:43:48Z
Venise12mai1834
8884
wikitext
text/x-wiki
{{หัวเรื่องงานแปล
| ชื่อ = {{PAGENAME}}
| ปี = 2332
| ภาษา = fr
| ต้นฉบับ = Loi du 21 octobre 1789 contre les attroupements, ou loi martiale
| ผู้สร้างสรรค์ = | เขียนทับผู้สร้างสรรค์ = โดย {{ลสย|สมัชชาแห่งชาติ (ประเทศฝรั่งเศส)|สมัชชาแห่งชาติ}}
| บรรณาธิการ =
| ส่วน =
| ผู้มีส่วนร่วม =
| ก่อนหน้า =
| ถัดไป =
| หมายเหตุ =
| สถานีย่อย = กฎอัยการศึก/กฎหมายฝรั่งเศส/การปฏิวัติฝรั่งเศส
}}
__NOTOC__
{{ตรคป
| {{ก|{{พญ|Déclaration du Roi}}}}
{{ก|Portant sanction d’un décret de l’Assemblée nationale, du 21 octobre 1789, pour l’établissement d’une loi martiale.}}
| {{ก|ประกาศของพระมหากษัตริย์}}
{{ก|พระราชทานพระราชานุมัติแก่กฤษฎีกาของสมัชชาแห่งชาติ ลงวันที่ 21 ตุลาคม 1789 สำหรับสถาปนากฎอัยการศึก}}
|ไม่ย่อหน้า =
}}
{{ตรคป
| Vu, par le Roi, le décret de l’Assemblée nationale, de ce jour, dont la teneur suit:
| กฤษฎีกาของสมัชชาแห่งชาติ ฉบับลงวันนี้ ที่พระมหากษัตริย์ทอดพระเนตรแล้ว มีเนื้อความตามนี้
}}
{{ตรคป
| ''Extrait du procès-verbal de l’Assemblée nationale, du 21 octobre 1789.''
| ''คัดมาจากบันทึกวาจาของสมัชชาแห่งชาติ ลงวันที่ 21 ตุลาคม 1789''
}}
{{คหน}}
{{ตรคป
| หัว = {{พญล|loi martiale contre les attroupements}}
| แปลหัว = กฎอัยการศึกต่อต้านการชุมนุม
| L’Assemblée nationale, considérant que la liberté affermit les empires, mais que la licence les détruit; que, loin d’être le droit de tout faire, la liberté n’existe que par l’obéissance aux lois; que si, dans les temps calmes, cette obeisance est suffisamment assurée par l’autorité publique ordinaire, il peut survenir des époques difficiles, où les peuples, agités par des causes souvent criminelles, deviennet l’instrument d’intrigues qu’ils ignorent; que ces temps de crise nécessitent momentanément des moyens extraordinaires pour maintenir la tranquillité publique et conserver les droits de tous, a décrété la présente loi martiale:
| ด้วยเห็นว่า เสรีภาพเป็นเครื่องเสริมสร้างความแข็งแกร่งให้แก่จักรวรรดิต่าง ๆ<ref>"จักรวรรดิ" ในที่นี้ อาจมีความหมายเพียง ประเทศหรือแว่นแคว้นโดยทั่ว ๆ ไป มากกว่าจะมีความหมายเจาะจงถึงดินแดนของจักรพรรดิ ดังที่ {{ลนน|cta|CNRTL (2012a)}} ว่า คำนาม "empire" สามารถหมายถึง ระบอบของจักรพรรดิ (régime...d’un empereur), รัฐ (État), กลุ่มรัฐ (ensemble d’États), รัฐที่มีความสำคัญบางประการ ไม่ว่าจะมีจักรพรรดิเป็นประมุขหรือไม่ (État d’une certaine importance ayant ou n’ayant pas d’empereur à sa tête) ฯลฯ</ref> แต่เสรีอย่างไร้ขอบเขต<ref>{{ลนน|ctb|CNRTL (2012b)}} ว่า คำนาม "licence" โดยทั่วไปหมายถึง การอนุญาต (permission) หรือใบอนุญาต (document écrit correspondant à une permission) และยังสามารถหมายถึง เสรีภาพ โดยเฉพาะเสรีภาพที่มากเกินไป (liberté que se donne quelqu’un; liberté généralement excessive que se donne une personne, parfois un groupe de personnes)</ref> จักทำลายจักรวรรดิทั้งหลาย เสรีภาพ ซึ่งเป็นคนละสิ่งกับสิทธิที่จะทำการใดก็ได้นั้น จะมีอยู่ได้ก็แต่โดยการเชื่อฟังกฎหมาย ถ้าในยามสงบ จะแน่ใจได้ว่ามีการเชื่อฟังดังกล่าวก็โดยใช้อำนาจสาธารณะตามปรกติ ครั้นผู้คนถูกปลุกระดมด้วยสาเหตุที่มักเป็นเรื่องผิดกฎหมายให้กลายเป็นเครื่องมือในแผนการที่ตนเองไม่สนใจรับรู้แล้วไซร้ ก็เป็นได้ที่จะเกิดยุคเข็ญ และในช่วงวิกฤติเช่นนี้ จำจะต้องมีวิธีการพิเศษเป็นการชั่วคราวเพื่อธำรงคงไว้ซึ่งความสงบสาธารณะและพิทักษ์รักษาซึ่งสิทธิของคนทั้งปวง สมัชชาแห่งชาติจึงตรากฎอัยการศึกนี้ขึ้นไว้
}}
{{ตรคป
| Article 1<sup>er</sup>. — Dans le cas où la tranquillité publique sera en péril, les officiers municipaux des lieux seront tenus, en vertu du pouvoir qu’ils ont reçu de la Commune, de déclarer que la force militaire doit être déployée à l’instant, pour rétablir l’ordre public, à peine, par ces officiers, d’être résponsables des suites de leur négligence.
| มาตราแรก ในกรณีที่ความสงบสุขสาธารณะตกอยู่ในอันตราย ให้เจ้าพนักงานเทศบาลมีพันธะที่จะต้องประกาศโดยอาศัยอำนาจซึ่งได้รับจากตำบลว่า ต้องใช้กำลังทหารทันทีเพื่อฟื้นฟูความเรียบร้อยสาธารณะ โดยที่เจ้าพนักงานเหล่านี้แทบไม่ต้องรับผิดชอบในผลที่ตามมาจากความประมาทของตน
}}
{{ตรคป
| II. — Cette déclaration se fera, en exposant à la principale fenêtre de la Maison de Ville et en portant dans toutes les rues et carrefours un drapeau rouge; et en même temps les officiers municipaux requerront les chefs des Gardes nationales, des troupes réglées et des maréchaussées, de prêter main-forte.
| 2. ประกาศเช่นนี้ให้กระทำด้วยการเผยธงแดงไว้ที่หน้าต่างบานหลักของศาลากลาง<ref>"Maison de ville" แปลตรงตัวว่า อาคารประจำเมือง ในปัจจุบันหมายถึง ทาวน์เฮาส์ (บ้านแถว) แต่ในสมัยโบราณหมายถึง ศาลากลาง หรือที่ว่าการเมือง {{ลนน|ctc|CNRTL (2012c)}} ว่า มีความหมายเหมือนกับ "hôtel de ville"</ref> และถือธงแดงไปตามถนนและทางแยกทุกสาย และขณะเดียวกัน ให้เจ้าพนักงานเทศบาลร้องขอต่อผู้บัญชาการองครักษ์แห่งชาติ กองทหารประจำการ และ ''มาเรโชเซ''<ref name = "mrcs">{{ลนน|ctd|CNRTL (2012d)}} ว่า คำนาม "maréchaussée" หมายถึง กองกำลังอัศวินที่รับผิดชอบการรักษาความเรียบร้อยและความมั่นคงสาธารณะในช่วงระบอบเก่า (corps de cavaliers chargé de maintenir l’ordre et la sécurité publique sous l’Ancien Régime)</ref> ให้ยื่นมือเข้าช่วย
}}
{{ตรคป
| III. — Au signal seul du drapeau rouge, tous attroupements, avec ou sans armes, deviendront criminels, et devront être dissipés par la force.
| 3. เมื่อมีสัญญาณธงแดงเพียงเท่านี้แล้ว การชุมนุมทั้งหมด จะมีอาวุธด้วยหรือไม่ก็ตาม ให้กลายเป็นความผิดอาญา และจะต้องถูกสลายโดยใช้กำลัง
}}
{{ตรคป
| IV. — Les Gardes nationales, troupes réglées et maréchaussées, requises par les officiers municipaux, seront tenues de marcher sur-le-champ, commandées par leurs officiers, précédées d’un drapeau rouge, et accompagnées d’un officier municipal au moins.
| 4. องครักษ์แห่งชาติ กองทหารประจำการ และ ''มาเรโชเซ''<ref name = "mrcs"/> ที่ได้รับการร้องขอจากเจ้าพนักงานเทศบาล ให้มีพันธะที่จะเคลื่อนพลโดยพลันภายใต้การบัญชาของเจ้าพนักงานของตน โดยให้มีธงแดงนำ และมีเจ้าพนักงานเทศบาลอย่างน้อยหนึ่งคนสมทบไปด้วย
}}
{{ตรคป
| V. — Il sera demandé, par un des officiers municipaux, aux personnes attroupées, quelle est la cause de leur réunion et le grief dont elles demandent le redressement. Elles seront autorisées à nommer six d’entre elles, pour exposer leur réclamation et présenter leur pétition, et tenues de se séparer sur-le-champ et de se retirer paisiblement.
| 5. ให้เจ้าพนักงานเทศบาลคนหนึ่งคนใดถามไปยังบุคคลที่ชุมนุมกันว่า สาเหตุที่มารวมตัวกันนั้นเป็นประการใด และความทุกข์ร้อนที่พวกตนเรียกร้องให้เยียวยานั้นเป็นประการใด ให้เขาเหล่านั้นมีอำนาจที่จะแต่งตั้งบุคคลหกคนจากกลุ่มพวกตนเข้ามาแถลงข้อกล่าวอ้างและเสนอคำร้อง และมีพันธะที่จะต้องแยกย้ายโดยไม่ชักช้าแล้วถอนตัวไปโดยสันติ
}}
{{ตรคป
| VI. — Faute par les personnes attroupées de se retirer en ce moment, il leur sera fait à haute voix, par les officiers municipaux ou l’un d’eux, trois sommations de se retirer tranquillement dans leur domicile. La première sommation sera exprimée en ces termes: « Avis est donné que la loi martiale est proclamée, que tous attroupements sont criminels; on va faire feu; que les bons citoyens se retirent. » A la deuxième et troisième sommation, il suffira de répéter ces mots: « On va faire feu; que les bons citoyens se retirent. » L’officier municipal énoncera que c’est ou la première, ou la seconde, ou la dernière.
| 6. หากบุคคลที่ชุมนุมกันนั้นไม่ถอนตัวไปในเวลาดังกล่าว ให้เจ้าพนักงานเทศบาลทั้งหลายหรือคนหนึ่งคนใดในบรรดาเจ้าพนักงานเทศบาลนั้นออกคำสั่งด้วยเสียงอันดังสามครั้งเพื่อให้ถอนตัวกลับภูมิลำเนาไปโดยราบรื่น คำสั่งครั้งแรกให้แสดงด้วยถ้อยคำดังนี้ "ขอแจ้งว่า ได้ประกาศกฎอัยการศึกแล้ว การชุมนุมทั้งหมดจึงเป็นความผิดอาญา เราจะยิง พลเมืองดีจงถอนตัวไป" ส่วนคำสั่งครั้งที่สองและสามนั้น ให้ทวนคำดังนี้ก็พอแล้ว "เราจะยิง พลเมืองดีจงถอนตัวไป" ให้เจ้าพนักงานเทศบาลประกาศด้วยว่า เป็นครั้งที่หนึ่ง หรือครั้งที่สอง หรือครั้งสุดท้าย
}}
{{ตรคป
| VII. — Dans le cas où, soit avant, soit pendant le prononcé des sommations, l’attroupement commettrait quelques violences, et pareillement dans le cas où, après les sommations faites, les personnes attroupées ne se retireraient pas paisiblement, la force des armes sera à l’instant déployée contre les séditieux, sans que personne soit responsable des évènements qui pourront en résulter.
| 7. ในกรณีที่การชุมนุมก่อความรุนแรงบางประการ ไม่ว่าก่อนหรือขณะประกาศคำสั่งก็ดี และเช่นเดียวกับในกรณีที่ได้มีคำสั่งแล้ว บุคคลที่ชุมนุมไม่ถอนตัวไปโดยสันติก็ดี ให้ใช้กองกำลังติดอาวุธต่อผู้จลาจลนั้นได้ทันที โดยไม่ต้องมีผู้ใดรับผิดชอบในเหตุทั้งหลายที่อาจเป็นผลสืบเนื่อง
}}
{{ตรคป
| VIII. — Dans le cas où le peuple attroupé, n’ayant fait aucune violence, se retirerait paisiblement, soit avant, soit immédiatement après la dernière sommation, les moteurs ou instigateurs de la sédition, s’ils sont connus, pourront seuls être poursuivis extraordinairement, et condamnés, savoir: à une prison de trois ans, si l’attroupement n’était pas armé, et à la peine de mort, si l’attroupement était en armes. Il ne sera fait aucune poursuite contre les autres.
| 8. ในกรณีที่ผู้ชุมนุมถอนตัวไปโดยสงบโดยมิได้กระทำความรุนแรงประการใด ไม่ว่าก่อนหรือทันทีที่ได้มีคำสั่งครั้งสุดท้าย เฉพาะผู้ยุยงหรือผู้ส่งเสริมให้เกิดการจลาจล ถ้าระบุตัวได้ จะถูกดำเนินคดีด้วยวิธีพิเศษ และจะต้องระวางโทษ กล่าวคือ จำคุกสามปี ถ้าการชุมนุมไม่มีอาวุธ และประหารชีวิต ถ้าการชุมนุมมีอาวุธ ส่วนคนอื่น ๆ ทั้งหลายนั้นจะไม่ถูกดำเนินคดี
}}
{{ตรคป
| IX. — Dans le cas où le peuple attroupé ferait quelques violences, ou ne se retirerait pas après la dernière sommation, ceux qui échapperont aux coups de la force militaire et qui pourront être arrêtés seront punis d’un emprisonnement d’un an, s’ils étaient sans armes; de trois ans, s’ils étaient armés; et de la peine de mort, s’ils étaient convaincus d’avoir commis des violences. Dans le cas du présent article, les moteurs et instigateurs de la sédition seront de même condamnés à mort.
| 9. ในกรณีที่ผู้ชุมนุมกระทำความรุนแรงบางประการ หรือไม่ถอนตัวไปหลังจากคำสั่งครั้งสุดท้าย บรรดาผู้ที่รอดพ้นจากการปราบปรามของกองกำลังทหาร และผู้ที่ถูกจับกุมได้ ต้องถูกลงโทษจำคุกหนึ่งปี ถ้าไม่มีอาวุธ สามปี ถ้ามีอาวุธ และประหารชีวิต ถ้าถูกพิพากษาว่าได้ก่อความรุนแรง ในกรณีตามมาตรานี้ ผู้ยุยงและผู้ส่งเสริมให้เกิดการจลาจล ต้องระวางโทษประหารชีวิตดุจเดียวกัน
}}
{{ตรคป
| X. — Tous chefs, officiers et soldats des Gardes nationales, des troupes et des maréchaussées qui exciteront et fomenteront des attroupements, émeutes et séditions, seront déclarés rebelles à la nation, au Roi et à la loi, et punis de mort; et ceux qui refuseront le service, à la réquisition des officiers municipaux, seront dégradés et punis de trois ans de prison.
| 10. ผู้บัญชาการ เจ้าพนักงาน และพลทหารทุกคนในองครักษ์แห่งชาติ กองทหาร และ ''มาเรโชเซ''<ref name = "mrcs"/> ที่กระตุ้นหรือยั่วยุให้เกิดการชุมนุม การลุกฮือ และการจลาจล จะถูกประกาศว่าเป็นกบฏต่อชาติ ต่อพระมหากษัตริย์ และต่อกฎหมาย และต้องถูกลงโทษประหารชีวิต ส่วนบรรดาผู้ไม่ยอมปฏิบัติการตามคำร้องขอของเจ้าพนักงานเทศบาล จะต้องถูกลดขั้นและถูกลงโทษจำคุกสามปี
}}
{{ตรคป
| XI. — Il sera dressé, par les officiers municipaux, procès-verbal, qui contiendra le récit des faits.
| 11. ให้เจ้าพนักงานเทศบาลจัดทำบันทึกวาจาโดยให้มีรายงานข้อเท็จจริง
}}
{{ตรคป
| XII. — Lorsque le calme sera rétabli, les officiers municipaux rendront un décret qui fera cesser la loi martiale, et le drapeau rouge sera retiré et remplacé, pendant huit jours, par un drapeau blanc.
| 12. เมื่อฟื้นฟูความสงบได้แล้ว ให้เจ้าพนักงานเทศบาลออกกฤษฎีกาซึ่งให้เลิกใช้กฎอัยการศึก และธงแดงนั้นให้ปลดลงแล้วแทนที่ด้วยธงขาวเป็นเวลาแปดวัน
}}
{{ตรคป
| ''Signé'': {{พญล|Fréteau}}, président; {{พญล|Alexandre de Lameth, Feydel, Bureau de Pusy}}, le marquis {{พญล|de Rostaing}}, secrétaires.
| ''ลงนาม'': เฟรโต, ประธาน;<ref>{{w|en:Emmanuel Marie Michel Philippe Fréteau de Saint-Just|แอมานุแอล มารี มีแชล ฟีลิป เฟรโต เดอ แซ็ง-ฌุสต์}} (Emmanuel Marie Michel Philippe Fréteau de Saint-Just) ประธานสมัชชาแห่งชาติ</ref> อาแล็กซ็องดร์ เดอ ลาแม็ต,<ref>{{w|en:Alexandre-Théodore-Victor, comte de Lameth|อาแล็กซ็องดร์-เตโอดอร์-วิกตอร์ กง เดอ ลาแม็ต}} (Alexandre-Théodore-Victor, comte de Lameth)</ref> เฟย์เดล,<ref>อาจหมายถึง กราบรีแยล เฟย์เดล (Gabriel Feydel)</ref> บูว์โร เดอ ปูว์ซี,<ref>{{w|en:Jean-Xavier Bureau de Pusy|ฌ็อง-ซาวีเยร์ บูว์โร เดอ ปูว์ซี}} (Jean-Xavier Bureau de Pusy)</ref> มาร์กี เดอ โรสแต็ง, เลขานุการ
}}
{{คั่นหน้า}}
{{ตรคป
| Le Roi a sanctionné et sanctionne le susdit décret, pour être exécuté dans tout son royaume. Mande et ordonne Sa Majesté, a tous les officiers municipaux, commandants de ses troupes, des troupes nationales, des maréchaussées et autres qu’il appartiendra, de la maintenir et observer, chancun en ce qui le concerne; et sera la présente Déclaration imprimée, publiée et affichée partout où besoin sera, et sur icelle expédié toutes lettres patentes nécessaires.
| พระมหากษัตริย์ทรงอนุมัติและได้ทรงอนุมัติแล้วซึ่งกฤษฎีกาข้างต้นเพื่อให้นำไปดำเนินการทั่วราชอาณาจักรของพระองค์ พระองค์มีพระราชโองการมานพระบัณฑูรมายังบรรดาผู้เป็นเจ้าพนักงานเทศบาล ผู้บังคับการกองทหารของพระองค์ กองทหารแห่งชาติ ''มาเรโชเซ''<ref name = "mrcs"/> และบุคคลอื่นทั้งหลายที่กฤษฎีกานี้จะได้เกี่ยวได้ข้อง ให้รักษาและปฏิบัติตามกฤษฎีกานี้ ตราบเท่าที่เกี่ยวข้องกับตน และประกาศอันนี้ ให้มีการพิมพ์ เผยแพร่ และปิดไว้ในทุกที่ที่ต้องมี และหนังสือตราตั้งอันจำเป็นสำหรับประกาศนี้ ให้มีการจัดส่งจงทุกฉบับไป
}}
{{ตรคป
| Fait à Paris, le vingt-un octobre mil sept cent quatre-vingt-neuf.
| กระทำ ณ ปารีส วันที่ยี่สิบเอ็ด ตุลาคม ปีพันเจ็ดร้อยแปดสิบเก้า
}}
{{ตรคป
| {{กข|{{รมมจ|''Signé'': {{พญล|Louis}}.|Et plus bas: {{พญล|de Saint-Priest}}.}}|center}}
| {{กข|{{รมมจ|''ลงพระนาม'': หลุยส์<ref>{{w|พระเจ้าหลุยส์ที่ 16}} (Louis XVI)</ref>|และลงนามรับสนอง: เดอ แซ็ง-พรีแย็สต์<ref>{{w|en:François-Emmanuel Guignard, comte de Saint-Priest|ฟร็องซัว-แอมานุแอล กีญาร์ กง เดอ แซ็ง-พรีแย็สต์}} (François-Emmanuel Guignard, comte de Saint-Priest)</ref>}}|center}}
|ไม่ย่อหน้า =
}}
==เชิงอรรถของวิกิซอร์ซ==
{{รกออ}}
==บรรณานุกรม==
===ต้นฉบับ===
{{เริ่มอ้างอิง}}
* {{อ้างหนังสือ|editor=Lacroix, S|year=1895|chapter=Du jeudi 22 octobre 1789, séance du matin|url=https://books.google.co.th/books?id=FqXNAAAAMAAJ|title=Actes de la Commune de Paris pendant la Révolution: Tome II|pp=385–386|location=Paris|publisher=Maison Quantin|language=fr}}
{{จบอ้างอิง}}
===อ้างอิง===
<div class="references-small" style="font-size:90%">
* {{ตรึง+|cta|CNRTL. (2012a)}}. Empire. ''Ortolang''. https://www.cnrtl.fr/definition/empire (In French).
* {{ตรึง+|ctb|CNRTL. (2012b)}}. Licence. ''Ortolang''. https://www.cnrtl.fr/definition/licence (In French).
* {{ตรึง+|ctc|CNRTL. (2012c)}}. Maison. ''Ortolang''. https://www.cnrtl.fr/definition/Maison (In French).
* {{ตรึง+|ctd|CNRTL. (2012d)}}. Maréchaussée. ''Ortolang''. https://www.cnrtl.fr/definition/maréchaussée (In French).
</div>
{{สัญญาอนุญาตงานแปล
| {{สาธารณสมบัติ-ฝรั่งเศส}}
| {{สาธารณสมบัติ-เอง}}
}}
[[หมวดหมู่:กฎหมายฝรั่งเศส]]
4h54xch7m9d1pmofitohvfb02yy4537
189462
189449
2022-08-16T16:09:21Z
Venise12mai1834
8884
wikitext
text/x-wiki
{{หัวเรื่องงานแปล
| ชื่อ = {{PAGENAME}}
| ปี = 2332
| ภาษา = fr
| ต้นฉบับ = Loi du 21 octobre 1789 contre les attroupements, ou loi martiale
| ผู้สร้างสรรค์ = | เขียนทับผู้สร้างสรรค์ = โดย {{ลสย|สมัชชาแห่งชาติ (ประเทศฝรั่งเศส)|สมัชชาแห่งชาติ}}
| บรรณาธิการ =
| ส่วน =
| ผู้มีส่วนร่วม =
| ก่อนหน้า =
| ถัดไป =
| หมายเหตุ =
| สถานีย่อย = กฎอัยการศึก/กฎหมายฝรั่งเศส/การปฏิวัติฝรั่งเศส
}}
__NOTOC__
{{ตรคป
| {{ก|{{พญ|Déclaration du Roi}}}}
{{ก|Portant sanction d’un décret de l’Assemblée nationale, du 21 octobre 1789, pour l’établissement d’une loi martiale.}}
| {{ก|ประกาศของพระมหากษัตริย์}}
{{ก|พระราชทานพระราชานุมัติแก่กฤษฎีกาของสมัชชาแห่งชาติ ลงวันที่ 21 ตุลาคม 1789 สำหรับสถาปนากฎอัยการศึก}}
|ไม่ย่อหน้า =
}}
{{ตรคป
| Vu, par le Roi, le décret de l’Assemblée nationale, de ce jour, dont la teneur suit:
| กฤษฎีกาของสมัชชาแห่งชาติ ฉบับลงวันนี้ ที่พระมหากษัตริย์ทอดพระเนตรแล้ว มีเนื้อความตามนี้
}}
{{ตรคป
| ''Extrait du procès-verbal de l’Assemblée nationale, du 21 octobre 1789.''
| ''คัดมาจากบันทึกวาจาของสมัชชาแห่งชาติ ลงวันที่ 21 ตุลาคม 1789''
}}
{{คหน}}
{{ตรคป
| หัว = {{พญล|loi martiale contre les attroupements}}
| แปลหัว = กฎอัยการศึกต่อต้านการชุมนุม
| L’Assemblée nationale, considérant que la liberté affermit les empires, mais que la licence les détruit; que, loin d’être le droit de tout faire, la liberté n’existe que par l’obéissance aux lois; que si, dans les temps calmes, cette obeisance est suffisamment assurée par l’autorité publique ordinaire, il peut survenir des époques difficiles, où les peuples, agités par des causes souvent criminelles, deviennet l’instrument d’intrigues qu’ils ignorent; que ces temps de crise nécessitent momentanément des moyens extraordinaires pour maintenir la tranquillité publique et conserver les droits de tous, a décrété la présente loi martiale:
| ด้วยเห็นว่า เสรีภาพเป็นเครื่องเสริมสร้างความแข็งแกร่งให้แก่จักรวรรดิต่าง ๆ<ref>"จักรวรรดิ" ในที่นี้ อาจมีความหมายเพียง ประเทศหรือแว่นแคว้นโดยทั่ว ๆ ไป มากกว่าจะมีความหมายเจาะจงถึงดินแดนของจักรพรรดิ ดังที่ {{ฮวอ|CNRTL|2012a}} ว่า คำนาม "empire" สามารถหมายถึง ระบอบของจักรพรรดิ (régime...d’un empereur), รัฐ (État), กลุ่มรัฐ (ensemble d’États), รัฐที่มีความสำคัญบางประการ ไม่ว่าจะมีจักรพรรดิเป็นประมุขหรือไม่ (État d’une certaine importance ayant ou n’ayant pas d’empereur à sa tête) ฯลฯ</ref> แต่เสรีอย่างไร้ขอบเขต<ref>{{ฮวอ|CNRTL|2012b}} ว่า คำนาม "licence" โดยทั่วไปหมายถึง การอนุญาต (permission) หรือใบอนุญาต (document écrit correspondant à une permission) และยังสามารถหมายถึง เสรีภาพ โดยเฉพาะเสรีภาพที่มากเกินไป (liberté que se donne quelqu’un; liberté généralement excessive que se donne une personne, parfois un groupe de personnes)</ref> จักทำลายจักรวรรดิทั้งหลาย เสรีภาพ ซึ่งเป็นคนละสิ่งกับสิทธิที่จะทำการใดก็ได้นั้น จะมีอยู่ได้ก็แต่โดยการเชื่อฟังกฎหมาย ถ้าในยามสงบ จะแน่ใจได้ว่ามีการเชื่อฟังดังกล่าวก็โดยใช้อำนาจสาธารณะตามปรกติ ครั้นผู้คนถูกปลุกระดมด้วยสาเหตุที่มักเป็นเรื่องผิดกฎหมายให้กลายเป็นเครื่องมือในแผนการที่ตนเองไม่สนใจรับรู้แล้วไซร้ ก็เป็นได้ที่จะเกิดยุคเข็ญ และในช่วงวิกฤติเช่นนี้ จำจะต้องมีวิธีการพิเศษเป็นการชั่วคราวเพื่อธำรงคงไว้ซึ่งความสงบสาธารณะและพิทักษ์รักษาซึ่งสิทธิของคนทั้งปวง สมัชชาแห่งชาติจึงตรากฎอัยการศึกนี้ขึ้นไว้
}}
{{ตรคป
| Article 1<sup>er</sup>. — Dans le cas où la tranquillité publique sera en péril, les officiers municipaux des lieux seront tenus, en vertu du pouvoir qu’ils ont reçu de la Commune, de déclarer que la force militaire doit être déployée à l’instant, pour rétablir l’ordre public, à peine, par ces officiers, d’être résponsables des suites de leur négligence.
| มาตราแรก ในกรณีที่ความสงบสุขสาธารณะตกอยู่ในอันตราย ให้เจ้าพนักงานเทศบาลมีพันธะที่จะต้องประกาศโดยอาศัยอำนาจซึ่งได้รับจากตำบลว่า ต้องใช้กำลังทหารทันทีเพื่อฟื้นฟูความเรียบร้อยสาธารณะ โดยที่เจ้าพนักงานเหล่านี้แทบไม่ต้องรับผิดชอบในผลที่ตามมาจากความประมาทของตน
}}
{{ตรคป
| II. — Cette déclaration se fera, en exposant à la principale fenêtre de la Maison de Ville et en portant dans toutes les rues et carrefours un drapeau rouge; et en même temps les officiers municipaux requerront les chefs des Gardes nationales, des troupes réglées et des maréchaussées, de prêter main-forte.
| 2. ประกาศเช่นนี้ให้กระทำด้วยการเผยธงแดงไว้ที่หน้าต่างบานหลักของศาลากลาง<ref>"Maison de ville" แปลตรงตัวว่า อาคารประจำเมือง ในปัจจุบันหมายถึง ทาวน์เฮาส์ (บ้านแถว) แต่ในสมัยโบราณหมายถึง ศาลากลาง หรือที่ว่าการเมือง {{ฮวอ|CNRTL|2012c}} ว่า มีความหมายเหมือนกับ "hôtel de ville"</ref> และถือธงแดงไปตามถนนและทางแยกทุกสาย และขณะเดียวกัน ให้เจ้าพนักงานเทศบาลร้องขอต่อผู้บัญชาการองครักษ์แห่งชาติ กองทหารประจำการ และ ''มาเรโชเซ''<ref name = "mrcs">{{ฮวอ|CNRTL|2012d}} ว่า คำนาม "maréchaussée" หมายถึง กองกำลังอัศวินที่รับผิดชอบการรักษาความเรียบร้อยและความมั่นคงสาธารณะในช่วงระบอบเก่า (corps de cavaliers chargé de maintenir l’ordre et la sécurité publique sous l’Ancien Régime)</ref> ให้ยื่นมือเข้าช่วย
}}
{{ตรคป
| III. — Au signal seul du drapeau rouge, tous attroupements, avec ou sans armes, deviendront criminels, et devront être dissipés par la force.
| 3. เมื่อมีสัญญาณธงแดงเพียงเท่านี้แล้ว การชุมนุมทั้งหมด จะมีอาวุธด้วยหรือไม่ก็ตาม ให้กลายเป็นความผิดอาญา และจะต้องถูกสลายโดยใช้กำลัง
}}
{{ตรคป
| IV. — Les Gardes nationales, troupes réglées et maréchaussées, requises par les officiers municipaux, seront tenues de marcher sur-le-champ, commandées par leurs officiers, précédées d’un drapeau rouge, et accompagnées d’un officier municipal au moins.
| 4. องครักษ์แห่งชาติ กองทหารประจำการ และ ''มาเรโชเซ''<ref name = "mrcs"/> ที่ได้รับการร้องขอจากเจ้าพนักงานเทศบาล ให้มีพันธะที่จะเคลื่อนพลโดยพลันภายใต้การบัญชาของเจ้าพนักงานของตน โดยให้มีธงแดงนำ และมีเจ้าพนักงานเทศบาลอย่างน้อยหนึ่งคนสมทบไปด้วย
}}
{{ตรคป
| V. — Il sera demandé, par un des officiers municipaux, aux personnes attroupées, quelle est la cause de leur réunion et le grief dont elles demandent le redressement. Elles seront autorisées à nommer six d’entre elles, pour exposer leur réclamation et présenter leur pétition, et tenues de se séparer sur-le-champ et de se retirer paisiblement.
| 5. ให้เจ้าพนักงานเทศบาลคนหนึ่งคนใดถามไปยังบุคคลที่ชุมนุมกันว่า สาเหตุที่มารวมตัวกันนั้นเป็นประการใด และความทุกข์ร้อนที่พวกตนเรียกร้องให้เยียวยานั้นเป็นประการใด ให้เขาเหล่านั้นมีอำนาจที่จะแต่งตั้งบุคคลหกคนจากกลุ่มพวกตนเข้ามาแถลงข้อกล่าวอ้างและเสนอคำร้อง และมีพันธะที่จะต้องแยกย้ายโดยไม่ชักช้าแล้วถอนตัวไปโดยสันติ
}}
{{ตรคป
| VI. — Faute par les personnes attroupées de se retirer en ce moment, il leur sera fait à haute voix, par les officiers municipaux ou l’un d’eux, trois sommations de se retirer tranquillement dans leur domicile. La première sommation sera exprimée en ces termes: « Avis est donné que la loi martiale est proclamée, que tous attroupements sont criminels; on va faire feu; que les bons citoyens se retirent. » A la deuxième et troisième sommation, il suffira de répéter ces mots: « On va faire feu; que les bons citoyens se retirent. » L’officier municipal énoncera que c’est ou la première, ou la seconde, ou la dernière.
| 6. หากบุคคลที่ชุมนุมกันนั้นไม่ถอนตัวไปในเวลาดังกล่าว ให้เจ้าพนักงานเทศบาลทั้งหลายหรือคนหนึ่งคนใดในบรรดาเจ้าพนักงานเทศบาลนั้นออกคำสั่งด้วยเสียงอันดังสามครั้งเพื่อให้ถอนตัวกลับภูมิลำเนาไปโดยราบรื่น คำสั่งครั้งแรกให้แสดงด้วยถ้อยคำดังนี้ "ขอแจ้งว่า ได้ประกาศกฎอัยการศึกแล้ว การชุมนุมทั้งหมดจึงเป็นความผิดอาญา เราจะยิง พลเมืองดีจงถอนตัวไป" ส่วนคำสั่งครั้งที่สองและสามนั้น ให้ทวนคำดังนี้ก็พอแล้ว "เราจะยิง พลเมืองดีจงถอนตัวไป" ให้เจ้าพนักงานเทศบาลประกาศด้วยว่า เป็นครั้งที่หนึ่ง หรือครั้งที่สอง หรือครั้งสุดท้าย
}}
{{ตรคป
| VII. — Dans le cas où, soit avant, soit pendant le prononcé des sommations, l’attroupement commettrait quelques violences, et pareillement dans le cas où, après les sommations faites, les personnes attroupées ne se retireraient pas paisiblement, la force des armes sera à l’instant déployée contre les séditieux, sans que personne soit responsable des évènements qui pourront en résulter.
| 7. ในกรณีที่การชุมนุมก่อความรุนแรงบางประการ ไม่ว่าก่อนหรือขณะประกาศคำสั่งก็ดี และเช่นเดียวกับในกรณีที่ได้มีคำสั่งแล้ว บุคคลที่ชุมนุมไม่ถอนตัวไปโดยสันติก็ดี ให้ใช้กองกำลังติดอาวุธต่อผู้จลาจลนั้นได้ทันที โดยไม่ต้องมีผู้ใดรับผิดชอบในเหตุทั้งหลายที่อาจเป็นผลสืบเนื่อง
}}
{{ตรคป
| VIII. — Dans le cas où le peuple attroupé, n’ayant fait aucune violence, se retirerait paisiblement, soit avant, soit immédiatement après la dernière sommation, les moteurs ou instigateurs de la sédition, s’ils sont connus, pourront seuls être poursuivis extraordinairement, et condamnés, savoir: à une prison de trois ans, si l’attroupement n’était pas armé, et à la peine de mort, si l’attroupement était en armes. Il ne sera fait aucune poursuite contre les autres.
| 8. ในกรณีที่ผู้ชุมนุมถอนตัวไปโดยสงบโดยมิได้กระทำความรุนแรงประการใด ไม่ว่าก่อนหรือทันทีที่ได้มีคำสั่งครั้งสุดท้าย เฉพาะผู้ยุยงหรือผู้ส่งเสริมให้เกิดการจลาจล ถ้าระบุตัวได้ จะถูกดำเนินคดีด้วยวิธีพิเศษ และจะต้องระวางโทษ กล่าวคือ จำคุกสามปี ถ้าการชุมนุมไม่มีอาวุธ และประหารชีวิต ถ้าการชุมนุมมีอาวุธ ส่วนคนอื่น ๆ ทั้งหลายนั้นจะไม่ถูกดำเนินคดี
}}
{{ตรคป
| IX. — Dans le cas où le peuple attroupé ferait quelques violences, ou ne se retirerait pas après la dernière sommation, ceux qui échapperont aux coups de la force militaire et qui pourront être arrêtés seront punis d’un emprisonnement d’un an, s’ils étaient sans armes; de trois ans, s’ils étaient armés; et de la peine de mort, s’ils étaient convaincus d’avoir commis des violences. Dans le cas du présent article, les moteurs et instigateurs de la sédition seront de même condamnés à mort.
| 9. ในกรณีที่ผู้ชุมนุมกระทำความรุนแรงบางประการ หรือไม่ถอนตัวไปหลังจากคำสั่งครั้งสุดท้าย บรรดาผู้ที่รอดพ้นจากการปราบปรามของกองกำลังทหาร และผู้ที่ถูกจับกุมได้ ต้องถูกลงโทษจำคุกหนึ่งปี ถ้าไม่มีอาวุธ สามปี ถ้ามีอาวุธ และประหารชีวิต ถ้าถูกพิพากษาว่าได้ก่อความรุนแรง ในกรณีตามมาตรานี้ ผู้ยุยงและผู้ส่งเสริมให้เกิดการจลาจล ต้องระวางโทษประหารชีวิตดุจเดียวกัน
}}
{{ตรคป
| X. — Tous chefs, officiers et soldats des Gardes nationales, des troupes et des maréchaussées qui exciteront et fomenteront des attroupements, émeutes et séditions, seront déclarés rebelles à la nation, au Roi et à la loi, et punis de mort; et ceux qui refuseront le service, à la réquisition des officiers municipaux, seront dégradés et punis de trois ans de prison.
| 10. ผู้บัญชาการ เจ้าพนักงาน และพลทหารทุกคนในองครักษ์แห่งชาติ กองทหาร และ ''มาเรโชเซ''<ref name = "mrcs"/> ที่กระตุ้นหรือยั่วยุให้เกิดการชุมนุม การลุกฮือ และการจลาจล จะถูกประกาศว่าเป็นกบฏต่อชาติ ต่อพระมหากษัตริย์ และต่อกฎหมาย และต้องถูกลงโทษประหารชีวิต ส่วนบรรดาผู้ไม่ยอมปฏิบัติการตามคำร้องขอของเจ้าพนักงานเทศบาล จะต้องถูกลดขั้นและถูกลงโทษจำคุกสามปี
}}
{{ตรคป
| XI. — Il sera dressé, par les officiers municipaux, procès-verbal, qui contiendra le récit des faits.
| 11. ให้เจ้าพนักงานเทศบาลจัดทำบันทึกวาจาโดยให้มีรายงานข้อเท็จจริง
}}
{{ตรคป
| XII. — Lorsque le calme sera rétabli, les officiers municipaux rendront un décret qui fera cesser la loi martiale, et le drapeau rouge sera retiré et remplacé, pendant huit jours, par un drapeau blanc.
| 12. เมื่อฟื้นฟูความสงบได้แล้ว ให้เจ้าพนักงานเทศบาลออกกฤษฎีกาซึ่งให้เลิกใช้กฎอัยการศึก และธงแดงนั้นให้ปลดลงแล้วแทนที่ด้วยธงขาวเป็นเวลาแปดวัน
}}
{{ตรคป
| ''Signé'': {{พญล|Fréteau}}, président; {{พญล|Alexandre de Lameth, Feydel, Bureau de Pusy}}, le marquis {{พญล|de Rostaing}}, secrétaires.
| ''ลงนาม'': เฟรโต, ประธาน;<ref>{{w|en:Emmanuel Marie Michel Philippe Fréteau de Saint-Just|แอมานุแอล มารี มีแชล ฟีลิป เฟรโต เดอ แซ็ง-ฌุสต์}} (Emmanuel Marie Michel Philippe Fréteau de Saint-Just) ประธานสมัชชาแห่งชาติ</ref> อาแล็กซ็องดร์ เดอ ลาแม็ต,<ref>{{w|en:Alexandre-Théodore-Victor, comte de Lameth|อาแล็กซ็องดร์-เตโอดอร์-วิกตอร์ กง เดอ ลาแม็ต}} (Alexandre-Théodore-Victor, comte de Lameth)</ref> เฟย์เดล,<ref>อาจหมายถึง กราบรีแยล เฟย์เดล (Gabriel Feydel)</ref> บูว์โร เดอ ปูว์ซี,<ref>{{w|en:Jean-Xavier Bureau de Pusy|ฌ็อง-ซาวีเยร์ บูว์โร เดอ ปูว์ซี}} (Jean-Xavier Bureau de Pusy)</ref> มาร์กี เดอ โรสแต็ง, เลขานุการ
}}
{{คั่นหน้า}}
{{ตรคป
| Le Roi a sanctionné et sanctionne le susdit décret, pour être exécuté dans tout son royaume. Mande et ordonne Sa Majesté, a tous les officiers municipaux, commandants de ses troupes, des troupes nationales, des maréchaussées et autres qu’il appartiendra, de la maintenir et observer, chancun en ce qui le concerne; et sera la présente Déclaration imprimée, publiée et affichée partout où besoin sera, et sur icelle expédié toutes lettres patentes nécessaires.
| พระมหากษัตริย์ทรงอนุมัติและได้ทรงอนุมัติแล้วซึ่งกฤษฎีกาข้างต้นเพื่อให้นำไปดำเนินการทั่วราชอาณาจักรของพระองค์ พระองค์มีพระราชโองการมานพระบัณฑูรมายังบรรดาผู้เป็นเจ้าพนักงานเทศบาล ผู้บังคับการกองทหารของพระองค์ กองทหารแห่งชาติ ''มาเรโชเซ''<ref name = "mrcs"/> และบุคคลอื่นทั้งหลายที่กฤษฎีกานี้จะได้เกี่ยวได้ข้อง ให้รักษาและปฏิบัติตามกฤษฎีกานี้ ตราบเท่าที่เกี่ยวข้องกับตน และประกาศอันนี้ ให้มีการพิมพ์ เผยแพร่ และปิดไว้ในทุกที่ที่ต้องมี และหนังสือตราตั้งอันจำเป็นสำหรับประกาศนี้ ให้มีการจัดส่งจงทุกฉบับไป
}}
{{ตรคป
| Fait à Paris, le vingt-un octobre mil sept cent quatre-vingt-neuf.
| กระทำ ณ ปารีส วันที่ยี่สิบเอ็ด ตุลาคม ปีพันเจ็ดร้อยแปดสิบเก้า
}}
{{ตรคป
| {{กข|{{รมมจ|''Signé'': {{พญล|Louis}}.|Et plus bas: {{พญล|de Saint-Priest}}.}}|center}}
| {{กข|{{รมมจ|''ลงพระนาม'': หลุยส์<ref>{{w|พระเจ้าหลุยส์ที่ 16}} (Louis XVI)</ref>|และลงนามรับสนอง: เดอ แซ็ง-พรีแย็สต์<ref>{{w|en:François-Emmanuel Guignard, comte de Saint-Priest|ฟร็องซัว-แอมานุแอล กีญาร์ กง เดอ แซ็ง-พรีแย็สต์}} (François-Emmanuel Guignard, comte de Saint-Priest)</ref>}}|center}}
|ไม่ย่อหน้า =
}}
==เชิงอรรถของวิกิซอร์ซ==
{{รกออ}}
==บรรณานุกรม==
===ต้นฉบับ===
{{เริ่มอ้างอิง}}
* {{อ้างหนังสือ|editor=Lacroix, S|year=1895|chapter=Du jeudi 22 octobre 1789, séance du matin|url=https://books.google.co.th/books?id=FqXNAAAAMAAJ|title=Actes de la Commune de Paris pendant la Révolution: Tome II|pp=385–386|location=Paris|publisher=Maison Quantin|language=fr}}
{{จบอ้างอิง}}
===อ้างอิง===
{{เริ่มอ้างอิง}}
* {{อ้างเว็บ|author=CNRTL|year=2012a|title=Empire|website=Ortolang|url=https://www.cnrtl.fr/definition/empire|language=fr|ref={{ฮวต|CNRTL|2012a}}}}
* {{อ้างเว็บ|author=CNRTL|year=2012b|title=Licence|website=Ortolang|url=https://www.cnrtl.fr/definition/licence|language=fr|ref={{ฮวต|CNRTL|2012b}}}}
* {{อ้างเว็บ|author=CNRTL|year=2012c|title=Maison|website=Ortolang|url=https://www.cnrtl.fr/definition/Maison|language=fr|ref={{ฮวต|CNRTL|2012c}}}}
* {{อ้างเว็บ|author=CNRTL|year=2012d|title=Maréchaussée|website=Ortolang|url=https://www.cnrtl.fr/definition/maréchaussée|language=fr|ref={{ฮวต|CNRTL|2012d}}}}
{{จบอ้างอิง}}
{{สัญญาอนุญาตงานแปล
| {{สาธารณสมบัติ-ฝรั่งเศส}}
| {{สาธารณสมบัติ-เอง}}
}}
[[หมวดหมู่:กฎหมายฝรั่งเศส]]
0yim7r0ymwz626hrcn7rpk76l0lsc2c
งานแปล:กฎหมาย ลงวันที่ 3 เมษายน ค.ศ. 1878
114
44101
189434
168335
2022-08-16T15:29:11Z
Venise12mai1834
8884
wikitext
text/x-wiki
{{หัวเรื่องงานแปล
| ชื่อ = {{PAGENAME}}
| ปี = 2421
| ภาษา = fr
| ต้นฉบับ = Loi du 3 avril 1878 relative à l’état de siège
| ผู้สร้างสรรค์ =
| บรรณาธิการ =
| ส่วน =
| ผู้มีส่วนร่วม =
| ก่อนหน้า =
| ถัดไป =
| หมายเหตุ =
| สถานีย่อย = กฎอัยการศึก/กฎหมายฝรั่งเศส
}}
__NOTOC__
{{ตรคป
| {{ก|Loi du 3 avril 1878 relative à l'état de siège.}}
| {{ก|กฎหมาย ลงวันที่ 3 เมษายน 1878 เกี่ยวกับภาวะปิดล้อม}}
| ไม่ย่อหน้า =
}}
{{ตรคป
| หัว = Article 1
| แปลหัว = มาตรา 1
| L'état de siège ne peut être déclaré qu'en cas de péril imminent, résultant d'une guerre étrangère ou d'une insurrection à main armée.
| ภาวะปิดล้อมนั้น จะประกาศได้ก็แต่ในกรณีที่มีอันตรายใกล้จะถึง ซึ่งเป็นผลมาจากสงครามกับต่างชาติหรือจากการกบฏโดยมีอาวุธ<ref>ต้นฉบับแปลตรงตัวว่า โดยมือมีอาวุธ หรือ โดยมือถืออาวุธ</ref>
}}
{{ตรคป
| Une loi peut seule déclarer l'état de siège, cette loi désigne les communes, les arrondissements ou départements auxquels il s'applique. Elle fixe le temps de sa durée. A l'expiration de ce temps, l'état de siège cesse de plein droit à moins qu'une loi nouvelle n'en prolonge les effets.
| กฎหมายเท่านั้นที่จะใช้ประกาศภาวะปิดล้อมได้ กฎหมายนี้ให้ระบุตำบล อำเภอ หรือจังหวัดที่จะให้มีการใช้บังคับ กฎหมายนี้ให้กำหนดระยะเวลาของตน เมื่อพ้นระยะนี้แล้ว ภาวะปิดล้อมย่อมสิ้นสุดลงไปโดยอัตโนมัติ<ref name = "dpd"/> เว้นแต่จะมีกฎหมายใหม่มาขยายผลบังคับ
}}
{{ตรคป
| หัว = Article 2
| แปลหัว = มาตรา 2
| En cas d'ajournement des chambres, le Président de la République peut déclarer l'état de siège, de l'avis du Conseil des ministres, mais alors les chambres se réunissent de plein droit, deux jours après.
| ในกรณีที่สภาอยู่ระหว่างปิดประชุม ประธานาธิบดีแห่งสาธารณรัฐจะประกาศภาวะปิดล้อมตามคำแนะนำของคณะรัฐมนตรีก็ได้ แต่สองวันหลังจากนั้น ให้สภาเป็นอันเปิดประชุมโดยอัตโนมัติ<ref name = "dpd">สำนวน "de plein droit" (แปลตรงตัวว่า โดยกฎหมายเต็มที่ หรือ โดยสิทธิเต็มที่) หมายความว่า โดยเป็นไปเอง โดยเกิดขึ้นเอง หรือโดยอัตโนมัติ</ref>
}}
{{ตรคป
| หัว = Article 3
| แปลหัว = มาตรา 3
| En cas de dissolution de la Chambre des députés jusqu'à l'accomplissement entier des opérations électorales, l'état de siège ne pourra, même provisoirement, être déclaré par le Président de la République.
| ในกรณีที่สภาผู้แทนถูกยุบ ประธานาธิบดีแห่งสาธารณรัฐจะประกาศภาวะปิดล้อมไม่ได้แม้เป็นการชั่วคราว จนกว่าจะดำเนินการเลือกตั้งเสร็จสิ้นทุกประการ
}}
{{ตรคป
| Néanmoins, s'il y avait guerre étrangère, le Président, de l'avis du Conseil des ministres, pourrait déclarer l'état de siège dans les territoires menacés par l'ennemi, à la condition de convoquer les collèges électoraux et de réunir les chambres dans le plus bref délai possible.
| อย่างไรก็ตาม ถ้ามีสงครามกับต่างชาติ ให้ประธานาธิบดีสามารถประกาศภาวะปิดล้อมในดินแดนที่ถูกศัตรูคุกคามได้ตามคำแนะนำของคณะรัฐมนตรี โดยมีเงื่อนไขว่า ต้องเรียกรวมคณะผู้เลือกตั้งและเรียกประชุมสภาโดยเร็วที่สุด
}}
{{ตรคป
| หัว = Article 4
| แปลหัว = มาตรา 4
| Dans le cas où les communications seraient interrompues avec l'Algérie, le gouverneur pourra déclarer tout ou partie de l'Algérie en état de siège, dans les conditions de la présente loi.
| ในกรณีที่การติดต่อสื่อสารกับอาลเฌรี<ref>ประเทศแอลจีเรียซึ่งเป็นอาณานิคมของฝรั่งเศส ดู {{w|en:French Algeria|แอลจีเรียของฝรั่งเศส}}</ref> นั้นเกิดขัดข้อง ผู้ว่าการ<ref>ตำแหน่งผู้ปกครองประเทศแอลจีเรียที่ตกเป็นอาณานิคมของฝรั่งเศส ชื่อเต็มคือ ผู้ว่าการใหญ่ (บ้างแปลว่า ข้าหลวงใหญ่) แห่งแอลจีเรีย (gouverneur général d'Algérie) ดู {{w|en:List of French governors of Algeria|รายชื่อผู้ว่าการแอลจีเรีย}}</ref> จะประกาศให้ทุกส่วนหรือบางส่วนของอาลเฌรีตกอยู่ในภาวะปิดล้อม ตามเงื่อนไขของกฎหมายฉบับนี้ก็ได้
}}
{{ตรคป
| หัว = Article 5
| แปลหัว = มาตรา 5
| Dans les cas prévus par les articles 2 et 3, les chambres,(le Parlement), dès quelles sont réunies, maintiennent ou lèvent l'état de siège. En cas de dissentiment entre elles, l'état de siège est levé de plein droit.
| ในกรณีที่บัญญัติไว้ในมาตรา 2 และ 3 นั้น ให้สภา (รัฐสภา) คงไว้หรือเพิกถอนซึ่งภาวะปิดล้อมทันทีที่สภาได้รับเรียกประชุม ในกรณีที่สภาตกลงกันไม่ได้ ก็ให้ภาวะปิดล้อมเป็นอันถูกเพิกถอนโดยอัตโนมัติ<ref name = "dpd"/>
}}
{{ตรคป
| หัว = Article 6
| แปลหัว = มาตรา 6
| Les articles 4 et 5 de la loi du 9 août 1849 sont maintenus ainsi que les dispositions de ses autres articles non contraires à la présente loi.
| มาตรา 4 และ 5 ของ[[งานแปล:กฎหมาย ลงวันที่ 9 สิงหาคม ค.ศ. 1849|กฎหมาย ลงวันที่ 9 สิงหาคม 1849]] กับทั้งบทบัญญัติมาตราอื่น ๆ ของกฎหมายดังกล่าวที่ไม่ขัดกับกฎหมายฉบับนี้ ให้คงใช้ต่อไป
}}
{{ตรคป
| Signe: Marechal de Mac-Mahon, Duc de Magenta.
| ลงนาม: จอมพล เดอ มัก-มาอง ดุ๊กแห่งมาฌ็องตา<ref>{{w|en:Patrice de MacMahon|ปาทริส เดอ มักมาอง}} (Patrice de MacMahon) มีบรรดาศักดิ์เป็น ดุ๊กคนแรกแห่งมาฌ็องตา (1<sup>er</sup> duc de Magenta)</ref>
}}
{{ตรคป
| Le président du Conseil, garde des sceaux, ministre de la justice, Signe: Dufaure
| ประธานคณะ,<ref>ชื่อเต็มคือ {{w|fr:Président du Conseil (France)|ประธานคณะรัฐมนตรี}} (président du Conseil des ministres)</ref> ผู้รักษาลัญจกร,<ref>ผู้รักษา{{w|en:Great Seal of France|มหาลัญจกรแห่งสาธารณรัฐ}} (Grand Sceau de la République) เป็นสถานะของรัฐมนตรียุติธรรม</ref> รัฐมนตรียุติธรรม, ลงนาม: ดูว์โฟร์<ref>{{w|en:Jules Armand Dufaure|ฌุล อาร์ม็อง ดูว์โฟร์}} (Jules Armand Dufaure)</ref>
}}
==เชิงอรรถของวิกิซอร์ซ==
{{รกออ}}
==บรรณานุกรม==
{{เริ่มอ้างอิง}}
* {{อ้างเว็บ|title=Loi du 3 avril 1878 relative à l'état de siège|date=1878-04-03|website=Légifrance|url=https://www.legifrance.gouv.fr/loda/id/JORFTEXT000000877113/1878-04-03/|language=fr}}
{{จบอ้างอิง}}
{{สัญญาอนุญาตงานแปล
| {{สาธารณสมบัติ-ฝรั่งเศส}}
| {{สาธารณสมบัติ-เอง}}
}}
[[หมวดหมู่:กฎหมายฝรั่งเศส]]
lpekxbhkb6nghy0o334emkakndddtc2
งานแปล:กฎหมาย ลงวันที่ 9 สิงหาคม ค.ศ. 1849
114
44390
189437
168338
2022-08-16T15:33:22Z
Venise12mai1834
8884
wikitext
text/x-wiki
{{หัวเรื่องงานแปล
| ชื่อ = {{PAGENAME}}
| ปี = 2392
| ภาษา = fr
| ต้นฉบับ = Loi du 9 août 1849 sur l’état de siège
| ผู้สร้างสรรค์ =
| บรรณาธิการ =
| ส่วน =
| ผู้มีส่วนร่วม =
| ก่อนหน้า =
| ถัดไป =
| หมายเหตุ =
| สถานีย่อย = กฎอัยการศึก/กฎหมายฝรั่งเศส
}}
{{ตรคป
| {{ก|Loi du 9 août 1849 sur l'état de siège.}}
| {{ก|กฎหมาย ลงวันที่ 9 สิงหาคม 1849 ว่าด้วยภาวะปิดล้อม}}
| ไม่ย่อหน้า =
}}
{{ตรคป
| หัว = Chapitre I: Cas où l'état du siège peut être déclaré.
| แปลหัว = หมวด 1 กรณีที่สามารถประกาศภาวะปิดล้อม
}}
{{ตรคป
| หัว = Article 1
| แปลหัว = มาตรา 1
| L'état de siège ne peut être déclaré qu'en cas de péril imminent pour la sécurité intérieure ou extérieure.
| ภาวะปิดล้อมสามารถประกาศได้แต่ในกรณีที่มีภยันตรายอันใกล้จะถึงต่อความมั่นคงภายในหรือภายนอก
}}
{{ตรคป
| หัว = Chapitre II: Des formes de la déclaration de l'état de siège.
| แปลหัว = หมวด 2 ว่าด้วยรูปแบบการประกาศภาวะปิดล้อม
}}
{{ตรคป
| หัว = Article 2
| แปลหัว = มาตรา 2
| L'Assemblée nationale peut seule déclarer l'état de siège, sauf les exceptions ci-après.
| สมัชชาแห่งชาติเท่านั้นที่ประกาศภาวะปิดล้อมได้ โดยมีข้อยกเว้น[ตามที่บัญญัติไว้]ถัดจากนี้
}}
{{ตรคป
| La déclaration de l'état de siège désigne les communes, les arrondissements ou départements auxquels il s'applique et pourra être étendu.
| ประกาศภาวะปิดล้อม ย่อมกำหนดตำบล อำเภอ หรือจังหวัด ที่ประกาศนั้นจะใช้บังคับและอาจขยายไปถึง
}}
{{ตรคป
| หัว = Article 3
| แปลหัว = มาตรา 3
| Dans le cas de prorogation de l'Assemblée nationale, le Président de la République peut déclarer l'état de siège, de l'avis du Conseil des ministres.
| ในกรณีที่สมัชชาแห่งชาติปิดสมัยประชุม ประธานาธิบดีแห่งสาธารณรัฐจะประกาศภาวะปิดล้อมตามคำแนะนำของคณะรัฐมนตรีก็ได้
}}
{{ตรคป
| Le Président, lorsqu'il a déclaré l'état de siège, doit immédiatement en informer la commission instituée en vertu de l'article 32 de la Constitution, et, selon la gravité des circonstances, convoquer l'Assemblée nationale.
| เมื่อประกาศภาวะปิดล้อมแล้ว ประธานาธิบดีต้องแจ้งคณะกรรมการที่ตั้งขึ้นด้วยอำนาจตามมาตรา 32 ของรัฐธรรมนูญ<ref>[[งานแปล:รัฐธรรมนูญฝรั่งเศส (ค.ศ. 1848)|รัฐธรรมนูญ ค.ศ. 1848]]</ref> โดยพลัน แล้วเรียกประชุมสมัชชาแห่งชาติ โดยขึ้นอยู่กับความร้ายแรงของพฤติการณ์
}}
{{ตรคป
| La prorogation de l'Assemblée cesse de plein droit lorsque Paris est déclaré en état de siège.
| การปิดสมัยประชุมสมัชชาเป็นอันสิ้นสุดลงโดยอัตโนมัติ<ref name>สำนวน "de plein droit" (แปลตรงตัวว่า โดยกฎหมายเต็มที่ หรือ โดยสิทธิเต็มที่) หมายความว่า โดยเป็นไปเอง โดยเกิดขึ้นเอง หรือโดยอัตโนมัติ</ref> เมื่อมีประกาศให้ปารีสอยู่ภายใต้ภาวะปิดล้อม
}}
{{ตรคป
| L'Assemblée nationale, dès qu'elle est réunie, maintient ou lève l'état de siège.
| ทันที่ที่มาประชุมกัน สมัชชาแห่งชาติย่อมจะรับรองหรือยกเลิกเสียซึ่งภาวะปิดล้อม
}}
{{ตรคป
| หัว = Article 4
| แปลหัว = มาตรา 4
| Dans les colonies françaises, la déclaration de l'état de siège est faite par le gouverneur de la colonie.
| ในอาณานิคมฝรั่งเศส การประกาศภาวะปิดล้อมย่อมกระทำโดยผู้ว่าการอาณานิคม
}}
{{ตรคป
| Il doit en rendre compte immédiatement au Gouvernement.
| ผู้ว่าการต้องรายงานรัฐบาลทันที
}}
{{ตรคป
| หัว = Article 5
| แปลหัว = มาตรา 5
| Dans les places de guerre et postes militaires soit de la frontière, soit de l'intérieur, la déclaration de l'état de siège peut être faite par le commandant militaire, dans les cas prévus par la loi du 10 juillet 1791 et par le décret du 24 décembre 1811.
| ณ สมรภูมิและที่ตั้งทหาร ไม่ว่าตามชายแดนหรือภายในประเทศ ผู้บัญชาการทหารจะประกาศภาวะปิดล้อมก็ได้ ในกรณีที่มีบัญญัติไว้ในกฎหมาย ลงวันที่ 10 กรกฎาคม 1791<ref name = "a">กฎหมาย ลงวันที่ 10 กรกฎาคม ค.ศ. 1791 เกี่ยวด้วยการรักษาและจัดประเภทสมรภูมิและที่ตั้งทหาร การรักษาความปลอดภัยป้อมปราการ และวัตถุอื่น ๆ ที่เกี่ยวข้อง (Loi du 10 juillet 1791 concernant la conservation et le classement des places de guerre et postes militaires, la police des fortifications et autres objets y relatifs)</ref> และในกฤษฎีกา ลงวันที่ 24 ธันวาคม 1811<ref name = "b">พระราชกฤษฎีกา ลงวันที่ 24 ธันวาคม ค.ศ. 1811 เกี่ยวกับการจัดระเบียบและกิจการของกองบัญชาการประจำสถานที่ (Décret imperial du 24 décembre 1811 relatif à l’organisation et au service des états-majors des places)</ref>
}}
{{ตรคป
| Le commandant en rend compte immédiatement au Gouvernement.
| ผู้บัญชาการต้องรายงานรัฐบาลทันที
}}
{{ตรคป
| หัว = Article 6
| แปลหัว = มาตรา 6
| Dans le cas des deux articles précédents, si le Président de la République ne croit pas devoir lever l'état de siège, il en propose sans délai le maintien à l'Assemblée nationale.
| ในกรณีตามมาตราทั้งสองก่อนหน้านี้ ถ้าประธานาธิบดีแห่งสาธารณรัฐไม่เชื่อว่าจะต้องยกเลิกภาวะปิดล้อม ประธานาธิบดีย่อมเสนอต่อสมัชชาแห่งชาติโดยพลันให้รับรองภาวะนั้น
}}
{{ตรคป
| หัว = Chapitre III: Des effets de l'état de siège.
| แปลหัว = หมวด 3 ว่าด้วยผลของภาวะปิดล้อม
}}
{{ตรคป
| หัว = Article 7
| แปลหัว = มาตรา 7
| Aussitôt l'état de siège déclaré, les pouvoirs dont l'autorité civile était revêtue pour le maintien de l'ordre et la police passent tout entiers à l'autorité militaire.
| ทันทีที่มีประกาศภาวะปิดล้อม อำนาจของเจ้าหน้าที่ฝ่ายพลเรือนในการรักษาความเรียบร้อยและการรักษาความปลอดภัย ย่อมเปลี่ยนผ่านไปเป็นของเจ้าหน้าที่ฝ่ายทหารโดยสิ้นเชิง
}}
{{ตรคป
| L'autorité civile continue néanmoins à exercer ceux de ces pouvoirs dont l'autorité militaire ne l'a pas dessaisie.
| อย่างไรก็ดี เจ้าหน้าที่ฝ่ายพลเรือนย่อมใช้อำนาจนั้นได้ต่อไป ถ้าเจ้าหน้าที่ฝ่ายทหารมิได้เพิกถอน
}}
{{ตรคป
| หัว = Article 8
| แปลหัว = มาตรา 8
| Les tribunaux militaires peuvent être saisis de la connaissance des crimes et délits contre la sûreté de la République, contre la Constitution, contre l'ordre et la paix publique, quelle que soit la qualité des auteurs principaux et les complices.
| คณะตุลาการทหารสามารถพิจารณาการแจ้งความผิดอาญาและการฝ่าฝืนกฎหมายต่อความมั่นคงแห่งสาธารณรัฐ ต่อรัฐธรรมนูญ ต่อความเรียบร้อยและความสงบสาธารณะ ไม่ว่าตัวการและผู้สนับสนุนจะมีลักษณะเช่นไร
}}
{{ตรคป
| หัว = Article 9
| แปลหัว = มาตรา 9
| L'autorité militaire a le droit:
| เจ้าหน้าที่ฝ่ายทหารมีสิทธิ
}}
{{ตรคป
| 1° De faire des perquisitions, de jour et de nuit, dans le domicile des citoyens;
| 1. ที่จะตรวจค้นในบ้านเรือนพลเมืองทั้งกลางวันและกลางคืน
}}
{{ตรคป
| 2° D'éloigner les repris de justice et les individus qui n'ont pas leur domicile dans les lieux soumis à l'état de siège;
| 2. ที่จะขับไล่ผู้มีประวัติอาชญากรรม<ref>สำนวน "repris de justice" (แปลตรงตัวว่า [ผู้]ถูกส่งเข้ากระบวนการยุติธรรมซ้ำ) หมายถึง ผู้เคยถูกลงโทษหรือถูกพิพากษาว่ากระทำความผิดมาก่อน</ref> และบุคคลที่ไม่มีภูมิลำเนาในพื้นที่ที่อยู่ภายใต้ภาวะปิดล้อม
}}
{{ตรคป
| 3° D'ordonner la remise des armes et munitions, et de procéder à leur recherche et à leur enlèvement;
| 3. ที่จะสั่งให้ส่งอาวุธและเครื่องกระสุน และที่จะสืบหาหรือยึดเสียซึ่งสิ่งดังกล่าว
}}
{{ตรคป
| 4° D'interdire les publications et les réunions qu'elle juge de nature à exciter ou à entretenir le désordre.
| 4. ที่จะห้ามการเผยแพร่และการชุมนุมซึ่งโดยสภาพแล้วถือได้ว่าจะทำให้ความวุ่นวายทวีขึ้นหรือคงอยู่ต่อไป
}}
{{ตรคป
| หัว = Article 10
| แปลหัว = มาตรา 10
| Dans les lieux énoncés en l'article 5, les effets de l'état de siège continuent à être déterminés par les dispositions de la loi du 10 juillet 1791 et du décret du 24 décembre 1811.
| นอกจากนี้ ในกรณีมีสงครามกับต่างชาติ ณ พื้นที่ที่ระบุไว้ในมาตรา 5 ผลของภาวะปิดล้อมให้คงเป็นไปตามที่กำหนดไว้ในบทบัญญัติของกฎหมาย ลงวันที่ 10 กรกฎาคม 1791<ref name = "a"/> และกฤษฎีกา ลงวันที่ 24 ธันวาคม 1811<ref name = "b"/> ต่อไป
}}
{{ตรคป
| หัว = Article 11
| แปลหัว = มาตรา 11
| Les citoyens continuent, nonobstant l'état de siège, à exercer tous ceux des droits garantis par la constitution, dont la jouissance n'est pas suspendue en vertu des articles précédents.
| แม้จะมีภาวะปิดล้อม พลเมืองย่อมใช้สิทธิทั้งปวงที่รัฐธรรมนูญรับรองไว้ได้ต่อไป ถ้าการใช้สิทธินั้นไม่ถูกระงับไปด้วยอำนาจของมาตราก่อน ๆ หน้านี้
}}
{{ตรคป
| หัว = Chapitre IV: De la levée de l'état de siège.
| แปลหัว = หมวด 4 ว่าด้วยการยกเลิกภาวะปิดล้อม
}}
{{ตรคป
| หัว = Article 12
| แปลหัว = มาตรา 12
| L'Assemblée nationale a seule le droit de lever l'état de siège, lors qu'il a été déclaré ou maintenu par elle.
| สมัชชาแห่งชาติเท่านั้นที่มีสิทธิยกเลิกภาวะปิดล้อม เมื่อภาวะนั้นได้รับการประกาศหรือรับรองโดยสมัชชา
}}
{{ตรคป
| Néanmoins, en cas de prorogation, ce droit appartiendra au Président de la République.
| อย่างไรก็ดี ในกรณีปิดสมัยประชุม สิทธินี้จะตกแก่ประธานาธิบดีแห่งสาธารณรัฐ
}}
{{ตรคป
| L'état de siège, déclaré conformément aux articles 3, 4 et 5, peut être levé par le Président de la République, tant qu'il n'a pas été maintenu par l'Assemblée nationale.
| ภาวะปิดล้อมที่ประกาศตามมาตรา 3, 4, และ 5 ประธานาธิบดีแห่งสาธารณรัฐจะยกเลิกเสียก็ได้ ตราบที่สมัชชาแห่งชาติยังมิได้รับรองภาวะนั้น
}}
{{ตรคป
| L'état de siège, déclaré conformément à l'article 4, pourra être levé par les gouverneurs des colonies aussitôt qu'ils croiront la tranquillité suffisamment rétablie.
| ภาวะปิดล้อมที่ประกาศตามมาตรา 4 นั้น ผู้ว่าการอาณานิคมจะยกเลิกเสียก็ได้ ในทันทีที่ผู้ว่าการเชื่อว่า ความสงบสุขได้ฟื้นคืนมาเพียงพอแล้ว
}}
{{ตรคป
| หัว = Article 13
| แปลหัว = มาตรา 13
| Après la levée de l'état de siège, les tribunaux militaires continuent de connaître des crimes et délits dont la poursuite leur avait été déférée.
| ภายหลังการยกเลิกภาวะปิดล้อม คณะตุลาการทหารย่อมพิจารณาความผิดอาญาและความผิดลหุโทษที่ได้ยื่นฟ้องต่อตนแล้วต่อไป
}}
{{ตรคป
| Le Président de la République:
| ประธานาธิบดีแห่งสาธารณรัฐ:
}}
{{ตรคป
| {{พญ|Louis-Napoleon Bonaparte.}}
| ลูย-นาปอเลอง บอนาปาร์ต<ref>{{w|en:Napoleon III|นโปเลียนที่ 3}} (Napoleon III)</ref>
}}
{{ตรคป
| Le garde des sceaux, ministre de la justice, {{พญ|Odilon Barrot}}.
| ผู้รักษาลัญจกร,<ref>ผู้รักษา{{w|en:Great Seal of France|มหาลัญจกรแห่งสาธารณรัฐ}} (Grand Sceau de la République) เป็นสถานะของรัฐมนตรียุติธรรม</ref> รัฐมนตรียุติธรรม: ออดีลง บาโร<ref>{{w|en:Odilon Barrot|ออดีลง บาโร}} (Odilon Barrot)</ref>
}}
==เชิงอรรถของวิกิซอร์ซ==
{{รกออ}}
==บรรณานุกรม==
{{เริ่มอ้างอิง}}
* {{อ้างเว็บ|title=Loi du 9 août 1849 sur l'état de siège|date=1849-08-09|website=Légifrance|url=https://www.legifrance.gouv.fr/loda/id/LEGITEXT000006070693/1849-08-09/|language=fr}}
{{จบอ้างอิง}}
{{สัญญาอนุญาตงานแปล
| {{สาธารณสมบัติ-ฝรั่งเศส}}
| {{สาธารณสมบัติ-เอง}}
}}
[[หมวดหมู่:กฎหมายฝรั่งเศส]]
sl8tbkyrycpslm9u6wqo0f3fa9ghznu
หมวดหมู่:งานที่ต้นฉบับเป็นภาษาจีน
14
47392
189441
148183
2022-08-16T15:36:38Z
Venise12mai1834
8884
wikitext
text/x-wiki
[[หมวดหมู่:งานแปลแบ่งตามภาษาต้นฉบับ|จีน]]
[[หมวดหมู่:ภาษาจีน]]
hy1020mj841wcrk4roscoeo5il990zz
งานแปล:ที่มาแห่งกฎหมายโบราณของสยาม
114
49141
189511
168339
2022-08-17T11:45:49Z
Venise12mai1834
8884
wikitext
text/x-wiki
{{หัวเรื่องงานแปล
| ชื่อ = ที่มาแห่งกฎหมายโบราณของสยาม
| ปี = 1905
| ศักราช = ค.ศ.
| ภาษา = en
| ต้นฉบับ = The Sources of Ancient Siamese Law
| ผู้สร้างสรรค์ = พระยามหิธรมนูปกรณ์โกศลคุณ (โทกิจิ มาซาโอะ)
| บรรณาธิการ =
| ส่วน =
| ผู้มีส่วนร่วม =
| ก่อนหน้า =
| ถัดไป =
| หมายเหตุ =
| สถานีย่อย = ประวัติศาสตร์กฎหมาย/กฎหมายตราสามดวง
}}
__NOTOC__
{{ตรคป
| หัว = The Sources of Ancient Siamese Law.<ref group = "a">This paper contains the substance of one of the chapters of a thesis entitled "Studies in Ancient Siamese Laws," which the author presented to the Imperial University of Tokio, Japan, a few years ago and of a lecture which he delivered recently before the Siam Society of Bangkok, Siam.</ref>
| แปลหัว = ที่มาแห่งกฎหมายโบราณของสยาม<ref group = "ก">เอกสารนี้จับใจความมาจากบทหนึ่งในวิทยานิพนธ์ เรื่อง ''การศึกษากฎหมายโบราณของสยาม'' ที่ผู้เขียนเสนอต่อมหาวิทยาลัยหลวงโตเกียว ญี่ปุ่น สองสามปีก่อน และจากปาฐกถาที่ผู้เขียนกล่าวต่อสยามสมาคม กรุงเทพฯ สยาม เมื่อเร็ว ๆ นี้</ref>
| ตัว = From the point of view of comparative jurisprudence it may be said that there are five original systems of laws from which the laws of the different countries of the world are derived. These are (1) the Roman law system; (2) the English law system; (3) the Hindu law system; (4) the Mohammedan law system, and (5) the Chinese law system. The laws of the continental countries of Europe are examples of the Roman law system—those of the German countries being Roman laws in purer form, and those of the Latin countries being Roman law in less pure form. The laws of England and the different states of the United States of America with the exception of Louisiana are examples of laws belonging to the English law system. India, with its multitudes of what once were independent kingdoms and principalities, some of one religious profession, some of another, but now all under the British administration, at the present day presents a unique example of a country in which the British courts administer the Brahman, the Buddhist, and the Mohammedan laws according to the religious profession of the litigant. The laws of China and Corea are examples of the Chinese law system. The ancient laws of Japan belonged to the Chinese law system, but the present laws may, on the whole, be said to belong to that branch of the Roman law system which may be called the German system, though they have taken a great deal from the English law system also. Considering the geographical proximity of Siam to India and the fact that in ancient times Siam was so much under the influence of Indian civilization, one naturally expects that the ancient laws of Siam should belong to the Hindu law system. But it is curious to note that although everybody seems to be under the impression that the ancient laws of Siam belong to the Hindu law system, no one has taken the trouble to prove it. The author ventures to think that this is not because the subject is uninteresting but because the point to be proved is generally admitted and taken for granted. The object of this paper is to bring forth such texts from the ancient laws of Siam as will show that these ancient laws belong to the Hindu law system. If the author were a philologist or archæologist he feels confident that he could bring forth interesting philological and archæological facts to support him in his task, but as he is nothing more than a working lawyer he can only fall back on such texts as have come under his notice in the course of his studies in the ancient laws of Siam.
| แปลตัว = มองจากมุมของนิติศาสตร์เปรียบเทียบ อาจกล่าวได้ว่า มีระบบกฎหมายดั้งเดิมอยู่ห้าระบบที่เป็นต้นเค้าของกฎหมายในประเทศต่าง ๆ ทั่วโลก คือ
# ระบบกฎหมายโรมัน
# ระบบกฎหมายอังกฤษ
# ระบบกฎหมายฮินดู
# ระบบกฎหมายมุฮัมมัด<ref group = "วซ">หมายถึง อิสลาม</ref> และ
# ระบบกฎหมายจีน
กฎหมายของกลุ่มประเทศภาคพื้นยุโรปเป็นตัวอย่างของระบบกฎหมายโรมัน กฎหมายของกลุ่มประเทศเยอรมันเป็นกฎหมายโรมันแบบบริสุทธิ์กว่าเพื่อน ส่วนกฎหมายของกลุ่มประเทศละตินเป็นกฎหมายโรมันแบบบริสุทธิ์น้อยลงมา กฎหมายของอังกฤษและรัฐต่าง ๆ ในสหรัฐอเมริกา ยกเว้นลุยเซียนา เป็นตัวอย่างของกฎหมายที่มาจากระบบกฎหมายอังกฤษ อินเดีย กับทั้งดินแดนมากมายในอินเดียที่ครั้งหนึ่งเป็นราชอาณาจักรและราชรัฐอิสระ บ้างถือศาสนาอย่างหนึ่ง บ้างถืออีกอย่างหนึ่ง แต่ทุกวันนี้อยู่ในความปกครองของบริเตนทั้งสิ้นแล้ว เป็นตัวอย่างเพียงหนึ่งเดียวในปัจจุบันของประเทศที่ศาลบริเตนต้องบริหารกฎหมายพราหมณ์ พุทธ และมุฮัมมัด ไปตามการนับถือศาสนาของคู่ความ ส่วนกฎหมายของจีนและเกาหลีนั้นเป็นตัวอย่างของระบบกฎหมายจีน กฎหมายโบราณของญี่ปุ่นก็มาจากระบบกฎหมายจีน แต่กฎหมายปัจจุบันนี้ อาจกล่าวได้ว่า ในภาพรวมแล้ว มาจากสาขาหนึ่งของระบบกฎหมายโรมันที่อาจเรียกขานว่า กฎหมายเยอรมัน แม้จะรับหลายสิ่งหลายอย่างมาจากระบบกฎหมายอังกฤษอยู่เหมือนกัน เมื่อคำนึงถึงความใกล้ชิดทางภูมิศาสตร์ของสยามกับอินเดีย กับข้อเท็จจริงที่ว่า ในครั้งโบราณ สยามอยู่ใต้อิทธิพลของอารยธรรมอินเดียมากอย่างยิ่ง ก็เป็นธรรมดาที่เราจะคาดหมายได้ว่า กฎหมายโบราณของสยามย่อมมาจากระบบกฎหมายฮินดู แต่น่าสงสัยชวนให้สังเกตเหลือเกินว่า ถึงแม้ใคร ๆ ก็ดูจะเข้าอกเข้าใจกันว่า กฎหมายโบราณของสยามย่อมมาจากระบบกฎหมายฮินดู แต่ไม่มีใครเลยที่เคยลงแรงพิสูจน์เรื่องนี้ ผู้เขียนลองคิดดูว่า ที่เป็นเช่นนี้ มิใช่เพราะหัวเรื่องนี้ไม่น่าสนใจ แต่เพราะประเด็นที่จะให้พิสูจน์นั้นก็เป็นที่ยอมรับละนับถือหมดใจโดยทั่วกันอยู่แล้ว วัตถุประสงค์ของเอกสารนี้จึงเป็นการนำเสนอตัวบทจากกฎหมายโบราณของสยามที่จะแสดงให้เห็นว่า กฎหมายโบราณเหล่านี้มีที่มาจากระบบกฎหมายฮินดู ถ้าผู้เขียนเป็นนักภาษาศาสตร์หรือนักโบราณคดี ก็คงรู้สึกมั่นใจได้ว่า จะสามารถนำข้อเท็จจริงทางภาษาศาสตร์หรือโบราณคดีที่น่าสนใจออกมากสงเคราะห์ตนเองในงานชิ้นนี้ แต่อย่างเดียวที่ผู้เขียนเป็น คือ นักกฎหมายสายอาชีพ ผู้เขียนจึงได้แต่พึ่งพาตัวบทที่ผ่านหูผ่านตามาในระหว่างศึกษากฎหมายโบราณของสยาม
}}
{{ตรคป
| The very first thing that struck the author when he commenced his study of ancient Siamese laws nearly eight years ago, was the very striking similarity of Siamese law to Hindu law in the manner of dividing the subjects or titles of law. In the code of Manu, the typical Hindu law book, the whole body of civil and criminal laws are divided into eighteen principal titles. According to Professor Bühler's translation these eighteen titles or causes of law suits are as follows: (1) Debt; (2) deposit and pledge; (3) sale without ownership; (4) concerns among partners; (5) resumption of gifts; (6) hiring of persons; (7) non-performance of agreements; (8) rescission of sale and purchase; (9) disputes between the owner of cattle and his servants; (10) disputes regarding boundaries; (11) assault; (12) defamation; (13) theft; (14) robbery and violence; (15) adultery; (16) duties {{ตตฉ|or|of}} man and wife; (17) partition of inheritance; (18) gambling and betting (Manu VIII, 4–8). On this same subject the Siamese Phra Tamasat<ref group = "a">The name of an ancient Siamese code. It is interesting to note that its very name "Tamasat" is suggestive of its Manuic origin as the code of Manu is called "Tamasatra."</ref> says: "The causes which give rise to law suits are as follows, etc," and enumerates all these eighteen titles in almost the identical words and adds eleven more, such as kidnapping, rebellion, war, the king's property and taxes, etc.
| สิ่งแรก ๆ ที่สะกิดใจผู้เขียนตอนเริ่มศึกษากฎหมายโบราณของสยามราวแปดปีก่อนนั้น คือ ความคล้ายคลึงกันอย่างเห็นได้ชัดของกฎหมายสยามกับกฎหมายฮินดูในแง่ของการแบ่งหัวเรื่องหรือชื่อเรื่อง ในประมวลกฎหมายพระมนู อันเป็นแบบฉบับตำรากฎหมายฮินดูนั้น มีการแบ่งส่วนกฎหมายแพ่งและอาญาทั้งหมดออกเป็น 18 หัวเรื่องหลัก ตามคำแปลของศาสตราจารย์บือเลอร์<ref group = "วซ">อาจหมายถึง เกออร์ค บือเลอร์ (Georg Bühler)</ref> หัวเรื่องหรือมูลคดีทั้ง 18 นี้ ได้แก่
# หนี้
# ฝาก และจำนำ
# ขายโดยไม่มีกรรมสิทธิ์
# ความเกี่ยวพันในหมู่หุ้นส่วน<ref group = "วซ">อาจตรงกับที่พระธรรมสาตรว่า “วิวาทด้วยปันหมู่ชาเปนมูล” ({{ฮวอม|แลงกาต์|2481a|p=29}})</ref>
# เอาสิ่งที่ให้แล้วคืน
# จ้างแรงงาน
# ไม่ปฏิบัติตามข้อตกลง
# บอกเลิกการซื้อขาย
# ข้อพิพาทระหว่างเจ้าของปศุสัตว์กับคนรับใช้ของตน
# ข้อพิพาทเรื่องเขตแดน
# ทำร้ายร่างกาย
# หมิ่นประมาท
# ลักทรัพย์
# ปล้นทรัพย์ และประทุษร้าย
# กระทำชู้
# หน้าที่ของสามีและภริยา
# แบ่งมรดก
# พนันขันต่อ (พระมนู เล่ม 8 หน้า 4–8)
ในเรื่องเดียวกันนี้ พระธรรมศาสตร์<ref group = "ก">ชื่อประมวลกฎหมายโบราณของสยาม เป็นเรื่องน่าสนใจชวนให้สังเกตว่า ชื่อ “ธรรมศาสตร์” นี้ส่อว่ามีที่มาจากพระมนู เพราะประมวลกฎหมายพระมนูก็เรียกว่า “ธรรมศาสตร์”</ref> ของสยามระบุว่า “มูลอันก่อให้เกิดคดีความมีดังนี้”<ref group = "วซ">ข้อความดั้งเดิมในพระธรรมสาตร ({{ฮวอม|แลงกาต์|2481a|p=27}}) ว่า “แม้นอันว่ามูลคดีวิวาทอันให้บังเกีดความทังปวง”</ref> แล้วลำดับหัวเรื่องทั้ง 18 นี้ด้วยถ้อยคำที่แทบจะไม่ผิดจากกัน ก่อนจะเพิ่มเข้าไปอีก 11 หัวเรื่อง เป็นต้นว่า ลักพา กบฏ สงคราม ราชทรัพย์ และภาษี ฯลฯ
}}
{{ตรคป
| The same similarity is observable in the manner of classifying slaves. In the code of Manu slaves are classified as follows: (1) those who have been made captives of war; (2) those who have become slaves for the sake of being fed; (3) those who have been born of female slaves in the house of their masters; (4) those who have been bought; (5) those who have been given; (6) those who have been inherited from ancestors, and (7) those who have become slaves on account of their inability to pay large fines (Manu VIII 4–15). On this subject the Siamese Laxana Tat<ref group = "a">The name of an ancient Siamese Law Concerning Slaves.</ref> begins by saying that there are seven kinds of slaves and enumerates them as follows: (1) slaves whom you have redeemed from other money masters; (2) slaves who have been born of slaves in your house; (3) slaves you have got from your father and mother{{ตตฉ|:|;}} (4) slaves whom you have got from others by way of gift; (5) slaves you have helped out of punishment; (6) those who have become your slaves by your having fed them when rice was dear, and (7) those whom you have brought back as captives when you went to war. It will be observed at once that the seven kinds of slaves mentioned in the code of Manu and the Siamese Laxana Tat are exactly the same.
| ความคล้ายคลึงกันเช่นนั้นยังเห็นได้ในแง่ของการจัดประเภททาส ในประมวลกฎหมายพระมนู ทาสจัดออกเป็นประเภทดังนี้
# ผู้เคยตกเป็นเชลยศึก
# ผู้กลายเป็นทาสเพียงเพื่อให้ท้องอิ่ม
# ผู้เกิดจากทาสหญิงในบ้านของนายทาส
# ผู้ถูกซื้อมา
# ผู้ถูกมอบให้
# ผู้ที่ได้รับมาจากมรดกของบุพการี และ
# ผู้กลายเป็นทาสเพราะจ่ายค่าปรับจำนวนมากไม่ไหว (พระมนู เล่ม 8 หน้า 4–15)
ในเรื่องนี้ ลักษณะทาส<ref group = "ก">ชื่อกฎหมายโบราณของสยามเกี่ยวกับทาส</ref> ของสยามเริ่มโดยกล่าวว่า ทาสมีเจ็ดประเภท แล้วลำดับแต่ละประเภท ดังนี้
# ทาสที่ท่านไถ่ถอนมาจากนายเงินผู้อื่น<ref group = "วซ">ข้อความดั้งเดิมในพระไอยการทาษ ({{ฮวอม|แลงกาต์|2481b|p=71}}) ว่า “ทาษไถ่มาด้วยทรัพย”</ref>
# ทาสที่เกิดจากทาสในบ้านของท่าน<ref group = "วซ">ข้อความดั้งเดิมในพระไอยการทาษ ({{ฮวอม|แลงกาต์|2481b|p=71}}) ว่า “ลูกทาษเกิดในเรือนเบี้ย”</ref>
# ทาสที่ท่านได้มาจากบิดามารดาของท่าน
# ทาสที่ท่านได้มาโดยผู้อื่นให้
# ทาสที่ท่านได้ช่วยให้พ้นจากโทษทัณฑ์
# ผู้ที่กลายเป็นทาสท่านเพราะท่านได้เลี้ยงในยามข้าวแพง และ
# ผู้ที่ท่านนำกลับมาเป็นเชลยในคราวที่ท่านไปรบมา<ref group = "วซ">ข้อความดั้งเดิมในพระไอยการทาษ ({{ฮวอม|แลงกาต์|2481b|p=71}}) ว่า “นำธงไชยไปรบศึกแล้วแลได้มาเปนทาษชะเลย”</ref>
จะเห็นได้ทันทีว่า ทาสทั้งเจ็ดประเภทที่เอ่ยถึงในประมวลกฎหมายพระมนูกับลักษณะทาสของสยามเหมือนกันทุกประการ
}}
{{ตรคป
|Sir John Bowring has said in his treatise on Siam that "legal reasons for excluding witnesses are so many in Siam that they would appear seriously to interfere with the collection of evidence." Here again is another illustration of the close analogy between the Hindu law and the ancient Siamese laws. The code of Manu says as follows: "Those must not be made witnesses who have an interest in the suit, nor familiar friends, companions, and enemies of the parties, nor men formerly convicted of perjury, nor persons suffering under severe illness, nor those tainted by mortal sin. The king cannot be made a witness, nor mechanics and actors, nor a Srotriya, nor a student of the Veda, nor an ascetic who has given up all connection with the world, nor one wholly dependent, nor one of bad fame, nor a Dasyu, nor one who follows cruel occupations, nor an aged man, nor an infant, nor one man alone, nor a man of the lowest castes, nor one deficient in organs of sense, nor one extremely grieved, nor one intoxicated, nor a mad man, nor one tormented by hunger or thirst, nor one oppressed by fatigue, nor one tormented by desire, nor a wrathful man, nor a "thief" (Manu VII1, 64–68). On this subject the Siamese Laxana Payan<ref group = "a">The name of an ancient Siamese law concerning witnesses.</ref> says that the following thirty-three kinds of persons are excluded from being witnesses, namely: (1) those who do not observe the five and eight precepts; (2) those who are debtors of litigants or have borrowed anything from them; (3) slaves of litigants; (4) relation of litigants; (5) friends of litigants; (6) companions of litigants who eat and sleep with them; (7) those who have quarrelled with litigants; (8) those who are covetous; (9) enemies of litigants; (10) those who {{ตตฉ|aro|are}} suffering under severe illness; (11) children under seven years of age; (12) aged people over seventy years of age; (13) those who go about defaming one person to another; (14) those who beg for food by dancing; (15) those who beg for food by singing and playing; (16) those who have no homes and wander about; (17) those who hold cocoanut shells and go about begging; (18) those who are deaf; (19) those who are blind; (20) prostitutes; (21) lewd women; (22) pregnant women; (23) those who are neither male nor female; (24) those who are both male and female; (25) sorcerers and sorceresses; (26) those who are mad; (27) physicians who have not studied medical books; (28) shoemakers; (29) fishermen; (30{{ปตปต|)}} those who are confirmed gamblers; (31) thieves and robbers; (32) those who are wrathful; (33) executioners. It will be observed if there is any difference between the text of the Hindu Manu and that of the Siamese Laxana Payan it is that while the Hindu text is more general in some instances the Siamese text is more specific. For instance, while the code of Manu says in a general way that infants and aged men cannot be made witnesses, the Laxana Payan is more specific by limiting the exact ages under and above which they cannot be made witnesses. Again, while the code of Manu excludes in a general way those who follow cruel occupations, those who are deficient in organs of sense, those who are of the lower castes, etc., the Laxana Payan goes into details and specifies what they are. But on the whole it cannot be denied that both the Hindu and Siamese texts are hinting at one and the same thing.
| เซอร์จอห์น เบาว์ริง กล่าวไว้ในความเรียงเรื่องสยาม<ref group = "วซ">อาจหมายถึง หนังสือ เรื่อง ''The Kingdom and People of Siam; with a Narrative of the Mission to That Country in 1855''</ref> ว่า “ในสยาม เหตุผลทางกฎหมายที่จะใช้ตัดพยานนั้นมีมากโข ถึงขั้นที่ดูจะก้าวก่ายกับการรวบรวมพยานหลักฐานเหลือเกิน” ตรงนี้จะขอยกอีกสักตัวอย่างหนึ่งให้เห็นว่า กฎหมายฮินดูกับกฎหมายโบราณของสยามนั้นเทียบกันได้ติด ประมวลกฎหมายพระมนูระบุว่า
: “ผู้มีส่วนได้เสียในคดีก็ดี เพื่อนคุ้นเคย คู่หู หรือศัตรูของคู่ความก็ดี ผู้เคยถูกพิพากษาว่าให้การเท็จก็ดี ผู้เจ็บป่วยรุนแรงก็ดี ช่างซ่อมและนักแสดงก็ดี โศรติยะ<ref group = "วซ">{{ฮวอ|Hiemstra|2021}} ว่า โศรติยะ (śrotriya) หมายถึง ผู้ “ชำนาญและรู้มากในพระเวท” (proficient and well versed in Veda), พราหมณ์ที่คงแก่เรียน (learned Brāhmaṇa), หรือ “ผู้รู้มากในวิชาอาคม” (one well versed in sacred learning)</ref> ก็ดี ผู้ร่ำเรียนพระเวทก็ดี นักพรตผู้ได้ละทิ้งความเกี่ยวข้องทั้งปวงกับทางโลกแล้วก็ดี ผู้ต้องพึ่งพาผู้อื่นโดยสิ้นเชิงก็ดี ผู้มีชื่อเสียงเสื่อมทรามก็ดี ทัสยุ<ref group = "วซ">ทัสยุ (dasyu) หมายถึง คนไม่นับถือศาสนา (impious one) หรือคนไร้อารยะ (barbarian) ''สารานุกรมบริแทนนิกา'' ({{ฮวอม|Stefon & Tikkanen|2010}}) ระบุว่า คำนี้ใช้เรียกคนพื้นเมืองดั้งเดิมของอินเดียซึ่งได้รับการพรรณนาว่า ผิวคล้ำ พูดจาไม่รื่นหู (harsh-spoken) บูชาลึงค์ และอาจจัดอยู่ในกลุ่มศูทร (วรรณะล่างสุดของอินเดีย) ซึ่งต้องรับใช้วรรณะที่เหลือ (พราหมณ์ กษัตริย์ แพศย์) และถูกกีดกันจากการร่วมพิธีกรรมกับวรรณะเหล่านั้น รากศัพท์ของคำนี้คือ “ทาส” (dāsa)</ref> ก็ดี ผู้ประกอบอาชีพโหดร้ายก็ดี ผู้สูงอายุก็ดี ทารกก็ดี คนโสดก็ดี คนจากวรรณะต่ำสุดก็ดี ผู้ขาดอวัยวะในการรับรู้ก็ดี ผู้ทุกข์ตรมอย่างหนักก็ดี คนเมาก็ดี คนบ้าก็ดี ผู้ทรมานเพราะความหิวหรือกระหายก็ดี ผู้ถูกความเหนื่อยล้ารังควานก็ดี ผู้ทรมานเพราะความอยากได้อยากมีก็ดี คนเจ้าอารมณ์ก็ดี ‘โจร’ ก็ดี เป็นผู้ที่ต้องห้ามเป็นพยาน” (พระมนู เล่ม 8 หน้า 64–68)
ในเรื่องนี้ ลักษณะพยาน<ref group = "ก">ชื่อกฎหมายโบราณของสยามเกี่ยวกับพยาน</ref> ของสยามระบุว่า บุคคล 33 จำพวกดังต่อไปนี้ ต้องตัดออกจากการเป็นพยาน คือ
# ผู้ไม่ถือศีลห้าและศีลแปด
# ผู้เป็นลูกหนี้ของคู่ความ หรือเคยยืมสิ่งใด ๆ จากเขาเหล่านั้น<ref group = "วซ">ข้อความดั้งเดิมในพระไอยการลักษณภญาณ ({{ฮวอม|แลงกาต์|2481a|p=333}}) ว่า “คนกู้นี่ยืมสีนผู้เปนความ”</ref>
# ทาสของคู่ความ
# ญาติของคู่ความ
# เพื่อนของคู่ความ
# คู่หูของคู่ความซึ่งกินอยู่หลับนอนด้วยกัน<ref group = "วซ">ข้อความดั้งเดิมในพระไอยการลักษณภญาณ ({{ฮวอม|แลงกาต์|2481a|p=333}}) ว่า “คนเปนเพื่อนกินอยู่สมเลกับผู้เปนความ”</ref>
# ผู้เคยวิวาทกับคู่ความ
# คนละโมบ<ref group = "วซ">"Those who are covetous" (คนผู้ซึ่งละโมบ) น่าจะเป็นการแปลผิด เพราะข้อความดั้งเดิมในพระไอยการลักษณภญาณ ({{ฮวอม|แลงกาต์|2481a|p=333}}) ว่า “คนมักมากถ้อยมากความ”</ref>
# ศัตรูของคู่ความ<ref group = "วซ">ข้อความดั้งเดิมในพระไอยการลักษณภญาณ ({{ฮวอม|แลงกาต์|2481a|p=333}}) ว่า “คนผูกเวรกับผู้เปนความ”</ref>
# คนเจ็บป่วยรุนแรง<ref group = "วซ">ข้อความดั้งเดิมในพระไอยการลักษณภญาณ ({{ฮวอม|แลงกาต์|2481a|p=333}}) ว่า “คนเปนโรคมาก”</ref>
# เด็กอายุต่ำกว่าเจ็ดปี<ref group = "วซ">ข้อความดั้งเดิมในพระไอยการลักษณภญาณ ({{ฮวอม|แลงกาต์|2481a|p=334}}) ว่า “เดก 7 เข้า” ความหมายของคำว่า “เข้า” ยังเป็นที่ถกเถียงอยู่ {{ฮวอ|ราชบัณฑิตยสถาน|2556|p=37}} ว่า หมายถึง ปี เช่น 19 เข้า คือ 19 ปี ส่วนพิฑูร มลิวัลย์ (ใน {{ฮวอม|สุจิตต์ วงษ์เทศ|2526|p=175}}) ว่า "เข้า ควรจะหมายถึง ย่างเข้า ไม่ควรหมายความว่า ปี ในวรรณคดีอิสานมีที่ใช้หลายแห่ง...เช่น อายุได้ 16 เข้า หมายความว่า ย่างเข้า 16 ปี ศิลาจารึกสุโขทัย หลักที่สอง ก็มีข้อความว่า อายุยี่สิบเก้าเข้าสามสิบ"</ref>
# คนแก่อายุกว่าเจ็ดสิบปี<ref group = "วซ">ข้อความดั้งเดิมในพระไอยการลักษณภญาณ ({{ฮวอม|แลงกาต์|2481a|p=334}}) ว่า “เถ้า 70”</ref>
# ผู้เที่ยวไปว่าร้ายคนโน้นคนนี้<ref group = "วซ">ข้อความดั้งเดิมในพระไอยการลักษณภญาณ ({{ฮวอม|แลงกาต์|2481a|p=334}}) ว่า “คนมักส่อเสียดท่าน”</ref>
# ผู้เต้นรำขออาหาร<ref group = "วซ">ข้อความดั้งเดิมในพระไอยการลักษณภญาณ ({{ฮวอม|แลงกาต์|2481a|p=334}}) ว่า “คนเต้นรำขอทานเลี้ยงชีวิตร”</ref>
# ผู้ขับร้องบรรเลงขออาหาร<ref group = "วซ">ข้อความดั้งเดิมในพระไอยการลักษณภญาณ ({{ฮวอม|แลงกาต์|2481a|p=334}}) ว่า “คนขับขอทานท่าน”</ref>
# ผู้ไร้บ้านและเที่ยวท่องไปเรื่อย<ref group = "วซ">ข้อความดั้งเดิมในพระไอยการลักษณภญาณ ({{ฮวอม|แลงกาต์|2481a|p=333}}) ว่า “คนไม่มีเรือนเที่ยวจร”</ref>
# ผู้ถือกะลามะพร้าวเที่ยวขอทาน<ref group = "วซ">ข้อความดั้งเดิมในพระไอยการลักษณภญาณ ({{ฮวอม|แลงกาต์|2481a|p=333}}) ว่า “คนถือกระเบื้องกระลาขอทาน”</ref>
# คนหูหนวก
# คนตาบอด
# โสเภณี<ref group = "วซ">ข้อความดั้งเดิมในพระไอยการลักษณภญาณ ({{ฮวอม|แลงกาต์|2481a|p=333}}) ว่า “หญิงนครโสภิณี”</ref>
# หญิงลามก<ref group = "วซ">ข้อความดั้งเดิมในพระไอยการลักษณภญาณ ({{ฮวอม|แลงกาต์|2481a|p=333}}) ว่า “หญิงแพศยา”</ref>
# หญิงมีครรภ์
# ผู้ไม่เป็นทั้งชายทั้งหญิง<ref group = "วซ">ข้อความดั้งเดิมในพระไอยการลักษณภญาณ ({{ฮวอม|แลงกาต์|2481a|p=333}}) ว่า “เปนกระเทย”</ref>
# ผู้เป็นทั้งชายทั้งหญิง<ref group = "วซ">ข้อความดั้งเดิมในพระไอยการลักษณภญาณ ({{ฮวอม|แลงกาต์|2481a|p=333}}) ว่า “เปนบันเดาะ”</ref>
# พ่อมดและแม่มด
# คนบ้า<ref group = "วซ">ข้อความดั้งเดิมในพระไอยการลักษณภญาณ ({{ฮวอม|แลงกาต์|2481a|p=333}}) ว่า “คนเปนพิกลจริต”</ref>
# แพทย์ซึ่งมิได้เรียนตำราแพทย์<ref group = "วซ">ข้อความดั้งเดิมในพระไอยการลักษณภญาณ ({{ฮวอม|แลงกาต์|2481a|p=334}}) ว่า “หมอยาหมีได้เรียนคำภีรแพท”</ref>
# คนทำรองเท้า<ref group = "วซ">ข้อความดั้งเดิมในพระไอยการลักษณภญาณ ({{ฮวอม|แลงกาต์|2481a|p=334}}) ว่า “ช่างเกือก”</ref>
# ชาวประมง
# คนติดพนันขันต่อ<ref group = "วซ">ข้อความดั้งเดิมในพระไอยการลักษณภญาณ ({{ฮวอม|แลงกาต์|2481a|p=334}}) ว่า “คนนักเลงเล่นเบี้ยบ่อน”</ref>
# โจรและขโมย<ref group = "วซ">ข้อความดั้งเดิมในพระไอยการลักษณภญาณ ({{ฮวอม|แลงกาต์|2481a|p=334}}) ว่า “คนเปนโจร”</ref>
# คนเจ้าอารมณ์<ref group = "วซ">ข้อความดั้งเดิมในพระไอยการลักษณภญาณ ({{ฮวอม|แลงกาต์|2481a|p=334}}) ว่า “คนโทโสมาก”</ref>
# เพชฌฆาต
จะสังเกตได้ว่า ข้อแตกต่างใด ๆ ในระหว่างตัวบทของพระมนูฮินดูกับตัวบทของลักษณะพยานสยาม ถ้าจะมี ก็คือ ตัวบทของฮินดูระบุบางกรณีเป็นการทั่วไปมากกว่า ขณะที่ตัวบทของสยามเจาะจงมากกว่า ตัวอย่างเช่น ประมวลกฎหมายพระมนูระบุในลักษณะทั่วไปว่า ทารกและคนชราจะนำมาเป็นพยานมิได้ ส่วนลักษณะพยานเจาะจงกว่า โดยจำกัดอายุที่เขาเหล่านั้นมีต่ำกว่าหรือสูงกว่าแล้วจะเป็นพยานไม่ได้ อีกประการหนึ่ง ประมวลกฎหมายพระมนูระบุอย่างทั่วไปว่า ให้ตัดผู้ประกอบอาชีพโหดร้าย ผู้ขาดอวัยวะในการรับรู้ ผู้มาจากวรรณะต่ำสุด ฯลฯ จากการเป็นพยาน ขณะที่ลักษณะพยานลงรายละเอียดและระบุว่า คนเหล่านี้ได้แก่ใครบ้าง แต่ในภาพรวมแล้ว ปฏิเสธไม่ได้เลยว่า ทั้งตัวบทของฮินดูและสยามกำลังเปรยถึงสิ่งเดียวกัน
}}
{{ตรคป
|It is a principle of Hindu law that interest ought never to exceed the capital (Manu VIII, 151–153). The Siamese Laxana Ku-ni<ref group = "a">The name of an ancient Siamese law concerning debts.</ref> expresses the same principles as follows: "Where a person contracts a debt and pays interest for one, two or three months, but afterwards fails to do so, and when the creditor presses him, he defers and evades payment, so that the creditor having received neither capital nor interest for so long a time, summons him before the judge. The interest which the debtor has paid for the first, second or third month is profit due to the creditor; the creditor may also claim the amount of interest which remains unpaid, but if the debt be a long standing one, let the interest not exceed the capital, according to law." (Archer's Translation of the Siamese Laws of Debts, page 6).
| กฎหมายฮินดูมีหลักว่า ดอกเบี้ยไม่ควรเกินต้น (พระมนู เล่ม 8 หน้า 151–153) ลักษณะกู้หนี้<ref group = "ก">ชื่อกฎหมายโบราณของสยามเกี่ยวกับหนี้</ref> ของสยามก็ปรากฏหลักอย่างเดียวกันว่า
: “เมื่อบุคคลทำสัญญาเป็นหนี้ และจ่ายดอกเบี้ยให้เดือนหนึ่ง สองเดือน หรือสามเดือนก็ดี แต่หลังจากนั้นก็ไม่กระทำเช่นนั้นอีก และเมื่อเจ้าหนี้มาทวง ก็ผัดผ่อนหลบเลี่ยงชำระเสีย เจ้าหนี้ซึ่งมิได้ทั้งต้นทั้งดอกมาช้านาน จึงเรียกให้มาอยู่ต่อหน้าตุลาการ [ดังนี้ ให้ถือว่า] ดอกเบี้ยที่ลูกหนี้จ่ายไปในเดือนแรก เดือนสอง หรือเดือนสามนั้น เป็นกำไรที่เจ้าหนี้ควรได้ เจ้าหนี้จะเรียกดอกเบี้ยจำนวนที่ค้างจ่ายอีกก็ได้ แต่ถ้าหนี้นั้นเนิ่นนานนักหนาแล้ว ดอกเบี้ยให้คิดไม่เกินต้น ตามความในกฎหมาย”<ref group = "วซ">ข้อความดั้งเดิมในภาษาไทย คือ มาตรา 34 ของพระไอยการลักษณกู้หนี้ ซึ่งระบุว่า ({{ฮวอม|แลงกาต์|2481b|p=186}}) “กู้เงินท่าน แลส่งดอกเบี้ยรายมาถึงเดือนหนึ่ง 2 เดือน 3 เดือนแล้วก็ดี แลอยู่มามิส่งนายเงิน ๆ ก็ไปทวง แลทำประเว่ประวิงไปมา ต้นเงินก็มิส่ง ดอกเบี้ยก็มิให้ เปนช้านาน นายเงินให้สมภักนักการเรียกหา แลท่านบังคับว่า ซึ่งดอกเบี้ยส่งรายเดือนหนึ่ง 2 เดือน 3 เดือนนั้น เปนลาภแก่นายเงินแต่ที่ได้ไว้แล้วนั้น แลซึ่งดอกเบี้ยยังไม่ส่งนั้น ให้บังคับตามมากแลน้อย ถ้าแลช้านานเท่าใด ให้บังคับแต่ต่อหน้าโดยพระราชกฤษฎีกา”</ref> (คำแปลกฎหมายสยามว่าด้วยหนี้ของอาร์เชอร์ หน้า 6)
}}
{{ตรคป
| It is a principle of Hindu law that if a defendant falsely denies a debt he is to be fined double the amount of the debt (Manu VIII, 59). The Siamese Laxana Kuni expresses the same principle as follows: "Where a debtor summoned before the judge does not acknowledge the debt: if it be ascertained that he is really so indebted, let him be fined double the amount of the debt" (Archer's Translation of Siamese Laws on Debts, page 9).
| หลักกฎหมายฮินดูมีว่า ถ้าจำเลยกล่าวเท็จว่าไม่ได้เป็นหนี้ เขาจะถูกปรับสองเท่าของจำนวนหนี้ (พระมนู เล่ม 8 หน้า 59) ลักษณะกู้หนี้ของสยามก็ปรากฏหลักอย่างเดียวกันว่า
: “เมื่อลูกหนี้ที่ถูกเรียกมาอยู่ต่อหน้าตุลาการไม่รับว่าเป็นหนี้ ถ้าพิสูจน์ทราบว่า เป็นหนี้เช่นนั้นจริง ๆ ให้ปรับสองเท่าของจำนวนหนี้”<ref group = "วซ">ข้อความดั้งเดิมในภาษาไทยอาจได้แก่ มาตรา 53 ของพระไอยการลักษณกู้หนี้ ที่ระบุว่า ({{ฮวอม|แลงกาต์|2481b|p=194}}) “ถ้ากู้หนี้ของท่านมิรับ ว่ามิได้กู้ ต่อสำนวนด้วยเจ้าหนี้ สวนสับขับแท้ แพ้แก่เจ้าหนี้ ให้เอาต้นสีนตั้งไหมทวีคูน”</ref> (คำแปลกฎหมายสยามว่าด้วยหนี้ของอาร์เชอร์ หน้า 9)
}}
{{ตรคป
| The forgoing texts which have been quoted somewhat at random from the Hindu code of Manu and the ancient laws o{{ปตปต|f}} Siam will, it is hoped, have been sufficient to show that the ancient laws of Siam are of Hindu origin and belong to that group of laws which may be called the Hindu law system—a proposition which is admitted and taken for granted by every one, but which curiously enough no one has ever undertaken to prove before.
| หวังว่า ข้อความข้างต้นซึ่งสุ่มยกมาจากประมวลกฎหมายฮินดูของพระมนูและกฎหมายโบราณของสยามจะพอแสดงให้เห็นว่า กฎหมายโบราณของสยามมีแหล่งกำเนิดมาจากฮินดู และอยู่ในกลุ่มกฎหมายที่อาจขนานนามว่า ระบบกฎหมายฮินดู อันเป็นทฤษฎีที่ทุกคนยอมรับและนับถือหมดใจ แต่แปลกดีที่ไม่เคยมีใครรับหน้าที่พิสูจน์มาก่อน
}}
==เชิงอรรถเดิม==
{{col-begin}}
{{col-2}}
{{reflist|group=a}}
{{col-2}}
{{reflist|group=ก}}
{{col-end}}
==เชิงอรรถของวิกิซอร์ซ==
{{reflist|group=วซ}}
==บรรณานุกรม==
===ต้นฉบับ===
{{รออ}}
* {{อวส|last=Masao|first=T|year=1905|title=[[:File:Sources_of_ancient_Siamese_law_(Masao_T,_1905).pdf|The Sources of Ancient Siamese Law]]|journal=Yale Law Journal|volume=15|pages=28–32}}
{{จออ}}
===อ้างอิง===
{{รออ}}
* {{อนส|author=ราชบัณฑิตยสถาน|year=2556|title=พจนานุกรมศัพท์วรรณคดีไทย สมัยสุโขทัย ศิลาจารึกพ่อขุนรามคำแหงมหาราช หลักที่ 1|edition=3|location=กรุงเทพฯ|publisher=ราชบัณฑิตยสถาน|isbn=978-616-7073-62-0|ref={{ฮวต|ราชบัณฑิตยสถาน|2556}}}}
* {{อนส|editor=แลงกาต์, ร.|year=2481a|title=ประมวลกฎหมายรัชกาลที่ 1 จุลศักราช 1166 พิมพ์ตามฉะบับหลวงตรา 3 ดวง|volume=1|location=พระนคร|publisher=โรงพิมพ์มหาวิทยาลัยวิชาธรรมศาสตร์และการเมือง|ref={{ฮวต|แลงกาต์|2481a}}}}
* {{อนส|editor=แลงกาต์, ร.|year=2481b|title=ประมวลกฎหมายรัชกาลที่ 1 จุลศักราช 1166 พิมพ์ตามฉะบับหลวงตรา 3 ดวง|volume=2|location=พระนคร|publisher=โรงพิมพ์มหาวิทยาลัยวิชาธรรมศาสตร์และการเมือง|ref={{ฮวต|แลงกาต์|2481b}}}}
* {{อนส|editor=สุจิตต์ วงษ์เทศ|year=2526|title=สุโขทัยไม่ใช่ราชธานีแห่งแรกของไทย|location=กรุงเทพฯ|publisher=เรือนแก้วการพิมพ์|isbn=974-8350-363|ref={{ฮวต|สุจิตต์ วงษ์เทศ|2526}}}}
* {{อว|last=Hiemstra|first=G|year=2021|title=Shrotriya, Śrotrīya, Śrotriya: 12 definitions|website=Wisdom Library|url=https://www.wisdomlib.org/definition/shrotriya|ref={{ฮวต|Hiemstra|2021}}}}
* {{อว|last=Stefon|first=M|last2=Tikkanen|first2=A|year=2010|title=Dasyu|website=Encyclopaedia Britannica|url=https://www.britannica.com/topic/dasyu|ref={{ฮวต|Stefon & Tikkanen|2010}}}}
{{จออ}}
{{สัญญาอนุญาตงานแปล
| {{สาธารณสมบัติ-สหรัฐ|1921}}
| {{สาธารณสมบัติ-เอง}}
}}
m9votvshh7kr2zbiwicgbcllpgqc6oj
งานแปล:การแก้ไขเพิ่มเติมรัฐธรรมนูญสหรัฐ ครั้งที่ 11
114
51935
189463
168348
2022-08-16T16:16:25Z
Venise12mai1834
8884
wikitext
text/x-wiki
{{หัวเรื่องงานแปล
| ชื่อ = {{PAGENAME}} ค.ศ. 1793
| ปี = 2336
| ภาษา = en
| ต้นฉบับ =
| ผู้สร้างสรรค์ = รัฐสภาสหรัฐ
| บรรณาธิการ =
| ส่วน =
| ผู้มีส่วนร่วม =
| ก่อนหน้า =
| ถัดไป =
| หมายเหตุ = {{ชุด
| ชุด = [[สถานีย่อย:รัฐธรรมนูญสหรัฐ|การแก้ไขเพิ่มเติมรัฐธรรมนูญสหรัฐ]]
| ชื่อ = ครั้งที่ 11
| ก่อน = [[งานแปล:บัญญัติสิทธิสหรัฐ|ครั้งที่ 1–10]]
| ถัด = [[งานแปล:การแก้ไขเพิ่มเติมรัฐธรรมนูญสหรัฐ ครั้งที่ 12|ครั้งที่ 12]]
}}
}}
__NOTOC__
{{ตรคป
| {{ก|Third Congress of the United States:}}
| {{ก|รัฐสภาสหรัฐ ชุดที่สาม}}
| ไม่ย่อหน้า =
}}
{{ตรคป
| At the first session, begun and held at the City of Philadelphia, in the State of Pennsylvania, on Monday the Second of December one thousand seven hundred and ninety three.
| ในสมัยที่หนึ่ง ซึ่งเริ่มต้นและจัดขึ้น ณ นครฟิลาเดลเฟีย ในรัฐเพนซิลเวเนีย เมื่อวันจันทร์ที่สอง ธันวาคม พันเจ็ดร้อยเก้าสิบสาม
}}
{{ตรคป
| {{สกอ|sp|100}}
| {{สกอ|sp|100}}
| ไม่ย่อหน้า =
}}
{{ตรคป
| Resolved by the Senate and House of Representatives of the United States of America, in Congress assembled, two thirds of both Houses concurring, that the following Article be proposed to the Legislatures of the several States as an amendment to the Constitution of the United States, which when ratified by three fourths of the said Legislatures shall be valid as part of the said Constitution, viz:
| วุฒิสภาและสภาผู้แทนราษฎรสหรัฐอเมริกา ณ รัฐสภาที่ชุมนุมกันนั้น มีมติโดยสองในสามของสภาทั้งสองเห็นพ้องต้องกันว่า ให้เสนอมาตราดังต่อไปนี้ต่อสภานิติบัญญัติของรัฐต่าง ๆ เป็นข้อแก้ไขเพิ่มเติมรัฐธรรมนูญสหรัฐ ซึ่งเมื่อได้รับสัตยาบันจากสามในสี่ของสภานิติบัญญัติดังกล่าวแล้ว จะสมบูรณ์เป็นส่วนหนึ่งของรัฐธรรมนูญดังกล่าว คือ
}}
{{ตรคป
| {{สกอ|sp|100}}
| {{สกอ|sp|100}}
| ไม่ย่อหน้า =
}}
{{ตรคป
| The Judicial power of the Unites States shall not be construed to extend to any suit in law or equity, commenced or prosecuted against one of the United States by Citizens of another State, or by Citizens or Subjects of any Foreign State.
| อำนาจตุลาการของสหรัฐนั้น มิให้นำไปตีความให้ขยายไปถึงคดีในทางกฎหมายหรือทางความเที่ยงธรรมคดีใด ๆ<ref>การแปล "equity" ว่า "ความเที่ยงธรรม" ในที่นี้ เป็นไปตามศัพท์บัญญัติของ{{ฮวอ|ราชบัณฑิตยสถาน|2549|p=98}} แต่บางทีจะพบว่า นักกฎหมายไทยเลือกทับศัพท์คำนี้มากกว่าจะแปล ส่วนรายละเอียดอื่น ๆ อ่านที่ ''{{w|en:Equity (law)|Equity}}''</ref> ซึ่งพลเมืองของรัฐแห่งหนึ่งแห่งใดในสหรัฐ หรือพลเมืองหรือคนในบังคับของรัฐต่างชาติ ตั้งต้นหรือดำเนิน<ref>อันที่จริง คำว่า "ตั้งต้น" หรือ "ดำเนิน" นี้ โดยทั่วไปหมายความว่า เป็นโจทก์ แต่ในทางกฎหมายแล้ว อาจมีความหมายเฉพาะได้ เช่น {{ฮวอ|Black|1968|p=335}} ระบุว่า คดีในทางความเที่ยงธรรม (suit in equity) จะตั้งต้นได้เมื่อมีการออกหมายเรียกพยาน (subpoena)</ref> ต่อรัฐแห่งอื่น[ในสหรัฐ]
}}
{{ตรคป
| {{สกอ|sp|100}}
| {{สกอ|sp|100}}
| ไม่ย่อหน้า =
}}
{{ตรคป
| Frederick Augustus Muhlenberg, Speaker of the House of Representatives.
| เฟร็ดริก ออกัสตัส มิวลินเบิร์ก ประธานสภาผู้แทนราษฎร
}}
{{ตรคป
| John Adams, Vice President of the United States and President of the Senate.
| จอห์น แอดัมส์ รองประธานาธิบดีสหรัฐและประธานวุฒิสภา
}}
{{ตรคป
| Attest
| พยาน
| ไม่ย่อหน้า =
}}
{{ตรคป
| John Beckley, Clerk of the House of Representatives.
| จอห์น เบ็กลีย์ เสมียนสภาผู้แทนราษฎร
}}
{{ตรคป
| Sam. A Otis, Secretary of the Senate
| แซม. เอ โอทิส เลขานุการวุฒิสภา
}}
==เชิงอรรถ==
{{รกออ}}
==บรรณานุกรม==
===ต้นฉบับ===
{{เริ่มอ้างอิง}}
* {{อ้างเว็บ|author=U.S. National Archives and Records Administration|year=n.d.|title=Picture of the Eleventh Amendment to the Constitution of the United States, Ratified in 1795|format=online image|website=Encyclopædia Britannica|url=https://cdn.britannica.com/82/142482-050-3CDF0069/Eleventh-Amendment-Constitution-of-the-United-States-1795.jpg}}
{{จบอ้างอิง}}
===อ้างอิง===
{{เริ่มอ้างอิง}}
* {{อ้างหนังสือ|author=ราชบัณฑิตยสถาน|year=2549|title=ศัพท์นิติศาสตร์ อังกฤษ-ไทย ไทย-อังกฤษ ฉบับราชบัณฑิตยสถาน|edition=6|location=กรุงเทพฯ|publisher=นานมีบุ๊คส์พับลิเคชั่นส์|isbn=978-974-9996-50-8|ref={{ฮวต|ราชบัณฑิตยสถาน|2549}}}}
* {{อ้างหนังสือ|first=H C|last=Black|title=Black's Law Dictionary|edition=4|location=Saint Paul, Minnesota|publisher=West Publishing|language=en|year=1968|ref={{ฮวต|Black|1968}}}}
{{จบอ้างอิง}}
{{สัญญาอนุญาตงานแปล
| 1 = {{สาธารณสมบัติ-รัฐบาลสหรัฐ}}
| 2 = {{สาธารณสมบัติ-เอง}}
}}
[[หมวดหมู่:รัฐธรรมนูญสหรัฐ]]
6n8trhsyigfa59hu4p6srd2g0lu0853
งานแปล:การแก้ไขเพิ่มเติมรัฐธรรมนูญสหรัฐ ครั้งที่ 12
114
52306
189466
168347
2022-08-16T16:20:45Z
Venise12mai1834
8884
wikitext
text/x-wiki
{{หัวเรื่องงานแปล
| ชื่อ = {{PAGENAME}} ค.ศ. 1803
| ปี = 2346
| ภาษา = en
| ต้นฉบับ =
| ผู้สร้างสรรค์ = รัฐสภาสหรัฐ
| บรรณาธิการ =
| ส่วน =
| ผู้มีส่วนร่วม =
| ก่อนหน้า =
| ถัดไป =
| หมายเหตุ = {{ชุด
| ชุด = [[สถานีย่อย:รัฐธรรมนูญสหรัฐ|การแก้ไขเพิ่มเติมรัฐธรรมนูญสหรัฐ]]
| ชื่อ = ครั้งที่ 12
| ก่อน = [[งานแปล:การแก้ไขเพิ่มเติมรัฐธรรมนูญสหรัฐ ครั้งที่ 11|ครั้งที่ 11]]
| ถัด = [[งานแปล:การแก้ไขเพิ่มเติมรัฐธรรมนูญสหรัฐ ครั้งที่ 13|ครั้งที่ 13]]
}}
}}
__NOTOC__
{{ตรคป
| {{ก|{{พญ|Eighth ''Congress'' of the United States:}}}}
| {{ก|รัฐสภาสหรัฐ ชุดที่แปด}}
| ไม่ย่อหน้า =
}}
{{ตรคป
| {{ก|{{พญล|at the first session,}}}}
| {{ก|ในสมัยที่หนึ่ง}}
| ไม่ย่อหน้า =
}}
{{ตรคป
| Begun and held at the city of Washington, in the territory of Columbia, on Monday the seventeenth of October, one thousand eight hundred and three.
| ซึ่งเริ่มต้นและจัดขึ้น ณ นครวอชิงตัน ในดินแดนโคลัมเบีย เมื่อวันจันทร์ที่เจ็ด ตุลาคม พันแปดร้อยสาม
}}
{{ตรคป
| {{สกอ|sp|100}}
| {{สกอ|sp|100}}
| ไม่ย่อหน้า =
}}
{{ตรคป
| Resolved by the Senate and House of Representatives of the United States of America, in Congress assembled, Two thirds of both houses concurring, that in lieu of the third paragraph of the first section of the second article of the constitution of the United States, the following be proposed as an amendment to the constitution of the United States, which when ratified by three fourths of the legislatures of the several states, shall be valid to all intents and purposes, as part of the said constitution, to wit:
| วุฒิสภาและสภาผู้แทนราษฎรสหรัฐอเมริกา ณ รัฐสภาที่ชุมนุมกันนั้น มีมติโดยสองในสามของสภาทั้งสองเห็นพ้องต้องกันว่า ให้เสนอ[ข้อความ]ต่อไปนี้เป็นการแก้ไขเพิ่มเติมรัฐธรรมนูญสหรัฐ [เพื่อใช้]แทนรัฐธรรมนูญสหรัฐ มาตราสอง ข้อหนึ่ง วรรคสาม ซึ่งเมื่อได้รับสัตยาบันจากสามในสี่ของสภานิติบัญญัติแห่งรัฐทั้งหลายแล้ว จะสมบูรณ์เป็นส่วนหนึ่งของรัฐธรรมนูญดังกล่าวในทุกสถานและทุกประการ คือ
}}
{{ตรคป
| The Electors shall meet in their respective states, and vote by ballot for President and Vice-President, one of whom, at least, shall not be an inhabitant of the same state with themselves; they shall name in their ballots the person voted for as President, and in distinct ballots the person voted for as Vice-President, and they shall make distinct lists of all persons voted for as President, and all persons voted for as Vice-President and of the number of votes for each, which lists they shall sign and certify, and transmit sealed to the seat of the government of the United States, directed to the President of the Senate; The President of the Senate shall, in the presence of the Senate and House of Representatives, open all the certificates and the votes shall then be counted; The person having the greatest number of votes for President, shall be the President, if such number be a majority of the whole number of Electors appointed; and if no person have such majority, then from the persons having the highest numbers not exceeding three on the list of those voted for as President, the House of Representatives shall choose immediately, by ballot, the President. But in choosing the President, the votes shall be taken by states, the representation from each state having one vote; a quorum for this purpose shall consist of a member or members from two-thirds of the states, and a majority of all the states shall be necessary to a choice. And if the House of Representatives shall not choose a President whenever the right of choice shall devolve upon them, before the fourth day of March next following, then the Vice-President shall act as President, as in the case of the death or other constitutional disability of the President. The person having the greatest number of votes as Vice-President, shall be the Vice-President, if such number be a majority of the whole number of Electors appointed, and if no person have a majority, then from the two highest numbers on the list, the Senate shall choose the Vice-President; a quorum for the purpose shall consist of two-thirds of the whole number of Senators, and a majority of the whole number shall be necessary to a choice. But no person constitutionally ineligible to the office of President shall be eligible to that of Vice-President of the United States.
| ให้ผู้เลือกตั้งประชุมกันในแต่ละรัฐของตน แล้วใช้บัตรออกเสียงให้แก่ประธานาธิบดีและรองประธานาธิบดี ซึ่งอย่างน้อยหนึ่งคนต้องไม่เป็นผู้อยู่อาศัยในรัฐเดียวกับผู้เลือกตั้งนั้นเอง ให้ผู้เลือกตั้งระบุชื่อบุคคลที่ตนออกเสียงให้เป็นประธานาธิบดีไว้ในบัตรของตนนั้น และ[ระบุชื่อ]บุคคลที่ตนออกเสียงให้เป็นรองประธานาธิบดีไว้ในบัตรต่างหาก แล้วให้ผู้เลือกตั้งทำรายชื่อขึ้นต่างหากสำหรับบรรดาบุคคลที่ได้รับการออกเสียงให้เป็นประธานาธิบดี และบรรดาบุคคลที่ได้รับการออกเสียงให้เป็นรองประธานาธิบดี และจำนวนคะแนนเสียงของแต่ละบุคคล โดยรายชื่อนี้ให้ผู้เลือกตั้งลงนามรับรอง แล้วปิดผนึกส่งไปยังที่ว่าการรัฐบาลสหรัฐโดยจ่าหน้าถึงประธานวุฒิสภา ให้ประธานาวุฒิสภาเปิดใบรับรองทั้งหมดต่อหน้าวุฒิสภาและสภาผู้แทนราษฎร และให้มีการนับคะแนนเสียง บุคคลที่ได้คะแนนเสียงให้เป็นประธานาธิบดีเป็นจำนวนมากที่สุด ให้เป็นประธานาธิบดี ถ้าจำนวนเช่นว่านั้นเป็นเสียงข้างมากของจำนวนผู้เลือกตั้งทั้งหมดที่ได้รับแต่งตั้งมา และถ้าไม่มีผู้ใดได้เสียงข้างมากเช่นนั้นแล้ว ก็ให้สภาผู้แทนราษฎรเลือกประธานาธิบดีโดยทันทีจากบรรดาบุคคลที่ได้คะแนนสูงสุดไม่เกินสามอันดับในรายชื่อผู้ได้รับการออกเสียงให้เป็นประธานาธิบดี ทว่า ในการเลือกประธานาธิบดีนั้น ให้ถามเสียงจากรัฐทั้งหลาย โดยผู้แทนของแต่ละรัฐมีหนึ่งเสียง ส่วนองค์ประชุมสำหรับการนี้ให้ประกอบด้วยสมาชิกหนึ่งคนหรือหลายคนจากสองในสามของรัฐต่าง ๆ และการเลือกนั้นจำเป็นต้องได้เสียงข้างมากของรัฐทั้งหมด และเมื่อใดก็ตามสภาผู้แทนราษฎรเกิดมีสิทธิในการเลือกประธานาธิบดี แล้วไม่เลือกภายในวันที่สี่ของเดือนมีนาคมที่จะถึง ก็ให้รองประธานาธิบดีทำหน้าที่เป็นประธานาธิบดีเสมือนกรณีที่ประธานาธิบดีถึงแก่ความตายหรือถูกห้ามด้วยประการอื่นตามรัฐธรรมนูญ บุคคลที่ได้คะแนนเสียงให้เป็นรองประธานาธิบดีเป็นจำนวนมากที่สุด ให้เป็นรองประธานาธบิดี ถ้าจำนวนเช่นว่านั้นเป็นเสียงข้างมากของจำนวนผู้เลือกตั้งทั้งหมดที่ได้รับแต่งตั้งมา และถ้าไม่มีผู้ใดได้เสียงข้างมากเช่นนั้นแล้ว ก็ให้วุฒิสภาเลือกรองประธานาธิบดีจากบรรดาบุคคลที่ได้คะแนนสูงสุดไม่เกินสองอันดับในรายชื่อ องค์ประชุมสำหรับการนี้ให้ประกอบด้วยสมาชิกวุฒิสภาสองในสามของจำนวนทั้งหมด และการเลือกนั้นจำเป็นต้องได้รับเสียงข้างมากของจำนวนทั้งหมด ทั้งนี้ ผู้ใดขาดคุณสมบัติตามรัฐธรรมนูญสำหรับตำแหน่งประธานาธิบดี ผู้นั้นจะไม่มีคุณสมบัติสำหรับตำแหน่งรองประธานาธิบดีสหรัฐ
}}
{{ตรคป
| {{ข|''Nathaniel Macon'' Speaker of the House of Representatives.}}
| {{ข|''นาทาเนียล เมคอน'' ประธานสภาผู้แทนราษฎร}}
}}
{{ตรคป
| {{ข|''A. Burr'' Vice President of the United States, and President of the Senate.}}
| {{ข|''เอ. เบอร์'' รองประธานาธิบดีสหรัฐและประธานวุฒิสภา}}
}}
{{ตรคป
| Attest
| พยาน
}}
{{ตรคป
| {{ข|''John Beckley'' Clerk of the House of Representatives.}}
| {{ข|''จอห์น เบ็กลีย์'' เสมียนสภาผู้แทนราษฎร}}
}}
{{ตรคป
| {{ข|''Sam. A Otis'' Secretary of the Senate.}}
| {{ข|''แซม. เอ โอทิส'' เลขานุการวุฒิสภา}}
}}
==บรรณานุกรม==
{{เริ่มอ้างอิง}}
* {{อ้างเว็บ|author=U.S. National Archives and Records Administration|year=n.d.|title=Picture of the Twelfth Amendment to the U.S. Constitution, Ratified in 1804|format=online image|website=Encyclopædia Britannica|url=https://cdn.britannica.com/83/142483-050-3570E434/Twelfth-Amendment-US-Constitution-1804.jpg}}
{{จบอ้างอิง}}
{{สัญญาอนุญาตงานแปล
| 1 = {{สาธารณสมบัติ-รัฐบาลสหรัฐ}}
| 2 = {{สาธารณสมบัติ-เอง}}
}}
[[หมวดหมู่:รัฐธรรมนูญสหรัฐ]]
pr7ensv49ryznomupnzqyiu3r9l27gt
189481
189466
2022-08-16T16:43:49Z
Venise12mai1834
8884
wikitext
text/x-wiki
{{หัวเรื่องงานแปล
| ชื่อ = {{PAGENAME}} ค.ศ. 1803
| ปี = 2346
| ภาษา = en
| ต้นฉบับ =
| ผู้สร้างสรรค์ = รัฐสภาสหรัฐ
| บรรณาธิการ =
| ส่วน =
| ผู้มีส่วนร่วม =
| ก่อนหน้า =
| ถัดไป =
| หมายเหตุ = {{ชุด
| ชุด = [[สถานีย่อย:รัฐธรรมนูญสหรัฐ|การแก้ไขเพิ่มเติมรัฐธรรมนูญสหรัฐ]]
| ชื่อ = ครั้งที่ 12
| ก่อน = [[งานแปล:การแก้ไขเพิ่มเติมรัฐธรรมนูญสหรัฐ ครั้งที่ 11|ครั้งที่ 11]]
| ถัด = [[งานแปล:การแก้ไขเพิ่มเติมรัฐธรรมนูญสหรัฐ ครั้งที่ 13|ครั้งที่ 13]]
}}
}}
__NOTOC__
{{ตรคป
| {{ก|{{พญ|Eighth ''Congress'' of the United States:}}}}
| {{ก|รัฐสภาสหรัฐ ชุดที่แปด}}
| ไม่ย่อหน้า =
}}
{{ตรคป
| {{ก|{{พญล|at the first session,}}}}
| {{ก|ในสมัยที่หนึ่ง}}
| ไม่ย่อหน้า =
}}
{{ตรคป
| Begun and held at the city of Washington, in the territory of Columbia, on Monday the seventeenth of October, one thousand eight hundred and three.
| ซึ่งเริ่มต้นและจัดขึ้น ณ นครวอชิงตัน ในดินแดนโคลัมเบีย เมื่อวันจันทร์ที่เจ็ด ตุลาคม พันแปดร้อยสาม
}}
{{ตรคป
| {{สกอ|sp|100}}
| {{สกอ|sp|100}}
| ไม่ย่อหน้า =
}}
{{ตรคป
| Resolved by the Senate and House of Representatives of the United States of America, in Congress assembled, Two thirds of both houses concurring, that in lieu of the third paragraph of the first section of the second article of the constitution of the United States, the following be proposed as an amendment to the constitution of the United States, which when ratified by three fourths of the legislatures of the several states, shall be valid to all intents and purposes, as part of the said constitution, to wit:
| วุฒิสภาและสภาผู้แทนราษฎรสหรัฐอเมริกา ณ รัฐสภาที่ชุมนุมกันนั้น มีมติโดยสองในสามของสภาทั้งสองเห็นพ้องต้องกันว่า ให้เสนอ[ข้อความ]ต่อไปนี้เป็นการแก้ไขเพิ่มเติมรัฐธรรมนูญสหรัฐ [เพื่อใช้]แทนรัฐธรรมนูญสหรัฐ มาตราสอง ข้อหนึ่ง วรรคสาม ซึ่งเมื่อได้รับสัตยาบันจากสามในสี่ของสภานิติบัญญัติแห่งรัฐทั้งหลายแล้ว จะสมบูรณ์เป็นส่วนหนึ่งของรัฐธรรมนูญดังกล่าวในทุกสถานและทุกประการ คือ
}}
{{ตรคป
| The Electors shall meet in their respective states, and vote by ballot for President and Vice-President, one of whom, at least, shall not be an inhabitant of the same state with themselves; they shall name in their ballots the person voted for as President, and in distinct ballots the person voted for as Vice-President, and they shall make distinct lists of all persons voted for as President, and all persons voted for as Vice-President and of the number of votes for each, which lists they shall sign and certify, and transmit sealed to the seat of the government of the United States, directed to the President of the Senate; The President of the Senate shall, in the presence of the Senate and House of Representatives, open all the certificates and the votes shall then be counted; The person having the greatest number of votes for President, shall be the President, if such number be a majority of the whole number of Electors appointed; and if no person have such majority, then from the persons having the highest numbers not exceeding three on the list of those voted for as President, the House of Representatives shall choose immediately, by ballot, the President. But in choosing the President, the votes shall be taken by states, the representation from each state having one vote; a quorum for this purpose shall consist of a member or members from two-thirds of the states, and a majority of all the states shall be necessary to a choice. And if the House of Representatives shall not choose a President whenever the right of choice shall devolve upon them, before the fourth day of March next following, then the Vice-President shall act as President, as in the case of the death or other constitutional disability of the President. The person having the greatest number of votes as Vice-President, shall be the Vice-President, if such number be a majority of the whole number of Electors appointed, and if no person have a majority, then from the two highest numbers on the list, the Senate shall choose the Vice-President; a quorum for the purpose shall consist of two-thirds of the whole number of Senators, and a majority of the whole number shall be necessary to a choice. But no person constitutionally ineligible to the office of President shall be eligible to that of Vice-President of the United States.
| ให้ผู้เลือกตั้งประชุมกันในแต่ละรัฐของตน แล้วใช้บัตรออกเสียงให้แก่ประธานาธิบดีและรองประธานาธิบดี ซึ่งอย่างน้อยหนึ่งคนต้องไม่เป็นผู้อยู่อาศัยในรัฐเดียวกับผู้เลือกตั้งนั้นเอง ให้ผู้เลือกตั้งระบุชื่อบุคคลที่ตนออกเสียงให้เป็นประธานาธิบดีไว้ในบัตรของตนนั้น และ[ระบุชื่อ]บุคคลที่ตนออกเสียงให้เป็นรองประธานาธิบดีไว้ในบัตรต่างหาก แล้วให้ผู้เลือกตั้งทำรายชื่อขึ้นต่างหากสำหรับบรรดาบุคคลที่ได้รับการออกเสียงให้เป็นประธานาธิบดี และบรรดาบุคคลที่ได้รับการออกเสียงให้เป็นรองประธานาธิบดี และจำนวนคะแนนเสียงของแต่ละบุคคล โดยรายชื่อนี้ให้ผู้เลือกตั้งลงนามรับรอง แล้วปิดผนึกส่งไปยังที่ว่าการรัฐบาลสหรัฐโดยจ่าหน้าถึงประธานวุฒิสภา ให้ประธานาวุฒิสภาเปิดใบรับรองทั้งหมดต่อหน้าวุฒิสภาและสภาผู้แทนราษฎร และให้มีการนับคะแนนเสียง บุคคลที่ได้คะแนนเสียงให้เป็นประธานาธิบดีเป็นจำนวนมากที่สุด ให้เป็นประธานาธิบดี ถ้าจำนวนเช่นว่านั้นเป็นเสียงข้างมากของจำนวนผู้เลือกตั้งทั้งหมดที่ได้รับแต่งตั้งมา และถ้าไม่มีผู้ใดได้เสียงข้างมากเช่นนั้นแล้ว ก็ให้สภาผู้แทนราษฎรเลือกประธานาธิบดีโดยทันทีจากบรรดาบุคคลที่ได้คะแนนสูงสุดไม่เกินสามอันดับในรายชื่อผู้ได้รับการออกเสียงให้เป็นประธานาธิบดี ทว่า ในการเลือกประธานาธิบดีนั้น ให้ถามเสียงจากรัฐทั้งหลาย โดยผู้แทนของแต่ละรัฐมีหนึ่งเสียง ส่วนองค์ประชุมสำหรับการนี้ให้ประกอบด้วยสมาชิกหนึ่งคนหรือหลายคนจากสองในสามของรัฐต่าง ๆ และการเลือกนั้นจำเป็นต้องได้เสียงข้างมากของรัฐทั้งหมด และเมื่อใดก็ตามสภาผู้แทนราษฎรเกิดมีสิทธิในการเลือกประธานาธิบดี แล้วไม่เลือกภายในวันที่สี่ของเดือนมีนาคมที่จะถึง ก็ให้รองประธานาธิบดีทำหน้าที่เป็นประธานาธิบดีเสมือนกรณีที่ประธานาธิบดีถึงแก่ความตายหรือถูกห้ามด้วยประการอื่นตามรัฐธรรมนูญ บุคคลที่ได้คะแนนเสียงให้เป็นรองประธานาธิบดีเป็นจำนวนมากที่สุด ให้เป็นรองประธานาธบิดี ถ้าจำนวนเช่นว่านั้นเป็นเสียงข้างมากของจำนวนผู้เลือกตั้งทั้งหมดที่ได้รับแต่งตั้งมา และถ้าไม่มีผู้ใดได้เสียงข้างมากเช่นนั้นแล้ว ก็ให้วุฒิสภาเลือกรองประธานาธิบดีจากบรรดาบุคคลที่ได้คะแนนสูงสุดไม่เกินสองอันดับในรายชื่อ องค์ประชุมสำหรับการนี้ให้ประกอบด้วยสมาชิกวุฒิสภาสองในสามของจำนวนทั้งหมด และการเลือกนั้นจำเป็นต้องได้รับเสียงข้างมากของจำนวนทั้งหมด ทั้งนี้ ผู้ใดขาดคุณสมบัติตามรัฐธรรมนูญสำหรับตำแหน่งประธานาธิบดี ผู้นั้นจะไม่มีคุณสมบัติสำหรับตำแหน่งรองประธานาธิบดีสหรัฐ
}}
{{ตรคป
| {{ข|''Nathaniel Macon'' Speaker of the House of Representatives.}}
| {{ข|''นาทาเนียล เมคอน'' ประธานสภาผู้แทนราษฎร}}
}}
{{ตรคป
| {{ข|''A. Burr'' Vice President of the United States, and President of the Senate.}}
| {{ข|''เอ. เบอร์'' รองประธานาธิบดีสหรัฐและประธานวุฒิสภา}}
}}
{{ตรคป
| Attest
| พยาน
}}
{{ตรคป
| {{ข|''John Beckley'' Clerk of the House of Representatives.}}
| {{ข|''จอห์น เบ็กลีย์'' เสมียนสภาผู้แทนราษฎร}}
}}
{{ตรคป
| {{ข|''Sam. A Otis'' Secretary of the Senate.}}
| {{ข|''แซม. เอ โอทิส'' เลขานุการวุฒิสภา}}
}}
==บรรณานุกรม==
{{รออ}}
* {{อว|author=U.S. National Archives and Records Administration|year=n.d.|title=Picture of the Twelfth Amendment to the U.S. Constitution, Ratified in 1804|format=online image|website=Encyclopædia Britannica|url=https://cdn.britannica.com/83/142483-050-3570E434/Twelfth-Amendment-US-Constitution-1804.jpg}}
{{จออ}}
{{สัญญาอนุญาตงานแปล
| 1 = {{สาธารณสมบัติ-รัฐบาลสหรัฐ}}
| 2 = {{สาธารณสมบัติ-เอง}}
}}
[[หมวดหมู่:รัฐธรรมนูญสหรัฐ]]
1oit35lsr6kr8nmcwnxge0oftm6dqmj
งานแปล:การแก้ไขเพิ่มเติมรัฐธรรมนูญสหรัฐ ครั้งที่ 13
114
52311
189480
168346
2022-08-16T16:42:53Z
Venise12mai1834
8884
wikitext
text/x-wiki
{{หัวเรื่องงานแปล
| ชื่อ = {{PAGENAME}} ค.ศ. 1864
| ปี = 2407
| ภาษา = en
| ต้นฉบับ =
| ผู้สร้างสรรค์ = รัฐสภาสหรัฐ
| บรรณาธิการ =
| ส่วน =
| ผู้มีส่วนร่วม =
| ก่อนหน้า =
| ถัดไป =
| หมายเหตุ = {{ชุด
| ชุด = [[สถานีย่อย:รัฐธรรมนูญสหรัฐ|การแก้ไขเพิ่มเติมรัฐธรรมนูญสหรัฐ]]
| ชื่อ = ครั้งที่ 13
| ก่อน = [[งานแปล:การแก้ไขเพิ่มเติมรัฐธรรมนูญสหรัฐ ครั้งที่ 12|ครั้งที่ 12]]
| ถัด = [[งานแปล:การแก้ไขเพิ่มเติมรัฐธรรมนูญสหรัฐ ครั้งที่ 14|ครั้งที่ 14]]
}}
| สถานีย่อย = รัฐธรรมนูญสหรัฐ/ทาส
}}
__NOTOC__
{{ตรคป
|{{ก|Thirty-Eighth {{พญ|Congress of the Unites States of America;}}}}
|{{ก|รัฐสภาสหรัฐอเมริกา ชุดที่สามสิบแปด}}
| ไม่ย่อหน้า =
}}
{{ตรคป
|{{ก|At the Second Session,}}
|{{ก|ในสมัยที่สอง}}
| ไม่ย่อหน้า =
}}
{{ตรคป
|Begun and held at the City of Washington, on Monday, the fifth day of December, one thousand eight hundred and sixty-four.
|ซึ่งเริ่มต้นและจัดขึ้น ณ นครวอชิงตัน เมื่อวันจันทร์ที่ห้า ธันวาคม พันแปดร้อยหกสิบสี่
}}
{{ตรคป
|{{สกอ|sp|100}}
|{{สกอ|sp|100}}
| ไม่ย่อหน้า =
}}
{{ตรคป
|{{ก|{{พญ|A Resolution}}}}
|{{ก|มติ}}
| ไม่ย่อหน้า =
}}
{{ตรคป
|Submitting to the legislatures of the several States a proposition to amend the Constitution of the United States.
|ให้ยื่นข้อเสนอแก้ไขเพิ่มเติมรัฐธรรมนูญสหรัฐต่อสภานิติบัญญัติของรัฐต่าง ๆ
}}
{{ตรคป
|{{สกอ|sp|100}}
|{{สกอ|sp|100}}
| ไม่ย่อหน้า =
}}
{{ตรคป
|Resolved by the Senate and House of Representatives of the United States of America in Congress assembled, (two-thirds of both houses concurring), that the following article be proposed to the legislatures of the several States as an amendment to the Constitution of the United States, which, when ratified by three-fourths of said legislatures, shall be valid, to all intents and purposes, as a part of the said Constitution, namely: Article XIII. Section 1. Neither slavery nor involuntary servitude, except as a punishment for crime whereof the party shall have been duly convicted, shall exist within the United States, or any place subject to their jurisdiction. Section 2. Congress shall have power to enforce this article by appropriate legislation.
|วุฒิสภาและสภาผู้แทนราษฎรสหรัฐอเมริกา ณ รัฐสภาที่ชุมนุมกันนั้น มีมติ (โดยสองในสามของสภาทั้งสองเห็นพ้องต้องกัน) ว่า ให้เสนอมาตราดังต่อไปนี้ต่อสภานิติบัญญัติของรัฐต่าง ๆ เป็นข้อแก้ไขเพิ่มเติมรัฐธรรมนูญสหรัฐ ซึ่งเมื่อได้รับสัตยาบันจากสามในสี่ของสภานิติบัญญัติดังกล่าวแล้ว จะสมบูรณ์เป็นส่วนหนึ่งของรัฐธรรมนูญดังกล่าวในทุกสถานและทุกประการ คือ มาตรา 13 ข้อ 1 ความเป็นทาสก็ดี ความเป็นผู้รับใช้โดยไม่เต็มใจก็ดี จะมีในสหรัฐหรือที่แห่งใดภายใต้เขตอำนาจของสหรัฐมิได้ เว้นแต่เป็นโทษสำหรับอาชญากรรมที่คู่ความได้ถูกพิพากษาอย่างถูกต้องแล้วว่ามีความผิดในเรื่องนั้น ข้อ 2 ให้รัฐสภามีอำนาจบังคับใช้มาตรานี้ด้วยการออกกฎหมายตามสมควร
}}
{{ตรคป
|{{กข|{{รมมจ|Schuyler Colfax.
|Speaker of the House of Representatives.}}|center}}
|{{กข|{{รมมจ|สกายเลอร์ โคลแฟกซ์
|ประธานสภาผู้แทนราษฎร}}|center}}
}}
{{ตรคป
|{{กข|{{รมมจ|H. Hamlin.
|Vice President of the Unites States,
|and President of the Senate.}}|center}}
|{{กข|{{รมมจ|เอช. แฮมลิน
|รองประธานาธิบดีสหรัฐ
|และประธานวุฒิสภา}}|center}}
}}
{{ตรคป
|{{หว|Approved February 1, 1865.||Abraham Lincoln.}}
|{{หว|เห็นชอบ 1 กุมภาพันธ์ 1865||เอบราแฮม ลิงคอล์น}}
| ไม่ย่อหน้า =
}}
==บรรณานุกรม==
{{รออ}}
* {{อว|author=U.S. National Archives and Records Administration|date=2016-09-08|title=13th Amendment to the U.S. Constitution: Abolition of Slavery|website=National Archives|accessdate=2021-09-03|url=https://www.archives.gov/historical-docs/13th-amendment}}
{{จออ}}
{{สัญญาอนุญาตงานแปล
| 1 = {{สาธารณสมบัติ-รัฐบาลสหรัฐ}}
| 2 = {{สาธารณสมบัติ-เอง}}
}}
[[หมวดหมู่:รัฐธรรมนูญสหรัฐ]]
lvfsaqc59tx99cu6anydd9yvzmdcbwy
งานแปล:การแก้ไขเพิ่มเติมรัฐธรรมนูญสหรัฐ ครั้งที่ 15
114
52920
189479
168350
2022-08-16T16:39:46Z
Venise12mai1834
8884
wikitext
text/x-wiki
{{หัวเรื่องงานแปล
| ชื่อ = {{PAGENAME}} ค.ศ. 1868
| ปี = 2411
| ภาษา = en
| ต้นฉบับ =
| ผู้สร้างสรรค์ = รัฐสภาสหรัฐ
| บรรณาธิการ =
| ส่วน =
| ผู้มีส่วนร่วม =
| ก่อนหน้า =
| ถัดไป =
| หมายเหตุ = {{ชุด
| ชุด = [[สถานีย่อย:รัฐธรรมนูญสหรัฐ|การแก้ไขเพิ่มเติมรัฐธรรมนูญสหรัฐ]]
| ชื่อ = ครั้งที่ 15
| ก่อน = [[งานแปล:การแก้ไขเพิ่มเติมรัฐธรรมนูญสหรัฐ ครั้งที่ 14|ครั้งที่ 14]]
| ถัด = [[งานแปล:การแก้ไขเพิ่มเติมรัฐธรรมนูญสหรัฐ ครั้งที่ 16|ครั้งที่ 16]]
}}
| สถานีย่อย =
}}
__NOTOC__
{{ตรคป
|{{ก|Fortieth Congress of the Unites States of America;}}
|{{ก|รัฐสภาสหรัฐอเมริกา ชุดที่สี่สิบ}}
| ไม่ย่อหน้า =
}}
{{ตรคป
|{{ก|At the Third Session}}
|{{ก|ในสมัยที่สาม}}
| ไม่ย่อหน้า =
}}
{{ตรคป
|Begun and held at the City of Washington, on Monday, the seventh day of December, one thousand eight hundred and sixty-eight.
|ซึ่งเริ่มต้นและจัดขึ้น ณ นครวอชิงตัน เมื่อวันจันทร์ที่เจ็ด ธันวาคม พันแปดร้อยหกสิบแปด
}}
{{ตรคป
|{{สกอ|sp|100}}
|{{สกอ|sp|100}}
| ไม่ย่อหน้า =
}}
{{ตรคป
|{{ก|{{พญ|A Resolution}}}}
|{{ก|มติ}}
| ไม่ย่อหน้า =
}}
{{ตรคป
|Proposing an amendment to the Constitution of the United States.
|เสนอแก้ไขเพิ่มเติมรัฐธรรมนูญสหรัฐ
}}
{{ตรคป
|{{สกอ|sp|100}}
|{{สกอ|sp|100}}
| ไม่ย่อหน้า =
}}
{{ตรคป
|Resolved by the Senate and House of Representatives of the United States of America in Congress assembled, (two-thirds of both houses concurring), that the following article be proposed to the legislatures of the several States as an amendment to the Constitution of the United States, which, when ratified by three-fourths of said legislatures, shall be valid as a part of the Constitution, namely:
|วุฒิสภาและสภาผู้แทนราษฎรสหรัฐอเมริกา ณ รัฐสภาที่ชุมนุมกันนั้น มีมติ (โดยสองในสามของสภาทั้งสองเห็นพ้องต้องกัน) ว่า ให้เสนอมาตราดังต่อไปนี้ต่อสภานิติบัญญัติของรัฐต่าง ๆ เป็นข้อแก้ไขเพิ่มเติมรัฐธรรมนูญสหรัฐ ซึ่งเมื่อได้รับสัตยาบันจากสามในสี่ของสภานิติบัญญัติดังกล่าวแล้ว จะสมบูรณ์เป็นส่วนหนึ่งของรัฐธรรมนูญ คือ
}}
{{ตรคป
|หัว=Article XV.
|แปลหัว=มาตรา 15
|ตัว=Section 1. The right of citizens of the United States to vote shall not be denied or abridged by the United States or by any State on account of race, color, or previous condition of servitude.
|แปลตัว={{กม|ข|1}}สิทธิของพลเมืองสหรัฐในการออกเสียงนั้น สหรัฐหรือรัฐใด ๆ จะบอกปัดหรือลิดรอนเพราะเหตุแห่งเชื้อชาติ สีผิว หรือความที่เคยเป็นผู้รับใช้มาก่อน<ref>"servitude" มีความหมายตามรากศัพท์ว่า "ความเป็นทาส" (จาก "servus" แปลว่า ทาส) แต่ใน[[งานแปล:การแก้ไขเพิ่มเติมรัฐธรรมนูญสหรัฐ ครั้งที่ 13|การแก้ไขเพิ่มเติม ครั้งที่ 13]] มีข้อความว่า "slavery nor involuntary servitude" แสดงว่า ประสงค์ให้ "servitude" มีความหมายแตกต่างจากและกว้างกว่า "slavery" (ซึ่งปรกติแล้วแปลว่า "ความเป็นทาส" เหมือนกัน) ในที่นี้จึงเก็บคำว่า "ความเป็นทาส" ไว้สำหรับ "slavery" และแปล "servitude" ว่า "ความเป็นผู้รับใช้"</ref> มิได้
}}
{{ตรคป
|Section 2. The Congress shall have power to enforce this article by appropriate legislation.
|{{กม|ข|2}}ให้รัฐสภามีอำนาจบังคับใช้มาตรานี้ด้วยการออกกฎหมายตามสมควร
}}
{{ตรคป
|{{ข|Schuyler Colfax.<br>Speaker of the House of Representatives.}}
|{{ข|สกายเลอร์ โคลแฟกซ์<br>ประธานสภาผู้แทนราษฎร}}
}}
{{ตรคป
|{{ข|B. F. Wade.<br>President of the Senate pro tempore.}}
|{{ข|บี. เอฟ. เวด<br>ประธานวุฒิสภาชั่วคราว}}
}}
{{ตรคป
| Attest
| พยาน
}}
{{ตรคป
|
: E. McPherson.
: Clerk of the House of Representatives.
|
: อี. แมกเฟอร์สัน
: เสมียนสภาผู้แทนราษฎร
}}
{{ตรคป
|
: G. C. Gorham.
: Secretary of the Senate.
|
: จี. ซี. กอร์แฮม
: เลขานุการวุฒิสภา
}}
==เชิงอรรถ==
{{รกออ}}
==บรรณานุกรม==
{{รออ}}
* {{อว|author=U.S. National Archives and Records Administration|year=2018|title=Picture of the 15th Amendment to the U.S. Constitution: Voting Rights|format=online image|website=National Archives|url=https://www.archives.gov/global-pages/larger-image.html?i=/historical-docs/doc-content/images/15th-amend-voting-rights-l.jpg}}
{{จออ}}
{{สัญญาอนุญาตงานแปล
| 1 = {{สาธารณสมบัติ-รัฐบาลสหรัฐ}}
| 2 = {{สาธารณสมบัติ-เอง}}
}}
[[หมวดหมู่:รัฐธรรมนูญสหรัฐ]]
jd6oltnw61jug2gdx3w3hs9kpmfvqwn
งานแปล:การแก้ไขเพิ่มเติมรัฐธรรมนูญสหรัฐ ครั้งที่ 19
114
53611
189478
168426
2022-08-16T16:38:21Z
Venise12mai1834
8884
wikitext
text/x-wiki
{{หัวเรื่องงานแปล
| ชื่อ = {{PAGENAME}} ค.ศ. 1919
| ปี = 2462
| ภาษา = en
| ต้นฉบับ =
| ผู้สร้างสรรค์ = รัฐสภาสหรัฐ
| บรรณาธิการ =
| ส่วน =
| ผู้มีส่วนร่วม =
| ก่อนหน้า =
| ถัดไป =
| หมายเหตุ = {{ชุด
| ชุด = [[สถานีย่อย:รัฐธรรมนูญสหรัฐ|การแก้ไขเพิ่มเติมรัฐธรรมนูญสหรัฐ]]
| ชื่อ = ครั้งที่ 19
| ก่อน = [[งานแปล:การแก้ไขเพิ่มเติมรัฐธรรมนูญสหรัฐ ครั้งที่ 18|ครั้งที่ 19]]
| ถัด = [[งานแปล:การแก้ไขเพิ่มเติมรัฐธรรมนูญสหรัฐ ครั้งที่ 20|ครั้งที่ 20]]
}}
| สถานีย่อย =
}}
__NOTOC__
{{ตรคป
|{{ก|Sixty-sixth Congress of the Unites States of America;}}
|{{ก|รัฐสภาสหรัฐอเมริกา ชุดที่หกสิบหก}}
| ไม่ย่อหน้า =
}}
{{ตรคป
|{{ก|At the First Session,}}
|{{ก|ในสมัยที่หนึ่ง}}
| ไม่ย่อหน้า =
}}
{{ตรคป
|Begun and held at the City of Washington, on Monday, the nineteenth day of May, one thousand nine hundred and nineteen.
|ซึ่งเริ่มต้นและจัดขึ้น ณ นครวอชิงตัน เมื่อวันจันทร์ที่สิบเก้า พฤษภาคม พันเก้าร้อยสิบเก้า
}}
{{ตรคป
|{{สกอ|sp|100}}
|{{สกอ|sp|100}}
| ไม่ย่อหน้า =
}}
{{ตรคป
|{{ก|{{พญ|Joint Resolution}}}}
|{{ก|มติร่วม}}
| ไม่ย่อหน้า =
}}
{{ตรคป
|Proposing an amendment to the Constitution extending the right of suffrage to women.
|ให้เสนอแก้ไขเพิ่มเติมรัฐธรรมนูญเพื่อขยายสิทธิออกเสียงเลือกตั้งไปสู่ผู้หญิง
}}
{{ตรคป
|{{สกอ|sp|100}}
|{{สกอ|sp|100}}
| ไม่ย่อหน้า =
}}
{{ตรคป
|Resolved by the Senate and House of Representatives of the United States of America in Congress assembled (two-thirds of each House concurring therein), That the following article is proposed as an amendment to the Constitution, which shall be valid to all intents and purposes as part of the Constitution when ratified by the legislatures of three-fourths of the several States.
|วุฒิสภาและสภาผู้แทนราษฎรสหรัฐอเมริกา ณ รัฐสภาที่ชุมนุมกัน มีมติ (โดยสองในสามของแต่ละสภาเห็นพ้องในเรื่องนั้น) ว่า มาตราดังต่อไปนี้เป็นอันเสนอขึ้นเป็นข้อแก้ไขเพิ่มเติมรัฐธรรมนูญ ซึ่งจะสมบูรณ์เป็นส่วนหนึ่งของรัฐธรรมนูญในทุกสถานและทุกประการ เมื่อได้รับสัตยาบันจากสามในสี่ของสภานิติบัญญัติแห่งรัฐต่าง ๆ แล้ว
}}
{{ตรคป
|หัว="{{พญล|Article}} _____.
|แปลหัว="มาตรา _____
|ตัว="The right of citizens of the Unites States to vote shall not be denied or abridged by the United States or by any State on account of sex.
|แปลตัว="สิทธิของพลเมืองสหรัฐในการออกเสียงนั้น สหรัฐหรือรัฐใด ๆ จะบอกปัดหรือลิดรอนเพราะเหตุแห่งเพศมิได้
}}
{{ตรคป
|"Congress shall have power to enforce this article by appropriate legislation."
|"ให้รัฐสภามีอำนาจบังคับใช้มาตรานี้ด้วยการออกกฎหมายตามสมควร"
}}
{{ตรคป
|{{ข|F. H. Gillett.<br>Speaker of the House of Representatives.}}
|{{ข|เอฟ. เอช. จิลเลตต์<br>ประธานสภาผู้แทนราษฎร}}
}}
{{ตรคป
|{{ข|Thos. R. Marshall.<br>Vice President of the United States and<br>President of the Senate.}}
|{{ข|ทอส. อาร์. มาร์แชลล์<br>รองประธานาธิบดีสหรัฐและ<br>ประธานวุฒิสภา}}
}}
==บรรณานุกรม==
{{รออ}}
* {{อว|author=U.S. National Archives and Records Administration|year=2020|title=Picture of the 19th Amendment|format=online image|website=National Archives|url=https://www.archives.gov/files/exhibits/featured-documents/amendment-19/images/amendment-19-l.jpg}}
{{จออ}}
{{สัญญาอนุญาตงานแปล
| 1 = {{สาธารณสมบัติ-รัฐบาลสหรัฐ}}
| 2 = {{สาธารณสมบัติ-เอง}}
}}
[[หมวดหมู่:รัฐธรรมนูญสหรัฐ]]
8y0x0nub95pm8a7oexiq0ejluty01o8
งานแปล:การแก้ไขเพิ่มเติมรัฐธรรมนูญสหรัฐ ครั้งที่ 22
114
53612
189477
168425
2022-08-16T16:34:23Z
Venise12mai1834
8884
wikitext
text/x-wiki
{{หัวเรื่องงานแปล
| ชื่อ = {{PAGENAME}} ค.ศ. 1947
| ปี = 2490
| ภาษา = en
| ต้นฉบับ =
| ผู้สร้างสรรค์ = รัฐสภาสหรัฐ
| บรรณาธิการ =
| ส่วน =
| ผู้มีส่วนร่วม =
| ก่อนหน้า =
| ถัดไป =
| หมายเหตุ = {{ชุด
| ชุด = [[สถานีย่อย:รัฐธรรมนูญสหรัฐ|การแก้ไขเพิ่มเติมรัฐธรรมนูญสหรัฐ]]
| ชื่อ = ครั้งที่ 22
| ก่อน = [[งานแปล:การแก้ไขเพิ่มเติมรัฐธรรมนูญสหรัฐ ครั้งที่ 21|ครั้งที่ 21]]
| ถัด = [[งานแปล:การแก้ไขเพิ่มเติมรัฐธรรมนูญสหรัฐ ครั้งที่ 23|ครั้งที่ 23]]
}}
| สถานีย่อย =
}}
__NOTOC__
{{ตรคป
|{{ก|Eightieth Congress of the Unites States of America;}}
|{{ก|รัฐสภาสหรัฐอเมริกา ชุดที่แปดสิบ}}
| ไม่ย่อหน้า =
}}
{{ตรคป
|{{ก|At the First Session,}}
|{{ก|ในสมัยที่หนึ่ง}}
| ไม่ย่อหน้า =
}}
{{ตรคป
|Begun and held at the City of Washington, on Friday, the third day of January, one thousand nine hundred and forty-seven.
|ซึ่งเริ่มต้นและจัดขึ้น ณ นครวอชิงตัน เมื่อวันศุกร์ที่สาม มกราคม พันเก้าร้อยสี่สิบเจ็ด
}}
{{ตรคป
|{{สกอ|sp|100}}
|{{สกอ|sp|100}}
| ไม่ย่อหน้า =
}}
{{ตรคป
|{{ก|{{พญ|Joint Resolution}}}}
|{{ก|มติร่วม}}
| ไม่ย่อหน้า =
}}
{{ตรคป
|Proposing an amendment to the Constitution of the United States relating to the terms of office of the President.
|ให้เสนอแก้ไขเพิ่มเติมรัฐธรรมนูญสหรัฐเกี่ยวกับวาระดำรงตำแหน่งประธานาธิบดี
}}
{{ตรคป
|{{สกอ|sp|100}}
|{{สกอ|sp|100}}
| ไม่ย่อหน้า =
}}
{{ตรคป
|Resolved by the Senate and House of Representatives of the United States of America in Congress assembled (two-thirds of each House concurring therein), That the following article is hereby proposed as an amendment to the Constitution of the United States, which shall be valid to all intents and purposes as part of the Constitution when ratified by the legislatures of three-fourths of the several States:
|วุฒิสภาและสภาผู้แทนราษฎรสหรัฐอเมริกา ณ รัฐสภาที่ชุมนุมกัน มีมติ (โดยสองในสามของแต่ละสภาเห็นพ้องในเรื่องนั้น) ว่า โดยการนี้ มาตราดังต่อไปนี้เป็นอันเสนอขึ้นเป็นข้อแก้ไขเพิ่มเติมรัฐธรรมนูญสหรัฐ ซึ่งจะสมบูรณ์เป็นส่วนหนึ่งของรัฐธรรมนูญในทุกสถานและทุกประการ เมื่อได้รับสัตยาบันจากสามในสี่ของสภานิติบัญญัติแห่งรัฐต่าง ๆ แล้ว
}}
{{ตรคป
|หัว="{{พญล|Article}} _____
|แปลหัว="มาตรา _____
|ตัว="{{พญล|Section}} 1. No person shall be elected to the office of the President more than twice, and no person who has held the office of President, or acted as President, for more than two years of a term to which some other person was elected President shall be elected to the office of the President more than once. But this Article shall not apply to any person holding the office of President when this Article was proposed by the Congress, and shall not prevent any person who may be holding the office of President, or acting as President, during the term within which this Article becomes operative from holding the office of President or acting as President during the remainder of such term.
|แปลตัว="{{กม|ข|1}}บุคคลจะได้รับเลือกตั้งเข้าสู่ตำแหน่งประธานาธิบดีเกินสองครั้งมิได้ และบุคคลผู้ได้ดำรงตำแหน่งประธานาธิบดีหรือรักษาการในตำแหน่งประธานาธิบดีมาแล้วเกินสองปีของวาระที่บุคคลอื่นใดได้รับเลือกตั้งขึ้นเป็นประธานาธิบดี จะได้รับเลือกตั้งเข้าสู่ตำแหน่งประธานาธิบดีเกินหนึ่งครั้งมิได้ แต่มาตรานี้มิให้ใช้บังคับแก่บุคคลใด ๆ ที่ดำรงตำแหน่งประธานาธิบดีอยู่ในขณะที่รัฐสภาเสนอมาตรานี้ขึ้น และไม่ห้ามบุคคลใด ๆ ที่อาจกำลังดำรงตำแหน่งประธานาธิบดีหรือรักษาการในตำแหน่งประธานาธิบดีอยู่ในวาระที่มาตรานี้มีผลใช้บังคับ มิให้ดำรงตำแหน่งประธานาธิบดีหรือรักษาการในตำแหน่งประธานาธิบดีในช่วงเวลาที่เหลืออยู่ของวาระ
}}
{{ตรคป
|"{{พญล|Section 2}}. This Article shall be inoperative unless it shall have been ratified as an amendment to the Constitution by the legislatures of three-fourths of the several states within seven years from the date of its submission to the states by the Congress."
|"มาตรานี้มิให้มีผลใช้บังคับ จนกว่าจะได้รับสัตยาบันให้เป็นข้อแก้ไขเพิ่มเติมรัฐธรรมนูญจากสามในสี่ของสภานิติบัญญัติแห่งรัฐต่าง ๆ ภายในเจ็ดปีตั้งแต่วันที่รัฐสภาเสนอมาตรานี้ต่อรัฐทั้งหลาย"
}}
{{ตรคป
|{{ข|Joseph W. Martin Jr.<br>Speaker of the House of Representatives.}}
|{{ข|โจเซฟ ดับเบิลยู. มาร์ติน จูเนียร์<br>ประธานสภาผู้แทนราษฎร}}
}}
{{ตรคป
|{{ข|Arthur H. Vandenberg.<br>Acting President of the Senate pro tempore.}}
|{{ข|อาร์เทอร์ เอช. แวนเดนเบิร์ก<br>รักษาการในตำแหน่งประธานวุฒิสภาชั่วคราว}}
}}
==บรรณานุกรม==
{{รออ}}
* {{อว|author=U.S. National Archives and Records Administration|year=2018|title=Picture of Amendment 22, 1 Page (232 KB) Constitution of the United States of America|format=online image|website=National Archives|url=https://www.archives.gov/files/founding-docs/downloads/22nd_Amendment_Pg1of1_AC.jpg}}
{{จออ}}
{{สัญญาอนุญาตงานแปล
| 1 = {{สาธารณสมบัติ-รัฐบาลสหรัฐ}}
| 2 = {{สาธารณสมบัติ-เอง}}
}}
[[หมวดหมู่:รัฐธรรมนูญสหรัฐ]]
4aw5quwzl2e26d3bvsgo61o4mvi85oo
งานแปล:การแก้ไขเพิ่มเติมรัฐธรรมนูญสหรัฐ ครั้งที่ 26
114
53613
189475
168427
2022-08-16T16:31:37Z
Venise12mai1834
8884
wikitext
text/x-wiki
{{หัวเรื่องงานแปล
| ชื่อ = {{PAGENAME}} ค.ศ. 1971
| ปี = 2514
| ภาษา = en
| ต้นฉบับ =
| ผู้สร้างสรรค์ = รัฐสภาสหรัฐ
| บรรณาธิการ =
| ส่วน =
| ผู้มีส่วนร่วม =
| ก่อนหน้า =
| ถัดไป =
| หมายเหตุ = {{ชุด
| ชุด = [[สถานีย่อย:รัฐธรรมนูญสหรัฐ|การแก้ไขเพิ่มเติมรัฐธรรมนูญสหรัฐ]]
| ชื่อ = ครั้งที่ 26
| ก่อน = [[งานแปล:การแก้ไขเพิ่มเติมรัฐธรรมนูญสหรัฐ ครั้งที่ 25|ครั้งที่ 25]]
| ถัด = [[งานแปล:การแก้ไขเพิ่มเติมรัฐธรรมนูญสหรัฐ ครั้งที่ 27|ครั้งที่ 27]]
}}
| สถานีย่อย =
}}
__NOTOC__
{{ตรคป
|{{ก|Ninety-second Congress of the Unites States of America;}}
|{{ก|รัฐสภาสหรัฐอเมริกา ชุดที่เก้าสิบสอง}}
| ไม่ย่อหน้า =
}}
{{ตรคป
|{{ก|{{พญ|At the First Session,}}}}
|{{ก|ในสมัยที่หนึ่ง}}
| ไม่ย่อหน้า =
}}
{{ตรคป
|Begun and held at the City of Washington, on Thursday, the twenty-first day of January, one thousand nine hundred and seventy-one.
|ซึ่งเริ่มต้นและจัดขึ้น ณ นครวอชิงตัน เมื่อวันจันทร์ที่ยี่สิบเอ็ด มกราคม พันเก้าร้อยเจ็ดสิบเอ็ด
}}
{{ตรคป
|{{สกอ|sp|100}}
|{{สกอ|sp|100}}
| ไม่ย่อหน้า =
}}
{{ตรคป
|{{ก|Joint Resolution}}
|{{ก|มติร่วม}}
| ไม่ย่อหน้า =
}}
{{ตรคป
|Proposing an amendment to the Constitution extending the right of vote to citizens eighteen years of age or older.
|ให้เสนอแก้ไขเพิ่มเติมรัฐธรรมนูญสหรัฐเพื่อขยายสิทธิในการออกเสียงไปสู่พลเมืองที่มีอายุสิบแปดปีหรืออายุมากกว่านั้น
}}
{{ตรคป
|{{สกอ|sp|100}}
|{{สกอ|sp|100}}
| ไม่ย่อหน้า =
}}
{{ตรคป
|Resolved by the Senate and House of Representatives of the United States of America in Congress assembled (two-thirds of each House concurring therein), That the following article is proposed as an amendment to the Constitution of the United States, which shall be valid to all intents and purposes as part of the Constitution when ratified by the legislatures of three-fourths of the several States within seven years from the date of its submission by the Congress:
|วุฒิสภาและสภาผู้แทนราษฎรสหรัฐอเมริกา ณ รัฐสภาที่ชุมนุมกัน มีมติ (โดยสองในสามของแต่ละสภาเห็นพ้องในเรื่องนั้น) ว่า มาตราดังต่อไปนี้เป็นอันเสนอขึ้นเป็นข้อแก้ไขเพิ่มเติมรัฐธรรมนูญสหรัฐ ซึ่งจะสมบูรณ์เป็นส่วนหนึ่งของรัฐธรรมนูญในทุกสถานและทุกประการ เมื่อได้รับสัตยาบันจากสามในสี่ของสภานิติบัญญัติแห่งรัฐต่าง ๆ ภายในเจ็ดปีตั้งแต่วันที่รัฐสภาจัดส่งข้อแก้ไขเพิ่มเติมนี้ให้
}}
{{ตรคป
|หัว="{{พญล|Article}} _____
|แปลหัว="มาตรา _____
|ตัว="{{พญล|Section 1.}} The right of citizens of the United States, who are eighteen years of age or older, to vote shall not be denied or abridged by the United States or by any State on account of age.
|แปลตัว="{{กม|ข|1}}สิทธิในการออกเสียงของพลเมืองสหรัฐผู้มีอายุสิบแปดปีหรืออายุมากกว่านั้น สหรัฐหรือรัฐใด ๆ จะบอกปัดหรือลิดรอนเพราะเหตุแห่งอายุมิได้
}}
{{ตรคป
|"{{พญล|Section 2.}} The Congress shall have power to enforce this article by appropriate legislation."
|"{{กม|ข|2}}ให้รัฐสภามีอำนาจบังคับใช้มาตรานี้ด้วยการออกกฎหมายตามสมควร"
}}
{{ตรคป
|{{ข|Carl Albert.<br>Speaker of the House of Representatives.}}
|{{ข|คาร์ล แอลเบิร์ต<br>ประธานสภาผู้แทนราษฎร}}
}}
{{ตรคป
|{{ข|Allen J. Ellender.<br><s>Vice President of the United States and</s><br>President of the Senate pro tempore.}}
|{{ข|แอลเลน เจ. เอลเลนเดอร์<br><s>รองประธานาธิบดีสหรัฐและ</s><br>ประธานวุฒิสภาชั่วคราว}}
}}
==บรรณานุกรม==
{{รออ}}
{{อว|author=U.S. National Archives and Records Administration|year=2018|tite=Picture of Amendment 26, 1 Page (201 KB) Constitution of the United States of America|format=online image|website=National Archives|url=https://www.archives.gov/files/founding-docs/downloads/26th_Amendment_Pg1of1_AC.jpg}}
{{จออ}}
{{สัญญาอนุญาตงานแปล
| 1 = {{สาธารณสมบัติ-รัฐบาลสหรัฐ}}
| 2 = {{สาธารณสมบัติ-เอง}}
}}
[[หมวดหมู่:รัฐธรรมนูญสหรัฐ]]
dn0i94w59j7m09yddtr48r4v1fnpkpe
189476
189475
2022-08-16T16:31:59Z
Venise12mai1834
8884
wikitext
text/x-wiki
{{หัวเรื่องงานแปล
| ชื่อ = {{PAGENAME}} ค.ศ. 1971
| ปี = 2514
| ภาษา = en
| ต้นฉบับ =
| ผู้สร้างสรรค์ = รัฐสภาสหรัฐ
| บรรณาธิการ =
| ส่วน =
| ผู้มีส่วนร่วม =
| ก่อนหน้า =
| ถัดไป =
| หมายเหตุ = {{ชุด
| ชุด = [[สถานีย่อย:รัฐธรรมนูญสหรัฐ|การแก้ไขเพิ่มเติมรัฐธรรมนูญสหรัฐ]]
| ชื่อ = ครั้งที่ 26
| ก่อน = [[งานแปล:การแก้ไขเพิ่มเติมรัฐธรรมนูญสหรัฐ ครั้งที่ 25|ครั้งที่ 25]]
| ถัด = [[งานแปล:การแก้ไขเพิ่มเติมรัฐธรรมนูญสหรัฐ ครั้งที่ 27|ครั้งที่ 27]]
}}
| สถานีย่อย =
}}
__NOTOC__
{{ตรคป
|{{ก|Ninety-second Congress of the Unites States of America;}}
|{{ก|รัฐสภาสหรัฐอเมริกา ชุดที่เก้าสิบสอง}}
| ไม่ย่อหน้า =
}}
{{ตรคป
|{{ก|{{พญ|At the First Session,}}}}
|{{ก|ในสมัยที่หนึ่ง}}
| ไม่ย่อหน้า =
}}
{{ตรคป
|Begun and held at the City of Washington, on Thursday, the twenty-first day of January, one thousand nine hundred and seventy-one.
|ซึ่งเริ่มต้นและจัดขึ้น ณ นครวอชิงตัน เมื่อวันจันทร์ที่ยี่สิบเอ็ด มกราคม พันเก้าร้อยเจ็ดสิบเอ็ด
}}
{{ตรคป
|{{สกอ|sp|100}}
|{{สกอ|sp|100}}
| ไม่ย่อหน้า =
}}
{{ตรคป
|{{ก|Joint Resolution}}
|{{ก|มติร่วม}}
| ไม่ย่อหน้า =
}}
{{ตรคป
|Proposing an amendment to the Constitution extending the right of vote to citizens eighteen years of age or older.
|ให้เสนอแก้ไขเพิ่มเติมรัฐธรรมนูญสหรัฐเพื่อขยายสิทธิในการออกเสียงไปสู่พลเมืองที่มีอายุสิบแปดปีหรืออายุมากกว่านั้น
}}
{{ตรคป
|{{สกอ|sp|100}}
|{{สกอ|sp|100}}
| ไม่ย่อหน้า =
}}
{{ตรคป
|Resolved by the Senate and House of Representatives of the United States of America in Congress assembled (two-thirds of each House concurring therein), That the following article is proposed as an amendment to the Constitution of the United States, which shall be valid to all intents and purposes as part of the Constitution when ratified by the legislatures of three-fourths of the several States within seven years from the date of its submission by the Congress:
|วุฒิสภาและสภาผู้แทนราษฎรสหรัฐอเมริกา ณ รัฐสภาที่ชุมนุมกัน มีมติ (โดยสองในสามของแต่ละสภาเห็นพ้องในเรื่องนั้น) ว่า มาตราดังต่อไปนี้เป็นอันเสนอขึ้นเป็นข้อแก้ไขเพิ่มเติมรัฐธรรมนูญสหรัฐ ซึ่งจะสมบูรณ์เป็นส่วนหนึ่งของรัฐธรรมนูญในทุกสถานและทุกประการ เมื่อได้รับสัตยาบันจากสามในสี่ของสภานิติบัญญัติแห่งรัฐต่าง ๆ ภายในเจ็ดปีตั้งแต่วันที่รัฐสภาจัดส่งข้อแก้ไขเพิ่มเติมนี้ให้
}}
{{ตรคป
|หัว="{{พญล|Article}} _____
|แปลหัว="มาตรา _____
|ตัว="{{พญล|Section 1.}} The right of citizens of the United States, who are eighteen years of age or older, to vote shall not be denied or abridged by the United States or by any State on account of age.
|แปลตัว="{{กม|ข|1}}สิทธิในการออกเสียงของพลเมืองสหรัฐผู้มีอายุสิบแปดปีหรืออายุมากกว่านั้น สหรัฐหรือรัฐใด ๆ จะบอกปัดหรือลิดรอนเพราะเหตุแห่งอายุมิได้
}}
{{ตรคป
|"{{พญล|Section 2.}} The Congress shall have power to enforce this article by appropriate legislation."
|"{{กม|ข|2}}ให้รัฐสภามีอำนาจบังคับใช้มาตรานี้ด้วยการออกกฎหมายตามสมควร"
}}
{{ตรคป
|{{ข|Carl Albert.<br>Speaker of the House of Representatives.}}
|{{ข|คาร์ล แอลเบิร์ต<br>ประธานสภาผู้แทนราษฎร}}
}}
{{ตรคป
|{{ข|Allen J. Ellender.<br><s>Vice President of the United States and</s><br>President of the Senate pro tempore.}}
|{{ข|แอลเลน เจ. เอลเลนเดอร์<br><s>รองประธานาธิบดีสหรัฐและ</s><br>ประธานวุฒิสภาชั่วคราว}}
}}
==บรรณานุกรม==
{{รออ}}
* {{อว|author=U.S. National Archives and Records Administration|year=2018|title=Picture of Amendment 26, 1 Page (201 KB) Constitution of the United States of America|format=online image|website=National Archives|url=https://www.archives.gov/files/founding-docs/downloads/26th_Amendment_Pg1of1_AC.jpg}}
{{จออ}}
{{สัญญาอนุญาตงานแปล
| 1 = {{สาธารณสมบัติ-รัฐบาลสหรัฐ}}
| 2 = {{สาธารณสมบัติ-เอง}}
}}
[[หมวดหมู่:รัฐธรรมนูญสหรัฐ]]
61ugw8pzgcn3w33xy1oh8cox38qsffd
ผู้ใช้:Thastp/ทดลองเขียน
2
53949
189494
189394
2022-08-17T03:42:44Z
Thastp
9008
/* VII. พลังที่ใช้แรงงาน */
wikitext
text/x-wiki
[[งานแปล:ค่าจ้าง ราคา และกำไร]]
== VII. พลังที่ใช้แรงงาน ==
[[งานแปล:ค่าจ้าง ราคา และกำไร/บทที่ 8|VII. พลังที่ใช้แรงงาน]]
หัวเรื่องงานแปล
<!-- ข้อมูลหลัก -->
| ชื่อ = ค่าจ้าง ราคา และกำไร
| ศักราช = ค.ศ.
| ปี = 1865
| ภาษา = en
| ต้นฉบับ = Wages, Price and Profit
| ผู้สร้างสรรค์ = คาร์ล มาคส์
| บรรณาธิการ = เอเลนอร์ มาคส์ เอฟลิง
| ส่วน = VII. พลังที่ใช้แรงงาน
| ผู้มีส่วนร่วม =
| ก่อนหน้า = [[งานแปล:ค่าจ้าง ราคา และกำไร/บทที่ 7|VI. มูลค่าและแรงงาน]]
| ถัดไป = [[งานแปล:ค่าจ้าง ราคา และกำไร/บทที่ 9|VIII. การผลิตมูลค่าส่วนเกิน]]
| หมายเหตุ =
<!-- ข้อมูลย่อย (สำหรับจัดระเบียบหรือเชื่อมโยงไปหน้าอื่น) -->
| หมวดหมู่ =
| แก้กำกวม =
| รุ่น =
| สถานีย่อย =
| ผู้สร้างสรรค์ที่เกี่ยวข้อง =
| วิกิพีเดีย =
| คอมมอนส์ =
| หมวดหมู่คอมมอนส์ =
| วิกิคำคม =
| วิกิข่าว =
| วิกิพจนานุกรม =
| วิกิตำรา =
| วิกิห้องสมุด =
| วิกิสนเทศ =
| วิกิท่องเที่ยว =
| วิกิวิทยาลัย =
| วิกิสปีชีส์ =
| เมทา =
{{ตรคป|Having now, as far as it could be done in such a cursory manner, analyzed the nature of Value, of the Value of any commodity whatever, we must turn our attention to the specific Value of Labour. And here, again, I must startle you by a seeming paradox. All of you feel sure that what they daily sell is their Labour; that, therefore, Labour has a Price, and that, the price of a commodity being only the monetary expression of its value, there must certainly exist such a thing as the Value of Labour. However, there exists no such thing as the Value of Labour in the common acceptance of the word. We have seen that the amount of necessary labour crystallized in a commodity constitutes its value. Now, applying this notion of value, how could we define, say, the value of a ten hours working day? How much labour is contained in that day? Ten hours' labour. To say that the value of a ten hours working day is equal to ten hours' labour, or the quantity of labour contained in it, would be a tautological and, moreover, a nonsensical expression. Of course, having once found out the true but hidden sense of the expression "Value of Labour," we shall be able to interpret this irrational, and seemingly impossible application of value, in the same way that, having once made sure of the real movement of the celestial bodies, we shall be able to explain their apparent or merely phenomenal movements. |}}
{{ตรคป|What the working man sells is not directly his Labour, but his Labour Power, the temporary disposal of which he makes over to the capitalist. This is so much the case that I do not know whether by the English laws, but certainly by some Continental laws, the maximum time is fixed for which a man is allowed to sell his labouring power. If allowed to do so for any indefinite period whatever, slavery would be immediately restored. Such a sale, if it comprised his lifetime, for example, would make him at once the lifelong slave of his employer. |}}
{{ตรคป|One of the oldest economists and most original philosophers of England -- Thomas Hobbes -- has already, in his ''Leviathan'', instinctively hit upon this point overlooked by all his successors. He says: "''The value or worth of a man'' is, as in all other things, his price: that is, so much as would be given for the ''Use of his Power''." |}}
{{ตรคป|Proceeding from this basis, we shall be able to determine the Value of Labour as that of all other commodities. |}}
{{ตรคป|But before doing so, we might ask, how does this strange phenomenon arise, that we find on the market a set of buyers, possessed of land, machinery, raw material, and the means of subsistence, all of them, save land in its crude state, the products of labour, and on the other hand, a set of sellers who have nothing to sell except their labouring power, their working arms and brains? That the one set buys continually in order to make a profit and enrich themselves, while the other set continually sells in order to earn their livelihood? The inquiry into this question would be an inquiry into what the economists call "Previous, or Original Accumulation," but which ought to be called Original Expropriation. We should heed that this so-called Original Accumulation means nothing but a series of historical processes, resulting in a Decomposition of Original Union existing between the Labouring Man and his Instruments of Labour. Such an inquiry, however, lies beyond the pale of my present subject. The Separation between the Man of Labour and the Instruments of Labour once established, such a state of things will maintain itself and reproduce itself upon a constantly increasing scale, until a new and fundamental revolution in the mode of production should again overturn it, and restore the original union in a new historical form.|}}
{{ตรคป|What, then, is the Value of Labouring Power? |}}
{{ตรคป|Like that of every other commodity, its value is determined by the quantity of labour necessary to produce it. The labouring power of a man exists only in his living individuality. A certain mass of necessaries must be consumed by a man to grow up and maintain his life. But the man, like the machine, will wear out, and must be replaced by another man. Beside the mass of necessaries required for his own maintenance, he wants another amount of necessaries to bring up a certain quota of children that are to replace him on the labour market and to perpetuate the race of labourers. Moreover, to develop his labouring power, and acquire a given skill, another amount of values must be spent. For our purpose it suffices to consider only average labour, the costs of whose education and development are vanishing magnitudes. Still I must seize upon this occasion to state that, as the costs of producing labouring powers of different quality differ, so must differ the values of the labouring powers employed in different trades. The cry for an equality of wages rests, therefore, upon a mistake, is an insane wish never to be fulfilled. It is an offspring of that false and superficial radicalism that accepts premises and tries to evade conclusions. Upon the basis of the wages system the value of labouring power is settled like that of every other commodity; and as different kinds of labouring power have different values, or require different quantities of labour for their production, they must fetch different prices in the labour market. To clamour for equal or even equitable retribution on the basis of the wages system is the same as to clamour for freedom on the basis of the slavery system. What you think just or equitable is out of the question. The question is: What is necessary and unavoidable with a given system of production? |}}
{{ตรคป|After what has been said, it will be seen that the value of labouring power is determined by the value of the necessaries required to produce, develop, maintain, and perpetuate the labouring power.|}}
== VIII. การผลิตมูลค่าส่วนเกิน ==
[[งานแปล:ค่าจ้าง ราคา และกำไร/บทที่ 9|VIII. การผลิตมูลค่าส่วนเกิน]]
หัวเรื่องงานแปล
<!-- ข้อมูลหลัก -->
| ชื่อ = ค่าจ้าง ราคา และกำไร
| ศักราช = ค.ศ.
| ปี = 1865
| ภาษา = en
| ต้นฉบับ = Wages, Price and Profit
| ผู้สร้างสรรค์ = คาร์ล มาคส์
| บรรณาธิการ = เอเลนอร์ มาคส์ เอฟลิง
| ส่วน =
| ผู้มีส่วนร่วม =
| ก่อนหน้า = [[งานแปล:ค่าจ้าง ราคา และกำไร/บทที่ 8|VII. พลังที่ใช้แรงงาน]]
| ถัดไป = [[งานแปล:ค่าจ้าง ราคา และกำไร/บทที่ 10|IX. มูลค่าของแรงงาน]]
| หมายเหตุ =
<!-- ข้อมูลย่อย (สำหรับจัดระเบียบหรือเชื่อมโยงไปหน้าอื่น) -->
| หมวดหมู่ =
| แก้กำกวม =
| รุ่น =
| สถานีย่อย =
| ผู้สร้างสรรค์ที่เกี่ยวข้อง =
| วิกิพีเดีย =
| คอมมอนส์ =
| หมวดหมู่คอมมอนส์ =
| วิกิคำคม =
| วิกิข่าว =
| วิกิพจนานุกรม =
| วิกิตำรา =
| วิกิห้องสมุด =
| วิกิสนเทศ =
| วิกิท่องเที่ยว =
| วิกิวิทยาลัย =
| วิกิสปีชีส์ =
| เมทา =
Now suppose that the average amount of the daily necessaries of a labouring man require six hours of average labour for their production. Suppose, moreover, six hours of average labour to be also realized in a quantity of gold equal to 3s. Then 3s. would be the Price, or the monetary expression of the Daily Value of that man's Labouring Power. If he worked daily six hours he would daily produce a value sufficient to buy the average amount of his daily necessaries, or to maintain himself as a labouring man.
But our man is a wages labourer. He must, therefore, sell his labouring power to a capitalist. If he sells it at 3s. daily, or 18s. weekly, he sells it at its value. Suppose him to be a spinner. If he works six hours daily he will add to the cotton a value of 3s. daily. This value, daily added by him, would be an exact equivalent for the wages, or the price of his labouring power, received daily. But in that case no surplus value or surplus produce whatever would go to the capitalist. Here, then, we come to the rub.
In buying the labouring power of the workman, and paying its value, the capitalist, like every other purchaser, has acquired the right to consume or use the commodity bought. You consume or use the labouring power of a man by making him work, as you consume or use a machine by making it run. By paying the daily or weekly value of the labouring power of the workman, the capitalist has, therefore, acquired the right to use or make that labouring power work during the whole day or week. The working day or the working week has, of course, certain limits, but those we shall afterwards look more closely at.
For the present I want to turn your attention to one decisive point.
The value of the labouring power is determined by the quantity of labour necessary to maintain or reproduce it, but the use of that labouring power is only limited by the active energies and physical strength of the labourer. The daily or weekly value of the labouring power is quite distinct from the daily or weekly exercise of that power, the same as the food a horse wants and the time it can carry the horseman are quite distinct. The quantity of labour by which the value of the workman's labouring power is limited to the quantity of labour which his labouring power is apt to perform. Take the example of our spinner. We have seen that, to daily reproduce his labouring power, he must daily reproduce a value of three shillings, which he will do by working six hours daily. But this does not disable him from working ten or twelve or more hours a day. But by paying the daily or weekly value of the spinner's labouring power, the capitalist has acquired the right of using that labouring power during the whole day or week. He will, therefore, make him work say, daily, twelve hours. Over and above the six hours required to replace his wages, or the value of his labouring power, he will, therefore, have to work six other hours, which I shall call hours of surplus labour, which surplus labour will realize itself in a surplus value and a surplus produce. If our spinner, for example, by his daily labour of six hours, added three shillings' value to the cotton, a value forming an exact equivalent to his wages, he will, in twelve hours, add six shillings' worth to the cotton, and produce a proportional surplus of yarn. As he has sold his labouring power to the capitalist, the whole value of produce created by him belongs to the capitalist, the owner pro tem. of his labouring power. By advancing three shillings, the capitalist will, therefore, realize a value of six shillings, because, advancing a value in which six hours of labour are crystallized, he will receive in return a value in which twelve hours of labour are crystallized. By repeating this same process daily, the capitalist will daily advance three shillings and daily pocket six shillings, one-half of which will go to pay wages anew, and the other half of which will form surplus value, for which the capitalist pays no equivalent. It is this sort of exchange between capital and labour upon which capitalistic production, or the wages system, is founded, and which must constantly result in reproducing the working man as a working man, and the capitalist as a capitalist.
The rate of surplus value, all other circumstances remaining the same, will depend on the proportion between that necessary to reproduce the value of the labouring power and the surplus time or surplus labour performed for the capitalist. It will, therefore, depend on the ratio in which the working day is prolonged over and above that extent, by working which the working man would only reproduce the value of his labouring power, or replace his wages.
== IX. มูลค่าของแรงงาน ==
[[งานแปล:ค่าจ้าง ราคา และกำไร/บทที่ 10|IX. มูลค่าของแรงงาน]]
หัวเรื่องงานแปล
<!-- ข้อมูลหลัก -->
| ชื่อ = ค่าจ้าง ราคา และกำไร
| ศักราช = ค.ศ.
| ปี = 1865
| ภาษา = en
| ต้นฉบับ = Wages, Price and Profit
| ผู้สร้างสรรค์ = คาร์ล มาคส์
| บรรณาธิการ = เอเลนอร์ มาคส์ เอฟลิง
| ส่วน =
| ผู้มีส่วนร่วม =
| ก่อนหน้า = [[งานแปล:ค่าจ้าง ราคา และกำไร/บทที่ 9|VIII. การผลิตมูลค่าส่วนเกิน]]
| ถัดไป = [[งานแปล:ค่าจ้าง ราคา และกำไร/บทที่ 11|X. กำไรถูกสร้างขึ้นด้วยการขายโภคภัณฑ์ที่มูลค่าของมัน]]
| หมายเหตุ =
<!-- ข้อมูลย่อย (สำหรับจัดระเบียบหรือเชื่อมโยงไปหน้าอื่น) -->
| หมวดหมู่ =
| แก้กำกวม =
| รุ่น =
| สถานีย่อย =
| ผู้สร้างสรรค์ที่เกี่ยวข้อง =
| วิกิพีเดีย =
| คอมมอนส์ =
| หมวดหมู่คอมมอนส์ =
| วิกิคำคม =
| วิกิข่าว =
| วิกิพจนานุกรม =
| วิกิตำรา =
| วิกิห้องสมุด =
| วิกิสนเทศ =
| วิกิท่องเที่ยว =
| วิกิวิทยาลัย =
| วิกิสปีชีส์ =
| เมทา =
We must now return to the expression, "''Value, or Price of Labour.''"
We have seen that, in fact, it is only the value of the labouring power, measured by the values of commodities necessary for its maintenance. But since the workman receives his wages after his labour is performed, and knows, moreover, that what he actually gives to the capitalist is his labour, the value or price of his labouring power necessarily appears to him as the price or value of his labour itself. If the price of his labouring power is three shillings, in which six hours of labour are realized, and if he works twelve hours, he necessarily considers these three shillings as the value or price of twelve hours of labour, although these twelve hours of labour realize themselves in a value of six shillings. A double consequence flows from this.
Firstly. The value or price of the labouring power takes the semblance of the price or value of labour itself, although, strictly speaking, value and price of labour are senseless terms.
Secondly. Although one part only of the workman's daily labour is paid, while the other part is unpaid, and while that unpaid or surplus labour constitutes exactly the fund out of which surplus value or profit is formed, it seems as if the aggregate labour was paid labour.
This false appearance distinguishes wages labour from other historical forms of labour. On the basis of the wages system even the unpaid labour seems to be paid labour. With the slave, on the contrary, even that part of his labour which is paid appears to be unpaid. Of course, in order to work the slave must live, and one part of his working day goes to replace the value of his own maintenance. But since no bargain is struck between him and his master, and no acts of selling and buying are going on between the two parties, all his labour seems to be given away for nothing.
Take, on the other hand, the peasant serf, such as he, I might say, until yesterday existed in the whole East of Europe. This peasant worked, for example, three days for himself on his own field or the held allotted to him, and the three subsequent days he performed compulsory and gratuitous labour on the estate of his lord. Here, then, the paid and unpaid parts of labour were sensibly separated, separated in time and space, and our Liberals overflowed with moral indignation at the preposterous notion of making a man work for nothing.
In point of fact, however, whether a man works three days of the week for himself on his own field and three days for nothing on the estate of his lord, or whether he works in the factory or the workshop six hours daily for himself and six for his employer, comes to the same, although in the latter case the paid and unpaid portions of labour are inseparably mixed up with each other, and the nature of the whole transaction is completely masked by the intervention of a contract and the pay received at the end of the week. The gratuitous labour appears to be voluntarily given in the one instance, and to be compulsory in the other. That makes all the difference.
In using the word "value of labour," I shall only use it as a popular slang term for "value of labouring power."
== X. กำไรถูกสร้างขึ้นด้วยการขายโภคภัณฑ์ที่มูลค่าของมัน ==
[[งานแปล:ค่าจ้าง ราคา และกำไร/บทที่ 11|X. กำไรถูกสร้างขึ้นด้วยการขายโภคภัณฑ์ที่มูลค่าของมัน]]
หัวเรื่องงานแปล
<!-- ข้อมูลหลัก -->
| ชื่อ = ค่าจ้าง ราคา และกำไร
| ศักราช = ค.ศ.
| ปี = 1865
| ภาษา = en
| ต้นฉบับ = Wages, Price and Profit
| ผู้สร้างสรรค์ = คาร์ล มาคส์
| บรรณาธิการ = เอเลนอร์ มาคส์ เอฟลิง
| ส่วน =
| ผู้มีส่วนร่วม =
| ก่อนหน้า = [[งานแปล:ค่าจ้าง ราคา และกำไร/บทที่ 10|IX. มูลค่าของแรงงาน]]
| ถัดไป = [[งานแปล:ค่าจ้าง ราคา และกำไร/บทที่ 12|XI. ส่วนต่าง ๆ ที่มูลค่าส่วนเกินถูกจำแนกไป]]
| หมายเหตุ =
<!-- ข้อมูลย่อย (สำหรับจัดระเบียบหรือเชื่อมโยงไปหน้าอื่น) -->
| หมวดหมู่ =
| แก้กำกวม =
| รุ่น =
| สถานีย่อย =
| ผู้สร้างสรรค์ที่เกี่ยวข้อง =
| วิกิพีเดีย =
| คอมมอนส์ =
| หมวดหมู่คอมมอนส์ =
| วิกิคำคม =
| วิกิข่าว =
| วิกิพจนานุกรม =
| วิกิตำรา =
| วิกิห้องสมุด =
| วิกิสนเทศ =
| วิกิท่องเที่ยว =
| วิกิวิทยาลัย =
| วิกิสปีชีส์ =
| เมทา =
Suppose an average hour of labour to be realized in a value equal to sixpence, or twelve average hours of labour to be realized in six shillings. Suppose, further, the value of labour to be three shillings or the produce of six hours' labour. If, then, in the raw material, machinery, and so forth, used up in a commodity, twenty-four hours of average labour were realized, its value would amount to twelve shillings. If, moreover, the workman employed by the capitalist added twelve hours of labour to those means of production, these twelve hours would be realized in an additional value of six shillings. The total value of the product would, therefore, amount to thirty-six hours of realized labour, and be equal to eighteen shillings. But as the value of labour, or the wages paid to the workman, would be three shillings only, no equivalent would have been paid by the capitalist for the six hours of surplus labour worked by the workman, and realized in the value of the commodity. By selling this commodity at its value for eighteen shillings, the capitalist would, therefore, realize a value of three shillings, for which he had paid no equivalent. These three shillings would constitute the surplus value or profit pocketed by him. The capitalist would consequently realize the profit of three shillings, not by selling his commodity at a price over and above its value, but by selling it at its real value.
The value of a commodity is determined by the total quantity of labour contained in it. But part of that quantity of labour is realized in a value, for which an equivalent has been paid in the form of wages; part of it is realized in a value for which no equivalent has been paid. Part of the labour contained in the commodity is paid labour; part is unpaid labour. By selling, therefore, the commodity at its value, that is, as the crystallization of the total quantity of labour bestowed upon it, the capitalist must necessarily sell it at a profit. He sells not only what has cost him an equivalent, but he sells also what has cost him nothing, although it has cost his workman labour. The cost of the commodity to the capitalist and its real cost are different things. I repeat, therefore, that normal and average profits are made by selling commodities not above, but at their real values.
== XI. ส่วนต่าง ๆ ที่มูลค่าส่วนเกินถูกจำแนกไป ==
[[งานแปล:ค่าจ้าง ราคา และกำไร/บทที่ 12|XI. ส่วนต่าง ๆ ที่มูลค่าส่วนเกินถูกจำแนกไป]]
หัวเรื่องงานแปล
<!-- ข้อมูลหลัก -->
| ชื่อ = ค่าจ้าง ราคา และกำไร
| ศักราช = ค.ศ.
| ปี = 1865
| ภาษา = en
| ต้นฉบับ = Wages, Price and Profit
| ผู้สร้างสรรค์ = คาร์ล มาคส์
| บรรณาธิการ = เอเลนอร์ มาคส์ เอฟลิง
| ส่วน =
| ผู้มีส่วนร่วม =
| ก่อนหน้า = [[งานแปล:ค่าจ้าง ราคา และกำไร/บทที่ 11|X. กำไรถูกสร้างขึ้นด้วยการขายโภคภัณฑ์ที่มูลค่าของมัน]]
| ถัดไป = [[งานแปล:ค่าจ้าง ราคา และกำไร/บทที่ 13|XII. ความสัมพันธ์โดยทั่วไปของกำไร ค่าจ้าง และราคา]]
| หมายเหตุ =
<!-- ข้อมูลย่อย (สำหรับจัดระเบียบหรือเชื่อมโยงไปหน้าอื่น) -->
| หมวดหมู่ =
| แก้กำกวม =
| รุ่น =
| สถานีย่อย =
| ผู้สร้างสรรค์ที่เกี่ยวข้อง =
| วิกิพีเดีย =
| คอมมอนส์ =
| หมวดหมู่คอมมอนส์ =
| วิกิคำคม =
| วิกิข่าว =
| วิกิพจนานุกรม =
| วิกิตำรา =
| วิกิห้องสมุด =
| วิกิสนเทศ =
| วิกิท่องเที่ยว =
| วิกิวิทยาลัย =
| วิกิสปีชีส์ =
| เมทา =
The surplus value, or that part of the total value of the commodity in which the surplus labour or unpaid labour of the working man is realized, I call Profit. The whole of that profit is not pocketed by the employing capitalist. The monopoly of land enables the landlord to take one part of that surplus value, under the name of rent, whether the land is used for agriculture, buildings or railways, or for any other productive purpose. On the other hand, the very fact that the possession of the instruments of labour enables the employing capitalist to produce a surplus value, or, what comes to the same, to appropriate to himself a certain amount of unpaid labour, enables the owner of the means of labour, which he lends wholly or partly to the employing capitalist -- enables, in one word, the money-lending capitalist to claim for himself under the name of interest another part of that surplus value, so that there remains to the employing capitalist as such only what is called industrial or commercial profit.
By what laws this division of the total amount of surplus value amongst the three categories of people is regulated is a question quite foreign to our subject. This much, however, results from what has been stated.
Rent, Interest, and Industrial Profit are only different names for different parts of the surplus value of the commodity, or the unpaid labour enclosed in it, and they are equally derived from this source, and from this source alone. They are not derived from land as such or from capital as such, but land and capital enable their owners to get their respective shares out of the surplus value extracted by the employing capitalist from the labourer. For the labourer himself it is a matter of subordinate importance whether that surplus value, the result of his surplus labour, or unpaid labour, is altogether pocketed by the employing capitalist, or whether the latter is obliged to pay portions of it, under the name of rent and interest, away to third parties. Suppose the employing capitalist to use only his own capital and to be his own landlord, then the whole surplus value would go into his pocket.
It is the employing capitalist who immediately extracts from the labourer this surplus value, whatever part of it he may ultimately be able to keep for himself. Upon this relation, therefore, between the employing capitalist and the wages labourer the whole wages system and the whole present system of production hinge. Some of the citizens who took part in our debate were, therefore, wrong in trying to mince matters, and to treat this fundamental relation between the employing capitalist and the working man as a secondary question, although they were right in stating that, under given circumstances, a rise of prices might affect in very unequal degrees the employing capitalist, the landlord, the moneyed capitalist, and, if you please, the tax gatherer.
Another consequence follows from what has been stated.
That part of the value of the commodity which represents only the value of the raw materials, the machinery, in one word, no revenue at all, but replaces only capital. But, apart from this, it is false that the other part of the value of the commodity which forms revenue, or may be spent in the form of wages, profits, rent, interest, is constituted by the value of wages, the value of rent, the value of profits, and so forth. We shall, in the first instance, discard wages, and only treat industrial profits, interest, and rent. We have just seen that the surplus value contained in the commodity or that part of its value in which unpaid labour is realized, resolves itself into different fractions, bearing three different names. But it would be quite the reverse of the truth to say that its value is composed of, or formed by, the addition of the independent values of these three constituents.
If one hour of labour realizes itself in a value of sixpence, if the working day of the labourer comprises twelve hours, if half of this time is unpaid labour, that surplus labour will add to the commodity a surplus value of three shillings, that is, of value for which no equivalent has been paid. This surplus value of three shillings constitutes the whole fund which the employing capitalist may divide, in whatever proportions, with the landlord and the money-lender. The value of these three shillings constitutes the limit of the value they have to divide amongst them. But it is not the employing capitalist who adds to the value of the commodity an arbitrary value for his profit, to which another value is added for the landlord, and so forth, so that the addition of these arbitrarily fixed values would constitute the total value. You see, therefore, the fallacy of the popular notion, which confounds the decomposition of a given value into three parts, with the formation of that value by the addition of three independent values, thus converting the aggregate value, from which rent, profit, and interest are derived, into an arbitrary magnitude.
If the total profit realized by a capitalist be equal to £100, we call this sum, considered as absolute magnitude, the amount of profit. But if we calculate the ratio which those £100 bear to the capital advanced, we call this relative magnitude. It is evident that this rate of profit may be expressed in a double way.
Suppose £100 to be the capital advanced in wages. If the surplus value created is also £100 -- and this would show us that half the working day of the labourer consists of unpaid labour -- and if we measured this profit by the value of the capital advanced in wages, we should say that the rate of profit amounted to one hundred per cent., because the value advanced would be one hundred and the value realized would be two hundred.
If, on the other hand, we should not only consider the capital advanced in wages, but the total capital advanced, say, for example, £500, of which £400 represented the value of raw materials, machinery, and so forth, we should say that the rate of profit amounted only to twenty per cent., because the profit of one hundred would be but the fifth part of the total capital advanced.
The first mode of expressing the rate of profit is the only one which shows you the real ratio between paid and unpaid labour, the real degree of the exploitation (you must allow me this French word) of labour. The other mode of expression is that in common use, and is, indeed, appropriate for certain purposes. At all events, it is very useful for concealing the degree in which the capitalist extracts gratuitous labour from the workman.
In the remarks I have still to make I shall use the word Profit for the whole amount of the surplus value extracted by the capitalist without any regard to the division of that surplus value between different parties, and in using the words Rate of Profit, I shall always measure profits by the value of the capital advanced in wages.
== XII. ความสัมพันธ์โดยทั่วไปของกำไร ค่าจ้าง และราคา ==
[[งานแปล:ค่าจ้าง ราคา และกำไร/บทที่ 13|XII. ความสัมพันธ์โดยทั่วไปของกำไร ค่าจ้าง และราคา]]
หัวเรื่องงานแปล
<!-- ข้อมูลหลัก -->
| ชื่อ = ค่าจ้าง ราคา และกำไร
| ศักราช = ค.ศ.
| ปี = 1865
| ภาษา = en
| ต้นฉบับ = Wages, Price and Profit
| ผู้สร้างสรรค์ = คาร์ล มาคส์
| บรรณาธิการ = เอเลนอร์ มาคส์ เอฟลิง
| ส่วน =
| ผู้มีส่วนร่วม =
| ก่อนหน้า = [[งานแปล:ค่าจ้าง ราคา และกำไร/บทที่ 12|XI. ส่วนต่าง ๆ ที่มูลค่าส่วนเกินถูกจำแนกไป]]
| ถัดไป = [[งานแปล:ค่าจ้าง ราคา และกำไร/บทที่ 14|XIII. กรณีหลักของความพยายามในการเพิ่มค่าจ้างหรือการต่อต้านการลดต่ำลงของมัน]]
| หมายเหตุ =
<!-- ข้อมูลย่อย (สำหรับจัดระเบียบหรือเชื่อมโยงไปหน้าอื่น) -->
| หมวดหมู่ =
| แก้กำกวม =
| รุ่น =
| สถานีย่อย =
| ผู้สร้างสรรค์ที่เกี่ยวข้อง =
| วิกิพีเดีย =
| คอมมอนส์ =
| หมวดหมู่คอมมอนส์ =
| วิกิคำคม =
| วิกิข่าว =
| วิกิพจนานุกรม =
| วิกิตำรา =
| วิกิห้องสมุด =
| วิกิสนเทศ =
| วิกิท่องเที่ยว =
| วิกิวิทยาลัย =
| วิกิสปีชีส์ =
| เมทา =
Deduct from the value of a commodity the value replacing the value of the raw materials and other means of production used upon it, that is to say, deduct the value representing the past labour contained in it, and the remainder of its value will resolve into the quantity of labour added by the working man last employed. If that working man works twelve hours daily, if twelve hours of average labour crystallize themselves in an amount of gold equal to six shillings, this additional value of six shillings is the only value his labour will have created. This given value, determined by the time of his labour, is the only fund from which both he and the capitalist have to draw their respective shares or dividends, the only value to be divided into wages and profits. It is evident that this value itself will not be altered by the variable proportions in which it may be divided amongst the two parties. There will also be nothing changed if in the place of one working man you put the whole working population, twelve million working days, for example, instead of one.
Since the capitalist and workman have only to divide this limited value, that is, the value measured by the total labour of the working man, the more the one gets the less will the other get, and vice versa. Whenever a quantity is given, one part of it will increase inversely as the other decreases. If the wages change, profits will change in an opposite direction. If wages fall profits will rise; and if wages rise, profits will fall. If the working man, on our former supposition, gets shillings, equal to one-half of the value he has created, or if his whole working day consists half of paid, half of unpaid labour, the rate of profit will be 100 per cent., because the capitalist would also get three shillings. If the working man receives only two shillings, or works only one third of the whole day for himself, the capitalist will get four shillings, and the rate of profit will be 200 per cent. If the working man receives four shillings, the capitalist will only receive two, and the rate of profit would sink to 50 per cent., but all these variations will not affect the value of the commodity. A general rise of wages would, therefore, result in a fall of the general rate of profit, but not affect values.
But although the values of commodities, which must ultimately regulate their market prices, are exclusively determined by the total quantities of labour fixed in them, and not by the division of that quantity into paid and unpaid labour, it by no means follows that the values of the single commodities, or lots of commodities, produced during twelve hours, for example, will remain constant. The number or mass of commodities produced in a given time of labour, or by a given quantity of labour, depends unon the productive power of the labour employed, and upon its extent or length. With one degree of the productive power of spinning labour, for example, a working day of twelve hours may produce twelve pounds of yarn, with a lesser degree of productive power only two pounds. If then twelve hours' average labour were realized in the value of six shillings in the one case, the twelve pounds of yarn would cost six shillings, in the other case the two pounds of yarn would also cost six shillings. One pound of yarn would, therefore, cost sixpence in the one case, and three shillings in the other. This difference of price would result from the difference in the productive powers of the labour employed. One hour of labour would be realized in one pound of yarn with the greater productive power, while with the smaller productive power, six hours of labour would be realized in one pound of yarn. The price of a pound of yarn would, in the one instance, be only sixpence, although wages were relatively high and the rate of profit low, it would be three shillings in the other instance, although wages were low and the rate of profit high. This would be so because the price of the pound of yarn is regulated by the total amount of labour worked up in it, and not by the proportional division of that total amount into paid and unpaid labour. The fact I have before mentioned that high-priced labour may produce cheap, and low-priced labour may produce dear commodities, loses, therefore, its paradoxical appearance. It is only the expression of the general law that the value of a commodity is regulated by the quantity of labour worked up in it, and that the quantity of labour worked up in it depends altogether upon the productive powers of the labour employed, and will, therefore, vary with every variation in the productivity of labour.
== XIII. กรณีหลักของความพยายามในการเพิ่มค่าจ้างหรือการต่อต้านการลดต่ำลงของมัน ==
[[งานแปล:ค่าจ้าง ราคา และกำไร/บทที่ 14|XIII. กรณีหลักของความพยายามในการเพิ่มค่าจ้างหรือการต่อต้านการลดต่ำลงของมัน]]
หัวเรื่องงานแปล
<!-- ข้อมูลหลัก -->
| ชื่อ = ค่าจ้าง ราคา และกำไร
| ศักราช = ค.ศ.
| ปี = 1865
| ภาษา = en
| ต้นฉบับ = Wages, Price and Profit
| ผู้สร้างสรรค์ = คาร์ล มาคส์
| บรรณาธิการ = เอเลนอร์ มาคส์ เอฟลิง
| ส่วน =
| ผู้มีส่วนร่วม =
| ก่อนหน้า = [[งานแปล:ค่าจ้าง ราคา และกำไร/บทที่ 13|XII. ความสัมพันธ์โดยทั่วไปของกำไร ค่าจ้าง และราคา]]
| ถัดไป = [[งานแปล:ค่าจ้าง ราคา และกำไร/บทที่ 15|XIV. การต่อสู้ระหว่างทุนกับแรงงานและผลลัพธ์ของมัน]]
| หมายเหตุ =
<!-- ข้อมูลย่อย (สำหรับจัดระเบียบหรือเชื่อมโยงไปหน้าอื่น) -->
| หมวดหมู่ =
| แก้กำกวม =
| รุ่น =
| สถานีย่อย =
| ผู้สร้างสรรค์ที่เกี่ยวข้อง =
| วิกิพีเดีย =
| คอมมอนส์ =
| หมวดหมู่คอมมอนส์ =
| วิกิคำคม =
| วิกิข่าว =
| วิกิพจนานุกรม =
| วิกิตำรา =
| วิกิห้องสมุด =
| วิกิสนเทศ =
| วิกิท่องเที่ยว =
| วิกิวิทยาลัย =
| วิกิสปีชีส์ =
| เมทา =
Let us now seriously consider the main cases in which a rise of wages is attempted or a reduction of wages resisted.
1. We have seen that the value of the labouring power, or in more popular parlance, the value of labour, is determined by the value of necessaries, or the quantity of labour required to produce them. If, then, in a given country the value of the daily average necessaries of the labourer represented six hours of labour expressed in three shillings, the labourer would have to work six hours daily to produce an equivalent for his daily maintenance. If the whole working day was twelve hours, the capitalist would pay him the value of his labour by paying him three shillings. Half the working day would be unpaid labour, and the rate of profit would amount to 100 per cent. But now suppose that, consequent upon a decrease of productivity, more labour should be wanted to produce, say, the same amount of agricultural produce, 60 that the price of the average daily necessaries should rise from three to four shillings. In that case the value of labour would rise by one-third, or 331/3 per cent. Eight hours of the working day would be required to produce an equivalent for the daily maintenance of the labourer, according to his old standard of living. The surplus labour would therefore sink from six hours to four, and the rate of profit from 100 to 50 per cent. But in insisting upon a rise of wages, the labourer would only insist upon getting the increased value of his labour, like every other seller of a commodity, who, the costs of his commodities having increased, tries to get its increased value paid. If wages did not rise, or not sufficiently rise, to compensate for the increased values of necessaries, the price of labour would sink below the value of labour, and the labourer's standard of life would deteriorate.
But a change might also take place in an opposite direction. By virtue of the increased productivity of labour, the same amount of the average daily necessaries might sink from three to two shillings, or only four hours out of the working day, instead of six, be wanted to reproduce an equivalent for the value of the daily necessaries. The working man would now be able to buy with two shillings as many necessaries as he did before with three shillings. Indeed, the value of labour would have sunk, but that diminished value would command the same amount of commodities as before. Then profits would rise from three to four shillings, and the rate of profit from 100 to 200 per cent. Although the labourer's absolute standard of life would have remained the same, his relative wages, and therewith his relative social position, as compared with that of the capitalist, would have been lowered. If the working man should resist that reduction of relative wages, he would only try to get some share in the increased productive powers of his own labour, and to maintain his former relative position in the social scale. Thus, after the abolition of the Corn Laws, and in flagrant violation of the most solemn pledges given during the anti-Corn Law agitation, the English factory lords generally reduced wages ten per cent. The resistance of the workmen was at first baffled, but, consequent upon circumstances I cannot now enter upon, the ten per cent. lost were afterwards regained.
2. The values of necessaries, and consequently the value of labour, might remain the same, but a change might occur in their money prices, consequent upon a previous change in the value of money.
By the discovery of more fertile mines and so forth, two ounces of gold might, for example, cost no more labour to produce than one ounce did before. The value of gold would then be depreciated by one-half, or fifty per cent. As the values of all other commodities would then be expressed in twice their former money prices, so also the same with the value of labour. Twelve hours of labour, formerly expressed in six shillings, would now be expressed in twelve shillings. If the working man's wages should remain three shillings, instead of rising to six shillings, the money price of his labour would only be equal to half the value of his labour, and his standard of life would fearfully deteriorate. This would also happen in a greater or lesser degree if his wages should rise, but not proportionately to the fall in the value of gold. In such a case nothing would have been changed, either in the productive powers of labour, or in supply and demand, or in values. Nothing could have changed except the money names of those values. To say that in such a case the workman ought not to insist upon a proportionate rise of wages, is to say that he must be content to be paid with names, instead of with things. All past history proves that whenever such a depreciation of money occurs, the capitalists are on the alert to seize this opportunity for defrauding the workman. A very large school of political economists assert that, consequent upon the new discoveries of gold lands, the better working of silver mines, and the cheaper supply of quicksilver, the value of precious metals has been again depreciated. This would explain the general and simultaneous attempts on the Continent at a rise of wages.
3. We have till now supposed that the working day has given limits. The working day, however, has, by itself, no constant limits. It is the constant tendency of capital to stretch it to its utmost physically possible length, because in the same degree surplus labour, and consequently the profit resulting therefrom, will be increased. The more capital succeeds in prolonging the working day, the greater the amount of other people's labour it will appropriate. During the seventeenth and even the first two-thirds of the eighteenth century a ten hours working day was the normal working day all over England. During the anti-Jacobin war, which was in fact a war waged by the British barons against the British working masses, capital celebrated its bacchanalia, and prolonged the working day from ten to twelve, fourteen, eighteen hours. Malthus, by no means a man whom you would suspect of a maudlin sentimentalism, declared in a pamphlet, published about 1815, that if this sort of thing was to go on the life of the nation would be attacked at its very source. A few years before the general introduction of the newly-invented machinery, about 1765, a pamphlet appeared in England under the title, An Essay on Trade. The anonymous author, an avowed enemy of the working classes, declaims on the necessity of expanding the limits of the working day. Amongst other means to this end, he proposes working houses, which, he says, ought to be "Houses of Terror." And what is the length of the working day he prescribes for these "Houses of Terror"? Twelve hours, the very same time which in 1832 was declared by capitalists, political economists, and ministers to be not only the existing but the necessary time of labour for a child under twelve years.
By selling his labouring power, and he must do so under the present system, the working man makes over to the capitalist the consumption of that power, but within certain rational limits. He sells his labouring power in order to maintain it, apart from its natural wear and tear, but not to destroy it. In selling his labouring power at its daily or weekly value, it is understood that in one day or one week that labouring power shall not be submitted to two days' or two weeks' waste or wear and tear. Take a machine worth £1,000. If it is used up in ten years it will add to the value of the commodities in whose production it assists £100 yearly. If it be used up in five years it would add £200 yearly, or the value of its annual wear and tear is in inverse ratio to the time in which it is consumed. But this distinguishes the working man from the machine. Machinery does not wear out exactly in the same ratio in which it is used. Man, on the contrary, decays in a greater ratio than would be visible from the mere numerical addition of work.
In their attempts at reducing the working day to its former rational dimensions, or, where they cannot enforce a legal fixation of a normal working day, at checking overwork by a rise of wages, a rise not only in proportion to the surplus time exacted, but in a greater proportion, working men fulfil only a duty to themselves and their race. They only set limits to the tyrannical usurpations of capital. Time is the room of human development. A man who has no free time to dispose of, whose whole lifetime, apart from the mere physical interruptions by sleep, meals, and so forth, is absorbed by his labour for the capitalist, is less than a beast of burden. He is a mere machine for producing Foreign Wealth, broken in body and brutalized in mind. Yet the whole history of modern industry shows that capital, if not checked, will recklessly and ruthlessly work to cast down the whole working class to this utmost state of degradation.
In prolonging the working day the capitalist may pay higher wages and still lower the value of labour, if the rise of wages does not correspond to the greater amount of labour extracted, and the quicker decay of the labouring power thus caused. This may be done in another way. Your middle-class statisticians will tell you, for instance, that the average wages of factory families in Lancashire have risen. They forget that instead of the labour of the man, the head of the family, his wife and perhaps three or four children are now thrown under the Juggernaut wheels of capital, and that the rise of the aggregate wages does not correspond to the aggregate surplus labour extracted from the family.
Even with given limits of the working day, such as they now exist in all branches of industry subjected to the factory laws, a rise of wages may become necessary, if only to keep up the old standard value of labour. By increasing the intensity of labour, a man may be made to expend as much vital force in one hour as he formerly did in two. This has, to a certain degree, been effected in the trades, placed under the Factory Acts, by the acceleration of machinery, and the greater number of working machines which a single individual has now to superintend. If the increase in the intensity of labour or the mass of labour spent in an hour keeps some fair proportion to the decrease in the extent of the working day, the working man will still be the winner. If this limit is overshot, he loses in one form what he has gained in another, and ten hours of labour may then become as ruinous as twelve hours were before. In checking this tendency of capital, by struggling for a rise of wages corresponding to the rising intensity of labour, the working man only resists the depreciation of his labour and the deterioration of his race.
4. All of you know that, from reasons I have not now to explain, capitalistic production moves through certain periodical cycles. It moves through a state of quiescence, growing animation, prosperity, overtrade, crisis, and stagnation. The market prices of commodities, and the market rates of profit, follow these phases, now sinking below their averages, now rising above them. Considering the whole cycle, you will find that one deviation of the market price is being compensated by the other, and that, taking the average of the cycle, the market prices of commodities are regulated by their values. Well! During the phase of sinking market prices and the phases of crisis and stagnation, the working man, if not thrown out of employment altogether, is sure to have his wages lowered. Not to be defrauded, he must, even with such a fall of market prices, debate with the capitalist in what proportional degree a fall of wages has become necessary. If, during the phases of prosperity, when extra profits are made, he did not battle for a rise of wages, he would, taking the average of one industrial cycle, not even receive his average wages, or the value of his labour. It is the utmost height of folly to demand that while his wages are necessarily affected by the adverse phases of the cycle, he should exclude himself from compensation during the prosperous phases of the cycle. Generally, the values of all commodities are only realized by the compensation of the continuously changing market prices, springing from the continuous fluctuations of demand and supply. On the basis of the present system labour is only a commodity like others. It must, therefore, pass through the same fluctuations to fetch an average price corresponding to its value. It would be absurd to treat it on the one hand as a commodity, and to want on the other hand to exempt it from the laws which regulate the prices of commodities. The slave receives a permanent and fixed amount of maintenance; the wages labourer does not. He must try to get a rise of wages in the one instance, if only to compensate for a fall of wages in the other. If he resigned himself to accept the will, the dictates of the capitalist as a permanent economical law, he would share in all the miseries of the slave, without the security of the slave.
5. In all the cases I have considered, and they form ninety-nine out of a hundred, you have seen that a struggle for a rise of wages follows only in the track of previous changes, and is the necessary offspring of previous changes in the amount of production, the productive powers of labour, the value of labour, the value of money, the extent or the intensity of labour extracted, the fluctuations of market prices, dependent upon the fluctuations of demand and supply, and consistent with the different phases of the industrial cycle; in one word, as reactions of labour against the previous action of capital. By treating the struggle for a rise of wages independently of all these circumstances, by looking only upon the changes of wages, and overlooking all the other changes from which they emanate, you proceed from a false premise in order to arrive at false conclusions.
== XIV. การต่อสู้ระหว่างทุนกับแรงงานและผลลัพธ์ของมัน ==
[[งานแปล:ค่าจ้าง ราคา และกำไร/บทที่ 15|XIV. การต่อสู้ระหว่างทุนกับแรงงานและผลลัพธ์ของมัน]]
หัวเรื่องงานแปล
<!-- ข้อมูลหลัก -->
| ชื่อ = ค่าจ้าง ราคา และกำไร
| ศักราช = ค.ศ.
| ปี = 1865
| ภาษา = en
| ต้นฉบับ = Wages, Price and Profit
| ผู้สร้างสรรค์ = คาร์ล มาคส์
| บรรณาธิการ = เอเลนอร์ มาคส์ เอฟลิง
| ส่วน =
| ผู้มีส่วนร่วม =
| ก่อนหน้า = [[งานแปล:ค่าจ้าง ราคา และกำไร/บทที่ 14|XIII. กรณีหลักของความพยายามในการเพิ่มค่าจ้างหรือการต่อต้านการลดต่ำลงของมัน]]
| ถัดไป =
| หมายเหตุ =
<!-- ข้อมูลย่อย (สำหรับจัดระเบียบหรือเชื่อมโยงไปหน้าอื่น) -->
| หมวดหมู่ =
| แก้กำกวม =
| รุ่น =
| สถานีย่อย =
| ผู้สร้างสรรค์ที่เกี่ยวข้อง =
| วิกิพีเดีย =
| คอมมอนส์ =
| หมวดหมู่คอมมอนส์ =
| วิกิคำคม =
| วิกิข่าว =
| วิกิพจนานุกรม =
| วิกิตำรา =
| วิกิห้องสมุด =
| วิกิสนเทศ =
| วิกิท่องเที่ยว =
| วิกิวิทยาลัย =
| วิกิสปีชีส์ =
| เมทา =
1. Having shown that the periodical resistance on the part of the working men against a reduction of wages, and their periodical attempts at getting a rise of wages, are inseparable from the wages system, and dictated by the very fact of labour being assimilated to commodities, and therefore subject to the laws regulating the general movement of prices; having, furthermore, shown that a general rise of wages would result in a fall in the general rate of profit, but not affect the average prices of commodities, or their values, the question now ultimately arises, how far, in this incessant struggle between capital and labour, the latter is likely to prove successful.
I might answer by a generalization, and say that, as with all other commodities, so with labour, its market price will, in the long run, adapt itself to its value; that, therefore, despite all the ups and downs, and do what he may, the working man will, on an average, only receive the value of his labour which resolves into the value of his labouring power, which is determined by the value of the necessaries required for its maintenance and reproduction, which value of necessaries finally is regulated by the quantity of labour wanted to produce them.
But there are some peculiar features which distinguish the value of the labouring power, or value of labour, from the value of all other commodities. The value of the labouring power is formed by two elements -- the one merely physical, the other historical or social. Its ultimate limit is determined by the physical element, that is to say, to maintain and reproduce itself, to perpetuate its physical existence, the working class must receive the necessaries absolutely indispensable for living and multiplying. The value of those indispensable necessaries forms, therefore, the ultimate limit of the value of labour. On the other hand, the length of the working day is also limited by ultimate, although very elastic boundaries. Its ultimate limit is given by the physical force of the labouring man. If the daily exhaustion of his vital forces exceeds a certain degree, it cannot be exerted anew, day by day. However, as I said, this limit is very elastic. A quick succession of unhealthy and short-lived generations will keep the labour market as well supplied as a series of vigorous and long-lived generations.
Besides this mere physical element, the value of labour is in every country determined by a traditional standard of life. It is not mere physical life, but it is the satisfaction of certain wants springing from the social conditions in which people are placed and reared up. The English standard of life may be reduced to the Irish standard; the standard of life of a German peasant to that of a Livonian peasant. The important part which historical tradition and social habitude play in this respect, you may learn from Mr. Thornton's work on Over-population, where he shows that the average wages in different agricultural districts of England still nowadays differ more or less according to the more or less favourable circumstances under which the districts have emerged from the state of serfdom.
This historical or social element, entering into the value of labour, may be expanded, or contracted, or altogether extinguished, so that nothing remains but the physical limit. During the time of the anti-Jacobin war, undertaken, as the incorrigible tax-eater and sinecurist, old George Rose, used to say, to save the comforts of our holy religion from the inroads of the French infidels, the honest English farmers, so tenderly handled in a former chapter of ours, depressed the wages of the agricultural labourers even beneath that mere physical minimum, but made up by Poor Laws the remainder necessary for the physical perpetuation of the race. This was a glorious way to convert the wages labourer into a slave, and Shakespeare's proud yeoman into a pauper.
By comparing the standard wages or values of labour in different countries, and by comparing them in different historical epochs of the same country, you will find that the value of labour itself is not a fixed but a variable magnitude, even supposing the values of all other commodities to remain constant.
A similar comparison would prove that not only the market rates of profit change, but its average rates.
But as to profits, there exists no law which determines their minimum. We cannot say what is the ultimate limit of their decrease. And why cannot we fix that limit? Because although we can fix the minimum of wages, we cannot fix their maximum. We can only say that, the limits of the working day being given, the maximum of profit corresponds to the physical minimum of wages; and that wages being given, the maximum of profit corresponds to such a prolongation of the working day as is compatible with the physical force of the labourer. The maximum of profit is, therefore, limited by the physical minimum of wages and the physical maximum of the working day. It is evident that between the two limits of this maximum rate of profit an immense scale of variations is possible. The fixation of its actual degree is only settled by the continuous struggle between capital and labour, the capitalist constantly tending to reduce wages to their physical minimum, and to extend the working day to its physical maximum, while the working man constantly presses in the opposite direction.
The matter resolves itself into a question of the respective powers of the combatants.
2. As to the limitation of the working day in England, as in all other countries, it has never been settled except by legislative interference. Without the working men's continuous pressure from without, that interference would never have taken place. But at all events, the result was not to be attained by private settlement between the working men and the capitalists. This very necessity of general political action affords the proof that in its merely economic action capital is the stronger side.
As to the limits of the value of labour, its actual settlement always depends upon supply and demand, I mean the demand for labour on the part of capital, and the supply of labour by the working men. In colonial countries the law of supply and demand favours the working man. Hence the relatively high standard of wages in the United States. Capital may there try its utmost. It cannot prevent the labour market from being continuously emptied by the continuous conversion of wages labourers into independent, self-sustaining peasants. The position of a wages labourer is for a very large part of the American people but a probational state, which they are sure to leave within a longer or shorter term. To mend this colonial state of things, the paternal British Government accepted for some time what is called the modern colonization theory, which consists in putting an artificial high price upon colonial land, in order to prevent the too quick conversion of the wages labourer into the independent peasant.
But let us now come to old civilized countries, in which capital domineers over the whole process of production. Take, for example, the rise in England of agricultural wages from 1849 to 1859. What was its consequence? The farmers could not, as our friend Weston would have advised them, raise the value of wheat, nor even its market prices. They had, on the contrary, to submit to their fall. But during these eleven years they introduced machinery of all sorts, adopted more scientific methods, converted part of arable land into pasture, increased the size of farms, and with this the scale of production, and by these and other processes diminishing the demand for labour by increasing its productive power, made the agricultural population again relatively redundant. This is the general method in which a reaction, quicker or slower, of capital against a rise of wages takes place in old, settled countries. Ricardo has justly remarked that machinery is in constant competition with labour, and can often be only introduced when the price of labour has reached a certain height, but the appliance of machinery is but one of the many methods for increasing the productive powers of labour. This very same development which makes common labour relatively redundant simplifies on the other hand skilled labour, and thus depreciates it.
The same law obtains in another form. With the development of the productive powers of labour the accumulation of capital will be accelerated, even despite a relatively high rate of wages. Hence, one might infer, as Adam Smith, in whose days modern industry was still in its infancy, did infer, that the accelerated accumulation of capital must turn the balance in favour of the working man, by securing a growing demand for his labour. From this same standpoint many contemporary writers have wondered that English capital having grown in the last twenty years so much quicker than English population, wages should not have been more enhanced. But simultaneously with the process of accumulation there takes place a progressive change in the composition of capital. That part of the aggregate capital which consists of fixed capital, machinery, raw materials, means of production in all possible forms, progressively increases as compared with the other part of capital, which is laid out in wages or in the purchase of labour. This law has been stated in a more or less accurate manner by Mr. Barton, Ricardo, Sismondi, Professor Richard Jones, Professor Ramsay, Cherbuliez, and others.
If the proportion of these two elements of capital was originally one to one, it will, in the progress of industry, become five to one, and so forth. If of a total capital of 600, 300 is laid out in instruments, raw materials, and so forth, and 300 in wages, the total capital wants only to be doubled to create a demand for 600 working men instead of for 300. But if of a capital of 600, 500 is laid out in machinery, materials, and so forth, and 100 only in wages, the same capital must increase from 600 to 3,600 in order to create a demand for 600 workmen instead of 300. In the progress of industry the demand for labour keeps, therefore, no pace with the accumulation of capital. It will still increase in a constantly diminishing ratio as compared with the increase of capital.
These few hints will suffice to show that the very development of modern industry must progressively turn the scale in favour of the capitalist against the working man, and that consequently the general tendency of capitalistic production is not to raise, but to sink the average standard of wages, or to push the value of labour more or less to its minimum limit. Such being the tendency of things in this system, is this saying that the working class ought to renounce their resistance against the encroachments of capital, and abandon their attempts at making the best of the occasional chances for the temporary improvement? If they did, they would be degraded to one level mass of broken wretches past salvation. I think I have shown that their struggles for the standard of wages are incidents inseparable from the whole wages system, that in 99 cases out of 100 their efforts at raising wages are only efforts at maintaining the given value of labour, and that the necessity of debating their price with the capitalist is inherent in their condition of having to sell themselves as commodities. By cowardly giving way in their every-day conflict with capital, they would certainly disqualify themselves for the initiating of any larger movement.
At the same time, and quite apart from the general servitude involved in the wages system, the working class ought not to exaggerate to themselves the ultimate working of these every-day struggles. They ought not to forget that they are fighting with effects, but not with the causes of those effects; that they are retarding the downward movement, but not changing its direction; that they are applying palliatives, not curing the malady. They ought, therefore, not to be exclusively absorbed in these unavoidable guerilla fights incessantly springing up from the never-ceasing encroachments of capital or changes of the market. They ought to understand that, with all the miseries it imposes upon them, the present system simultaneously engenders the material conditions and the social forms necessary for an economical reconstruction of society. Instead of the conservative motto, "A fair day's wage for a fair day's work!" they ought to inscribe on their banner the revolutionary watchword, "Abolition of the wages system!"
After this very long and, I fear, tedious exposition which I was obliged to enter into to do some justice to the subject matter, I shall conclude by proposing the following resolutions:
Firstly. A general rise in the rate of wages would result in a fall of the general rate of profit, but, broadly speaking, not affect the prices of commodities.
Secondly. The general tendency of capitalist production is not to raise, but to sink the average standard of wages.
Thirdly. Trades Unions work well as centres of resistance against the encroachments of capital. They fail partially from an injudicious use of their power. They fail generally from limiting themselves to a guerilla war against the effects of the existing system, instead of simultaneously trying to change it, instead of using their organized forces as a lever for the final emancipation of the working class, that is to say, the ultimate abolition of the wages system.
29fqudi1x80h0in1f1h5zaqy79arb5e
189496
189494
2022-08-17T04:03:17Z
Thastp
9008
/* VII. พลังที่ใช้แรงงาน */
wikitext
text/x-wiki
[[งานแปล:ค่าจ้าง ราคา และกำไร]]
== VII. พลังที่ใช้แรงงาน ==
[[งานแปล:ค่าจ้าง ราคา และกำไร/บทที่ 8|VII. พลังที่ใช้แรงงาน]]
หัวเรื่องงานแปล
<!-- ข้อมูลหลัก -->
| ชื่อ = ค่าจ้าง ราคา และกำไร
| ศักราช = ค.ศ.
| ปี = 1865
| ภาษา = en
| ต้นฉบับ = Wages, Price and Profit
| ผู้สร้างสรรค์ = คาร์ล มาคส์
| บรรณาธิการ = เอเลนอร์ มาคส์ เอฟลิง
| ส่วน = VII. พลังที่ใช้แรงงาน
| ผู้มีส่วนร่วม =
| ก่อนหน้า = [[งานแปล:ค่าจ้าง ราคา และกำไร/บทที่ 7|VI. มูลค่าและแรงงาน]]
| ถัดไป = [[งานแปล:ค่าจ้าง ราคา และกำไร/บทที่ 9|VIII. การผลิตมูลค่าส่วนเกิน]]
| หมายเหตุ =
<!-- ข้อมูลย่อย (สำหรับจัดระเบียบหรือเชื่อมโยงไปหน้าอื่น) -->
| หมวดหมู่ =
| แก้กำกวม =
| รุ่น =
| สถานีย่อย =
| ผู้สร้างสรรค์ที่เกี่ยวข้อง =
| วิกิพีเดีย =
| คอมมอนส์ =
| หมวดหมู่คอมมอนส์ =
| วิกิคำคม =
| วิกิข่าว =
| วิกิพจนานุกรม =
| วิกิตำรา =
| วิกิห้องสมุด =
| วิกิสนเทศ =
| วิกิท่องเที่ยว =
| วิกิวิทยาลัย =
| วิกิสปีชีส์ =
| เมทา =
{{ตรคป|Having now, as far as it could be done in such a cursory manner, analyzed the nature of Value, of the Value of any commodity whatever, we must turn our attention to the specific Value of Labour. And here, again, I must startle you by a seeming paradox. All of you feel sure that what they daily sell is their Labour; that, therefore, Labour has a Price, and that, the price of a commodity being only the monetary expression of its value, there must certainly exist such a thing as the Value of Labour. However, there exists no such thing as the Value of Labour in the common acceptance of the word. We have seen that the amount of necessary labour crystallized in a commodity constitutes its value. Now, applying this notion of value, how could we define, say, the value of a ten hours working day? How much labour is contained in that day? Ten hours' labour. To say that the value of a ten hours working day is equal to ten hours' labour, or the quantity of labour contained in it, would be a tautological and, moreover, a nonsensical expression. Of course, having once found out the true but hidden sense of the expression "Value of Labour," we shall be able to interpret this irrational, and seemingly impossible application of value, in the same way that, having once made sure of the real movement of the celestial bodies, we shall be able to explain their apparent or merely phenomenal movements. |ตอนนี้เราได้ทำการวิเคราะห์ธรรมชาติของมูลค่าไปแล้ว เท่าที่สามารถทำได้อย่างคร่าว ๆ เช่นนี้ ของมูลค่าของโภคภัณฑ์ใดก็ตาม ต่อมาเราต้องหันมาให้ความสนใจในมูลค่าของแรงงานโดยเฉพาะ และ ณ ที่นี้ผมจำต้องทำให้คุณตกใจด้วยสิ่งที่ดูเหมือนเป็นปฏิทรรศน์ พวกคุณทุกคนแน่ใจว่าสิ่งที่พวกเขาขายในทุก ๆ วันคือแรงงานของเขา ดังนั้นแรงงานจึงมีราคา และเมื่อราคาของสินค้าโภคภัณฑ์เป็นการแสดงออกมาในรูปเงินตราของมูลค่าของมัน มูลค่าของแรงงานก็ต้องเป็นสิ่งที่มีอยู่จริงอย่างแน่นอน ทว่ามูลค่าของแรงงานในความหมายที่ยอมรับกันทั่วไปที่ว่านั้นมันไม่มีอยู่จริง เราพบแล้วว่าผลึกของปริมาณของแรงงานอันจำเป็นข้างในสินค้าโภคภัณฑ์นั้นประกอบเป็นมูลค่าของมัน ทีนี้เมื่อนำแนวคิดนี้มาใช้ เราจะให้นิยามกับมูลค่าของวันทำงานนานสิบชั่วโมงได้อย่างไร ในหนึ่งวันนั้นมีแรงงานปริมาณเท่าใด ก็แรงงานนานสิบชั่วโมง เป็นต้น การกล่าวว่ามูลค่าของวันทำงานนานสิบชั่วโมงนั้นเท่ากับแรงงานนานสิบชั่วโมง หรือปริมาณของแรงงานที่มีอยู่ในนั้น ก็จะเป็นข้อความที่ซ้ำความและยังไร้ความหมายเสียอีก แน่นอนว่าหลังจากที่เราจะได้ค้นพบกับความหมายที่แท้จริงและอยู่เบื้องหลังคำว่า "มูลค่าของแรงงาน" แล้ว เราจะสามารถตีความการประยุกต์ใช้แนวคิดเรื่องมูลค่าที่ไร้เหตุผลและดูเหมือนจะเป็นไปไม่ได้เช่นนี้ ได้ในหนทางเดียวกันกับที่เมื่อเรารู้แน่ถึงการเคลื่อนที่ที่แท้จริงของเหล่าเทห์ฟากฟ้าแล้ว เราก็จะสามารถอธิบายการเคลื่อนไหวที่ชัดเจน หรือเป็นเพียงปรากฏการณ์ของพวกมันได้}}
{{ตรคป|What the working man sells is not directly his Labour, but his Labour Power, the temporary disposal of which he makes over to the capitalist. This is so much the case that I do not know whether by the English laws, but certainly by some Continental laws, the maximum time is fixed for which a man is allowed to sell his labouring power. If allowed to do so for any indefinite period whatever, slavery would be immediately restored. Such a sale, if it comprised his lifetime, for example, would make him at once the lifelong slave of his employer. |}}
{{ตรคป|One of the oldest economists and most original philosophers of England -- Thomas Hobbes -- has already, in his ''Leviathan'', instinctively hit upon this point overlooked by all his successors. He says: "''The value or worth of a man'' is, as in all other things, his price: that is, so much as would be given for the ''Use of his Power''." |}}
{{ตรคป|Proceeding from this basis, we shall be able to determine the Value of Labour as that of all other commodities. |}}
{{ตรคป|But before doing so, we might ask, how does this strange phenomenon arise, that we find on the market a set of buyers, possessed of land, machinery, raw material, and the means of subsistence, all of them, save land in its crude state, the products of labour, and on the other hand, a set of sellers who have nothing to sell except their labouring power, their working arms and brains? That the one set buys continually in order to make a profit and enrich themselves, while the other set continually sells in order to earn their livelihood? The inquiry into this question would be an inquiry into what the economists call "Previous, or Original Accumulation," but which ought to be called Original Expropriation. We should heed that this so-called Original Accumulation means nothing but a series of historical processes, resulting in a Decomposition of Original Union existing between the Labouring Man and his Instruments of Labour. Such an inquiry, however, lies beyond the pale of my present subject. The Separation between the Man of Labour and the Instruments of Labour once established, such a state of things will maintain itself and reproduce itself upon a constantly increasing scale, until a new and fundamental revolution in the mode of production should again overturn it, and restore the original union in a new historical form.|}}
{{ตรคป|What, then, is the Value of Labouring Power? |}}
{{ตรคป|Like that of every other commodity, its value is determined by the quantity of labour necessary to produce it. The labouring power of a man exists only in his living individuality. A certain mass of necessaries must be consumed by a man to grow up and maintain his life. But the man, like the machine, will wear out, and must be replaced by another man. Beside the mass of necessaries required for his own maintenance, he wants another amount of necessaries to bring up a certain quota of children that are to replace him on the labour market and to perpetuate the race of labourers. Moreover, to develop his labouring power, and acquire a given skill, another amount of values must be spent. For our purpose it suffices to consider only average labour, the costs of whose education and development are vanishing magnitudes. Still I must seize upon this occasion to state that, as the costs of producing labouring powers of different quality differ, so must differ the values of the labouring powers employed in different trades. The cry for an equality of wages rests, therefore, upon a mistake, is an insane wish never to be fulfilled. It is an offspring of that false and superficial radicalism that accepts premises and tries to evade conclusions. Upon the basis of the wages system the value of labouring power is settled like that of every other commodity; and as different kinds of labouring power have different values, or require different quantities of labour for their production, they must fetch different prices in the labour market. To clamour for equal or even equitable retribution on the basis of the wages system is the same as to clamour for freedom on the basis of the slavery system. What you think just or equitable is out of the question. The question is: What is necessary and unavoidable with a given system of production? |}}
{{ตรคป|After what has been said, it will be seen that the value of labouring power is determined by the value of the necessaries required to produce, develop, maintain, and perpetuate the labouring power.|}}
== VIII. การผลิตมูลค่าส่วนเกิน ==
[[งานแปล:ค่าจ้าง ราคา และกำไร/บทที่ 9|VIII. การผลิตมูลค่าส่วนเกิน]]
หัวเรื่องงานแปล
<!-- ข้อมูลหลัก -->
| ชื่อ = ค่าจ้าง ราคา และกำไร
| ศักราช = ค.ศ.
| ปี = 1865
| ภาษา = en
| ต้นฉบับ = Wages, Price and Profit
| ผู้สร้างสรรค์ = คาร์ล มาคส์
| บรรณาธิการ = เอเลนอร์ มาคส์ เอฟลิง
| ส่วน =
| ผู้มีส่วนร่วม =
| ก่อนหน้า = [[งานแปล:ค่าจ้าง ราคา และกำไร/บทที่ 8|VII. พลังที่ใช้แรงงาน]]
| ถัดไป = [[งานแปล:ค่าจ้าง ราคา และกำไร/บทที่ 10|IX. มูลค่าของแรงงาน]]
| หมายเหตุ =
<!-- ข้อมูลย่อย (สำหรับจัดระเบียบหรือเชื่อมโยงไปหน้าอื่น) -->
| หมวดหมู่ =
| แก้กำกวม =
| รุ่น =
| สถานีย่อย =
| ผู้สร้างสรรค์ที่เกี่ยวข้อง =
| วิกิพีเดีย =
| คอมมอนส์ =
| หมวดหมู่คอมมอนส์ =
| วิกิคำคม =
| วิกิข่าว =
| วิกิพจนานุกรม =
| วิกิตำรา =
| วิกิห้องสมุด =
| วิกิสนเทศ =
| วิกิท่องเที่ยว =
| วิกิวิทยาลัย =
| วิกิสปีชีส์ =
| เมทา =
Now suppose that the average amount of the daily necessaries of a labouring man require six hours of average labour for their production. Suppose, moreover, six hours of average labour to be also realized in a quantity of gold equal to 3s. Then 3s. would be the Price, or the monetary expression of the Daily Value of that man's Labouring Power. If he worked daily six hours he would daily produce a value sufficient to buy the average amount of his daily necessaries, or to maintain himself as a labouring man.
But our man is a wages labourer. He must, therefore, sell his labouring power to a capitalist. If he sells it at 3s. daily, or 18s. weekly, he sells it at its value. Suppose him to be a spinner. If he works six hours daily he will add to the cotton a value of 3s. daily. This value, daily added by him, would be an exact equivalent for the wages, or the price of his labouring power, received daily. But in that case no surplus value or surplus produce whatever would go to the capitalist. Here, then, we come to the rub.
In buying the labouring power of the workman, and paying its value, the capitalist, like every other purchaser, has acquired the right to consume or use the commodity bought. You consume or use the labouring power of a man by making him work, as you consume or use a machine by making it run. By paying the daily or weekly value of the labouring power of the workman, the capitalist has, therefore, acquired the right to use or make that labouring power work during the whole day or week. The working day or the working week has, of course, certain limits, but those we shall afterwards look more closely at.
For the present I want to turn your attention to one decisive point.
The value of the labouring power is determined by the quantity of labour necessary to maintain or reproduce it, but the use of that labouring power is only limited by the active energies and physical strength of the labourer. The daily or weekly value of the labouring power is quite distinct from the daily or weekly exercise of that power, the same as the food a horse wants and the time it can carry the horseman are quite distinct. The quantity of labour by which the value of the workman's labouring power is limited to the quantity of labour which his labouring power is apt to perform. Take the example of our spinner. We have seen that, to daily reproduce his labouring power, he must daily reproduce a value of three shillings, which he will do by working six hours daily. But this does not disable him from working ten or twelve or more hours a day. But by paying the daily or weekly value of the spinner's labouring power, the capitalist has acquired the right of using that labouring power during the whole day or week. He will, therefore, make him work say, daily, twelve hours. Over and above the six hours required to replace his wages, or the value of his labouring power, he will, therefore, have to work six other hours, which I shall call hours of surplus labour, which surplus labour will realize itself in a surplus value and a surplus produce. If our spinner, for example, by his daily labour of six hours, added three shillings' value to the cotton, a value forming an exact equivalent to his wages, he will, in twelve hours, add six shillings' worth to the cotton, and produce a proportional surplus of yarn. As he has sold his labouring power to the capitalist, the whole value of produce created by him belongs to the capitalist, the owner pro tem. of his labouring power. By advancing three shillings, the capitalist will, therefore, realize a value of six shillings, because, advancing a value in which six hours of labour are crystallized, he will receive in return a value in which twelve hours of labour are crystallized. By repeating this same process daily, the capitalist will daily advance three shillings and daily pocket six shillings, one-half of which will go to pay wages anew, and the other half of which will form surplus value, for which the capitalist pays no equivalent. It is this sort of exchange between capital and labour upon which capitalistic production, or the wages system, is founded, and which must constantly result in reproducing the working man as a working man, and the capitalist as a capitalist.
The rate of surplus value, all other circumstances remaining the same, will depend on the proportion between that necessary to reproduce the value of the labouring power and the surplus time or surplus labour performed for the capitalist. It will, therefore, depend on the ratio in which the working day is prolonged over and above that extent, by working which the working man would only reproduce the value of his labouring power, or replace his wages.
== IX. มูลค่าของแรงงาน ==
[[งานแปล:ค่าจ้าง ราคา และกำไร/บทที่ 10|IX. มูลค่าของแรงงาน]]
หัวเรื่องงานแปล
<!-- ข้อมูลหลัก -->
| ชื่อ = ค่าจ้าง ราคา และกำไร
| ศักราช = ค.ศ.
| ปี = 1865
| ภาษา = en
| ต้นฉบับ = Wages, Price and Profit
| ผู้สร้างสรรค์ = คาร์ล มาคส์
| บรรณาธิการ = เอเลนอร์ มาคส์ เอฟลิง
| ส่วน =
| ผู้มีส่วนร่วม =
| ก่อนหน้า = [[งานแปล:ค่าจ้าง ราคา และกำไร/บทที่ 9|VIII. การผลิตมูลค่าส่วนเกิน]]
| ถัดไป = [[งานแปล:ค่าจ้าง ราคา และกำไร/บทที่ 11|X. กำไรถูกสร้างขึ้นด้วยการขายโภคภัณฑ์ที่มูลค่าของมัน]]
| หมายเหตุ =
<!-- ข้อมูลย่อย (สำหรับจัดระเบียบหรือเชื่อมโยงไปหน้าอื่น) -->
| หมวดหมู่ =
| แก้กำกวม =
| รุ่น =
| สถานีย่อย =
| ผู้สร้างสรรค์ที่เกี่ยวข้อง =
| วิกิพีเดีย =
| คอมมอนส์ =
| หมวดหมู่คอมมอนส์ =
| วิกิคำคม =
| วิกิข่าว =
| วิกิพจนานุกรม =
| วิกิตำรา =
| วิกิห้องสมุด =
| วิกิสนเทศ =
| วิกิท่องเที่ยว =
| วิกิวิทยาลัย =
| วิกิสปีชีส์ =
| เมทา =
We must now return to the expression, "''Value, or Price of Labour.''"
We have seen that, in fact, it is only the value of the labouring power, measured by the values of commodities necessary for its maintenance. But since the workman receives his wages after his labour is performed, and knows, moreover, that what he actually gives to the capitalist is his labour, the value or price of his labouring power necessarily appears to him as the price or value of his labour itself. If the price of his labouring power is three shillings, in which six hours of labour are realized, and if he works twelve hours, he necessarily considers these three shillings as the value or price of twelve hours of labour, although these twelve hours of labour realize themselves in a value of six shillings. A double consequence flows from this.
Firstly. The value or price of the labouring power takes the semblance of the price or value of labour itself, although, strictly speaking, value and price of labour are senseless terms.
Secondly. Although one part only of the workman's daily labour is paid, while the other part is unpaid, and while that unpaid or surplus labour constitutes exactly the fund out of which surplus value or profit is formed, it seems as if the aggregate labour was paid labour.
This false appearance distinguishes wages labour from other historical forms of labour. On the basis of the wages system even the unpaid labour seems to be paid labour. With the slave, on the contrary, even that part of his labour which is paid appears to be unpaid. Of course, in order to work the slave must live, and one part of his working day goes to replace the value of his own maintenance. But since no bargain is struck between him and his master, and no acts of selling and buying are going on between the two parties, all his labour seems to be given away for nothing.
Take, on the other hand, the peasant serf, such as he, I might say, until yesterday existed in the whole East of Europe. This peasant worked, for example, three days for himself on his own field or the held allotted to him, and the three subsequent days he performed compulsory and gratuitous labour on the estate of his lord. Here, then, the paid and unpaid parts of labour were sensibly separated, separated in time and space, and our Liberals overflowed with moral indignation at the preposterous notion of making a man work for nothing.
In point of fact, however, whether a man works three days of the week for himself on his own field and three days for nothing on the estate of his lord, or whether he works in the factory or the workshop six hours daily for himself and six for his employer, comes to the same, although in the latter case the paid and unpaid portions of labour are inseparably mixed up with each other, and the nature of the whole transaction is completely masked by the intervention of a contract and the pay received at the end of the week. The gratuitous labour appears to be voluntarily given in the one instance, and to be compulsory in the other. That makes all the difference.
In using the word "value of labour," I shall only use it as a popular slang term for "value of labouring power."
== X. กำไรถูกสร้างขึ้นด้วยการขายโภคภัณฑ์ที่มูลค่าของมัน ==
[[งานแปล:ค่าจ้าง ราคา และกำไร/บทที่ 11|X. กำไรถูกสร้างขึ้นด้วยการขายโภคภัณฑ์ที่มูลค่าของมัน]]
หัวเรื่องงานแปล
<!-- ข้อมูลหลัก -->
| ชื่อ = ค่าจ้าง ราคา และกำไร
| ศักราช = ค.ศ.
| ปี = 1865
| ภาษา = en
| ต้นฉบับ = Wages, Price and Profit
| ผู้สร้างสรรค์ = คาร์ล มาคส์
| บรรณาธิการ = เอเลนอร์ มาคส์ เอฟลิง
| ส่วน =
| ผู้มีส่วนร่วม =
| ก่อนหน้า = [[งานแปล:ค่าจ้าง ราคา และกำไร/บทที่ 10|IX. มูลค่าของแรงงาน]]
| ถัดไป = [[งานแปล:ค่าจ้าง ราคา และกำไร/บทที่ 12|XI. ส่วนต่าง ๆ ที่มูลค่าส่วนเกินถูกจำแนกไป]]
| หมายเหตุ =
<!-- ข้อมูลย่อย (สำหรับจัดระเบียบหรือเชื่อมโยงไปหน้าอื่น) -->
| หมวดหมู่ =
| แก้กำกวม =
| รุ่น =
| สถานีย่อย =
| ผู้สร้างสรรค์ที่เกี่ยวข้อง =
| วิกิพีเดีย =
| คอมมอนส์ =
| หมวดหมู่คอมมอนส์ =
| วิกิคำคม =
| วิกิข่าว =
| วิกิพจนานุกรม =
| วิกิตำรา =
| วิกิห้องสมุด =
| วิกิสนเทศ =
| วิกิท่องเที่ยว =
| วิกิวิทยาลัย =
| วิกิสปีชีส์ =
| เมทา =
Suppose an average hour of labour to be realized in a value equal to sixpence, or twelve average hours of labour to be realized in six shillings. Suppose, further, the value of labour to be three shillings or the produce of six hours' labour. If, then, in the raw material, machinery, and so forth, used up in a commodity, twenty-four hours of average labour were realized, its value would amount to twelve shillings. If, moreover, the workman employed by the capitalist added twelve hours of labour to those means of production, these twelve hours would be realized in an additional value of six shillings. The total value of the product would, therefore, amount to thirty-six hours of realized labour, and be equal to eighteen shillings. But as the value of labour, or the wages paid to the workman, would be three shillings only, no equivalent would have been paid by the capitalist for the six hours of surplus labour worked by the workman, and realized in the value of the commodity. By selling this commodity at its value for eighteen shillings, the capitalist would, therefore, realize a value of three shillings, for which he had paid no equivalent. These three shillings would constitute the surplus value or profit pocketed by him. The capitalist would consequently realize the profit of three shillings, not by selling his commodity at a price over and above its value, but by selling it at its real value.
The value of a commodity is determined by the total quantity of labour contained in it. But part of that quantity of labour is realized in a value, for which an equivalent has been paid in the form of wages; part of it is realized in a value for which no equivalent has been paid. Part of the labour contained in the commodity is paid labour; part is unpaid labour. By selling, therefore, the commodity at its value, that is, as the crystallization of the total quantity of labour bestowed upon it, the capitalist must necessarily sell it at a profit. He sells not only what has cost him an equivalent, but he sells also what has cost him nothing, although it has cost his workman labour. The cost of the commodity to the capitalist and its real cost are different things. I repeat, therefore, that normal and average profits are made by selling commodities not above, but at their real values.
== XI. ส่วนต่าง ๆ ที่มูลค่าส่วนเกินถูกจำแนกไป ==
[[งานแปล:ค่าจ้าง ราคา และกำไร/บทที่ 12|XI. ส่วนต่าง ๆ ที่มูลค่าส่วนเกินถูกจำแนกไป]]
หัวเรื่องงานแปล
<!-- ข้อมูลหลัก -->
| ชื่อ = ค่าจ้าง ราคา และกำไร
| ศักราช = ค.ศ.
| ปี = 1865
| ภาษา = en
| ต้นฉบับ = Wages, Price and Profit
| ผู้สร้างสรรค์ = คาร์ล มาคส์
| บรรณาธิการ = เอเลนอร์ มาคส์ เอฟลิง
| ส่วน =
| ผู้มีส่วนร่วม =
| ก่อนหน้า = [[งานแปล:ค่าจ้าง ราคา และกำไร/บทที่ 11|X. กำไรถูกสร้างขึ้นด้วยการขายโภคภัณฑ์ที่มูลค่าของมัน]]
| ถัดไป = [[งานแปล:ค่าจ้าง ราคา และกำไร/บทที่ 13|XII. ความสัมพันธ์โดยทั่วไปของกำไร ค่าจ้าง และราคา]]
| หมายเหตุ =
<!-- ข้อมูลย่อย (สำหรับจัดระเบียบหรือเชื่อมโยงไปหน้าอื่น) -->
| หมวดหมู่ =
| แก้กำกวม =
| รุ่น =
| สถานีย่อย =
| ผู้สร้างสรรค์ที่เกี่ยวข้อง =
| วิกิพีเดีย =
| คอมมอนส์ =
| หมวดหมู่คอมมอนส์ =
| วิกิคำคม =
| วิกิข่าว =
| วิกิพจนานุกรม =
| วิกิตำรา =
| วิกิห้องสมุด =
| วิกิสนเทศ =
| วิกิท่องเที่ยว =
| วิกิวิทยาลัย =
| วิกิสปีชีส์ =
| เมทา =
The surplus value, or that part of the total value of the commodity in which the surplus labour or unpaid labour of the working man is realized, I call Profit. The whole of that profit is not pocketed by the employing capitalist. The monopoly of land enables the landlord to take one part of that surplus value, under the name of rent, whether the land is used for agriculture, buildings or railways, or for any other productive purpose. On the other hand, the very fact that the possession of the instruments of labour enables the employing capitalist to produce a surplus value, or, what comes to the same, to appropriate to himself a certain amount of unpaid labour, enables the owner of the means of labour, which he lends wholly or partly to the employing capitalist -- enables, in one word, the money-lending capitalist to claim for himself under the name of interest another part of that surplus value, so that there remains to the employing capitalist as such only what is called industrial or commercial profit.
By what laws this division of the total amount of surplus value amongst the three categories of people is regulated is a question quite foreign to our subject. This much, however, results from what has been stated.
Rent, Interest, and Industrial Profit are only different names for different parts of the surplus value of the commodity, or the unpaid labour enclosed in it, and they are equally derived from this source, and from this source alone. They are not derived from land as such or from capital as such, but land and capital enable their owners to get their respective shares out of the surplus value extracted by the employing capitalist from the labourer. For the labourer himself it is a matter of subordinate importance whether that surplus value, the result of his surplus labour, or unpaid labour, is altogether pocketed by the employing capitalist, or whether the latter is obliged to pay portions of it, under the name of rent and interest, away to third parties. Suppose the employing capitalist to use only his own capital and to be his own landlord, then the whole surplus value would go into his pocket.
It is the employing capitalist who immediately extracts from the labourer this surplus value, whatever part of it he may ultimately be able to keep for himself. Upon this relation, therefore, between the employing capitalist and the wages labourer the whole wages system and the whole present system of production hinge. Some of the citizens who took part in our debate were, therefore, wrong in trying to mince matters, and to treat this fundamental relation between the employing capitalist and the working man as a secondary question, although they were right in stating that, under given circumstances, a rise of prices might affect in very unequal degrees the employing capitalist, the landlord, the moneyed capitalist, and, if you please, the tax gatherer.
Another consequence follows from what has been stated.
That part of the value of the commodity which represents only the value of the raw materials, the machinery, in one word, no revenue at all, but replaces only capital. But, apart from this, it is false that the other part of the value of the commodity which forms revenue, or may be spent in the form of wages, profits, rent, interest, is constituted by the value of wages, the value of rent, the value of profits, and so forth. We shall, in the first instance, discard wages, and only treat industrial profits, interest, and rent. We have just seen that the surplus value contained in the commodity or that part of its value in which unpaid labour is realized, resolves itself into different fractions, bearing three different names. But it would be quite the reverse of the truth to say that its value is composed of, or formed by, the addition of the independent values of these three constituents.
If one hour of labour realizes itself in a value of sixpence, if the working day of the labourer comprises twelve hours, if half of this time is unpaid labour, that surplus labour will add to the commodity a surplus value of three shillings, that is, of value for which no equivalent has been paid. This surplus value of three shillings constitutes the whole fund which the employing capitalist may divide, in whatever proportions, with the landlord and the money-lender. The value of these three shillings constitutes the limit of the value they have to divide amongst them. But it is not the employing capitalist who adds to the value of the commodity an arbitrary value for his profit, to which another value is added for the landlord, and so forth, so that the addition of these arbitrarily fixed values would constitute the total value. You see, therefore, the fallacy of the popular notion, which confounds the decomposition of a given value into three parts, with the formation of that value by the addition of three independent values, thus converting the aggregate value, from which rent, profit, and interest are derived, into an arbitrary magnitude.
If the total profit realized by a capitalist be equal to £100, we call this sum, considered as absolute magnitude, the amount of profit. But if we calculate the ratio which those £100 bear to the capital advanced, we call this relative magnitude. It is evident that this rate of profit may be expressed in a double way.
Suppose £100 to be the capital advanced in wages. If the surplus value created is also £100 -- and this would show us that half the working day of the labourer consists of unpaid labour -- and if we measured this profit by the value of the capital advanced in wages, we should say that the rate of profit amounted to one hundred per cent., because the value advanced would be one hundred and the value realized would be two hundred.
If, on the other hand, we should not only consider the capital advanced in wages, but the total capital advanced, say, for example, £500, of which £400 represented the value of raw materials, machinery, and so forth, we should say that the rate of profit amounted only to twenty per cent., because the profit of one hundred would be but the fifth part of the total capital advanced.
The first mode of expressing the rate of profit is the only one which shows you the real ratio between paid and unpaid labour, the real degree of the exploitation (you must allow me this French word) of labour. The other mode of expression is that in common use, and is, indeed, appropriate for certain purposes. At all events, it is very useful for concealing the degree in which the capitalist extracts gratuitous labour from the workman.
In the remarks I have still to make I shall use the word Profit for the whole amount of the surplus value extracted by the capitalist without any regard to the division of that surplus value between different parties, and in using the words Rate of Profit, I shall always measure profits by the value of the capital advanced in wages.
== XII. ความสัมพันธ์โดยทั่วไปของกำไร ค่าจ้าง และราคา ==
[[งานแปล:ค่าจ้าง ราคา และกำไร/บทที่ 13|XII. ความสัมพันธ์โดยทั่วไปของกำไร ค่าจ้าง และราคา]]
หัวเรื่องงานแปล
<!-- ข้อมูลหลัก -->
| ชื่อ = ค่าจ้าง ราคา และกำไร
| ศักราช = ค.ศ.
| ปี = 1865
| ภาษา = en
| ต้นฉบับ = Wages, Price and Profit
| ผู้สร้างสรรค์ = คาร์ล มาคส์
| บรรณาธิการ = เอเลนอร์ มาคส์ เอฟลิง
| ส่วน =
| ผู้มีส่วนร่วม =
| ก่อนหน้า = [[งานแปล:ค่าจ้าง ราคา และกำไร/บทที่ 12|XI. ส่วนต่าง ๆ ที่มูลค่าส่วนเกินถูกจำแนกไป]]
| ถัดไป = [[งานแปล:ค่าจ้าง ราคา และกำไร/บทที่ 14|XIII. กรณีหลักของความพยายามในการเพิ่มค่าจ้างหรือการต่อต้านการลดต่ำลงของมัน]]
| หมายเหตุ =
<!-- ข้อมูลย่อย (สำหรับจัดระเบียบหรือเชื่อมโยงไปหน้าอื่น) -->
| หมวดหมู่ =
| แก้กำกวม =
| รุ่น =
| สถานีย่อย =
| ผู้สร้างสรรค์ที่เกี่ยวข้อง =
| วิกิพีเดีย =
| คอมมอนส์ =
| หมวดหมู่คอมมอนส์ =
| วิกิคำคม =
| วิกิข่าว =
| วิกิพจนานุกรม =
| วิกิตำรา =
| วิกิห้องสมุด =
| วิกิสนเทศ =
| วิกิท่องเที่ยว =
| วิกิวิทยาลัย =
| วิกิสปีชีส์ =
| เมทา =
Deduct from the value of a commodity the value replacing the value of the raw materials and other means of production used upon it, that is to say, deduct the value representing the past labour contained in it, and the remainder of its value will resolve into the quantity of labour added by the working man last employed. If that working man works twelve hours daily, if twelve hours of average labour crystallize themselves in an amount of gold equal to six shillings, this additional value of six shillings is the only value his labour will have created. This given value, determined by the time of his labour, is the only fund from which both he and the capitalist have to draw their respective shares or dividends, the only value to be divided into wages and profits. It is evident that this value itself will not be altered by the variable proportions in which it may be divided amongst the two parties. There will also be nothing changed if in the place of one working man you put the whole working population, twelve million working days, for example, instead of one.
Since the capitalist and workman have only to divide this limited value, that is, the value measured by the total labour of the working man, the more the one gets the less will the other get, and vice versa. Whenever a quantity is given, one part of it will increase inversely as the other decreases. If the wages change, profits will change in an opposite direction. If wages fall profits will rise; and if wages rise, profits will fall. If the working man, on our former supposition, gets shillings, equal to one-half of the value he has created, or if his whole working day consists half of paid, half of unpaid labour, the rate of profit will be 100 per cent., because the capitalist would also get three shillings. If the working man receives only two shillings, or works only one third of the whole day for himself, the capitalist will get four shillings, and the rate of profit will be 200 per cent. If the working man receives four shillings, the capitalist will only receive two, and the rate of profit would sink to 50 per cent., but all these variations will not affect the value of the commodity. A general rise of wages would, therefore, result in a fall of the general rate of profit, but not affect values.
But although the values of commodities, which must ultimately regulate their market prices, are exclusively determined by the total quantities of labour fixed in them, and not by the division of that quantity into paid and unpaid labour, it by no means follows that the values of the single commodities, or lots of commodities, produced during twelve hours, for example, will remain constant. The number or mass of commodities produced in a given time of labour, or by a given quantity of labour, depends unon the productive power of the labour employed, and upon its extent or length. With one degree of the productive power of spinning labour, for example, a working day of twelve hours may produce twelve pounds of yarn, with a lesser degree of productive power only two pounds. If then twelve hours' average labour were realized in the value of six shillings in the one case, the twelve pounds of yarn would cost six shillings, in the other case the two pounds of yarn would also cost six shillings. One pound of yarn would, therefore, cost sixpence in the one case, and three shillings in the other. This difference of price would result from the difference in the productive powers of the labour employed. One hour of labour would be realized in one pound of yarn with the greater productive power, while with the smaller productive power, six hours of labour would be realized in one pound of yarn. The price of a pound of yarn would, in the one instance, be only sixpence, although wages were relatively high and the rate of profit low, it would be three shillings in the other instance, although wages were low and the rate of profit high. This would be so because the price of the pound of yarn is regulated by the total amount of labour worked up in it, and not by the proportional division of that total amount into paid and unpaid labour. The fact I have before mentioned that high-priced labour may produce cheap, and low-priced labour may produce dear commodities, loses, therefore, its paradoxical appearance. It is only the expression of the general law that the value of a commodity is regulated by the quantity of labour worked up in it, and that the quantity of labour worked up in it depends altogether upon the productive powers of the labour employed, and will, therefore, vary with every variation in the productivity of labour.
== XIII. กรณีหลักของความพยายามในการเพิ่มค่าจ้างหรือการต่อต้านการลดต่ำลงของมัน ==
[[งานแปล:ค่าจ้าง ราคา และกำไร/บทที่ 14|XIII. กรณีหลักของความพยายามในการเพิ่มค่าจ้างหรือการต่อต้านการลดต่ำลงของมัน]]
หัวเรื่องงานแปล
<!-- ข้อมูลหลัก -->
| ชื่อ = ค่าจ้าง ราคา และกำไร
| ศักราช = ค.ศ.
| ปี = 1865
| ภาษา = en
| ต้นฉบับ = Wages, Price and Profit
| ผู้สร้างสรรค์ = คาร์ล มาคส์
| บรรณาธิการ = เอเลนอร์ มาคส์ เอฟลิง
| ส่วน =
| ผู้มีส่วนร่วม =
| ก่อนหน้า = [[งานแปล:ค่าจ้าง ราคา และกำไร/บทที่ 13|XII. ความสัมพันธ์โดยทั่วไปของกำไร ค่าจ้าง และราคา]]
| ถัดไป = [[งานแปล:ค่าจ้าง ราคา และกำไร/บทที่ 15|XIV. การต่อสู้ระหว่างทุนกับแรงงานและผลลัพธ์ของมัน]]
| หมายเหตุ =
<!-- ข้อมูลย่อย (สำหรับจัดระเบียบหรือเชื่อมโยงไปหน้าอื่น) -->
| หมวดหมู่ =
| แก้กำกวม =
| รุ่น =
| สถานีย่อย =
| ผู้สร้างสรรค์ที่เกี่ยวข้อง =
| วิกิพีเดีย =
| คอมมอนส์ =
| หมวดหมู่คอมมอนส์ =
| วิกิคำคม =
| วิกิข่าว =
| วิกิพจนานุกรม =
| วิกิตำรา =
| วิกิห้องสมุด =
| วิกิสนเทศ =
| วิกิท่องเที่ยว =
| วิกิวิทยาลัย =
| วิกิสปีชีส์ =
| เมทา =
Let us now seriously consider the main cases in which a rise of wages is attempted or a reduction of wages resisted.
1. We have seen that the value of the labouring power, or in more popular parlance, the value of labour, is determined by the value of necessaries, or the quantity of labour required to produce them. If, then, in a given country the value of the daily average necessaries of the labourer represented six hours of labour expressed in three shillings, the labourer would have to work six hours daily to produce an equivalent for his daily maintenance. If the whole working day was twelve hours, the capitalist would pay him the value of his labour by paying him three shillings. Half the working day would be unpaid labour, and the rate of profit would amount to 100 per cent. But now suppose that, consequent upon a decrease of productivity, more labour should be wanted to produce, say, the same amount of agricultural produce, 60 that the price of the average daily necessaries should rise from three to four shillings. In that case the value of labour would rise by one-third, or 331/3 per cent. Eight hours of the working day would be required to produce an equivalent for the daily maintenance of the labourer, according to his old standard of living. The surplus labour would therefore sink from six hours to four, and the rate of profit from 100 to 50 per cent. But in insisting upon a rise of wages, the labourer would only insist upon getting the increased value of his labour, like every other seller of a commodity, who, the costs of his commodities having increased, tries to get its increased value paid. If wages did not rise, or not sufficiently rise, to compensate for the increased values of necessaries, the price of labour would sink below the value of labour, and the labourer's standard of life would deteriorate.
But a change might also take place in an opposite direction. By virtue of the increased productivity of labour, the same amount of the average daily necessaries might sink from three to two shillings, or only four hours out of the working day, instead of six, be wanted to reproduce an equivalent for the value of the daily necessaries. The working man would now be able to buy with two shillings as many necessaries as he did before with three shillings. Indeed, the value of labour would have sunk, but that diminished value would command the same amount of commodities as before. Then profits would rise from three to four shillings, and the rate of profit from 100 to 200 per cent. Although the labourer's absolute standard of life would have remained the same, his relative wages, and therewith his relative social position, as compared with that of the capitalist, would have been lowered. If the working man should resist that reduction of relative wages, he would only try to get some share in the increased productive powers of his own labour, and to maintain his former relative position in the social scale. Thus, after the abolition of the Corn Laws, and in flagrant violation of the most solemn pledges given during the anti-Corn Law agitation, the English factory lords generally reduced wages ten per cent. The resistance of the workmen was at first baffled, but, consequent upon circumstances I cannot now enter upon, the ten per cent. lost were afterwards regained.
2. The values of necessaries, and consequently the value of labour, might remain the same, but a change might occur in their money prices, consequent upon a previous change in the value of money.
By the discovery of more fertile mines and so forth, two ounces of gold might, for example, cost no more labour to produce than one ounce did before. The value of gold would then be depreciated by one-half, or fifty per cent. As the values of all other commodities would then be expressed in twice their former money prices, so also the same with the value of labour. Twelve hours of labour, formerly expressed in six shillings, would now be expressed in twelve shillings. If the working man's wages should remain three shillings, instead of rising to six shillings, the money price of his labour would only be equal to half the value of his labour, and his standard of life would fearfully deteriorate. This would also happen in a greater or lesser degree if his wages should rise, but not proportionately to the fall in the value of gold. In such a case nothing would have been changed, either in the productive powers of labour, or in supply and demand, or in values. Nothing could have changed except the money names of those values. To say that in such a case the workman ought not to insist upon a proportionate rise of wages, is to say that he must be content to be paid with names, instead of with things. All past history proves that whenever such a depreciation of money occurs, the capitalists are on the alert to seize this opportunity for defrauding the workman. A very large school of political economists assert that, consequent upon the new discoveries of gold lands, the better working of silver mines, and the cheaper supply of quicksilver, the value of precious metals has been again depreciated. This would explain the general and simultaneous attempts on the Continent at a rise of wages.
3. We have till now supposed that the working day has given limits. The working day, however, has, by itself, no constant limits. It is the constant tendency of capital to stretch it to its utmost physically possible length, because in the same degree surplus labour, and consequently the profit resulting therefrom, will be increased. The more capital succeeds in prolonging the working day, the greater the amount of other people's labour it will appropriate. During the seventeenth and even the first two-thirds of the eighteenth century a ten hours working day was the normal working day all over England. During the anti-Jacobin war, which was in fact a war waged by the British barons against the British working masses, capital celebrated its bacchanalia, and prolonged the working day from ten to twelve, fourteen, eighteen hours. Malthus, by no means a man whom you would suspect of a maudlin sentimentalism, declared in a pamphlet, published about 1815, that if this sort of thing was to go on the life of the nation would be attacked at its very source. A few years before the general introduction of the newly-invented machinery, about 1765, a pamphlet appeared in England under the title, An Essay on Trade. The anonymous author, an avowed enemy of the working classes, declaims on the necessity of expanding the limits of the working day. Amongst other means to this end, he proposes working houses, which, he says, ought to be "Houses of Terror." And what is the length of the working day he prescribes for these "Houses of Terror"? Twelve hours, the very same time which in 1832 was declared by capitalists, political economists, and ministers to be not only the existing but the necessary time of labour for a child under twelve years.
By selling his labouring power, and he must do so under the present system, the working man makes over to the capitalist the consumption of that power, but within certain rational limits. He sells his labouring power in order to maintain it, apart from its natural wear and tear, but not to destroy it. In selling his labouring power at its daily or weekly value, it is understood that in one day or one week that labouring power shall not be submitted to two days' or two weeks' waste or wear and tear. Take a machine worth £1,000. If it is used up in ten years it will add to the value of the commodities in whose production it assists £100 yearly. If it be used up in five years it would add £200 yearly, or the value of its annual wear and tear is in inverse ratio to the time in which it is consumed. But this distinguishes the working man from the machine. Machinery does not wear out exactly in the same ratio in which it is used. Man, on the contrary, decays in a greater ratio than would be visible from the mere numerical addition of work.
In their attempts at reducing the working day to its former rational dimensions, or, where they cannot enforce a legal fixation of a normal working day, at checking overwork by a rise of wages, a rise not only in proportion to the surplus time exacted, but in a greater proportion, working men fulfil only a duty to themselves and their race. They only set limits to the tyrannical usurpations of capital. Time is the room of human development. A man who has no free time to dispose of, whose whole lifetime, apart from the mere physical interruptions by sleep, meals, and so forth, is absorbed by his labour for the capitalist, is less than a beast of burden. He is a mere machine for producing Foreign Wealth, broken in body and brutalized in mind. Yet the whole history of modern industry shows that capital, if not checked, will recklessly and ruthlessly work to cast down the whole working class to this utmost state of degradation.
In prolonging the working day the capitalist may pay higher wages and still lower the value of labour, if the rise of wages does not correspond to the greater amount of labour extracted, and the quicker decay of the labouring power thus caused. This may be done in another way. Your middle-class statisticians will tell you, for instance, that the average wages of factory families in Lancashire have risen. They forget that instead of the labour of the man, the head of the family, his wife and perhaps three or four children are now thrown under the Juggernaut wheels of capital, and that the rise of the aggregate wages does not correspond to the aggregate surplus labour extracted from the family.
Even with given limits of the working day, such as they now exist in all branches of industry subjected to the factory laws, a rise of wages may become necessary, if only to keep up the old standard value of labour. By increasing the intensity of labour, a man may be made to expend as much vital force in one hour as he formerly did in two. This has, to a certain degree, been effected in the trades, placed under the Factory Acts, by the acceleration of machinery, and the greater number of working machines which a single individual has now to superintend. If the increase in the intensity of labour or the mass of labour spent in an hour keeps some fair proportion to the decrease in the extent of the working day, the working man will still be the winner. If this limit is overshot, he loses in one form what he has gained in another, and ten hours of labour may then become as ruinous as twelve hours were before. In checking this tendency of capital, by struggling for a rise of wages corresponding to the rising intensity of labour, the working man only resists the depreciation of his labour and the deterioration of his race.
4. All of you know that, from reasons I have not now to explain, capitalistic production moves through certain periodical cycles. It moves through a state of quiescence, growing animation, prosperity, overtrade, crisis, and stagnation. The market prices of commodities, and the market rates of profit, follow these phases, now sinking below their averages, now rising above them. Considering the whole cycle, you will find that one deviation of the market price is being compensated by the other, and that, taking the average of the cycle, the market prices of commodities are regulated by their values. Well! During the phase of sinking market prices and the phases of crisis and stagnation, the working man, if not thrown out of employment altogether, is sure to have his wages lowered. Not to be defrauded, he must, even with such a fall of market prices, debate with the capitalist in what proportional degree a fall of wages has become necessary. If, during the phases of prosperity, when extra profits are made, he did not battle for a rise of wages, he would, taking the average of one industrial cycle, not even receive his average wages, or the value of his labour. It is the utmost height of folly to demand that while his wages are necessarily affected by the adverse phases of the cycle, he should exclude himself from compensation during the prosperous phases of the cycle. Generally, the values of all commodities are only realized by the compensation of the continuously changing market prices, springing from the continuous fluctuations of demand and supply. On the basis of the present system labour is only a commodity like others. It must, therefore, pass through the same fluctuations to fetch an average price corresponding to its value. It would be absurd to treat it on the one hand as a commodity, and to want on the other hand to exempt it from the laws which regulate the prices of commodities. The slave receives a permanent and fixed amount of maintenance; the wages labourer does not. He must try to get a rise of wages in the one instance, if only to compensate for a fall of wages in the other. If he resigned himself to accept the will, the dictates of the capitalist as a permanent economical law, he would share in all the miseries of the slave, without the security of the slave.
5. In all the cases I have considered, and they form ninety-nine out of a hundred, you have seen that a struggle for a rise of wages follows only in the track of previous changes, and is the necessary offspring of previous changes in the amount of production, the productive powers of labour, the value of labour, the value of money, the extent or the intensity of labour extracted, the fluctuations of market prices, dependent upon the fluctuations of demand and supply, and consistent with the different phases of the industrial cycle; in one word, as reactions of labour against the previous action of capital. By treating the struggle for a rise of wages independently of all these circumstances, by looking only upon the changes of wages, and overlooking all the other changes from which they emanate, you proceed from a false premise in order to arrive at false conclusions.
== XIV. การต่อสู้ระหว่างทุนกับแรงงานและผลลัพธ์ของมัน ==
[[งานแปล:ค่าจ้าง ราคา และกำไร/บทที่ 15|XIV. การต่อสู้ระหว่างทุนกับแรงงานและผลลัพธ์ของมัน]]
หัวเรื่องงานแปล
<!-- ข้อมูลหลัก -->
| ชื่อ = ค่าจ้าง ราคา และกำไร
| ศักราช = ค.ศ.
| ปี = 1865
| ภาษา = en
| ต้นฉบับ = Wages, Price and Profit
| ผู้สร้างสรรค์ = คาร์ล มาคส์
| บรรณาธิการ = เอเลนอร์ มาคส์ เอฟลิง
| ส่วน =
| ผู้มีส่วนร่วม =
| ก่อนหน้า = [[งานแปล:ค่าจ้าง ราคา และกำไร/บทที่ 14|XIII. กรณีหลักของความพยายามในการเพิ่มค่าจ้างหรือการต่อต้านการลดต่ำลงของมัน]]
| ถัดไป =
| หมายเหตุ =
<!-- ข้อมูลย่อย (สำหรับจัดระเบียบหรือเชื่อมโยงไปหน้าอื่น) -->
| หมวดหมู่ =
| แก้กำกวม =
| รุ่น =
| สถานีย่อย =
| ผู้สร้างสรรค์ที่เกี่ยวข้อง =
| วิกิพีเดีย =
| คอมมอนส์ =
| หมวดหมู่คอมมอนส์ =
| วิกิคำคม =
| วิกิข่าว =
| วิกิพจนานุกรม =
| วิกิตำรา =
| วิกิห้องสมุด =
| วิกิสนเทศ =
| วิกิท่องเที่ยว =
| วิกิวิทยาลัย =
| วิกิสปีชีส์ =
| เมทา =
1. Having shown that the periodical resistance on the part of the working men against a reduction of wages, and their periodical attempts at getting a rise of wages, are inseparable from the wages system, and dictated by the very fact of labour being assimilated to commodities, and therefore subject to the laws regulating the general movement of prices; having, furthermore, shown that a general rise of wages would result in a fall in the general rate of profit, but not affect the average prices of commodities, or their values, the question now ultimately arises, how far, in this incessant struggle between capital and labour, the latter is likely to prove successful.
I might answer by a generalization, and say that, as with all other commodities, so with labour, its market price will, in the long run, adapt itself to its value; that, therefore, despite all the ups and downs, and do what he may, the working man will, on an average, only receive the value of his labour which resolves into the value of his labouring power, which is determined by the value of the necessaries required for its maintenance and reproduction, which value of necessaries finally is regulated by the quantity of labour wanted to produce them.
But there are some peculiar features which distinguish the value of the labouring power, or value of labour, from the value of all other commodities. The value of the labouring power is formed by two elements -- the one merely physical, the other historical or social. Its ultimate limit is determined by the physical element, that is to say, to maintain and reproduce itself, to perpetuate its physical existence, the working class must receive the necessaries absolutely indispensable for living and multiplying. The value of those indispensable necessaries forms, therefore, the ultimate limit of the value of labour. On the other hand, the length of the working day is also limited by ultimate, although very elastic boundaries. Its ultimate limit is given by the physical force of the labouring man. If the daily exhaustion of his vital forces exceeds a certain degree, it cannot be exerted anew, day by day. However, as I said, this limit is very elastic. A quick succession of unhealthy and short-lived generations will keep the labour market as well supplied as a series of vigorous and long-lived generations.
Besides this mere physical element, the value of labour is in every country determined by a traditional standard of life. It is not mere physical life, but it is the satisfaction of certain wants springing from the social conditions in which people are placed and reared up. The English standard of life may be reduced to the Irish standard; the standard of life of a German peasant to that of a Livonian peasant. The important part which historical tradition and social habitude play in this respect, you may learn from Mr. Thornton's work on Over-population, where he shows that the average wages in different agricultural districts of England still nowadays differ more or less according to the more or less favourable circumstances under which the districts have emerged from the state of serfdom.
This historical or social element, entering into the value of labour, may be expanded, or contracted, or altogether extinguished, so that nothing remains but the physical limit. During the time of the anti-Jacobin war, undertaken, as the incorrigible tax-eater and sinecurist, old George Rose, used to say, to save the comforts of our holy religion from the inroads of the French infidels, the honest English farmers, so tenderly handled in a former chapter of ours, depressed the wages of the agricultural labourers even beneath that mere physical minimum, but made up by Poor Laws the remainder necessary for the physical perpetuation of the race. This was a glorious way to convert the wages labourer into a slave, and Shakespeare's proud yeoman into a pauper.
By comparing the standard wages or values of labour in different countries, and by comparing them in different historical epochs of the same country, you will find that the value of labour itself is not a fixed but a variable magnitude, even supposing the values of all other commodities to remain constant.
A similar comparison would prove that not only the market rates of profit change, but its average rates.
But as to profits, there exists no law which determines their minimum. We cannot say what is the ultimate limit of their decrease. And why cannot we fix that limit? Because although we can fix the minimum of wages, we cannot fix their maximum. We can only say that, the limits of the working day being given, the maximum of profit corresponds to the physical minimum of wages; and that wages being given, the maximum of profit corresponds to such a prolongation of the working day as is compatible with the physical force of the labourer. The maximum of profit is, therefore, limited by the physical minimum of wages and the physical maximum of the working day. It is evident that between the two limits of this maximum rate of profit an immense scale of variations is possible. The fixation of its actual degree is only settled by the continuous struggle between capital and labour, the capitalist constantly tending to reduce wages to their physical minimum, and to extend the working day to its physical maximum, while the working man constantly presses in the opposite direction.
The matter resolves itself into a question of the respective powers of the combatants.
2. As to the limitation of the working day in England, as in all other countries, it has never been settled except by legislative interference. Without the working men's continuous pressure from without, that interference would never have taken place. But at all events, the result was not to be attained by private settlement between the working men and the capitalists. This very necessity of general political action affords the proof that in its merely economic action capital is the stronger side.
As to the limits of the value of labour, its actual settlement always depends upon supply and demand, I mean the demand for labour on the part of capital, and the supply of labour by the working men. In colonial countries the law of supply and demand favours the working man. Hence the relatively high standard of wages in the United States. Capital may there try its utmost. It cannot prevent the labour market from being continuously emptied by the continuous conversion of wages labourers into independent, self-sustaining peasants. The position of a wages labourer is for a very large part of the American people but a probational state, which they are sure to leave within a longer or shorter term. To mend this colonial state of things, the paternal British Government accepted for some time what is called the modern colonization theory, which consists in putting an artificial high price upon colonial land, in order to prevent the too quick conversion of the wages labourer into the independent peasant.
But let us now come to old civilized countries, in which capital domineers over the whole process of production. Take, for example, the rise in England of agricultural wages from 1849 to 1859. What was its consequence? The farmers could not, as our friend Weston would have advised them, raise the value of wheat, nor even its market prices. They had, on the contrary, to submit to their fall. But during these eleven years they introduced machinery of all sorts, adopted more scientific methods, converted part of arable land into pasture, increased the size of farms, and with this the scale of production, and by these and other processes diminishing the demand for labour by increasing its productive power, made the agricultural population again relatively redundant. This is the general method in which a reaction, quicker or slower, of capital against a rise of wages takes place in old, settled countries. Ricardo has justly remarked that machinery is in constant competition with labour, and can often be only introduced when the price of labour has reached a certain height, but the appliance of machinery is but one of the many methods for increasing the productive powers of labour. This very same development which makes common labour relatively redundant simplifies on the other hand skilled labour, and thus depreciates it.
The same law obtains in another form. With the development of the productive powers of labour the accumulation of capital will be accelerated, even despite a relatively high rate of wages. Hence, one might infer, as Adam Smith, in whose days modern industry was still in its infancy, did infer, that the accelerated accumulation of capital must turn the balance in favour of the working man, by securing a growing demand for his labour. From this same standpoint many contemporary writers have wondered that English capital having grown in the last twenty years so much quicker than English population, wages should not have been more enhanced. But simultaneously with the process of accumulation there takes place a progressive change in the composition of capital. That part of the aggregate capital which consists of fixed capital, machinery, raw materials, means of production in all possible forms, progressively increases as compared with the other part of capital, which is laid out in wages or in the purchase of labour. This law has been stated in a more or less accurate manner by Mr. Barton, Ricardo, Sismondi, Professor Richard Jones, Professor Ramsay, Cherbuliez, and others.
If the proportion of these two elements of capital was originally one to one, it will, in the progress of industry, become five to one, and so forth. If of a total capital of 600, 300 is laid out in instruments, raw materials, and so forth, and 300 in wages, the total capital wants only to be doubled to create a demand for 600 working men instead of for 300. But if of a capital of 600, 500 is laid out in machinery, materials, and so forth, and 100 only in wages, the same capital must increase from 600 to 3,600 in order to create a demand for 600 workmen instead of 300. In the progress of industry the demand for labour keeps, therefore, no pace with the accumulation of capital. It will still increase in a constantly diminishing ratio as compared with the increase of capital.
These few hints will suffice to show that the very development of modern industry must progressively turn the scale in favour of the capitalist against the working man, and that consequently the general tendency of capitalistic production is not to raise, but to sink the average standard of wages, or to push the value of labour more or less to its minimum limit. Such being the tendency of things in this system, is this saying that the working class ought to renounce their resistance against the encroachments of capital, and abandon their attempts at making the best of the occasional chances for the temporary improvement? If they did, they would be degraded to one level mass of broken wretches past salvation. I think I have shown that their struggles for the standard of wages are incidents inseparable from the whole wages system, that in 99 cases out of 100 their efforts at raising wages are only efforts at maintaining the given value of labour, and that the necessity of debating their price with the capitalist is inherent in their condition of having to sell themselves as commodities. By cowardly giving way in their every-day conflict with capital, they would certainly disqualify themselves for the initiating of any larger movement.
At the same time, and quite apart from the general servitude involved in the wages system, the working class ought not to exaggerate to themselves the ultimate working of these every-day struggles. They ought not to forget that they are fighting with effects, but not with the causes of those effects; that they are retarding the downward movement, but not changing its direction; that they are applying palliatives, not curing the malady. They ought, therefore, not to be exclusively absorbed in these unavoidable guerilla fights incessantly springing up from the never-ceasing encroachments of capital or changes of the market. They ought to understand that, with all the miseries it imposes upon them, the present system simultaneously engenders the material conditions and the social forms necessary for an economical reconstruction of society. Instead of the conservative motto, "A fair day's wage for a fair day's work!" they ought to inscribe on their banner the revolutionary watchword, "Abolition of the wages system!"
After this very long and, I fear, tedious exposition which I was obliged to enter into to do some justice to the subject matter, I shall conclude by proposing the following resolutions:
Firstly. A general rise in the rate of wages would result in a fall of the general rate of profit, but, broadly speaking, not affect the prices of commodities.
Secondly. The general tendency of capitalist production is not to raise, but to sink the average standard of wages.
Thirdly. Trades Unions work well as centres of resistance against the encroachments of capital. They fail partially from an injudicious use of their power. They fail generally from limiting themselves to a guerilla war against the effects of the existing system, instead of simultaneously trying to change it, instead of using their organized forces as a lever for the final emancipation of the working class, that is to say, the ultimate abolition of the wages system.
3pt6jziaxkh721beqbywoa7oed9qcux
189497
189496
2022-08-17T04:26:16Z
Thastp
9008
/* VII. พลังที่ใช้แรงงาน */
wikitext
text/x-wiki
[[งานแปล:ค่าจ้าง ราคา และกำไร]]
== VII. พลังที่ใช้แรงงาน ==
[[งานแปล:ค่าจ้าง ราคา และกำไร/บทที่ 8|VII. พลังที่ใช้แรงงาน]]
หัวเรื่องงานแปล
<!-- ข้อมูลหลัก -->
| ชื่อ = ค่าจ้าง ราคา และกำไร
| ศักราช = ค.ศ.
| ปี = 1865
| ภาษา = en
| ต้นฉบับ = Wages, Price and Profit
| ผู้สร้างสรรค์ = คาร์ล มาคส์
| บรรณาธิการ = เอเลนอร์ มาคส์ เอฟลิง
| ส่วน = VII. พลังที่ใช้แรงงาน
| ผู้มีส่วนร่วม =
| ก่อนหน้า = [[งานแปล:ค่าจ้าง ราคา และกำไร/บทที่ 7|VI. มูลค่าและแรงงาน]]
| ถัดไป = [[งานแปล:ค่าจ้าง ราคา และกำไร/บทที่ 9|VIII. การผลิตมูลค่าส่วนเกิน]]
| หมายเหตุ =
<!-- ข้อมูลย่อย (สำหรับจัดระเบียบหรือเชื่อมโยงไปหน้าอื่น) -->
| หมวดหมู่ =
| แก้กำกวม =
| รุ่น =
| สถานีย่อย =
| ผู้สร้างสรรค์ที่เกี่ยวข้อง =
| วิกิพีเดีย =
| คอมมอนส์ =
| หมวดหมู่คอมมอนส์ =
| วิกิคำคม =
| วิกิข่าว =
| วิกิพจนานุกรม =
| วิกิตำรา =
| วิกิห้องสมุด =
| วิกิสนเทศ =
| วิกิท่องเที่ยว =
| วิกิวิทยาลัย =
| วิกิสปีชีส์ =
| เมทา =
{{ตรคป|Having now, as far as it could be done in such a cursory manner, analyzed the nature of Value, of the Value of any commodity whatever, we must turn our attention to the specific Value of Labour. And here, again, I must startle you by a seeming paradox. All of you feel sure that what they daily sell is their Labour; that, therefore, Labour has a Price, and that, the price of a commodity being only the monetary expression of its value, there must certainly exist such a thing as the Value of Labour. However, there exists no such thing as the Value of Labour in the common acceptance of the word. We have seen that the amount of necessary labour crystallized in a commodity constitutes its value. Now, applying this notion of value, how could we define, say, the value of a ten hours working day? How much labour is contained in that day? Ten hours' labour. To say that the value of a ten hours working day is equal to ten hours' labour, or the quantity of labour contained in it, would be a tautological and, moreover, a nonsensical expression. Of course, having once found out the true but hidden sense of the expression "Value of Labour," we shall be able to interpret this irrational, and seemingly impossible application of value, in the same way that, having once made sure of the real movement of the celestial bodies, we shall be able to explain their apparent or merely phenomenal movements. |ตอนนี้เราได้ทำการวิเคราะห์ธรรมชาติของมูลค่าไปแล้ว เท่าที่สามารถทำได้อย่างคร่าว ๆ เช่นนี้ ของมูลค่าของโภคภัณฑ์ใดก็ตาม ต่อมาเราต้องหันมาให้ความสนใจในมูลค่าของแรงงานโดยเฉพาะ และ ณ ที่นี้ผมจำต้องทำให้คุณตกใจด้วยสิ่งที่ดูเหมือนเป็นปฏิทรรศน์ พวกคุณทุกคนแน่ใจว่าสิ่งที่พวกเขาขายในทุก ๆ วันคือแรงงานของเขา ดังนั้นแรงงานจึงมีราคา และเมื่อราคาของสินค้าโภคภัณฑ์เป็นการแสดงออกมาในรูปเงินตราของมูลค่าของมัน มูลค่าของแรงงานก็ต้องเป็นสิ่งที่มีอยู่จริงอย่างแน่นอน ทว่ามูลค่าของแรงงานในความหมายที่ยอมรับกันทั่วไปที่ว่านั้นมันไม่มีอยู่จริง เราพบแล้วว่าผลึกของปริมาณของแรงงานอันจำเป็นข้างในสินค้าโภคภัณฑ์นั้นประกอบเป็นมูลค่าของมัน ทีนี้เมื่อนำแนวคิดนี้มาใช้ เราจะให้นิยามกับมูลค่าของวันทำงานนานสิบชั่วโมงได้อย่างไร ในหนึ่งวันนั้นมีแรงงานปริมาณเท่าใด ก็แรงงานนานสิบชั่วโมง เป็นต้น การกล่าวว่ามูลค่าของวันทำงานนานสิบชั่วโมงนั้นเท่ากับแรงงานนานสิบชั่วโมง หรือปริมาณของแรงงานที่มีอยู่ในนั้น ก็จะเป็นข้อความที่ซ้ำความและยังไร้ความหมายเสียอีก แน่นอนว่าหลังจากที่เราจะได้ค้นพบกับความหมายที่แท้จริงและอยู่เบื้องหลังคำว่า "มูลค่าของแรงงาน" แล้ว เราจะสามารถตีความการประยุกต์ใช้แนวคิดเรื่องมูลค่าที่ไร้เหตุผลและดูเหมือนจะเป็นไปไม่ได้เช่นนี้ ได้ในหนทางเดียวกันกับที่เมื่อเรารู้แน่ถึงการเคลื่อนที่ที่แท้จริงของเหล่าเทห์ฟากฟ้าแล้ว เราก็จะสามารถอธิบายการเคลื่อนไหวที่ชัดเจน หรือเป็นเพียงปรากฏการณ์ของพวกมันได้}}
{{ตรคป|What the working man sells is not directly his Labour, but his Labour Power, the temporary disposal of which he makes over to the capitalist. This is so much the case that I do not know whether by the English laws, but certainly by some Continental laws, the maximum time is fixed for which a man is allowed to sell his labouring power. If allowed to do so for any indefinite period whatever, slavery would be immediately restored. Such a sale, if it comprised his lifetime, for example, would make him at once the lifelong slave of his employer. |คนทำงานไม่ได้ขายแรงงานของเขาไปโดยตรง แต่ขายพลังแรงงานของเขา ซึ่งเขาจำหน่ายให้กับนายทุนไปเป็นเวลาชั่วคราว นี่เป็นจริงอย่างยิ่งโดยผมรู้อย่างแน่นอนในกฎหมายภาคพื้นทวีป แต่กฎหมายอังกฤษเป็นอย่างไรผมไม่รู้ ว่าคน ๆ หนึ่งได้รับอนุญาตให้ขายพลังที่ใช้แรงงานของเขาภายในระยะเวลาสูงสุดที่ถูกกำหนดไว้เท่านั้น หากเขาได้รับอนุญาตให้ทำไปเป็นเวลาไม่จำกัดเท่าใดก็ตาม ก็เป็นการฟื้นฟูระบบทาสขึ้นมาทันที การค้าขายเช่นนี้ เช่นหากประกอบด้วยชั่วชีวิตของเขาแล้ว ก็จะทำให้เขาเป็นทาสของนายจ้างของเขาไปตลอดชีวิต}}
{{ตรคป|One of the oldest economists and most original philosophers of England -- Thomas Hobbes -- has already, in his ''Leviathan'', instinctively hit upon this point overlooked by all his successors. He says: "''The value or worth of a man'' is, as in all other things, his price: that is, so much as would be given for the ''Use of his Power''." |}}
{{ตรคป|Proceeding from this basis, we shall be able to determine the Value of Labour as that of all other commodities. |}}
{{ตรคป|But before doing so, we might ask, how does this strange phenomenon arise, that we find on the market a set of buyers, possessed of land, machinery, raw material, and the means of subsistence, all of them, save land in its crude state, the products of labour, and on the other hand, a set of sellers who have nothing to sell except their labouring power, their working arms and brains? That the one set buys continually in order to make a profit and enrich themselves, while the other set continually sells in order to earn their livelihood? The inquiry into this question would be an inquiry into what the economists call "Previous, or Original Accumulation," but which ought to be called Original Expropriation. We should heed that this so-called Original Accumulation means nothing but a series of historical processes, resulting in a Decomposition of Original Union existing between the Labouring Man and his Instruments of Labour. Such an inquiry, however, lies beyond the pale of my present subject. The Separation between the Man of Labour and the Instruments of Labour once established, such a state of things will maintain itself and reproduce itself upon a constantly increasing scale, until a new and fundamental revolution in the mode of production should again overturn it, and restore the original union in a new historical form.|}}
{{ตรคป|What, then, is the Value of Labouring Power? |}}
{{ตรคป|Like that of every other commodity, its value is determined by the quantity of labour necessary to produce it. The labouring power of a man exists only in his living individuality. A certain mass of necessaries must be consumed by a man to grow up and maintain his life. But the man, like the machine, will wear out, and must be replaced by another man. Beside the mass of necessaries required for his own maintenance, he wants another amount of necessaries to bring up a certain quota of children that are to replace him on the labour market and to perpetuate the race of labourers. Moreover, to develop his labouring power, and acquire a given skill, another amount of values must be spent. For our purpose it suffices to consider only average labour, the costs of whose education and development are vanishing magnitudes. Still I must seize upon this occasion to state that, as the costs of producing labouring powers of different quality differ, so must differ the values of the labouring powers employed in different trades. The cry for an equality of wages rests, therefore, upon a mistake, is an insane wish never to be fulfilled. It is an offspring of that false and superficial radicalism that accepts premises and tries to evade conclusions. Upon the basis of the wages system the value of labouring power is settled like that of every other commodity; and as different kinds of labouring power have different values, or require different quantities of labour for their production, they must fetch different prices in the labour market. To clamour for equal or even equitable retribution on the basis of the wages system is the same as to clamour for freedom on the basis of the slavery system. What you think just or equitable is out of the question. The question is: What is necessary and unavoidable with a given system of production? |}}
{{ตรคป|After what has been said, it will be seen that the value of labouring power is determined by the value of the necessaries required to produce, develop, maintain, and perpetuate the labouring power.|}}
== VIII. การผลิตมูลค่าส่วนเกิน ==
[[งานแปล:ค่าจ้าง ราคา และกำไร/บทที่ 9|VIII. การผลิตมูลค่าส่วนเกิน]]
หัวเรื่องงานแปล
<!-- ข้อมูลหลัก -->
| ชื่อ = ค่าจ้าง ราคา และกำไร
| ศักราช = ค.ศ.
| ปี = 1865
| ภาษา = en
| ต้นฉบับ = Wages, Price and Profit
| ผู้สร้างสรรค์ = คาร์ล มาคส์
| บรรณาธิการ = เอเลนอร์ มาคส์ เอฟลิง
| ส่วน =
| ผู้มีส่วนร่วม =
| ก่อนหน้า = [[งานแปล:ค่าจ้าง ราคา และกำไร/บทที่ 8|VII. พลังที่ใช้แรงงาน]]
| ถัดไป = [[งานแปล:ค่าจ้าง ราคา และกำไร/บทที่ 10|IX. มูลค่าของแรงงาน]]
| หมายเหตุ =
<!-- ข้อมูลย่อย (สำหรับจัดระเบียบหรือเชื่อมโยงไปหน้าอื่น) -->
| หมวดหมู่ =
| แก้กำกวม =
| รุ่น =
| สถานีย่อย =
| ผู้สร้างสรรค์ที่เกี่ยวข้อง =
| วิกิพีเดีย =
| คอมมอนส์ =
| หมวดหมู่คอมมอนส์ =
| วิกิคำคม =
| วิกิข่าว =
| วิกิพจนานุกรม =
| วิกิตำรา =
| วิกิห้องสมุด =
| วิกิสนเทศ =
| วิกิท่องเที่ยว =
| วิกิวิทยาลัย =
| วิกิสปีชีส์ =
| เมทา =
Now suppose that the average amount of the daily necessaries of a labouring man require six hours of average labour for their production. Suppose, moreover, six hours of average labour to be also realized in a quantity of gold equal to 3s. Then 3s. would be the Price, or the monetary expression of the Daily Value of that man's Labouring Power. If he worked daily six hours he would daily produce a value sufficient to buy the average amount of his daily necessaries, or to maintain himself as a labouring man.
But our man is a wages labourer. He must, therefore, sell his labouring power to a capitalist. If he sells it at 3s. daily, or 18s. weekly, he sells it at its value. Suppose him to be a spinner. If he works six hours daily he will add to the cotton a value of 3s. daily. This value, daily added by him, would be an exact equivalent for the wages, or the price of his labouring power, received daily. But in that case no surplus value or surplus produce whatever would go to the capitalist. Here, then, we come to the rub.
In buying the labouring power of the workman, and paying its value, the capitalist, like every other purchaser, has acquired the right to consume or use the commodity bought. You consume or use the labouring power of a man by making him work, as you consume or use a machine by making it run. By paying the daily or weekly value of the labouring power of the workman, the capitalist has, therefore, acquired the right to use or make that labouring power work during the whole day or week. The working day or the working week has, of course, certain limits, but those we shall afterwards look more closely at.
For the present I want to turn your attention to one decisive point.
The value of the labouring power is determined by the quantity of labour necessary to maintain or reproduce it, but the use of that labouring power is only limited by the active energies and physical strength of the labourer. The daily or weekly value of the labouring power is quite distinct from the daily or weekly exercise of that power, the same as the food a horse wants and the time it can carry the horseman are quite distinct. The quantity of labour by which the value of the workman's labouring power is limited to the quantity of labour which his labouring power is apt to perform. Take the example of our spinner. We have seen that, to daily reproduce his labouring power, he must daily reproduce a value of three shillings, which he will do by working six hours daily. But this does not disable him from working ten or twelve or more hours a day. But by paying the daily or weekly value of the spinner's labouring power, the capitalist has acquired the right of using that labouring power during the whole day or week. He will, therefore, make him work say, daily, twelve hours. Over and above the six hours required to replace his wages, or the value of his labouring power, he will, therefore, have to work six other hours, which I shall call hours of surplus labour, which surplus labour will realize itself in a surplus value and a surplus produce. If our spinner, for example, by his daily labour of six hours, added three shillings' value to the cotton, a value forming an exact equivalent to his wages, he will, in twelve hours, add six shillings' worth to the cotton, and produce a proportional surplus of yarn. As he has sold his labouring power to the capitalist, the whole value of produce created by him belongs to the capitalist, the owner pro tem. of his labouring power. By advancing three shillings, the capitalist will, therefore, realize a value of six shillings, because, advancing a value in which six hours of labour are crystallized, he will receive in return a value in which twelve hours of labour are crystallized. By repeating this same process daily, the capitalist will daily advance three shillings and daily pocket six shillings, one-half of which will go to pay wages anew, and the other half of which will form surplus value, for which the capitalist pays no equivalent. It is this sort of exchange between capital and labour upon which capitalistic production, or the wages system, is founded, and which must constantly result in reproducing the working man as a working man, and the capitalist as a capitalist.
The rate of surplus value, all other circumstances remaining the same, will depend on the proportion between that necessary to reproduce the value of the labouring power and the surplus time or surplus labour performed for the capitalist. It will, therefore, depend on the ratio in which the working day is prolonged over and above that extent, by working which the working man would only reproduce the value of his labouring power, or replace his wages.
== IX. มูลค่าของแรงงาน ==
[[งานแปล:ค่าจ้าง ราคา และกำไร/บทที่ 10|IX. มูลค่าของแรงงาน]]
หัวเรื่องงานแปล
<!-- ข้อมูลหลัก -->
| ชื่อ = ค่าจ้าง ราคา และกำไร
| ศักราช = ค.ศ.
| ปี = 1865
| ภาษา = en
| ต้นฉบับ = Wages, Price and Profit
| ผู้สร้างสรรค์ = คาร์ล มาคส์
| บรรณาธิการ = เอเลนอร์ มาคส์ เอฟลิง
| ส่วน =
| ผู้มีส่วนร่วม =
| ก่อนหน้า = [[งานแปล:ค่าจ้าง ราคา และกำไร/บทที่ 9|VIII. การผลิตมูลค่าส่วนเกิน]]
| ถัดไป = [[งานแปล:ค่าจ้าง ราคา และกำไร/บทที่ 11|X. กำไรถูกสร้างขึ้นด้วยการขายโภคภัณฑ์ที่มูลค่าของมัน]]
| หมายเหตุ =
<!-- ข้อมูลย่อย (สำหรับจัดระเบียบหรือเชื่อมโยงไปหน้าอื่น) -->
| หมวดหมู่ =
| แก้กำกวม =
| รุ่น =
| สถานีย่อย =
| ผู้สร้างสรรค์ที่เกี่ยวข้อง =
| วิกิพีเดีย =
| คอมมอนส์ =
| หมวดหมู่คอมมอนส์ =
| วิกิคำคม =
| วิกิข่าว =
| วิกิพจนานุกรม =
| วิกิตำรา =
| วิกิห้องสมุด =
| วิกิสนเทศ =
| วิกิท่องเที่ยว =
| วิกิวิทยาลัย =
| วิกิสปีชีส์ =
| เมทา =
We must now return to the expression, "''Value, or Price of Labour.''"
We have seen that, in fact, it is only the value of the labouring power, measured by the values of commodities necessary for its maintenance. But since the workman receives his wages after his labour is performed, and knows, moreover, that what he actually gives to the capitalist is his labour, the value or price of his labouring power necessarily appears to him as the price or value of his labour itself. If the price of his labouring power is three shillings, in which six hours of labour are realized, and if he works twelve hours, he necessarily considers these three shillings as the value or price of twelve hours of labour, although these twelve hours of labour realize themselves in a value of six shillings. A double consequence flows from this.
Firstly. The value or price of the labouring power takes the semblance of the price or value of labour itself, although, strictly speaking, value and price of labour are senseless terms.
Secondly. Although one part only of the workman's daily labour is paid, while the other part is unpaid, and while that unpaid or surplus labour constitutes exactly the fund out of which surplus value or profit is formed, it seems as if the aggregate labour was paid labour.
This false appearance distinguishes wages labour from other historical forms of labour. On the basis of the wages system even the unpaid labour seems to be paid labour. With the slave, on the contrary, even that part of his labour which is paid appears to be unpaid. Of course, in order to work the slave must live, and one part of his working day goes to replace the value of his own maintenance. But since no bargain is struck between him and his master, and no acts of selling and buying are going on between the two parties, all his labour seems to be given away for nothing.
Take, on the other hand, the peasant serf, such as he, I might say, until yesterday existed in the whole East of Europe. This peasant worked, for example, three days for himself on his own field or the held allotted to him, and the three subsequent days he performed compulsory and gratuitous labour on the estate of his lord. Here, then, the paid and unpaid parts of labour were sensibly separated, separated in time and space, and our Liberals overflowed with moral indignation at the preposterous notion of making a man work for nothing.
In point of fact, however, whether a man works three days of the week for himself on his own field and three days for nothing on the estate of his lord, or whether he works in the factory or the workshop six hours daily for himself and six for his employer, comes to the same, although in the latter case the paid and unpaid portions of labour are inseparably mixed up with each other, and the nature of the whole transaction is completely masked by the intervention of a contract and the pay received at the end of the week. The gratuitous labour appears to be voluntarily given in the one instance, and to be compulsory in the other. That makes all the difference.
In using the word "value of labour," I shall only use it as a popular slang term for "value of labouring power."
== X. กำไรถูกสร้างขึ้นด้วยการขายโภคภัณฑ์ที่มูลค่าของมัน ==
[[งานแปล:ค่าจ้าง ราคา และกำไร/บทที่ 11|X. กำไรถูกสร้างขึ้นด้วยการขายโภคภัณฑ์ที่มูลค่าของมัน]]
หัวเรื่องงานแปล
<!-- ข้อมูลหลัก -->
| ชื่อ = ค่าจ้าง ราคา และกำไร
| ศักราช = ค.ศ.
| ปี = 1865
| ภาษา = en
| ต้นฉบับ = Wages, Price and Profit
| ผู้สร้างสรรค์ = คาร์ล มาคส์
| บรรณาธิการ = เอเลนอร์ มาคส์ เอฟลิง
| ส่วน =
| ผู้มีส่วนร่วม =
| ก่อนหน้า = [[งานแปล:ค่าจ้าง ราคา และกำไร/บทที่ 10|IX. มูลค่าของแรงงาน]]
| ถัดไป = [[งานแปล:ค่าจ้าง ราคา และกำไร/บทที่ 12|XI. ส่วนต่าง ๆ ที่มูลค่าส่วนเกินถูกจำแนกไป]]
| หมายเหตุ =
<!-- ข้อมูลย่อย (สำหรับจัดระเบียบหรือเชื่อมโยงไปหน้าอื่น) -->
| หมวดหมู่ =
| แก้กำกวม =
| รุ่น =
| สถานีย่อย =
| ผู้สร้างสรรค์ที่เกี่ยวข้อง =
| วิกิพีเดีย =
| คอมมอนส์ =
| หมวดหมู่คอมมอนส์ =
| วิกิคำคม =
| วิกิข่าว =
| วิกิพจนานุกรม =
| วิกิตำรา =
| วิกิห้องสมุด =
| วิกิสนเทศ =
| วิกิท่องเที่ยว =
| วิกิวิทยาลัย =
| วิกิสปีชีส์ =
| เมทา =
Suppose an average hour of labour to be realized in a value equal to sixpence, or twelve average hours of labour to be realized in six shillings. Suppose, further, the value of labour to be three shillings or the produce of six hours' labour. If, then, in the raw material, machinery, and so forth, used up in a commodity, twenty-four hours of average labour were realized, its value would amount to twelve shillings. If, moreover, the workman employed by the capitalist added twelve hours of labour to those means of production, these twelve hours would be realized in an additional value of six shillings. The total value of the product would, therefore, amount to thirty-six hours of realized labour, and be equal to eighteen shillings. But as the value of labour, or the wages paid to the workman, would be three shillings only, no equivalent would have been paid by the capitalist for the six hours of surplus labour worked by the workman, and realized in the value of the commodity. By selling this commodity at its value for eighteen shillings, the capitalist would, therefore, realize a value of three shillings, for which he had paid no equivalent. These three shillings would constitute the surplus value or profit pocketed by him. The capitalist would consequently realize the profit of three shillings, not by selling his commodity at a price over and above its value, but by selling it at its real value.
The value of a commodity is determined by the total quantity of labour contained in it. But part of that quantity of labour is realized in a value, for which an equivalent has been paid in the form of wages; part of it is realized in a value for which no equivalent has been paid. Part of the labour contained in the commodity is paid labour; part is unpaid labour. By selling, therefore, the commodity at its value, that is, as the crystallization of the total quantity of labour bestowed upon it, the capitalist must necessarily sell it at a profit. He sells not only what has cost him an equivalent, but he sells also what has cost him nothing, although it has cost his workman labour. The cost of the commodity to the capitalist and its real cost are different things. I repeat, therefore, that normal and average profits are made by selling commodities not above, but at their real values.
== XI. ส่วนต่าง ๆ ที่มูลค่าส่วนเกินถูกจำแนกไป ==
[[งานแปล:ค่าจ้าง ราคา และกำไร/บทที่ 12|XI. ส่วนต่าง ๆ ที่มูลค่าส่วนเกินถูกจำแนกไป]]
หัวเรื่องงานแปล
<!-- ข้อมูลหลัก -->
| ชื่อ = ค่าจ้าง ราคา และกำไร
| ศักราช = ค.ศ.
| ปี = 1865
| ภาษา = en
| ต้นฉบับ = Wages, Price and Profit
| ผู้สร้างสรรค์ = คาร์ล มาคส์
| บรรณาธิการ = เอเลนอร์ มาคส์ เอฟลิง
| ส่วน =
| ผู้มีส่วนร่วม =
| ก่อนหน้า = [[งานแปล:ค่าจ้าง ราคา และกำไร/บทที่ 11|X. กำไรถูกสร้างขึ้นด้วยการขายโภคภัณฑ์ที่มูลค่าของมัน]]
| ถัดไป = [[งานแปล:ค่าจ้าง ราคา และกำไร/บทที่ 13|XII. ความสัมพันธ์โดยทั่วไปของกำไร ค่าจ้าง และราคา]]
| หมายเหตุ =
<!-- ข้อมูลย่อย (สำหรับจัดระเบียบหรือเชื่อมโยงไปหน้าอื่น) -->
| หมวดหมู่ =
| แก้กำกวม =
| รุ่น =
| สถานีย่อย =
| ผู้สร้างสรรค์ที่เกี่ยวข้อง =
| วิกิพีเดีย =
| คอมมอนส์ =
| หมวดหมู่คอมมอนส์ =
| วิกิคำคม =
| วิกิข่าว =
| วิกิพจนานุกรม =
| วิกิตำรา =
| วิกิห้องสมุด =
| วิกิสนเทศ =
| วิกิท่องเที่ยว =
| วิกิวิทยาลัย =
| วิกิสปีชีส์ =
| เมทา =
The surplus value, or that part of the total value of the commodity in which the surplus labour or unpaid labour of the working man is realized, I call Profit. The whole of that profit is not pocketed by the employing capitalist. The monopoly of land enables the landlord to take one part of that surplus value, under the name of rent, whether the land is used for agriculture, buildings or railways, or for any other productive purpose. On the other hand, the very fact that the possession of the instruments of labour enables the employing capitalist to produce a surplus value, or, what comes to the same, to appropriate to himself a certain amount of unpaid labour, enables the owner of the means of labour, which he lends wholly or partly to the employing capitalist -- enables, in one word, the money-lending capitalist to claim for himself under the name of interest another part of that surplus value, so that there remains to the employing capitalist as such only what is called industrial or commercial profit.
By what laws this division of the total amount of surplus value amongst the three categories of people is regulated is a question quite foreign to our subject. This much, however, results from what has been stated.
Rent, Interest, and Industrial Profit are only different names for different parts of the surplus value of the commodity, or the unpaid labour enclosed in it, and they are equally derived from this source, and from this source alone. They are not derived from land as such or from capital as such, but land and capital enable their owners to get their respective shares out of the surplus value extracted by the employing capitalist from the labourer. For the labourer himself it is a matter of subordinate importance whether that surplus value, the result of his surplus labour, or unpaid labour, is altogether pocketed by the employing capitalist, or whether the latter is obliged to pay portions of it, under the name of rent and interest, away to third parties. Suppose the employing capitalist to use only his own capital and to be his own landlord, then the whole surplus value would go into his pocket.
It is the employing capitalist who immediately extracts from the labourer this surplus value, whatever part of it he may ultimately be able to keep for himself. Upon this relation, therefore, between the employing capitalist and the wages labourer the whole wages system and the whole present system of production hinge. Some of the citizens who took part in our debate were, therefore, wrong in trying to mince matters, and to treat this fundamental relation between the employing capitalist and the working man as a secondary question, although they were right in stating that, under given circumstances, a rise of prices might affect in very unequal degrees the employing capitalist, the landlord, the moneyed capitalist, and, if you please, the tax gatherer.
Another consequence follows from what has been stated.
That part of the value of the commodity which represents only the value of the raw materials, the machinery, in one word, no revenue at all, but replaces only capital. But, apart from this, it is false that the other part of the value of the commodity which forms revenue, or may be spent in the form of wages, profits, rent, interest, is constituted by the value of wages, the value of rent, the value of profits, and so forth. We shall, in the first instance, discard wages, and only treat industrial profits, interest, and rent. We have just seen that the surplus value contained in the commodity or that part of its value in which unpaid labour is realized, resolves itself into different fractions, bearing three different names. But it would be quite the reverse of the truth to say that its value is composed of, or formed by, the addition of the independent values of these three constituents.
If one hour of labour realizes itself in a value of sixpence, if the working day of the labourer comprises twelve hours, if half of this time is unpaid labour, that surplus labour will add to the commodity a surplus value of three shillings, that is, of value for which no equivalent has been paid. This surplus value of three shillings constitutes the whole fund which the employing capitalist may divide, in whatever proportions, with the landlord and the money-lender. The value of these three shillings constitutes the limit of the value they have to divide amongst them. But it is not the employing capitalist who adds to the value of the commodity an arbitrary value for his profit, to which another value is added for the landlord, and so forth, so that the addition of these arbitrarily fixed values would constitute the total value. You see, therefore, the fallacy of the popular notion, which confounds the decomposition of a given value into three parts, with the formation of that value by the addition of three independent values, thus converting the aggregate value, from which rent, profit, and interest are derived, into an arbitrary magnitude.
If the total profit realized by a capitalist be equal to £100, we call this sum, considered as absolute magnitude, the amount of profit. But if we calculate the ratio which those £100 bear to the capital advanced, we call this relative magnitude. It is evident that this rate of profit may be expressed in a double way.
Suppose £100 to be the capital advanced in wages. If the surplus value created is also £100 -- and this would show us that half the working day of the labourer consists of unpaid labour -- and if we measured this profit by the value of the capital advanced in wages, we should say that the rate of profit amounted to one hundred per cent., because the value advanced would be one hundred and the value realized would be two hundred.
If, on the other hand, we should not only consider the capital advanced in wages, but the total capital advanced, say, for example, £500, of which £400 represented the value of raw materials, machinery, and so forth, we should say that the rate of profit amounted only to twenty per cent., because the profit of one hundred would be but the fifth part of the total capital advanced.
The first mode of expressing the rate of profit is the only one which shows you the real ratio between paid and unpaid labour, the real degree of the exploitation (you must allow me this French word) of labour. The other mode of expression is that in common use, and is, indeed, appropriate for certain purposes. At all events, it is very useful for concealing the degree in which the capitalist extracts gratuitous labour from the workman.
In the remarks I have still to make I shall use the word Profit for the whole amount of the surplus value extracted by the capitalist without any regard to the division of that surplus value between different parties, and in using the words Rate of Profit, I shall always measure profits by the value of the capital advanced in wages.
== XII. ความสัมพันธ์โดยทั่วไปของกำไร ค่าจ้าง และราคา ==
[[งานแปล:ค่าจ้าง ราคา และกำไร/บทที่ 13|XII. ความสัมพันธ์โดยทั่วไปของกำไร ค่าจ้าง และราคา]]
หัวเรื่องงานแปล
<!-- ข้อมูลหลัก -->
| ชื่อ = ค่าจ้าง ราคา และกำไร
| ศักราช = ค.ศ.
| ปี = 1865
| ภาษา = en
| ต้นฉบับ = Wages, Price and Profit
| ผู้สร้างสรรค์ = คาร์ล มาคส์
| บรรณาธิการ = เอเลนอร์ มาคส์ เอฟลิง
| ส่วน =
| ผู้มีส่วนร่วม =
| ก่อนหน้า = [[งานแปล:ค่าจ้าง ราคา และกำไร/บทที่ 12|XI. ส่วนต่าง ๆ ที่มูลค่าส่วนเกินถูกจำแนกไป]]
| ถัดไป = [[งานแปล:ค่าจ้าง ราคา และกำไร/บทที่ 14|XIII. กรณีหลักของความพยายามในการเพิ่มค่าจ้างหรือการต่อต้านการลดต่ำลงของมัน]]
| หมายเหตุ =
<!-- ข้อมูลย่อย (สำหรับจัดระเบียบหรือเชื่อมโยงไปหน้าอื่น) -->
| หมวดหมู่ =
| แก้กำกวม =
| รุ่น =
| สถานีย่อย =
| ผู้สร้างสรรค์ที่เกี่ยวข้อง =
| วิกิพีเดีย =
| คอมมอนส์ =
| หมวดหมู่คอมมอนส์ =
| วิกิคำคม =
| วิกิข่าว =
| วิกิพจนานุกรม =
| วิกิตำรา =
| วิกิห้องสมุด =
| วิกิสนเทศ =
| วิกิท่องเที่ยว =
| วิกิวิทยาลัย =
| วิกิสปีชีส์ =
| เมทา =
Deduct from the value of a commodity the value replacing the value of the raw materials and other means of production used upon it, that is to say, deduct the value representing the past labour contained in it, and the remainder of its value will resolve into the quantity of labour added by the working man last employed. If that working man works twelve hours daily, if twelve hours of average labour crystallize themselves in an amount of gold equal to six shillings, this additional value of six shillings is the only value his labour will have created. This given value, determined by the time of his labour, is the only fund from which both he and the capitalist have to draw their respective shares or dividends, the only value to be divided into wages and profits. It is evident that this value itself will not be altered by the variable proportions in which it may be divided amongst the two parties. There will also be nothing changed if in the place of one working man you put the whole working population, twelve million working days, for example, instead of one.
Since the capitalist and workman have only to divide this limited value, that is, the value measured by the total labour of the working man, the more the one gets the less will the other get, and vice versa. Whenever a quantity is given, one part of it will increase inversely as the other decreases. If the wages change, profits will change in an opposite direction. If wages fall profits will rise; and if wages rise, profits will fall. If the working man, on our former supposition, gets shillings, equal to one-half of the value he has created, or if his whole working day consists half of paid, half of unpaid labour, the rate of profit will be 100 per cent., because the capitalist would also get three shillings. If the working man receives only two shillings, or works only one third of the whole day for himself, the capitalist will get four shillings, and the rate of profit will be 200 per cent. If the working man receives four shillings, the capitalist will only receive two, and the rate of profit would sink to 50 per cent., but all these variations will not affect the value of the commodity. A general rise of wages would, therefore, result in a fall of the general rate of profit, but not affect values.
But although the values of commodities, which must ultimately regulate their market prices, are exclusively determined by the total quantities of labour fixed in them, and not by the division of that quantity into paid and unpaid labour, it by no means follows that the values of the single commodities, or lots of commodities, produced during twelve hours, for example, will remain constant. The number or mass of commodities produced in a given time of labour, or by a given quantity of labour, depends unon the productive power of the labour employed, and upon its extent or length. With one degree of the productive power of spinning labour, for example, a working day of twelve hours may produce twelve pounds of yarn, with a lesser degree of productive power only two pounds. If then twelve hours' average labour were realized in the value of six shillings in the one case, the twelve pounds of yarn would cost six shillings, in the other case the two pounds of yarn would also cost six shillings. One pound of yarn would, therefore, cost sixpence in the one case, and three shillings in the other. This difference of price would result from the difference in the productive powers of the labour employed. One hour of labour would be realized in one pound of yarn with the greater productive power, while with the smaller productive power, six hours of labour would be realized in one pound of yarn. The price of a pound of yarn would, in the one instance, be only sixpence, although wages were relatively high and the rate of profit low, it would be three shillings in the other instance, although wages were low and the rate of profit high. This would be so because the price of the pound of yarn is regulated by the total amount of labour worked up in it, and not by the proportional division of that total amount into paid and unpaid labour. The fact I have before mentioned that high-priced labour may produce cheap, and low-priced labour may produce dear commodities, loses, therefore, its paradoxical appearance. It is only the expression of the general law that the value of a commodity is regulated by the quantity of labour worked up in it, and that the quantity of labour worked up in it depends altogether upon the productive powers of the labour employed, and will, therefore, vary with every variation in the productivity of labour.
== XIII. กรณีหลักของความพยายามในการเพิ่มค่าจ้างหรือการต่อต้านการลดต่ำลงของมัน ==
[[งานแปล:ค่าจ้าง ราคา และกำไร/บทที่ 14|XIII. กรณีหลักของความพยายามในการเพิ่มค่าจ้างหรือการต่อต้านการลดต่ำลงของมัน]]
หัวเรื่องงานแปล
<!-- ข้อมูลหลัก -->
| ชื่อ = ค่าจ้าง ราคา และกำไร
| ศักราช = ค.ศ.
| ปี = 1865
| ภาษา = en
| ต้นฉบับ = Wages, Price and Profit
| ผู้สร้างสรรค์ = คาร์ล มาคส์
| บรรณาธิการ = เอเลนอร์ มาคส์ เอฟลิง
| ส่วน =
| ผู้มีส่วนร่วม =
| ก่อนหน้า = [[งานแปล:ค่าจ้าง ราคา และกำไร/บทที่ 13|XII. ความสัมพันธ์โดยทั่วไปของกำไร ค่าจ้าง และราคา]]
| ถัดไป = [[งานแปล:ค่าจ้าง ราคา และกำไร/บทที่ 15|XIV. การต่อสู้ระหว่างทุนกับแรงงานและผลลัพธ์ของมัน]]
| หมายเหตุ =
<!-- ข้อมูลย่อย (สำหรับจัดระเบียบหรือเชื่อมโยงไปหน้าอื่น) -->
| หมวดหมู่ =
| แก้กำกวม =
| รุ่น =
| สถานีย่อย =
| ผู้สร้างสรรค์ที่เกี่ยวข้อง =
| วิกิพีเดีย =
| คอมมอนส์ =
| หมวดหมู่คอมมอนส์ =
| วิกิคำคม =
| วิกิข่าว =
| วิกิพจนานุกรม =
| วิกิตำรา =
| วิกิห้องสมุด =
| วิกิสนเทศ =
| วิกิท่องเที่ยว =
| วิกิวิทยาลัย =
| วิกิสปีชีส์ =
| เมทา =
Let us now seriously consider the main cases in which a rise of wages is attempted or a reduction of wages resisted.
1. We have seen that the value of the labouring power, or in more popular parlance, the value of labour, is determined by the value of necessaries, or the quantity of labour required to produce them. If, then, in a given country the value of the daily average necessaries of the labourer represented six hours of labour expressed in three shillings, the labourer would have to work six hours daily to produce an equivalent for his daily maintenance. If the whole working day was twelve hours, the capitalist would pay him the value of his labour by paying him three shillings. Half the working day would be unpaid labour, and the rate of profit would amount to 100 per cent. But now suppose that, consequent upon a decrease of productivity, more labour should be wanted to produce, say, the same amount of agricultural produce, 60 that the price of the average daily necessaries should rise from three to four shillings. In that case the value of labour would rise by one-third, or 331/3 per cent. Eight hours of the working day would be required to produce an equivalent for the daily maintenance of the labourer, according to his old standard of living. The surplus labour would therefore sink from six hours to four, and the rate of profit from 100 to 50 per cent. But in insisting upon a rise of wages, the labourer would only insist upon getting the increased value of his labour, like every other seller of a commodity, who, the costs of his commodities having increased, tries to get its increased value paid. If wages did not rise, or not sufficiently rise, to compensate for the increased values of necessaries, the price of labour would sink below the value of labour, and the labourer's standard of life would deteriorate.
But a change might also take place in an opposite direction. By virtue of the increased productivity of labour, the same amount of the average daily necessaries might sink from three to two shillings, or only four hours out of the working day, instead of six, be wanted to reproduce an equivalent for the value of the daily necessaries. The working man would now be able to buy with two shillings as many necessaries as he did before with three shillings. Indeed, the value of labour would have sunk, but that diminished value would command the same amount of commodities as before. Then profits would rise from three to four shillings, and the rate of profit from 100 to 200 per cent. Although the labourer's absolute standard of life would have remained the same, his relative wages, and therewith his relative social position, as compared with that of the capitalist, would have been lowered. If the working man should resist that reduction of relative wages, he would only try to get some share in the increased productive powers of his own labour, and to maintain his former relative position in the social scale. Thus, after the abolition of the Corn Laws, and in flagrant violation of the most solemn pledges given during the anti-Corn Law agitation, the English factory lords generally reduced wages ten per cent. The resistance of the workmen was at first baffled, but, consequent upon circumstances I cannot now enter upon, the ten per cent. lost were afterwards regained.
2. The values of necessaries, and consequently the value of labour, might remain the same, but a change might occur in their money prices, consequent upon a previous change in the value of money.
By the discovery of more fertile mines and so forth, two ounces of gold might, for example, cost no more labour to produce than one ounce did before. The value of gold would then be depreciated by one-half, or fifty per cent. As the values of all other commodities would then be expressed in twice their former money prices, so also the same with the value of labour. Twelve hours of labour, formerly expressed in six shillings, would now be expressed in twelve shillings. If the working man's wages should remain three shillings, instead of rising to six shillings, the money price of his labour would only be equal to half the value of his labour, and his standard of life would fearfully deteriorate. This would also happen in a greater or lesser degree if his wages should rise, but not proportionately to the fall in the value of gold. In such a case nothing would have been changed, either in the productive powers of labour, or in supply and demand, or in values. Nothing could have changed except the money names of those values. To say that in such a case the workman ought not to insist upon a proportionate rise of wages, is to say that he must be content to be paid with names, instead of with things. All past history proves that whenever such a depreciation of money occurs, the capitalists are on the alert to seize this opportunity for defrauding the workman. A very large school of political economists assert that, consequent upon the new discoveries of gold lands, the better working of silver mines, and the cheaper supply of quicksilver, the value of precious metals has been again depreciated. This would explain the general and simultaneous attempts on the Continent at a rise of wages.
3. We have till now supposed that the working day has given limits. The working day, however, has, by itself, no constant limits. It is the constant tendency of capital to stretch it to its utmost physically possible length, because in the same degree surplus labour, and consequently the profit resulting therefrom, will be increased. The more capital succeeds in prolonging the working day, the greater the amount of other people's labour it will appropriate. During the seventeenth and even the first two-thirds of the eighteenth century a ten hours working day was the normal working day all over England. During the anti-Jacobin war, which was in fact a war waged by the British barons against the British working masses, capital celebrated its bacchanalia, and prolonged the working day from ten to twelve, fourteen, eighteen hours. Malthus, by no means a man whom you would suspect of a maudlin sentimentalism, declared in a pamphlet, published about 1815, that if this sort of thing was to go on the life of the nation would be attacked at its very source. A few years before the general introduction of the newly-invented machinery, about 1765, a pamphlet appeared in England under the title, An Essay on Trade. The anonymous author, an avowed enemy of the working classes, declaims on the necessity of expanding the limits of the working day. Amongst other means to this end, he proposes working houses, which, he says, ought to be "Houses of Terror." And what is the length of the working day he prescribes for these "Houses of Terror"? Twelve hours, the very same time which in 1832 was declared by capitalists, political economists, and ministers to be not only the existing but the necessary time of labour for a child under twelve years.
By selling his labouring power, and he must do so under the present system, the working man makes over to the capitalist the consumption of that power, but within certain rational limits. He sells his labouring power in order to maintain it, apart from its natural wear and tear, but not to destroy it. In selling his labouring power at its daily or weekly value, it is understood that in one day or one week that labouring power shall not be submitted to two days' or two weeks' waste or wear and tear. Take a machine worth £1,000. If it is used up in ten years it will add to the value of the commodities in whose production it assists £100 yearly. If it be used up in five years it would add £200 yearly, or the value of its annual wear and tear is in inverse ratio to the time in which it is consumed. But this distinguishes the working man from the machine. Machinery does not wear out exactly in the same ratio in which it is used. Man, on the contrary, decays in a greater ratio than would be visible from the mere numerical addition of work.
In their attempts at reducing the working day to its former rational dimensions, or, where they cannot enforce a legal fixation of a normal working day, at checking overwork by a rise of wages, a rise not only in proportion to the surplus time exacted, but in a greater proportion, working men fulfil only a duty to themselves and their race. They only set limits to the tyrannical usurpations of capital. Time is the room of human development. A man who has no free time to dispose of, whose whole lifetime, apart from the mere physical interruptions by sleep, meals, and so forth, is absorbed by his labour for the capitalist, is less than a beast of burden. He is a mere machine for producing Foreign Wealth, broken in body and brutalized in mind. Yet the whole history of modern industry shows that capital, if not checked, will recklessly and ruthlessly work to cast down the whole working class to this utmost state of degradation.
In prolonging the working day the capitalist may pay higher wages and still lower the value of labour, if the rise of wages does not correspond to the greater amount of labour extracted, and the quicker decay of the labouring power thus caused. This may be done in another way. Your middle-class statisticians will tell you, for instance, that the average wages of factory families in Lancashire have risen. They forget that instead of the labour of the man, the head of the family, his wife and perhaps three or four children are now thrown under the Juggernaut wheels of capital, and that the rise of the aggregate wages does not correspond to the aggregate surplus labour extracted from the family.
Even with given limits of the working day, such as they now exist in all branches of industry subjected to the factory laws, a rise of wages may become necessary, if only to keep up the old standard value of labour. By increasing the intensity of labour, a man may be made to expend as much vital force in one hour as he formerly did in two. This has, to a certain degree, been effected in the trades, placed under the Factory Acts, by the acceleration of machinery, and the greater number of working machines which a single individual has now to superintend. If the increase in the intensity of labour or the mass of labour spent in an hour keeps some fair proportion to the decrease in the extent of the working day, the working man will still be the winner. If this limit is overshot, he loses in one form what he has gained in another, and ten hours of labour may then become as ruinous as twelve hours were before. In checking this tendency of capital, by struggling for a rise of wages corresponding to the rising intensity of labour, the working man only resists the depreciation of his labour and the deterioration of his race.
4. All of you know that, from reasons I have not now to explain, capitalistic production moves through certain periodical cycles. It moves through a state of quiescence, growing animation, prosperity, overtrade, crisis, and stagnation. The market prices of commodities, and the market rates of profit, follow these phases, now sinking below their averages, now rising above them. Considering the whole cycle, you will find that one deviation of the market price is being compensated by the other, and that, taking the average of the cycle, the market prices of commodities are regulated by their values. Well! During the phase of sinking market prices and the phases of crisis and stagnation, the working man, if not thrown out of employment altogether, is sure to have his wages lowered. Not to be defrauded, he must, even with such a fall of market prices, debate with the capitalist in what proportional degree a fall of wages has become necessary. If, during the phases of prosperity, when extra profits are made, he did not battle for a rise of wages, he would, taking the average of one industrial cycle, not even receive his average wages, or the value of his labour. It is the utmost height of folly to demand that while his wages are necessarily affected by the adverse phases of the cycle, he should exclude himself from compensation during the prosperous phases of the cycle. Generally, the values of all commodities are only realized by the compensation of the continuously changing market prices, springing from the continuous fluctuations of demand and supply. On the basis of the present system labour is only a commodity like others. It must, therefore, pass through the same fluctuations to fetch an average price corresponding to its value. It would be absurd to treat it on the one hand as a commodity, and to want on the other hand to exempt it from the laws which regulate the prices of commodities. The slave receives a permanent and fixed amount of maintenance; the wages labourer does not. He must try to get a rise of wages in the one instance, if only to compensate for a fall of wages in the other. If he resigned himself to accept the will, the dictates of the capitalist as a permanent economical law, he would share in all the miseries of the slave, without the security of the slave.
5. In all the cases I have considered, and they form ninety-nine out of a hundred, you have seen that a struggle for a rise of wages follows only in the track of previous changes, and is the necessary offspring of previous changes in the amount of production, the productive powers of labour, the value of labour, the value of money, the extent or the intensity of labour extracted, the fluctuations of market prices, dependent upon the fluctuations of demand and supply, and consistent with the different phases of the industrial cycle; in one word, as reactions of labour against the previous action of capital. By treating the struggle for a rise of wages independently of all these circumstances, by looking only upon the changes of wages, and overlooking all the other changes from which they emanate, you proceed from a false premise in order to arrive at false conclusions.
== XIV. การต่อสู้ระหว่างทุนกับแรงงานและผลลัพธ์ของมัน ==
[[งานแปล:ค่าจ้าง ราคา และกำไร/บทที่ 15|XIV. การต่อสู้ระหว่างทุนกับแรงงานและผลลัพธ์ของมัน]]
หัวเรื่องงานแปล
<!-- ข้อมูลหลัก -->
| ชื่อ = ค่าจ้าง ราคา และกำไร
| ศักราช = ค.ศ.
| ปี = 1865
| ภาษา = en
| ต้นฉบับ = Wages, Price and Profit
| ผู้สร้างสรรค์ = คาร์ล มาคส์
| บรรณาธิการ = เอเลนอร์ มาคส์ เอฟลิง
| ส่วน =
| ผู้มีส่วนร่วม =
| ก่อนหน้า = [[งานแปล:ค่าจ้าง ราคา และกำไร/บทที่ 14|XIII. กรณีหลักของความพยายามในการเพิ่มค่าจ้างหรือการต่อต้านการลดต่ำลงของมัน]]
| ถัดไป =
| หมายเหตุ =
<!-- ข้อมูลย่อย (สำหรับจัดระเบียบหรือเชื่อมโยงไปหน้าอื่น) -->
| หมวดหมู่ =
| แก้กำกวม =
| รุ่น =
| สถานีย่อย =
| ผู้สร้างสรรค์ที่เกี่ยวข้อง =
| วิกิพีเดีย =
| คอมมอนส์ =
| หมวดหมู่คอมมอนส์ =
| วิกิคำคม =
| วิกิข่าว =
| วิกิพจนานุกรม =
| วิกิตำรา =
| วิกิห้องสมุด =
| วิกิสนเทศ =
| วิกิท่องเที่ยว =
| วิกิวิทยาลัย =
| วิกิสปีชีส์ =
| เมทา =
1. Having shown that the periodical resistance on the part of the working men against a reduction of wages, and their periodical attempts at getting a rise of wages, are inseparable from the wages system, and dictated by the very fact of labour being assimilated to commodities, and therefore subject to the laws regulating the general movement of prices; having, furthermore, shown that a general rise of wages would result in a fall in the general rate of profit, but not affect the average prices of commodities, or their values, the question now ultimately arises, how far, in this incessant struggle between capital and labour, the latter is likely to prove successful.
I might answer by a generalization, and say that, as with all other commodities, so with labour, its market price will, in the long run, adapt itself to its value; that, therefore, despite all the ups and downs, and do what he may, the working man will, on an average, only receive the value of his labour which resolves into the value of his labouring power, which is determined by the value of the necessaries required for its maintenance and reproduction, which value of necessaries finally is regulated by the quantity of labour wanted to produce them.
But there are some peculiar features which distinguish the value of the labouring power, or value of labour, from the value of all other commodities. The value of the labouring power is formed by two elements -- the one merely physical, the other historical or social. Its ultimate limit is determined by the physical element, that is to say, to maintain and reproduce itself, to perpetuate its physical existence, the working class must receive the necessaries absolutely indispensable for living and multiplying. The value of those indispensable necessaries forms, therefore, the ultimate limit of the value of labour. On the other hand, the length of the working day is also limited by ultimate, although very elastic boundaries. Its ultimate limit is given by the physical force of the labouring man. If the daily exhaustion of his vital forces exceeds a certain degree, it cannot be exerted anew, day by day. However, as I said, this limit is very elastic. A quick succession of unhealthy and short-lived generations will keep the labour market as well supplied as a series of vigorous and long-lived generations.
Besides this mere physical element, the value of labour is in every country determined by a traditional standard of life. It is not mere physical life, but it is the satisfaction of certain wants springing from the social conditions in which people are placed and reared up. The English standard of life may be reduced to the Irish standard; the standard of life of a German peasant to that of a Livonian peasant. The important part which historical tradition and social habitude play in this respect, you may learn from Mr. Thornton's work on Over-population, where he shows that the average wages in different agricultural districts of England still nowadays differ more or less according to the more or less favourable circumstances under which the districts have emerged from the state of serfdom.
This historical or social element, entering into the value of labour, may be expanded, or contracted, or altogether extinguished, so that nothing remains but the physical limit. During the time of the anti-Jacobin war, undertaken, as the incorrigible tax-eater and sinecurist, old George Rose, used to say, to save the comforts of our holy religion from the inroads of the French infidels, the honest English farmers, so tenderly handled in a former chapter of ours, depressed the wages of the agricultural labourers even beneath that mere physical minimum, but made up by Poor Laws the remainder necessary for the physical perpetuation of the race. This was a glorious way to convert the wages labourer into a slave, and Shakespeare's proud yeoman into a pauper.
By comparing the standard wages or values of labour in different countries, and by comparing them in different historical epochs of the same country, you will find that the value of labour itself is not a fixed but a variable magnitude, even supposing the values of all other commodities to remain constant.
A similar comparison would prove that not only the market rates of profit change, but its average rates.
But as to profits, there exists no law which determines their minimum. We cannot say what is the ultimate limit of their decrease. And why cannot we fix that limit? Because although we can fix the minimum of wages, we cannot fix their maximum. We can only say that, the limits of the working day being given, the maximum of profit corresponds to the physical minimum of wages; and that wages being given, the maximum of profit corresponds to such a prolongation of the working day as is compatible with the physical force of the labourer. The maximum of profit is, therefore, limited by the physical minimum of wages and the physical maximum of the working day. It is evident that between the two limits of this maximum rate of profit an immense scale of variations is possible. The fixation of its actual degree is only settled by the continuous struggle between capital and labour, the capitalist constantly tending to reduce wages to their physical minimum, and to extend the working day to its physical maximum, while the working man constantly presses in the opposite direction.
The matter resolves itself into a question of the respective powers of the combatants.
2. As to the limitation of the working day in England, as in all other countries, it has never been settled except by legislative interference. Without the working men's continuous pressure from without, that interference would never have taken place. But at all events, the result was not to be attained by private settlement between the working men and the capitalists. This very necessity of general political action affords the proof that in its merely economic action capital is the stronger side.
As to the limits of the value of labour, its actual settlement always depends upon supply and demand, I mean the demand for labour on the part of capital, and the supply of labour by the working men. In colonial countries the law of supply and demand favours the working man. Hence the relatively high standard of wages in the United States. Capital may there try its utmost. It cannot prevent the labour market from being continuously emptied by the continuous conversion of wages labourers into independent, self-sustaining peasants. The position of a wages labourer is for a very large part of the American people but a probational state, which they are sure to leave within a longer or shorter term. To mend this colonial state of things, the paternal British Government accepted for some time what is called the modern colonization theory, which consists in putting an artificial high price upon colonial land, in order to prevent the too quick conversion of the wages labourer into the independent peasant.
But let us now come to old civilized countries, in which capital domineers over the whole process of production. Take, for example, the rise in England of agricultural wages from 1849 to 1859. What was its consequence? The farmers could not, as our friend Weston would have advised them, raise the value of wheat, nor even its market prices. They had, on the contrary, to submit to their fall. But during these eleven years they introduced machinery of all sorts, adopted more scientific methods, converted part of arable land into pasture, increased the size of farms, and with this the scale of production, and by these and other processes diminishing the demand for labour by increasing its productive power, made the agricultural population again relatively redundant. This is the general method in which a reaction, quicker or slower, of capital against a rise of wages takes place in old, settled countries. Ricardo has justly remarked that machinery is in constant competition with labour, and can often be only introduced when the price of labour has reached a certain height, but the appliance of machinery is but one of the many methods for increasing the productive powers of labour. This very same development which makes common labour relatively redundant simplifies on the other hand skilled labour, and thus depreciates it.
The same law obtains in another form. With the development of the productive powers of labour the accumulation of capital will be accelerated, even despite a relatively high rate of wages. Hence, one might infer, as Adam Smith, in whose days modern industry was still in its infancy, did infer, that the accelerated accumulation of capital must turn the balance in favour of the working man, by securing a growing demand for his labour. From this same standpoint many contemporary writers have wondered that English capital having grown in the last twenty years so much quicker than English population, wages should not have been more enhanced. But simultaneously with the process of accumulation there takes place a progressive change in the composition of capital. That part of the aggregate capital which consists of fixed capital, machinery, raw materials, means of production in all possible forms, progressively increases as compared with the other part of capital, which is laid out in wages or in the purchase of labour. This law has been stated in a more or less accurate manner by Mr. Barton, Ricardo, Sismondi, Professor Richard Jones, Professor Ramsay, Cherbuliez, and others.
If the proportion of these two elements of capital was originally one to one, it will, in the progress of industry, become five to one, and so forth. If of a total capital of 600, 300 is laid out in instruments, raw materials, and so forth, and 300 in wages, the total capital wants only to be doubled to create a demand for 600 working men instead of for 300. But if of a capital of 600, 500 is laid out in machinery, materials, and so forth, and 100 only in wages, the same capital must increase from 600 to 3,600 in order to create a demand for 600 workmen instead of 300. In the progress of industry the demand for labour keeps, therefore, no pace with the accumulation of capital. It will still increase in a constantly diminishing ratio as compared with the increase of capital.
These few hints will suffice to show that the very development of modern industry must progressively turn the scale in favour of the capitalist against the working man, and that consequently the general tendency of capitalistic production is not to raise, but to sink the average standard of wages, or to push the value of labour more or less to its minimum limit. Such being the tendency of things in this system, is this saying that the working class ought to renounce their resistance against the encroachments of capital, and abandon their attempts at making the best of the occasional chances for the temporary improvement? If they did, they would be degraded to one level mass of broken wretches past salvation. I think I have shown that their struggles for the standard of wages are incidents inseparable from the whole wages system, that in 99 cases out of 100 their efforts at raising wages are only efforts at maintaining the given value of labour, and that the necessity of debating their price with the capitalist is inherent in their condition of having to sell themselves as commodities. By cowardly giving way in their every-day conflict with capital, they would certainly disqualify themselves for the initiating of any larger movement.
At the same time, and quite apart from the general servitude involved in the wages system, the working class ought not to exaggerate to themselves the ultimate working of these every-day struggles. They ought not to forget that they are fighting with effects, but not with the causes of those effects; that they are retarding the downward movement, but not changing its direction; that they are applying palliatives, not curing the malady. They ought, therefore, not to be exclusively absorbed in these unavoidable guerilla fights incessantly springing up from the never-ceasing encroachments of capital or changes of the market. They ought to understand that, with all the miseries it imposes upon them, the present system simultaneously engenders the material conditions and the social forms necessary for an economical reconstruction of society. Instead of the conservative motto, "A fair day's wage for a fair day's work!" they ought to inscribe on their banner the revolutionary watchword, "Abolition of the wages system!"
After this very long and, I fear, tedious exposition which I was obliged to enter into to do some justice to the subject matter, I shall conclude by proposing the following resolutions:
Firstly. A general rise in the rate of wages would result in a fall of the general rate of profit, but, broadly speaking, not affect the prices of commodities.
Secondly. The general tendency of capitalist production is not to raise, but to sink the average standard of wages.
Thirdly. Trades Unions work well as centres of resistance against the encroachments of capital. They fail partially from an injudicious use of their power. They fail generally from limiting themselves to a guerilla war against the effects of the existing system, instead of simultaneously trying to change it, instead of using their organized forces as a lever for the final emancipation of the working class, that is to say, the ultimate abolition of the wages system.
3zdoq06t1dwhafann2c7x41decpgu5s
งานแปล:เจ้าชายกบ
114
55343
189482
185363
2022-08-16T16:45:12Z
Venise12mai1834
8884
wikitext
text/x-wiki
{{หัวเรื่องงานแปล
| ชื่อ = {{PAGENAME}}
| ปี = 2417
| ภาษา = en
| ต้นฉบับ = The Frog Prince (1874, Crane)
| ผู้สร้างสรรค์ = | เขียนทับผู้สร้างสรรค์ = โดย {{ลผส|พี่น้องกริมม์}}, ภาพประกอบ โดย {{ลผส|วอลเทอร์ เครน}}
| บรรณาธิการ =
| ส่วน =
| ผู้มีส่วนร่วม =
| ก่อนหน้า =
| ถัดไป =
| หมายเหตุ =
| สถานีย่อย = วรรณกรรมเยาวชน
}}
[[File:The Frog Prince-1875-01.jpg|center|400px]]
{{ตรคป
|{{ก|{{พญ|The Frog Prince.}}|บ=font-size:120%}}
[[File:Yellow Dwarf 1875 02.jpg|center|100px]]
|{{ก|เจ้าชายกบ|บ=font-size:140%}}
[[File:Yellow Dwarf 1875 02.jpg|center|100px]]
|ไม่ย่อหน้า=
}}
{{ตรคป
|{{ขจ|I}}{{พญ|n}} the olden time, when wishing was having, there lived a King, whose daughters were all beautiful; but the youngest was so exceedingly beautiful that the Sun himself, although he saw her very often, was enchanted every time she came out into the sunshine.
|{{ขจ|แ}}ต่ครั้งโบราณ ในกาลที่ยังมีผู้คนคอยอธิษฐานขอพรอยู่ มีพระราชาพระองค์หนึ่งซึ่งมีพระธิดาล้วนสิริโฉมโสภา แต่พระธิดาพระองค์เล็กสุดนั้นสุดเลอลักษณ์ แม้ดวงตะวันเองซึ่งได้ยลเธอเป็นนิตย์ ก็ยังติดใจไม่รู้ลืมทุกคราที่เธอปรากฏองค์ท่ามกลางแสงสูรย์
|ไม่ย่อหน้า=
}}
{{ตรคป
|Near the castle of this King was a large and gloomy forest, and in the midst stood an old lime-tree, beneath whose branches splashed a little fountain; so, whenever it was very hot, the King’s youngest daughter ran off into this wood, and sat down by the side of this fountain; and, when she felt dull, would often divert herself by throwing a golden ball up in the air and catching it. And this was her favourite amusement.
|ใกล้ปราสาทราชวังของพระราชาพระองค์นี้มีป่าใหญ่อึมครึม และใจกลางป่ามีต้นมะนาวเก่าแก่ต้นหนึ่งยืนต้นอยู่ ใต้กิ่งพฤกษานั้นมีน้ำพุลำน้อยคอยกระเซ็นสาย ก็ยามใดที่ร้อนอบอ้าวเหลือใจ พระราชบุตรีพระองค์เล็กมักวิ่งตรงเข้าสู่ป่านี้ แล้วประทับนั่งลงริมสระน้ำพุนี้ และคราใดที่พระทัยหม่นหมอง เธอก็มักคลายอัธยาศัยด้วยการเล่นโยนลูกบอลสีทองขึ้นฟ้าแล้วคว้าไว้ให้ทัน ก็นั่นแหละกิจกรรมเพลิดเพลินสุดโปรดของพระธิดา
}}
{{ตรคป
|Now, one day it happened, that this golden ball, when the King’s daughter threw it into the air, did not fall down into her hand, but on the grass; and then it rolled past her into the fountain. The King’s daughter followed the ball with her eyes, but it disappeared beneath the water, which was so deep that no one could see to the bottom. Then she began to lament, and to cry louder and louder; and, as she cried, a voice called out, “Why weepest thou, O King’s daughter? thy tears would melt even a stone to pity.” And she looked around to the spot whence the voice came, and saw a Frog stretching his thick ugly head out of the water. “Ah! you old water-paddler,” said she, “was it you that spoke? I am weeping for my golden ball, which has slipped away from me into the water.”
|ทีนี้ มีเรื่องเกิดขึ้นในวันหนึ่ง คือว่า เจ้าลูกบอลสีทองนี้ ตอนที่พระธิดาโยนขึ้นฟ้า มันหากลับคืนสู่พระหัตถ์ของเธอไม่ กลับตกลงไปในพงหญ้า แล้วกลิ้งผ่านพระธิดาลงไปในน้ำพุ พระราชบุตรีสอดส่ายสายพระเนตรไปตามลูกบอลที่กลิ้ง แต่มันจมดิ่งหายลงน้ำไป ซึ่งลึกเกินกว่าผู้ใดจะหยั่งเห็นพื้นได้ ดังนั้น เธอจึงตั้งต้นโอดครวญ กันแสงดังขึ้นและดังขึ้นเรื่อย ๆ และในยามที่เธอโทมนัสอยู่นั้น เสียงเสียงหนึ่งพลันดังขึ้นว่า "ดูก่อน พระองค์หญิง เท็จจริงเป็นประการใดจึงมาร่ำไห้ฉะนี้ มิรู้หรือว่า ก้อนศิลาก็มิอาจทนไม่หลอมละลายไปกับน้ำตาของพระองค์" เธอจึงกวาดสายตาไปยังจุดที่เสียงนั้นเปล่งมา และพบกบตัวหนึ่งยื่นหัวอันหนาเตอะเกรอะกรังออกมาจากผิวน้ำ "อ้า เจ้านักประดาน้ำแก่" องค์หญิงตรัส "นั่นเจ้าพูดหรือไร ข้าร้องไห้เพราะลูกบอลทองคำของข้าไหลหลุดจากข้าลงไปในน้ำหรอก"
}}
[[File:The_Frog_Prince-1875-03.jpg|center|400px]]
{{ตรคป
|“Be quiet, and do not cry,” answered the Frog; “I can give thee good advice. But what wilt thou give me if I fetch thy plaything up again? ”
|"เงียบเสีย อย่ากันแสงอีก" เจ้ากบทูล "ข้าพระองค์จะถวายคำแนะนำดี ๆ แต่มีคำถาม คือ พระองค์จะให้อะไรข้า ถ้าข้างมของเล่นของพระองค์กลับคืนขึ้นมาให้"
}}
{{ตรคป
|“What will you have, dear Frog?” said she. “My dresses, my pearls and jewels, or the golden crown which I wear?”
|"อยากได้อะไรเล่า เจ้ากบจ๋า" พระธิดาตรัส "เสื้อผ้าข้ามากมี อัญมณีข้ามากล้น หรือมงกุฎทองอำพนที่ข้าสวมอยู่"
}}
{{ตรคป
|The Frog answered, “Dresses, or jewels, or golden crowns, are not for me; but if thou wilt love me, and let me be thy companion and playfellow, and sit at thy table, and eat from thy little golden plate, and drink out of thy cup, and sleep in thy little bed, — if thou wilt promise me all these, then will I dive down and fetch up thy golden ball.”
|กบทูลตอบ "เสื้อผ้า แก้วแหวน หรือมงกุฎทอง หาใช่ข้าวของสำหรับข้า แต่ทว่า ถ้าพระองค์จะทรงรักข้า และยอมให้ข้าเป็นผู้อยู่คู่เคียง เป็นเพื่อนเล่นคู่ใจ และได้นั่งร่วมโต๊ะเสวย แล้วรับประทานอาหารจากจานทองใบน้อย ๆ ของพระองค์ พร้อมดื่มด่ำน้ำใด ๆ จากแก้วของพระองค์ รวมถึงได้นอนบนเตียงหลังเล็กของพระองค์ ถ้าพระองค์จะทรงสัญญาเรื่องเหล่านี้ทั้งหมดกับข้าแล้วไซร้ ข้าจะดำดิ่งลงไปเก็บกู้ลูกบอลสีทองขึ้นมาให้"
}}
{{ตรคป
|“Oh, I will promise you all,” said she, “if you will only get me my ball.” But she thought to herself, “What is the silly Frog chattering about? Let him remain in the water with his equals; he cannot mix in society.” But the Frog, as soon as he had received her promise, drew his head under the water and dived down. Presently he swam up again with the ball in his mouth, and threw it on the grass. The King’s daughter was full of joy when she again saw her beautiful plaything; and, taking it up, she ran off immediately. “Stop! stop!” cried the Frog; “take me with thee. I cannot run as thou canst.” But all his croaking was useless; although it was loud enough, the King’s daughter did not hear it, but, hastening home, soon forgot the poor Frog, who was obliged to leap back into the fountain.
|"โอ้ ข้ารับคำทั้งหมดนั่นแหละ" เธอว่า "ขอเพียงแต่เจ้าเอาลูกบอลมาให้ข้า" แต่พระธิดาคิดในพระทัยว่า "เจ้ากบโง่ตัวนี้พล่ามอะไร ปล่อยมันอยู่ในน้ำไปกับเพื่อนที่คู่ควรของมันนั่นล่ะ จะมาร่วมสมาคมกับข้าได้ฉันใด" แต่กบนั้น ฉับพลันที่ได้รับคำมั่นจากพระโอษฐ์ ก็กระโดดทิ้งหัวลงน้ำและดำลึกลงไป ชั่วอึดใจมันก็ว่ายกลับขึ้นมาโดยคาบลูกบอลอยู่ในปาก แล้วทิ้งบอลไว้บนผืนหญ้า พระราชบุตรีปีติที่ได้เห็นของเล่นอันตระการของเธออีกครั้ง ทรงเก็บมันขึ้นแล้ววิ่งหายลับไปกับตา "เดี๋ยว ๆ" เจ้ากบร้อง "เอาข้าไปด้วย ข้าวิ่งตามท่านไม่ทันหรอก" แต่จะร้องจนคอแห้งปานใดก็ไร้ผล แม้เสียงจะดังถึงขนาด แต่พระราชธิดาก็ไม่ทรงฟัง กลับหลังแล่นกลับวัง ไม่ช้าก็หลงลืมกบผู้น่าสมเพช ก็จำเป็นที่เจ้ากบจะต้องกระโจนกลับสระไป
}}
[[File:The_Frog_Prince-1875-07.jpg|center|400px]]
{{ตรคป
|The next day, when the King’s daughter was sitting at table with her father and all his courtiers, and was eating from her own little golden plate, something was heard coming up the marble stairs, splish-splash, splish-splash; and when it arrived at the top, it knocked at the door, and a voice said, “Open the door, thou youngest daughter of the King!” So she rose and went to see who it was that called her; but when she opened the door and caught sight of the Frog, she shut it again with great vehemence, and sat down at the table, looking very pale. But the King perceived that her heart was beating violently, and asked her whether it were a giant who had come to fetch her away who stood at the door. “Oh, no!” answered she; “it is no giant, but an ugly Frog.”
|วันถัดมา ขณะที่พระธิดาประทับร่วมโต๊ะกับพระบิดาและข้าหลวงขุนนางของพระองค์ และกำลังทรงอิ่มเอมกับกระยาหารบนจานทองใบน้อย ๆ อยู่นั้นเอง ก็ได้ยินเสียงสิ่งใดสักอย่างย่างขึ้นบันไดหินอ่อนมา ดังกระดึ๊บกระดั๊บ กระโดดกระเด้ง และเมื่อเจ้าสิ่งนั้นมาถึงขั้นบนสุด มันก็หยุดแล้วเคาะประตู ครั้นแล้วก็เปล่งวาจาว่า "เปิดประตูหน่อยเถิดพระเจ้าข้า ฝ่าพระบาทพระราชธิดาพระองค์น้อย" องค์หญิงจึงลุกขึ้นไปดูว่า ใครกันนะที่มาเรียกพระองค์ แต่เมื่อทรงเปิดประตูออกและพบเห็นกบ ก็ทรงปิดกลับดังปังสุดกำลัง แล้วกลับมานั่งที่โต๊ะ มีพระพักตร์ขาวซีดสุดพรรณนา พระบิดาทรงรู้สึกถึงพระทัยของพระธิดาที่กำลังเต้นรัวอย่างรุนแรง จึงถามว่า ผู้มาอยู่หน้าประตูนั้นเป็นยักษ์ร้ายที่หมายมาฉุดคร่าไปหรือไร "โอ้ มิได้เพคะ" พระธิดาตอบ "หาใช่ยักษ์ เป็นกบอัปลักษณ์"
}}
{{ตรคป
|“What does the Frog want with you?” said the King.
|"กบหมายสิ่งใดจากลูกเล่า" พระเจ้าแผ่นดินตรัส
}}
{{ตรคป
|“Oh, dear father, when I was sitting yesterday playing by the fountain, my golden ball fell into the water, and this Frog fetched it up again because I cried so much: but first, I must tell you, he pressed me so much, that I promised him he should be my companion. I never thought that he could come out of the water, but somehow he has jumped out, and now he wants to come in here.
|"โอ้ ทูลกระหม่อมพ่อ วานนี้ตอนที่ลูกนั่งเล่นอยู่ริมสระ บอลทองคำของลูกตกน้ำ และกบตัวนี้งมกลับขึ้นมาให้ เพราะลูกร้องไห้คร่ำครวญเหลือเกิน แต่ลูกขอทูลก่อนว่า เจ้ากบบีบคั้นลูกยิ่งนัก จนลูกรับปากกับมันว่า จะให้มันเป็นคู่เคียงของลูก ลูกไม่คิดเลยว่า มันจะออกจากน้ำได้ แต่จนแล้วจนรอด มันก็กระโจนออกมาได้ และตอนนี้ มันก็อยากเข้ามาในนี้"
}}
{| style="margin-left:auto; margin-right:auto; border:none;"
|-
|[[File:The Frog Prince-1875-12.jpg|center|400px]]
|[[File:The Frog Prince-1875-13.jpg|center|400px]]
|-
|}
{{ตรคป
|At that moment there was another knock, and a voice said,—
|จังหวะนั้นเอง มีเสียงเคาะขึ้นอีก พร้อมเสียงร้องว่า
}}
<table cellspacing="0" style="width:100%;">
<tr>
<td style="width:50%; padding-right:1em; border-right:1px solid gray;" valign="top">
{{กก|{{รมมจ|“King’s daughter, youngest,
|Open the door.
|Hast thou forgotten
|Thy promises made
|At the fountain so clear
|’Neath the lime-tree’s shade?
|King’s daughter, youngest,
|Open the door.”
}}}}
</td>
<td style="width:50%; padding-left:1em;" valign="top">
{| style="margin-left:auto; margin-right:auto; border:none;"
|-style="vertical-align:top;"
|{{ชว}}"องค์หญิงองค์น้อย
|width=10% rowspan=6|
|ค่อยเปิดประตู
|-style="vertical-align:top;"
|เยี่ยมหน้ามาดู
|รับข้าเข้าไป
|-style="vertical-align:top;"
|{{ชว}}หรือลืมคำมั่น
|อันท่านให้ไว้
|-style="vertical-align:top;"
|ณ สระน้ำใส
|ใต้ต้นมะนาว
|-style="vertical-align:top;"
|{{ชว}}โปรดลองตรองตรึก
|รำลึกเรื่องราว
|-style="vertical-align:top;"
|อย่ารอยืดยาว
|เปิดประตูที"
|-
|}
</td>
</tr>
</table>
{{ตรคป
|Then the King said, “What you have promised, that you must perform; go and let him in.” So the King’s daughter went and opened the door, and the Frog hopped in after her right up to her chair: and as soon as she was seated, the Frog said, “Take me up;” but she hesitated so long that at last the King ordered her to obey. And as soon as the Frog sat on the chair, he jumped on to the table, and said, “Now push thy plate near me, that we may eat together.” And she did so, but as everyone saw, very unwillingly. The Frog seemed to relish his dinner much, but every bit that the King’s daughter ate nearly choked her, till at last the Frog said, “I have satisfied my hunger and feel very tired; wilt thou carry me upstairs now into thy chamber, and make thy bed ready that we may sleep together?” At this speech the King’s daughter began to cry, for she was afraid of the cold Frog, and dared not touch him; and besides, he actually wanted to sleep in her own beautiful, clean bed.
|องค์ราชาจึงตรัสว่า "สัญญาอะไรกับใครไว้ ลูกต้องทำตามนั้น ไปรับเขาเข้ามา" ฉะนั้น พระธิดาจึงเสด็จไปเปิดประตู และเจ้ากบก็กระโดดหย่อง ๆ ตามเข้ามาจนถึงพระที่นั่ง และทันทีที่พระธิดาประทับนั่ง กบก็ว่า "เอาข้าขึ้นไปด้วย" แต่เธอประวิงอยู่เป็นนานช้า จนพระราชารับสั่งให้ทำตามนั้น และทันใดที่กบได้นั่งบนพระที่นั่ง มันก็กระโดดขึ้นโต๊ะแล้วว่า "เอาล่ะ เถิบจานมาใกล้ ๆ เราจะได้ร่วมมื้ออาหารกัน" และพระธิดาทำตามนั้น แต่ก็อย่างที่ทุกคนเห็น มิได้เต็มพระทัยสักเท่าใด เจ้ากบเปรมใจไปกับเครื่องต้นอย่างยิ่ง ส่วนพระธิดาก็กล้ำกลืนฝืนกินจนแทบสำลักไปเสียทุกคำ จนที่สุดเจ้ากบก็ว่า "ข้าพระองค์ได้ดับความหิวกระหายสิ้นแล้ว และรู้สึกอ่อนเปลี้ยเพลียแรงเหลือกำลัง จะโปรดอุ้มข้าขึ้นบันไดไปยังห้องพระบรรทม และเตรียมพระแท่นให้พร้อมสรรพ เพื่อที่เราจะได้หลับนอนร่วมกัน ได้ไหมพระเจ้าข้า" ฟังแล้วพระธิดาก็น้ำตาตก เพราะทรงวิตกแขยงที่เจ้ากบตัวเย็นเฉียบ กลัวจนไม่กล้าจับต้องมัน และที่สำคัญ มันอยากนอนเตียงอันวิจิตรหมดจดของเธอจริง ๆ เสียด้วย
}}
{{ตรคป
|But her tears only made the King very angry, and he said, “He who helped you in the time of your trouble, must not now be despised!” So she took the Frog up with two fingers, and put him in a corner of her chamber. But as she lay in her bed, he crept up to it, and said, “I am so very tired that I shall sleep well; do take me up or I will tell thy father.” This speech put the King’s daughter in a terrible passion, and catching the Frog up, she threw him with all her strength against the wall, saying, “Now, will you be quiet, you ugly Frog?”
|แต่น้ำพระเนตรพระธิดาทำให้พระราชาพิโรธนัก ตรัสว่า "ใครช่วยเจ้าไว้ในยามทุกข์ร้อน ก็อย่าไปรังเกียจรังงอนเขา" เพราะฉะนั้น พระธิดาจึงพากบขึ้นไปด้วยนิ้วสองนิ้ว แล้ววางกบไว้ ณ มุมหนึ่งของห้อง แต่เมื่อเธอนอนลงบนเตียง เจ้ากบก็ไต่ขึ้นเตียงแล้วทูลว่า "ข้าพระองค์เหนื่อยนักใคร่พักผ่อน อยากแผ่นอนให้เต็มเม็ดเต็มหน่วย จงพาข้าขึ้นเตียงพระองค์ด้วย ไม่ช่วยแล้วจะฟ้องพระบิดา" คำพูดนี้ยังให้พระราชบุตรีโกรธเป็นกำลัง คว้ามันขึ้นแล้วโยนมันใส่กำแพงเต็มกำลัง พลางว่า "ทีนี้เงียบได้หรือยัง เจ้ากบน่าเกลียด"
}}
[[File:The Frog Prince-1875-18.jpg|center|400px]]
{{ตรคป
|But as he fell he was changed from a frog into a handsome Prince with beautiful eyes, who, after a little while became, with her father’s consent, her dear companion and betrothed. Then he told her how he had been transformed by an evil witch, and that no one but herself could have had the power to take him out of the fountain; and that on the morrow they would go together into his own kingdom.
|แต่เมื่อกบร่วงลง มันก็เปลี่ยนร่างจากกบเป็นเจ้าชายหล่อเหลา ดวงตาเกลี้ยงเกลา ผู้ซึ่งต่อมาได้กลายเป็นคู่เคียงและคู่หมั้นของพระธิดาโดยราชานุมัติของพระบิดาเธอ ครั้นแล้ว เจ้าชายผู้นั้นก็เล่าให้เธอฟังถึงเรื่องที่พระองค์ถูกแม่มดร้ายกลายร่าง และไม่มีใครเลยนอกจากพระธิดาที่จะพาพระองค์ออกจากสระน้ำพุได้ และยังว่า วันรุ่งพรุ่งนี้ จะจรลีไปเยือนแว่นแคว้นของพระองค์กัน
}}
{{ตรคป
|The next morning, as soon as the sun rose, a carriage drawn by eight white horses, with ostrich feathers on their heads, and golden bridles, drove up to the door of the palace, and behind the carriage stood the trusty Henry, the servant of the young Prince. When his master was changed into a frog, trusty Henry had grieved so much that he had bound three iron bands round his heart, for fear it should break with grief and sorrow. But now that the carriage was ready to carry the young Prince to his own country, the faithful Henry helped in the bride and bridegroom, and placed himself in the seat behind, full of joy at his master’s release. They had not proceeded far when the Prince heard a crack as if something had broken behind the carriage; so he put his head out of the window and asked Henry what was broken, and Henry answered, “It was not the carriage, my master, but a band which I bound round my heart when it was in such grief because you were changed into a frog.”
|เช้าวันถัดมา ทันทีที่ดวงสุริยาขึ้นเฉิดฉาย รถม้าเทียมม้าขาวแปดตัว ประดับขนนกกระจอกเทศบนหัว พร้อมบังเหียนทองคำ ก็ย่ำฝีเท้ามาจนถึงพระทวารพระราชวัง ท้ายรถมีราชวัลลภเฮนรี บริพารของเจ้าชายหนุ่ม ยืนอยู่ คราวที่เจ้าชายผู้เป็นนายกลับกลายร่างเป็นกบนั้น ราชวัลลภเฮนรีโศกาจาบัลย์เป็นที่ยิ่ง จนกริ่งเกรงว่า อกจะแตกตายเพราะความวิปโยคโศกตรม จึงตรึงโลหะสามแผ่นไว้กับราวนมตลอดมา ทว่าบัดนี้ ราชรถพร้อมพาเจ้าชายหนุ่มเสด็จคืนบ้านเมืองของพระองค์เองแล้ว เฮนรีผู้ภักดีจึงคอยประคองคู่บ่าวสาวและนั่งประจำท้ายโดยเปี่ยมปีติที่ผู้เป็นนายพ้นมนต์สะกด ราชรถดำเนินไปได้ไม่ไกล เจ้าชายก็ได้ยินเสียงปริแตกดั่งมีอันใดหักพังอยู่ท้ายรถ พระองค์จึงทรงชะโงกออกมาจากพระบัญชร แล้วตรัสถามเฮนว่า อะไรแตกหักหรือ เฮนรีทูลตอบว่า "ที่แตกสลายมิใช่ราชรถหรอกพระเจ้าข้า หากเป็นแผ่นเหล็กที่ข้าผูกรัดไว้รอบอกเมื่อคราวโศกตรมเพราะทรงกลายเป็นกบ"
}}
[[File:The_Frog_Prince-1875-22.jpg|center|400px]]
{{ตรคป
|Twice afterwards on the journey there was the same noise, and each time the Prince thought that it was some part of the carriage that had given way; but it was only the breaking of the bands which bound the heart of the trusty Henry, who was thenceforward free and happy.
|ระหว่างทางเสด็จหลังจากนั้น ก็มีเสียงอย่างเดียวกันบังเกิดขึ้นอีกสองครั้ง และทุกครั้งเจ้าชายจะทรงนึกว่า ราชรถคงแตกพังลงบางจุด แต่ที่สุดแล้วเป็นเพียงการแตกสลายไปของแผ่นโลหะที่ตราตรึงรอบอกราชวัลลภเฮนรี ผู้นับแต่นั้นมีแต่ความยินดีปรีดิ์เปรม
}}
[[File:Yellow Dwarf 1875 02.jpg|center|100px]]
==บรรณานุกรม==
{{รออ}}
* {{อนส|author=Brothers Grimm|year=1874|title=[[:File:The Frog Prince-1874.djvu|The Frog Prince]]|location=London|publisher=George Routledge and Sons}}
{{จออ}}
{{สัญญาอนุญาตงานแปล
| {{สาธารณสมบัติ-สหรัฐ|1914}}
| {{สาธารณสมบัติ-เอง}}
}}
[[หมวดหมู่:หนังสือภาพ]]
aq4nccrqiqtgxirdf363h3aerfb838p
งานแปล:โฉมงามกับอสูร
114
55413
189490
185361
2022-08-16T16:59:17Z
Venise12mai1834
8884
wikitext
text/x-wiki
{{หัวเรื่องงานแปล
| ชื่อ = {{PAGENAME}}
| ปี = 2417
| ภาษา = en
| ต้นฉบับ = Beauty_and_the_Beast_(1874,_Crane)
| ผู้สร้างสรรค์ = | เขียนทับผู้สร้างสรรค์ = โดย {{ลผส|กราบรีแยล-ซูซาน เดอ วีย์เนิฟ}}, ภาพประกอบ โดย {{ลผส|วอลเทอร์ เครน}}
| บรรณาธิการ =
| ส่วน =
| ผู้มีส่วนร่วม =
| ก่อนหน้า =
| ถัดไป =
| หมายเหตุ =
| สถานีย่อย = วรรณกรรมเยาวชน
}}
[[File:Beauty_and_the_Beast-1874-01.jpg|400px|center]]
{{ตรคป
|{{ก|{{พญ|Beauty and the Beast.}}|บ=font-size:120%}}
[[File:Yellow Dwarf 1875 02.jpg|center|100px]]
|{{ก|โฉมงามกับอสูร|บ=font-size:140%}}
[[File:Yellow Dwarf 1875 02.jpg|center|100px]]
|ไม่ย่อหน้า=
}}
{{ตรคป
|{{ขจ|O}}{{พญ|nce}} upon a time a rich Merchant, meeting with heavy losses, had to retire to a small cottage, with his three daughters. The two elder grumbled at this; but the youngest, named Beauty, tried to comfort her father and make his home happy. Once, when he was going on a journey, to try to mend his fortunes, the girls came to wish him good-bye; the two elder told him to bring them some nice presents on his return, but Beauty merely begged of him to bring her a rose. When the Merchant was on his way back he saw some fine roses, and thinking of Beauty, plucked the prettiest he could find. He had no sooner taken it than he saw a hideous Beast, armed with a deadly weapon. This fierce-looking creature asked him how he dared to touch his flowers, and talked of putting him to death. The Merchant pleaded that he only took the rose to please his daughter Beauty, who had begged of him to get her one.
|{{ขจ|ก}}าลครั้งหนึ่ง พ่อค้าผู้มั่งมีต้องหลีกรี้ไปอยู่กระท่อมน้อยกับลูกสาวทั้งสามของตนเพราะผจญความขาดทุนย่อยยับ เรื่องนี้นับเป็นที่โอดครวญของลูกสาวสองคนแรก แต่คนสุดท้อง ผู้ครองนามว่า โฉมงาม พยายามปลอบประโลมบิดาและทำให้บ้านคงเป็นบ้านอันสุขสันต์ ครั้งหนึ่งในคราวที่พ่อค้าออกเดินทางเพื่อหาทางกอบกู้ความมั่งคั่ง บุตรสาวก็พากันมาอำลา ธิดาสองคนแรกขอให้พ่อนำของขวัญชั้นดีกลับมาให้พวกตนด้วย ส่วนโฉมงามขอให้พ่อเพียงนำกุหลาบสักดอกมาให้ ฉะนั้น ในคราขากลับ เมื่อพ่อค้าเห็นกุหลาบงาม ๆ และนึกถึงโฉมงาม จึงดึงดอกที่พริ้งเพราที่สุดที่ตนจะหาได้ออกมา แต่เด็ดกุหลาบได้ไม่นาน เขาก็พานพบอสูรร้าย มีอาวุธอันตรายพร้อมมือ เจ้าสัตว์หน้าตาป่าเถื่อนตนนี้ถามเขาว่า กล้าดีเช่นไรจึงแตะต้องดอกไม้ของมัน และพร่ำรำพันว่า มันจะฆ่าพ่อค้าเสีย พ่อค้าจึงอ้อนวอนว่า ตนเพียงเอากุหลาบไปเพื่อเป็นที่ชื่นชูใจของโฉมงาม บุตรสาวผู้ขอให้นำกลับมาให้สักดอก
|ไม่ย่อหน้า=
}}
[[File:Beauty_and_the_Beast-1874-03.jpg|400px|center]]
{{ตรคป
|On this, the Beast said gruffly, “Well, I will not take your life, if you will bring one of your daughters here to die in your stead. She must come willingly, or I will not have her. You may stay and rest in my palace until to-morrow.” Although the Merchant found an excellent supper laid for him, he could not eat; nor could he sleep, although everything was made ready for his comfort. The next morning he set out on a handsome horse, provided by the Beast.
|ได้ฟังดังนี้ เจ้าปีศาจก็กล่าวด้วยเสียงแหบห้าวว่า "ได้ ข้าจะไม่เอาชีวิตเจ้า หากเจ้าเอาลูกสาวคนหนึ่งมาที่นี่เพื่อเป็นตัวตายตัวแทนเจ้า นางจักต้องมาด้วยความเต็มใจ หาไม่แล้วข้าก็ไม่เอา เจ้าจะอยู่และพำนักในตำหนักของข้าได้จนถึงวันรุ่งพรุ่งนี้" แม้พ่อค้าจะพบว่า มีมื้อค่ำอันล้ำเลิศจัดแจงไว้ให้ เขาก็กินไม่ลง และแม้ทุกอย่างจะเตรียมไว้พร้อมสรรพเพื่อรองรับความสะดวกสบายของเขา เขาก็หลับไม่ลง เช้าวันถัดมา เขาออกเดินทางมาบนหลังม้าตัวงามที่อสูรจัดให้
}}
{{ตรคป
|When he came near his house his children came out to greet him. But seeing the sadness of his face, and his eyes filled with tears, they asked the cause of his trouble. Giving Beauty the rose, he told her all. The two elder sisters laid all the blame on Beauty; but his sons, who had come from the forest to meet him, declared that they would go to the Beast instead. But Beauty said that as she was the cause of this misfortune, she alone must suffer for it, and was quite willing to go; and, in spite of the entreaties of her brothers, who loved her dearly, she set out with her father, to the secret joy of her two envious sisters.
|ครั้นพ่อค้ามาจวนถึงบ้าน ลูกหลานก็ออกมารับ แต่เมื่อเห็นใบหน้าสลดของบิดาพร้อมน้ำตาท่วมตา พวกเขาก็ถามถึงสาเหตุแห่งความทุกข์ร้อน พ่อค้ามอบกุหลาบให้โฉมงามแล้วเล่าให้เธอฟังทุกเรื่องราว สองศรีพี่สาวกล่าวโทษโฉมงามในสิ่งทั้งหลาย แต่ลูกชายของพ่อค้า ซึ่งเดินทางจากป่ามาเยี่ยม ออกตัวว่าจะไปหาอสูรแทนเอง อย่างไรก็ตาม โฉมงามกล่าวว่า เพราะเธอเป็นต้นเค้าแห่งคราวเคราะห์ครั้งนี้ เธอผู้เดียวที่จะต้องทนรับมัน ดังนั้น เธอจึงออกจะเต็มใจไป และแม้พี่ชายผู้รักเธอสุดดวงใจจะอ้อนวอนปานใด เธอก็ออกเดินทางไปพร้อมกับบิดา โดยพี่สาวผู้มีจิตริษยาทั้งสองนั้นแอบดีใจกัน
}}
[[File:Beauty_and_the_Beast-1874-07.jpg|400px|center]]
{{ตรคป
|When they arrived at the palace the doors opened of themselves; sweet music was heard, and they walked into a room where supper was prepared. Just as they had eaten their supper, the Beast entered, and said in a mild tone, “Beauty, did you come here willingly to die in place of your father?” “Willingly,” she answered, with a trembling voice. “So much the better for you,” said the Beast; “your father can stay here to-night, but must go home on the following morning.” Beauty tried to cheer her father, at parting, by saying that she would try to soften the heart of the Beast, and get him to let her return home soon. After he was gone, she went into a fine room, on the door of which was written, in letters of gold, “Beauty’s Room;” and lying on the table was a portrait of herself, under which were these words: “Beauty is Queen here; all things will obey her.” All her meals were served to the sound of music, and at supper-time the Beast, drawing the curtains aside, would walk in, and talk so pleasantly that she soon lost much of her fear of him. At last, he turned towards her, and said, “Am I so very ugly?” “Yes, indeed you are,” replied Beauty, “but then you are so kind that I don’t mind your looks.” “Will you marry me, then?” asked he. Beauty, looking away, said, “Pray don’t ask me.” He then bade her “Good-night” with a sad voice, and she retired to her bed-chamber.
|ครั้นพวกเขามาถึงวังอสูร ประตูก็เปิดออกเอง ดนตรีก็บรรเลงหวานละไม พวกเขาจึงเดินเข้าไปในห้องอันมีอาหารค่ำเตรียมไว้รอ พอพวกเขาลงมือรับประทาน อสูรก็เข้ามาและเอ่ยวาจาด้วยเสียงนุ่มนวลว่า "เจ้าโฉมงาม มาตายแทนพ่อที่นี่ด้วยความยินดีหรือไร" นางตอบด้วยน้ำเสียงสั่นเครือว่า "ข้ายินดี" "ได้เจ้ามาย่อมดีกว่าเป็นไหน ๆ" อสูรว่า "บิดาเจ้าอยู่นี่ได้แต่ในคืนนี้ พอรุ่งพรุ่งนี้จักต้องกลับบ้าน" ยามจากกัน โฉมงามพยายามทำให้บิดาชื่นบานโดยกล่าวว่า จะลองผ่อนคลายความหยาบกระด้างในจิตใจอสูรและให้อสูรปล่อยนางกลับบ้านในไม่ช้า เมื่อบิดาจากไปแล้ว โฉมงามก็เข้าไปในห้องโอ่อ่าแห่งหนึ่ง ซึ่งมีอักษรสีทองเขียนไว้บนประตูว่า "ห้องของโฉมงาม" และมีภาพเหมือนของเธอเองตั้งอยู่บนโต๊ะ ใต้ภาพนั้นมีข้อความว่า "โฉมงามเป็นใหญ่ในที่นี้ ทุกชีวีจงเชื่อฟังถ้อยคำนาง" ทุกมื้อของโฉมงามนั้นจัดเข้ามาให้พร้อมเสียงดนตรีคลอ และในมื้อค่ำ อสูรจะเลิกผ้าม่านออกแล้วเดินเข้ามาก่อนเจรจาหวานซึ้ง ไม่ช้าโฉมงามก็หมดสิ้นซึ่งความหวาดกลัวในอสูร จนที่สุดอสูรก็หันเข้าหาโฉมงามแล้วพร่ำถามว่า "ข้าน่าเกลียดนักหรือ" "ใช่ ท่านเป็นเช่นนั้น" โฉมงามตอบ "แต่แล้ว ท่านก็กลับกลายเป็นใจดี จนข้าไม่ไยดีในรูปกายท่านอีก" "แล้วจะแต่งงานกับข้าได้ไหม" อสูรถาม โฉมงามมองไปทางอื่นพลางว่า "โปรดอย่าถามอีก" อสูรจึงบอกลา "ราตรีสวัสดิ์" ด้วยซุ่มเสียงโศกซึม และแล้ว นางก็จากลาไปห้องนิทรา
}}
{| style="margin-left:auto; margin-right:auto; border:none;"
|-
|[[File:Beauty_and_the_Beast-1874-12.jpg|center|400px]]
|[[File:Beauty_and_the_Beast-1874-13.jpg|center|400px]]
|-
|}
{{ตรคป
|The palace was full of galleries and apartments, containing the most beautiful works of art. In one room was a cage filled with rare birds. Not far from this room she saw a numerous troop of monkeys of all sizes. They advanced to meet her, making her low bows. Beauty was much pleased with them, and said she would like some of them to follow her and keep her company. Instantly two tall young apes, in court dresses, advanced, and placed themselves with great gravity beside her, and two sprightly little monkeys took up her train as pages. From this time the monkeys always waited upon her with all the attention and respect that officers of a royal household are accustomed to pay to queens.
|วังอสูรพร้อมมูลด้วยห้องยาวและห้องแถวซึ่งมีศิลปวัตถุสุดวิจิตร ในห้องหนึ่งมีกรงขังนกหายาก ไม่ไกลจากห้องนี้โฉมงามเห็นลิงฝูงหนึ่งซึ่งมีครบทุกขนาด พวกมันเข้ามาพบเธอพลางโค้งคำนับให้เธอ โฉมงามยินดีที่ได้พบเจอเหล่าลิงยิ่งนัก และออกปากอยากได้ลิงบางตัวมาเป็นผู้ติดตามใกล้ชิด ทันใดนั้น วานรหนุ่มรูปร่างสูงสองตัว แต่งชุดราชสำนัก ก็เข้ามาพิทักษ์เคียงข้างอย่างเคร่งขรึมเป็นที่สุด พร้อมลิงน้อยปราดเปรียวอีกสองตัวก็เข้ามาตามประจำเหมือนมหาดเล็ก นับแต่นี้ไป เจ้าลิงก็คอยปรนนิบัติโฉมงามด้วยความเคารพและเอาใจใส่ทุกประการดังที่ข้าราชบริพารพึงมีต่อราชินี
}}
[[File:Beauty_and_the_Beast-1874-18.jpg|400px|center]]
{{ตรคป
|Beauty was now, in fact, quite the Queen of the palace, and all her wishes were gratified; but, excepting at supper-time, she was always alone; the Beast then appeared, and behaved so agreeably that she liked him more and more. But to his question, “Beauty, will you marry me?” he never could get any other answer than a shake of the head from her, on which he always took his leave very sadly.
|บัดนี้ อันที่จริง โฉมงามเป็นยิ่งราชินีแห่งวังอสูร และเธอประสงค์สิ่งใด ก็จักได้สิ่งนั้นทุกอย่าง ยกเว้นเสียแต่ในมื้อค่ำที่ต้องอยู่ลำพังร่ำไป แต่แล้ว อสูรก็ปรากฏตัวและประพฤติตัวน่ารักใคร่เสียจนเธอมีใจให้มากขึ้น ๆ กระนั้น เมื่ออสูรถาม "โฉมงาม แต่งงานกันได้ไหม" อสูรก็ไม่เคยได้คำตอบอื่นนอกจากการส่ายหัวจากเธอ ซึ่งเมื่อเป็นเช่นนั้นแล้ว อสูรก็จะขอตัวลาจากไปด้วยหัวใจเศร้าซึมเสมอ
}}
{{ตรคป
|Although Beauty had everything she could wish for she was not happy, as she could not forget her father, and brothers, and sisters. At last, one evening, she begged so hard of the Beast to let her go home that he agreed to her wish, on her promising not to stay away longer than two months, and gave her a ring, telling her to place it on her dressing-table whenever she desired to go or to return; and then showed her where to find suitable clothes, as well as presents to take home. The poor Beast was more sad than ever. She tried to cheer him, saying, “Beauty will soon return,” but nothing seemed to comfort him. Beauty then went to her room, and before retiring to rest she took care to place the ring on the dressing-table. When she awoke next morning, what was her joy at finding herself in her father’s house, with the gifts and clothes from the palace at her bed-side.
|แม้โฉมงามจะมีทุกอย่างที่หวังจะมีได้ แต่เธอก็ไร้ซึ่งความสุข เพราะลืมพ่อ พี่ชาย และพี่สาวไม่ลง ที่สุดแล้ว เย็นวันหนึ่ง เธอจึงวิงวอนอย่างหนักต่ออสูรให้ปล่อยเธอกลับบ้าน จนอสูรอนุญาตตามที่ขอ โดยมีข้อสัญญาว่า เธอจะไม่จากไปไกลเกินกว่าสองเดือน และอสูรมอบแหวนวงหนึ่งให้เธอ บอกเธอว่า ยามใดประสงค์จะจากไปหรือกลับมา จงวางแหวนนี้ไว้บนโต๊ะเครื่องแป้ง จากนั้น อสูรนำพาเธอไปดูเสื้อผ้าอันสมฐานะ กับทั้งของขวัญสำหรับนำกลับบ้าน สงสารก็แต่อสูรที่มิเคยอาดูรถึงเพียงนี้ เธอพยายามที่จะทำให้อสูรเบิกบานโดยกล่าวว่า "เดี๋ยวโฉมงามก็กลับมาแล้ว" แต่ดูจะไม่ช่วยประโลมจิตใจอสูรแม้แต่น้อย โฉมงามจึงค่อยกลับคืนไปยังห้อง และก่อนจะล่องลอยเข้าสู่ห้วงนิทรา ก็ไม่ลืมว่าต้องวางแหวนไว้บนโต๊ะเครื่องแป้ง เมื่อเธอตื่นจากหลับใหลในเช้าวันถัดมา ก็ยินดีปรีดาที่พบว่า ตนอยู่ที่บ้านของบิดาแล้ว ข้างเตียงมีของขวัญของฝากหลากผ้าอาภรณ์จากวังวางอยู่
}}
{{ตรคป
|At first she wondered where she was; but she soon heard the voice of her father, and, rushing out, she flung her arms round his neck. The father and daughter had much to say to each other. Beauty related all that had happened to her at the palace. Her father, enriched by the liberality of the Beast, had left his old house, and now lived in a very large city, and her sisters were engaged to be married to young men of good family.
|ทีแรก โฉมงามฉงนใจว่ากำลังอยู่ที่ใด แต่ทันทีที่ได้ยินเสียงพ่อ เธอก็โผเข้ากอดคอทันควัน พ่อลูกต่างมีเรื่องให้พูดคุยกันไม่น้อย โฉมงามเรียงร้อยเรื่องราวทั้งหมดที่เกิดขึ้นแก่เธอในวังอสูรให้ฟัง ส่วนบิดาซึ่งบัดนี้ร่ำรวยขึ้นด้วยน้ำใจของอสูรก็ลาจากบ้านเก่าเข้าไปอยู่ในนครโอฬาร และบรรดาพี่สาวของโฉมงามก็หมั้นหมายกับชายหนุ่มจากตระกูลผู้ดีแล้ว
}}
{{ตรคป
|When she had passed some weeks with her family, Beauty found that her sisters, who were secretly vexed at her good fortune, still looked upon her as a rival, and treated her with coldness. Besides this, she remembered her promise to the Beast, and resolved to return to him. But her father and brothers begged her to stay a day or two longer, and she could not resist their entreaties. But one night she dreamed that the poor Beast was lying dead in the palace garden; she awoke in a fright, looked for her ring, and placed it on the table. In the morning she was at the Palace again, but the Beast was nowhere to be found: at last she ran to the place in the garden that she had dreamed about, and there, sure enough, the poor Beast was, lying senseless on his back.
|เมื่อเธอใช้เวลากับครอบครัวไปได้หลายสัปดาห์ โฉมงามก็พบว่า พี่สาวผู้แอบเป็นเดือดเป็นร้อนในความวาสนาดีของเธอ ยังคงมองเธอดั่งศัตรูคู่อาฆาต และปฏิบัติต่อเธอด้วยความเย็นชา นอกจากนี้ เธอจำได้ว่า สัญญาอะไรกับอสูรไว้ และตัดสินใจจะกลับไปหาอสูร แต่พ่อกับพี่ชายรั้งไว้ให้อยู่ด้วยกันอีกสักวันสองวัน และเธอก็ขัดคำอ้อนวอนของเขาเหล่านั้นมิได้ อย่างไรก็ดี ในราตรีหนึ่ง เธอฝันถึงอสูรผู้น่าสงสารว่า มันกำลังนอนตายอยู่ในอุทยานของวัง เธอสะดุ้งตื่นขึ้น มองหาแหวน แล้ววางแหวนไว้บนโต๊ะ ครั้นรุ่งเช้า เธอก็กลับเข้ามาอยู่ในวังอีกครั้ง แต่เจ้าอสูรจะอยู่หนใดก็ไม่พบ จนที่สุดเธอวิ่งตลบเข้าไปในอุทยานตรงจุดที่เธอฝันถึง ซึ่งก็เป็นจริงตามนั้น ที่ตรงนั้นมีอสูรผู้น่าเห็นใจนอนหงายไร้สติสมประดีอยู่
}}
[[File:Beauty_and_the_Beast-1874-22.jpg|400px|center]]
{{ตรคป
|At this sight Beauty wept and reproached herself for having caused his death. She ran to a fountain and sprinkled his face with water. The Beast opened his eyes, and as soon as he could speak, he said, sorrowfully, “Now that I see you once more, I die contented.” “No, no!” she cried, “you shall not die! Oh, live to be my husband, and Beauty will be your faithful wife!” The moment she had uttered these words, a dazzling light shone everywhere; the Palace windows glittered with lamps, and music was heard around. To her great wonder, a handsome young Prince stood before her, who said that her words had broken the spell of a magician, by which he had been doomed to wear the form of a Beast, until a beautiful girl should love him in spite of his ugliness. The grateful Prince now claimed Beauty as his wife. The Merchant was soon informed of his daughter’s good fortune, and the Prince was married to Beauty on the following day.
|เห็นเช่นนี้แล้ว โฉมงามก็คร่ำครวญและโทษตนเองว่าเป็นต้นเหตุให้อสูรตาย เธอวิ่งไปยังน้ำพุแล้วนำน้ำมาพรมใบหน้าอสูร อสูรลืมตาขึ้น และทันทีที่พูดออก ก็บอกกล่าวอย่างเศร้าตรมว่า "เพราะข้าได้เห็นเจ้าอีก ข้าตายก็ไม่เสียดายแล้ว" "ไม่ ๆ" โฉมงามร้อง "ท่านต้องไม่ตาย โอ้ โปรดอยู่เป็นคู่เคียงข้า และข้า โฉมงาม จะเป็นภริยาที่ซื่อตรงต่อท่าน" วินาทีที่เธอกล่าวถ้อยคำเหล่านี้ มีแสงสกาวพราวฉายไปทั้งบริเวณ หน้าต่างวังก็สว่างวับไปกับแสงตะเกียง และดุริยสำเนียงก็ได้ยินทั่วกัน พลันก็นำความประหลาดใจใหญ่หลวงมาให้เธอ เมื่อได้เห็นเจ้าชายหนุ่มรูปงามองค์หนึ่งประทับยืนอยู่เบื้องหน้า เอื้อนเอ่ยวาจาว่า ถ้อยคำของเธอนั้นลบล้างมนต์สะกดของผู้วิเศษที่สาปพระองค์ไว้ให้อยู่ในร่างอสูร จนกว่าสาวงามจะรักพระองค์แม้จะทรงอัปลักษณ์สักเพียงใด บัดนี้ เจ้าชายผู้มีความซาบซึ้งใจก็ได้โฉมงามมาครองเป็นชายา ไม่ช้าพ่อค้าได้รับแจ้งข่าวคราวความวาสนาดีของบุตรีแห่งตน และเจ้าชายก็เสกสมรสกับโฉมงามในวันถัดมา
}}
[[File:Yellow Dwarf 1875 02.jpg|center|100px]]
==บรรณานุกรม==
{{รออ}}
* {{อนส|last=Villeneuve|first=Gabrielle-Suzanne de|year=1874|title=[[:File:Beauty and the Beast-1874.djvu|Beauty and the Beast]]|location=London|publisher=George Routledge and Sons}}
{{จออ}}
{{สัญญาอนุญาตงานแปล
| {{สาธารณสมบัติ-สหรัฐ|1914}}
| {{สาธารณสมบัติ-เอง}}
}}
[[หมวดหมู่:หนังสือภาพ]]
ee2fwyjfjl8o70o1rvmvq0857cbo6wh
ผู้ใช้:Noktonissian/ทดลองเขียน/นัคครคุรุประเทษ
2
56166
189464
184251
2022-08-16T16:18:42Z
Venise12mai1834
8884
ปิดหมวดหมู่ในหน้าส่วนตัว
wikitext
text/x-wiki
{{หน้าทดลองเขียน}}
<pre>
{{หัวเรื่องงานแปล
<!-- ข้อมูลหลัก -->
| ชื่อ = [[ดัชนี:ᩉ᩠ᨶ᩠ᨦᩢᩈᩨᨶᨣ᩠ᨣᩁᨣᩩᩁᩩᨷᩕᨴᩮ᩠ᩇ Lao Geography.pdf|{{PAGENAME}}]]
| ปี = | เขียนทับปี = ค.ศ. 1896
| ภาษา = nod
| ต้นฉบับ =
| ผู้สร้างสรรค์ = คอร์นีเลีย แมคกิลวารี
| บรรณาธิการ =
| ส่วน =
| ผู้มีส่วนร่วม =
| ก่อนหน้า =
| ถัดไป = [[/บท ๑|บท ๑ ว่าด้วยแผ่นดีนโลก]]
| หมายเหตุ = เป็นการแปลแบบกึ่งปริวรรต โดยจะยังรักษารูปแบบการสะกดคำจากภาษาล้านนาดั้งเดิม แต่ปรับอักขรวิธีให้ใกล้เคียงภาษาไทยมาตรฐานเพื่อให้ง่ายต่อการอ่าน
}}
</pre>
{{ตรคป
| <pages index="ᩉ᩠ᨶ᩠ᨦᩢᩈᩨᨶᨣ᩠ᨣᩁᨣᩩᩁᩩᨷᩕᨴᩮ᩠ᩇ Lao Geography.pdf" include="1" />
| {{center|
หนังสือนัคครคุรุประเทษ
{{larger|ภูมิศาสตร์ภาษาลาว}}<ref>ในที่นี้หมายถึงภาษาล้านนา หรือคำเมือง ซึ่งในสมัยนั้นข้าราชการสยามและมิชชันนารีชาวต่างประเทศนิยมเรียกว่าภาษาลาว</ref>
{{Custom rule|sp|100|d|6|sp|10|d|10|sp|10|d|6|sp|100}}
เรียบเรียงโดย ซี. เอช. แมคกิลวารี<ref>คอร์นีเลีย แมคกิลวารี ภรรยาของศานาจารย์วิลเลียม แฮรีส (William Harris) อาจารย์ใหญ่ของโรงเรียนชายวังสิงห์คำ (ปัจจุบันคือโรงเรียนปรินส์รอแยลส์วิทยาลัย จังหวัดเชียงใหม่) ในขณะนั้น (ปี พ.ศ. 2439) เธอยังเป็นหลานสาวของ[[th:w:แดน บีช แบรดลีย์|หมอบรัดเลย์]] ผู้บุกเบิกการพิมพ์ในสยาม</ref>, โดยความช่วยเหลือจาก ศิษยาภิบาลหนานตา และ อินตา
{{Custom rule|sp|100|d|6|sp|10|d|10|sp|10|d|6|sp|100}}
เตกพิมที่บ้านวังสีงฅำเชียงไหม่<ref>โรงพิมพ์ของคริสตจักรคณะเพรสไบทีเรียน ณ บ้านวังสิงห์คำ ปัจจุบันอยู่ใน อ.เมืองเชียงใหม่</ref>
คริษสักราช ๑๘๙๖<ref>พ.ศ. 2439</ref>
}}
}}
{{page break|label=}}
{{AuxTOC|
*[[/บท ๑|บท ๑ ว่าด้วยแผ่นดีนโลก]]
**[[/บท ๑#p3-1|ว่าด้วยรักขณรูปล่างแห่งแผ่นดีนโลกนี้]]
**[[/บท ๑#p3-2|ว่าด้วยแผ่นดีนโลกนี้ผัดหมูน]]
**[[/บท ๑#p4-1|ว่าด้วยแผ่นดีนโลกนี้เวียนรอบดวงอาทิต]]
**[[/บท ๑#p4-2|ว่าด้วยแลทิธูด]]
**[[/บท ๑#p6-1|ว่าด้วยลอนจิธูด]]
**[[/บท ๑#p7-1|ว่าด้วยระดู]]
**[[/บท ๑#p7-2|ว่าด้วยโฌ่น]]
**[[/บท ๑#p9-1|ว่าด้วยส่วนแผ่นดิน]]
**[[/บท ๑#p10-1|ว่าด้วยส่วนน้ำ]]
*[[/บท ๒|บท ๒ ว่าด้วยฅนมนุสส์]]
**ว่าด้วยฅนมนุสส์
**ว่าด้วยสาสนา
**ว่าด้วยผู้ครอบครอง
*[[/บท ๓|บท ๓ ว่าด้วยทีปอาเซีย]]
**ว่าด้วยทีปอาเซีย
**ว่าด้วยประเทศซายบีเรีย
**ว่าด้วยประเทศจีน
**ว่าด้วยประเทศโฅเรีย
**ว่าด้วยประเทศยี่ปู่น
**ว่าด้วยเมืองยวนแลเมืองขระเหมน
**ว่าด้วยประเทศสยาม
**ว่าด้วยประเทศภม่าแลประเทศอิณเดีย
**ว่าด้วยเกาะลํกา
**ว่าด้วยประเทศเบลูชิสสทาน
**ว่าด้วยประเทศฟารัศ
**ว่าด้วยประเทศอะราเบีย
**ว่าด้วยประเทศเธอเค
*[[/บท ๔|บท ๔ ว่าด้วยทีปออสะเทรเลีย]]
**ว่าด้วยทีปออสะเทรเลีย
**ว่าด้วยเกาะแธซะเมเนียแลเกาะนีวซีแลน
**ว่าด้วยเกาะหลายหมู่
*[[/บท ๕|บท ๕ ว่าด้วยทีปยูรบ]]
**ว่าด้วยทีปยูรบ
**ว่าด้วยประเทศอังกริษ
**ว่าด้วยประเทศนอระเวแลประเทศซีวเดน
**ว่าด้วยประเทศรูเซีย
**ว่าด้วยประเทศออสะเทรีย
**ว่าด้วยประเทศรูเมเนีย
**ว่าด้วยประเทศบูละเคเรีย
**ว่าด้วยประเทศเซอเวีย
**ว่าด้วยประเทศเธอเคไนยูรบ
**ว่าด้วยประเทศครีสส์คือเฮเลน
**ว่าด้วยประเทศอิทาเลีย
**ว่าด้วยประเทศซะพาเนีย
**ว่าด้วยประเทศโภซูแคล
**ว่าด้วยประเทศฝลั่งเสต
**ว่าด้วยประเทศซะวิสสแลน
**ว่าด้วยประเทศเชอระมัน
**ว่าด้วยประเทศเบลชัม
**ว่าด้วยประเทศฮอแลน
**ว่าด้วยประเทศเดนหมาก
*[[/บท ๖|บท ๖ ว่าด้วยทีปอาฟริกา]]
**ว่าด้วยทีปอาฟริกา
**ว่าด้วยบาบาริสะเทษ
**ว่าด้วยโมรักโค
**ว่าด้วยประเทศอัลชีเรีย
**ว่าด้วยประเทศธูนิศ
**ว่าด้วยประเทศทริปโภลี
**ว่าด้วยประเทศเฟซัน
**ว่าด้วยประเทศบาคา
**ว่าด้วยประเทศอีชิปคืออายฅุปโต
**ว่าด้วยประเทศแอบีซีเนีย
**ว่าด้วยทะเลซายซะฮาระ
**ว่าด้วยซูแดน
**ว่าด้วยประเทศทังหลายที่อยู่ไนส่วนทิตตวันตกแห่งทีปอาฟริกา
**ว่าด้วยประเทศทังหลายที่อยู่ไนส่วนทิตตวันออกแห่งทีปอาฟริกา
**ว่าด้วยประเทศทังหลายที่อยู่ไนส่วนทิตไต้แห่งทีปอาฟริกา
**ว่าด้วยเกาะทังหลายที่อยู่รีมทีปอาฟริกา
*[[/บท ๗|บท ๗ ว่าด้วยทีปอาเมริกาไต้]]
**ว่าด้วยทีปอาเมริกาไต้
**ว่าด้วยประเทศยูไนทิสสเทษโคลำเบีย
**ว่าด้วยประเทศเวนสุวีลา
**ว่าด้วยประเทศคีอานาทังสาม
**ว่าด้วยประเทศเปรซิล
**ว่าด้วยประเทศอาเชนธีนริภับลิก
**ว่าด้วยประเทศจีลี
**ว่าด้วยประเทศโบหลีเวีย
**ว่าด้วยประเทศภีรู
**ว่าด้วยประเทศเอ็กเฅวดอ
*[[/บท ๘|บท ๘ ว่าด้วยทีปอาเมริกาเหนือ]]
**ว่าด้วยทีปอาเมริกาเหนือ
**ว่าด้วยเซนทรัลอาเมริกาแปลว่าอาเมริกากาง
**ว่าด้วยประเทศเม็กซีโค่
**ว่าด้วยประเทศยูไนทิสสเทษอาเมริกา
**ว่าด้วยประเทศปรีทิสส์อาเมริกา
**ว่าด้วยเมืองเอแลซะคา
**ว่าด้วยเกาะครีนแลนกับเกาะไอซะแลน
**ว่าด้วยเกาะเวสส์อินดีคืออินดีทังวันตก
'''ภาพประกอบ'''
*[[/บท ๑#pic1|มหาทีปทิตตวันตก]]
*[[/บท ๑#pic2|มหาทีปทิตตวันออก]]
*[[/บท ๔|แผนที่ของออสะเทรเลีย กับหมู่เกาะที่อยู่ล้อมรอบ]]
*[[/บท ๔|แผนที่ของยูรบ]]
*[[/บท ๗|แผนที่ของอาเมริกาไต้]]
*[[/บท ๘|แผนที่ของอาเมริกาเหนือ]]
}}
=เชิงอรรถของวิกิซอร์ซ=
{{รกออ}}
=บรรณานุกรม=
แมคกิลวารี, คอร์นีเลีย เอช. (2441). ''หนังสือนัคครคุรุประเทษ''. เชียงใหม่: โรงพิมพ์บ้านวังสิงห์คำ.
<pre>
{{สัญญาอนุญาตงานแปล
| {{ลิขสิทธิ์หมดอายุ-ไทย}}
| {{สาธารณสมบัติ-เอง}}
}}
[[หมวดหมู่:ภาษาล้านนา]]
</pre>
brjacqhtu17r8vsl619fv0ddnp9uere
ผู้ใช้:Noktonissian/ทดลองเขียน/นัคครคุรุประเทษ/บท ๑
2
56172
189465
184253
2022-08-16T16:19:26Z
Venise12mai1834
8884
ปิดหมวดหมู่ในหน้าส่วนตัว
wikitext
text/x-wiki
{{หน้าทดลองเขียน}}
<pre>
{{หัวเรื่องงานแปล
| title = [[/นัคครคุรุประเทษ|นัคครคุรุประเทษ]]
| author = คอร์นีเลีย แมคกิลวารี
| ภาษา = nod
| translator =
| section = บท ๑ ว่าด้วยแผ่นดีนโลก
| previous =
| next = [[/บท ๒|บท ๒ ว่าด้วยฅนมนุสส์]]
| year = |เขียนทับปี = ค.ศ. 1896
| notes =
}}
</pre>
{{center|
{{anchor|pic1|pic2}}<pages index="ᩉ᩠ᨶ᩠ᨦᩢᩈᩨᨶᨣ᩠ᨣᩁᨣᩩᩁᩩᨷᩕᨴᩮ᩠ᩇ Lao Geography.pdf" include="5,8" />
}}
{{page break|label=}}
{{ตรคป|<pages index="ᩉ᩠ᨶ᩠ᨦᩢᩈᩨᨶᨣ᩠ᨣᩁᨣᩩᩁᩩᨷᩕᨴᩮ᩠ᩇ Lao Geography.pdf" include="3" onlysection="3-0" />
|{{center|
<br>{{larger|หนังสือนัคครคุรุประเทษ}}
บท ๑}}
๏ หนังสือนี้จักสอนด้วยแผ่นดีนโลกแลขนบธำเนียมแลสาสนาแลกานแห่งฅนมนุสสโลกนี้ อันนื่ง{{tooltip|รักขนรูป|ลักษณะรูป}}แห่งโลกนี้มนเปรียบเหมือนดั่งหน่วยส้มมะโอ เราค็บ่หันว่าโลกนี้มนเพราะว่าโลกนี้เปนหน่วยอั้นไหย่ แลตัวเราค็หน้อย เพราะเหตุเชื้อนี้ เราได้หันแต่ส่วนหน้อยที่สุด เปรียบเหมือนดั่งมดแดงน้อยที่ติดอยู่กับส้มมะโอ แต่ว่ามดนั้นหันแต่ส่วนหน้อยที่สุด แลส่วนที่มดหันนี้ค็เหมือนดูบ่มนแล}}
{{ตรคป|<pages index="ᩉ᩠ᨶ᩠ᨦᩢᩈᩨᨶᨣ᩠ᨣᩁᨣᩩᩁᩩᨷᩕᨴᩮ᩠ᩇ Lao Geography.pdf" include="3" onlysection="3-1" />
|{{center|
<br>ว่าด้วย{{ทูลทิป|รักขนรูปล่าง|ลักษณะรูปร่าง}}แห่งแผ่นดีนโลกนี้}}
๏ ที่นี้จักส่ำแดงหื้อรู้แจ้ง แต่เดิมนั้นฅนทังหลายบ่รู้ว่าโลกนี้มน ตั้งแต่คริษสักราชได้ ๑๕๑๙ ปลีนั้นมา ยังมีฅนผู้นื่งชื่อท่านว่า เฟอดีนันเมเชลัน<ref>[[w:th:เฟอร์ดินานด์ มาเจลลัน|เฟอร์ดินานด์ มาเจลลัน]] หรือที่มักเรียกกันโดยทั่วไปว่า แม็กเจเลน</ref>ได้ขี่สะเพลาไบไพเวียนรอบโลก ตั้งแต่เวรานั้นมาฅนที่ได้เรียนรู้ค็บ่มีคำสงไสไนข้อนี้ ถ่าว่าฅนจักลุกแต่เมืองนี้ไพไนทิตตวันออกเสมอเมินมาค็จักพิก มารอดที่เก่า แล โลกนี้ฅนได้วัดวาไว้ยแล้วทางอ้อมมีสักสองหมื่นห้าพันไม่ล คือ สองพันห้าร้อยสิบสามโยชนะ ถ่าจักวัดลัดซื่อค็มีสักแปดพันไม่ล คือแปดร้อยสิบโยชนะแล
}}
{{ตรคป|<pages index="ᩉ᩠ᨶ᩠ᨦᩢᩈᩨᨶᨣ᩠ᨣᩁᨣᩩᩁᩩᨷᩕᨴᩮ᩠ᩇ Lao Geography.pdf" from="3" fromsection="3-2" to="4" tosection="4-0" />
|{{center|
<br>ว่าด้วยแผ่นดีนโลกนี้ผัดหมูน}}
๏ อันนื่งเราทังหลายผู้อยู่ที่แผ่นดีนโลกนี้ผ่อดูดวงอาทิตแลดวงจันท์แลดวงดาวดาราทังหลาย เราหันดูเหมือนดั่งเทียวข้ามฟ้าตั้งแต่ทิตตวันออกไพเถิงทิตตวันตกแต่ว่ามันบ่เทียวแท้ เราหันดูเปนเหมือนเชื้อนั้นเพราะว่าโลกนี้ผัดอยู่เสมอ เหมือนเมื่อฅืนเดือนแจ้งถ่าว่ามีฝ้าลอยข้ามหน้าดวงจันท์ ดวงจัทน์นั้นเราผ่อหันดูเหมือนแล่นไพเวย ด้วยที่แท้ฝ้านั้นลอยข้ามบ่ดาย ดวงจันท์บ่เทียวแล อันนื่งโลกนี้ผัดหมูนไพไคว่เทื่อนื่งตั้งแต่ทิตตวันตกไพเถิงทิตตวันออกไน ๒๔ โมงปายคือวันนื่งกับฅืนนื่ง ถ่าว่าไคร่รู้แน่ว่าโลกนี้ผัดหมูนเชื้อไดหื้อเอาไม้แทงขวั้นส้มมะโอหื้อผดแล้วผัดส้มมะโอเหมือนหลุกผัดนั้นแล หื้อเข้าไจว่าโลกนี้ผัดเหมือนส้มมะโอนั้น แต่ว่าโลกนี้จักมีไม้แทงเหมือนเราแทงส้มมะโอนั้นค็บ่มี พอเอามาเปนคำเปรียบบ่ดาย ไม้ที่เราเปรียบว่ามีผดโลกนี้เหมือนที่เราได้แทงส้มมะโอนั้นมีชื่อว่าแอกซิษคือดูมโลก สองที่คือที่ไม้หล้างจักผดนั้น ถ่าว่ามีแท้นั้นมีชื่อว่าโภ่ล คือปายดูมโลก ที่เหนือชื่อว่าโภ่ลเหนือ ที่ไต้มีชื่อว่าโภ่ลไต้ เพราะว่าโลกนี้ผัดเราจี่งมีเวราแจ้งแลเวรามืด ฝ่ายโลกที่เบ่นไพหาดวงอาทิตนั้นเปนเมื่อวัน ฝ่ายโลกที่เบ่นหนีไพจากดวงอาทิตนั้นเปนเมื่อฅืน เพราะเหตุเชื้อนั้นฅนที่อยู่ไนประเทษนี้ได้รับรัสสมีแห่งดวงอาทิตส่องแจ้ง ฅนที่อยู่ฝ่ายโลกทัดเราอยู่นั้นค็บ่ได้รับรัสสมีแห่งดวงอาทิตแล เมื่อโลกนี้ผัดหมูนไพแถม ประเทษนี้จักเบ่นหนีไพจากดวงอาทิต ประเทษฝ่ายโลกทัดเราอยู่ค็จักเบ่นไพหาดวงอาทิตแล {{เส้นใต้จุด|ที่เราอยู่จักเปนเมื่อฅืน ที่เขาอยู่จักเปนเมื่อวัน}}<ref>น่าจะเป็นการพิมพ์ผิด โดยพิมพ์สลับกันระหว่างกลางวันกลางคืน ข้อความที่ถูกต้องควรจะเขียนว่า ''ที่เราอยู่จักเปนเมื่อ'''วัน''' ที่เขาอยู่จักเปนเมื่อ'''ฅืน''''' เช่นนี้มากกว่า</ref>
}}
{{ตรคป|
<pages index="ᩉ᩠ᨶ᩠ᨦᩢᩈᩨᨶᨣ᩠ᨣᩁᨣᩩᩁᩩᨷᩕᨴᩮ᩠ᩇ Lao Geography.pdf" include="4" onlysection="4-1" />
|{{center|
<br>ว่าด้วยแผ่นดีนโลกนี้เวียนรอบดวงอาทิต}}
๏ อันนื่งโลกนี้เมื่อยังผัดอยู่ทุกวันค็เวียนรอบดวงอาทิตไคว่เทื่อนื่งไน ๓๖๕ วันปาย ๖ โมง เปนปลีนื่ง ทางที่โลกเทียวเมื่อมันเวียนรอบดวงอาทิตทุกปลีนั้นเราไส่ชื่อว่าออบิดคือมัคคาวิถีโลกนั้น ไนเดือนไดค็ดีโลกนี้อยู่ไกจากดวงอาทิตเก้าโกฏสามล้านไม่ลคือเก้าล้านสี่แสนหมื่นเจ็ดพันเจ็ดร้อยซาวสองโยชนะ
}}
{{ตรคป|
<pages index="ᩉ᩠ᨶ᩠ᨦᩢᩈᩨᨶᨣ᩠ᨣᩁᨣᩩᩁᩩᨷᩕᨴᩮ᩠ᩇ Lao Geography.pdf" from="4" to="6" fromsection="4-2" tosection="6-0" step="2" />
|{{center|
<br>ว่าด้วยแลทิธูด}}
อันนื่งเมื่อโลกนี้ยังผ้งก่ำลังเวียนรอบดวงอาทิตนั้นหน่วยโลกค็เหงี่ยงอยู่เสมอ เพราะโลกนี้เหงี่ยงเมื่อยังเวียนรอบดวงอาทิตหล้างเทื่อเราผ่อตาวันดูเหมือนตกเหนือหล้างเทื่อดูเหมือนตกไต้ หื้อเข้าไจว่ามีเส้นภะทัดเปนวงหมายไว้ยหลายที่คือทิตเหนือทิตไต้แลทิตตวันตกทิตตวันออก ด้วยวงภะทัดนี้พอเอามาเป็นคำเปรียบหื้อได้เข้าไจเพื่อจักได้รู้ที่บ้านที่เมือง มีวงสองอย่างคือวงไหย่วงหน้อย วงไหย่นั้นเปนที่แบ่งโลกนี้เปนสองส่วนเท่ากัน วงหน้อยนั้นเปนวงที่แบ่งโลกนี้เปนส่วนบ่เท่ากัน วงที่แวดโลกตั้งแต่เหนือเถิงได้นั้นเปนวงไหย่ทังมวนแลมีชื่อว่า{{tooltip|เมริเดียน|Meridian}} วงที่แวดโลกนี้ตั้งแต่ทิตตวันออกเถิงทิตตวันตกนั้นมีชื่อว่า{{tooltip|แภเรเลล|Parallel}} แลวงหมู่นี้เปนวงหน้อยทังมวนเว้นแต่วงนี้ชื่อว่าอีเฅวทอ อีเฅวทอนั้นเปนที่แบ่งเกิ่งโลกนี้คือทางลุกแต่โภ่ลเหนือไพเถิงโภ่ลไต้ ที่แห่งบ้านไดเมืองไดนับตั้งแต่อีเฅวทอขื้นไพทังเหนือค็มีลงไพทังไต้ค็มี เราร้องชื่อว่าแลทิธูดแห่งบ้านนั้นเมืองนั้น บ้านไดเมืองไดอยู่เหนืออีเฅวทอนั้นเราว่ามีไนแลทิธูดเหนือแล บ้านไดเมืองไดอยู่ไต้อีเฅวทอนั้นเราว่ามีไนแลทิธูดได้ ที่ไหนอยู่ไกจากอีเฅวทอคี่ดีครีเราว่าที่นั้นอยู่ไนดีครีนั้น เมืองเชียงไหม่นี้อยู่สิบเก้าดีครีเหนืออีเฅวทอ เราว่าเวียงนั้นอยู่แลทิธูดเหนือสิบเก้าดีครี หื้อเราคืดไนไจว่ามีวงนื่งเหนืออีเฅวทอ ๒๓ ดีครีเกิ่ง วงนั้นมีชื่อว่าตรับพิกแฅนเซอ เหนือตรับพิกแฅนเซอนั้นดวงอาทิตบ่ส่องทัดบนหัวสักเทื่อ ไต้อีเฅวทอ ๒๓ ดีครีเกิ่งมีแถมวงนื่งชื่อว่าตรับพิกแฅบพรีคอน ไต้ตรับพิกแฅบพริคอนนั้นดวงอาทิตบ่ส่องทัดบนหัวสักเทื่อ ไต้โภ่ลเหนือไพ ๒๓ ดีครีเกิ่งมีแถมวงนื่งชื่อว่าวงอากทิก เหนือโภ่ลไต้ ๒๓ ดีครีเกิ่งมีแถมวงนื่งชื่อว่าวงแอนอากทิก อันนื่งเมื่อดวงอาทิตส่องทัดบนหัวฅนที่อยู่ทัดตรับพิกแฅบพรีฅอนนั้นรัสสมีแห่งดวงอาทิตค็บ่ส่องล้ำวงอากทิก ก่อนนั้นสามเดือนลูนนั้นสามเดือนค็เปนอั้นมืดอยู่ที่โภ่ลเหนือนั้น ไนนาระหว่างหกเดือนที่รัสสมีแห่งดวงอาทิตบ่ส่องล้ำวงอากทิกนั้น รัสสมีแห่งดวงอาทิตค็ส่องล้ำโภ่ลไต้ไพได้ ๒๓ ดีครีเกิ่งแลในนาระหว่างนั้นที่โภ่ลไต้นั้นค็มีแจ้งอยู่ตรอดได้หกเดือน เวราเมื่อดวงอาทิตส่องทัดฅนที่อยู่ตรับพิกแฅนเซอนั้นรัสสมีแห่งดวงอาทิตค็บ่ส่องล้ำวงแอนอากทิก ก่อนนั้นสามเดือนลูนนั้นสามเดือนที่โภ่ลได้นั้นค็มีมืดอยู่ตราบได้หกเดือนแล ไนหกเดือนนั้นรัสสมีแห่งดวงอาทิตค็ส่องล้ำโภ่ลเหนือไพได้ ๒๓ ดีครีเกิ่งแลที่โภ่ลเหนือนั้นค็มีแจ้งอยู่ตรอดได้หกเดือนแล
}}
{{ตรคป|
<pages index="ᩉ᩠ᨶ᩠ᨦᩢᩈᩨᨶᨣ᩠ᨣᩁᨣᩩᩁᩩᨷᩕᨴᩮ᩠ᩇ Lao Geography.pdf" from="6" fromsection="6-1" to="7" tosection="7-0" />
|<br>{{center|ว่าด้วยลอนจิธูด}}
๏ อันนื่งวงที่เราเปรียบว่ามีรอบแผ่นดินโลกนี้แลที่ประซูมกันที่โภ่ลเหนือแลที่โภ่ลไต้นั้นค็เป่นที่ช่วยเราหื้อรู้ว่าบ้านแลเมืองทังหลายอยู่ทิตตวันออกคาทิตตวันตกแลอยู่ไกจากเราเท่าได ฅนทังหลายเคยนับตั้งแต่วงที่ผ่าเวียงครีนิชนื่งที่ผ่าเวียงวอซีงทันนื่งส่วนหมู่ชาวอังกริษเขาค็เคยนับตั้งแต่วงที่ผ่าเวียงครีนิชนั้นส่วนชาวเมืองอาเมริกาหล้างเทื่อเขาค็นับตั้งแต่วงที่ผ่าเวียงครีนิชหล้างเทื่อค็นับตั้งแต่วงที่ผ่าเวียงวอซีงทันแล อันว่าที่แห่งบ้างไดเมืองไดค็ดีถ่าจักนับตั้งแต่วงที่ผ่าเวียงครีนิชนั้นไพไนทิตตวันออกค็ดีไพในทิตตวันตกค็ดีเราร้องชื่อว่าลอนจิธูดแห่งบ้านนั้นเมืองนั้น บ้านไดเมืองไดอยู่ทิตตวันออกวงนั้นเราว่ามีไนลอนจิธูดทิตตวันออก แลบ้านไดเมืองไดอยู่ไนทิตตวันตกวงนั้นเราว่ามีไนลอนจิธูดทิตตวันตกแล เหมือนเวียงเชียงไหม่อยู่ทิตตวันออกวงนั้นได้เก้าสิบแปดดีครี เราว่ามีไนลอนจิธูดทิตตวันออกเก้าสิบแปดแล
}}
{{ตรคป|
<pages index="ᩉ᩠ᨶ᩠ᨦᩢᩈᩨᨶᨣ᩠ᨣᩁᨣᩩᩁᩩᨷᩕᨴᩮ᩠ᩇ Lao Geography.pdf" include="7" onlysection="7-1" />
|<br>{{center|ว่าด้วยระดู}}
๏ อันนื่งหนังสือนี้บอกแล้วว่าโลกนี้เวียนรอบดวงอาทิตปลีไหนไคว่หนนื่งไนเมื่อโลกเวียนอยู่นั้นค็ได้เหงี่ยง ๒๓ ดีครีเกิ่ง ไนโภ่ลเหนือที่เราเปรียบว่ามีนั้นค็ชี้ไพหาดาวปละจำอุดอรทิตอยู่เสมอ เพราะเหตุเชื้อนั้นจี่งมีระดูร้อนแลระดูหนาวส่วนไดไนแผ่นดินโลกนี้เบ่นไพหาดวงอาทิตส่วนนั้นมีระดูร้อนแลส่วนไหนที่เบ่นไพจากดวงอาทิตนั้นค็มีระดูหนาวแล เมื่อฅนที่อยู่เหนืออีเฅวทอค็มีระดูร้อนฅนที่อยู่ได้อีเฅวทอค็มีระดูหนาวแล เมื่อฅนที่อยู่เหนืออีเฅวทอค็มีระดูหนาวฅนที่อยู่ได้อีเฅวทอค็มีระดูร้อน ไนส่วนแผ่นดินโลกที่อยู่รีมโภ่ลเหนือแลโภ่ลไต้ค็หนาวเหลือส่วนอื่น เพราะรัสสมีดวงอาทิตบ่ร้อนแผวที่นั้น เพราะที่นั้นอยู่ไกจากดวงอาทิตแล
}}
{{ตรคป|
<pages index="ᩉ᩠ᨶ᩠ᨦᩢᩈᩨᨶᨣ᩠ᨣᩁᨣᩩᩁᩩᨷᩕᨴᩮ᩠ᩇ Lao Geography.pdf" include="7" onlysection="7-2" />
|<br>{{center|ว่าด้วยโฌ่น}}
๏ อันนื่งวงอากทิกแลวงตรับพิกแฅนเซอวงตรับพิกแฅบพรีฅอนแลวงแอนอากทิกแบ่งโลกนี้เปนห้าส่วน ไนส่วนทังมวนที่ว่ามานี้ชื่อว่าโฌ่นแลห้าส่วนนี้แผกกันเพราะว่าบ่ร้อนเหมือนกันบ่หนาวเหมือนกัน ส่วนที่อยู่ไนหว่างตรับพิกแฅนเซอกับตรับพิกแฅบพรีฅอนมีชื่อว่าโฌ่นร้อน ไนโฌ่นนั้นกว้างสี่สิบเจดดีครี ประเทศสยามนี้อยู่ไนโฌ่นร้อนแลระดูหนาวแท้บ่มี มีแต่ระดูร้อนพายนักแลมีระดูฝนระดูแล้ง แลระดูไนประเทศอื่นที่อยู่ไนโฌ่นร้อนค็ค้ายกันกับระดูไนประเทศสยามนี้ ถัดโฌ่นร้อนไพทังเหนือมีแถมโฌ่นนื่งชื่อว่าโฌ่นอู่นคือว่าบ่ร้อนบ่หนาว ถัดโฌ่นร้อนไพทังไต้ค็มีแถมโฌ่นแถมโฌ่นนื่งมีชื่อว่าโฌ่นอู่นเหมือนกัน อันนื่งตั้งแต่ครับพิกแฅนเซอไพเถิงวงอากทิกมีชื่อว่าโฌ่นอู่นเหนือ โฌ่นนั้นกว้าง ๔๓ ดีครี ตั้งแต่ตรับพิกแฅบพรีฅอนไพเถิงวงแอนอากทิกมีชื่อว่าโฌ่นอู่นไต้นั้นกว้าง ๔๓ ดีครี ไนโฌ่นอู่นเหนือแลโฌ่นอู่นไต้นั้นเมื่อหนาวค็หนาวนักเมื่อร้อนค็ร้อนนักแต่ว่าร้อนบ่พอร้อนหลายเดือนแลไนสามเดือนก่อนระดูร้อนนั้นมีฅวามสบายบ่พอร้อนบ่พอหนาวตั้งแต่นั้นมาแถมจับระดูร้อนสามเดือน ไนสามเดือนนั้นมีเดือนนื่งร้อนนักเหลือกว่าเดือนอื่นตั้งแต่นั้นมีแถมสามเดือนบ่พอร้อนบ่พอหนาว คันล้ำสามเดือนนั้นมาจับระดูหนาวแลหนาวนั้นหนาวเหลือเมืองนี้นัก ระดูฝนแลระดูแล้งบ่มีแต่ว่าฝนตกค็บ่เปนระดูแล ถัดโฌ่นอู่นเหนือไพทังเหนือเถิงโภ่ลเหนือมีแถมโฌ่นนื่งชื่อว่าโฌ่นหนาวเหนือ ถัดโฌ่นอู่นได้ไพทังไต้ไพเถิงโภ่ลไต้มีแถมโฌ่นนื่งชื่อว่าโฌ่นหนาวไต้แลสองโฌ่นหนาวนั้นโฌ่นไหนกว้าง ๒๓ ดีครีเกิ่ง สองโฌ่นนั้นบ่มีระดูร้อนสักเทื่อแลมีหนาวอยู่ตรอดไพ หนาวนั้นหนาวที่สุด หนาวเหลือโฌ่นอู่น
}}
{{ตรคป|
|<br>{{center|ว่าด้วยส่วนแผ่นดิน}}
๏ อันนื่งนักปราชได้คืดอ่านแปงรูปแห่งแผ่นดินโลกนี้เพื่อจักหื้อฅนทังหลายรู้แลเข้าไจรักขนรูปล่างแลกว้างยาวแห่งมหาทีปแลทีปแลประเทศแลเมืองทังหลายแลส่วนน้ำทังหลายคือน้ำมหาสมุทท์ แลทะเล แลอ่าว แลแม่น้ำแลรูปทังหลายแห่งแผ่นดินโลกนี้เราไส่ชื่อว่าแผ่นที่ ถ้าจัดแบ่งแผ่นดินโลกนี้หื้อเปนสี่ส่วน เปนน้ำสามส่วน เปนแผ่นดินส่วนเดียว ส่วนแห่งแผ่นดีนค็มีหลายอย่างคือมหาทีปแลทีปแลเกาะแลเพนนีนซูลาคือแผ่นดินที่ดุยื่นออกไพหาน้ำแลแหลมม์แล{{ทูลทิป|อิสสเมต|Isthmus ภาษาไทยปัจจุบันเรียก คอคอด}} อิสสเมตนั้นคือแผ่นดินกิ่ว ถ่าจักเอาสูงต่ำว่านั้นเราแบ่งแผ่นดินเปนพูเขาแลหว่างพูเขาแลที่ราบเพียง อันนื่งไนส่วนน้ำนั้นค็มีหลายอย่างคือมหาสมุทท์แลทะเลแลอ่าวแลแม่น้ำหนองห้วยแล ส่วนแผ่นดินนั้นที่ไหย่เหลือส่วนอื่นเราไส่ชื่อว่ามหาทีป ไนโลกนี้มีสองมหาทีปคือมหาทีปทิตตวันออกนื่ง มหาทีปทิตตวันตกนื่ง ถ่าว่าเราจักแบ่งมหาทีปนี้เปนส่วนเปนส่วน ส่วนที่แบ่งนั้นมีชื่อว่าทีป ไนมหาทีปทิตตวันออกนั้นมีสามทีปคืออาเซียแลยูรบแลอาฟริกา ไนมหาทีปทิตตวันตกมีสองทีปคืออาเมริกาเหนือแลอาเมริกาไต้ มีเกาะไหย่ไต้ทีปอาเซียชื่อออสเทรเลีย หล้างส่วนร้องว่าทีป อันนื่งส่วนแผ่นดินบ่พอไหย่แลที่มีน้ำอยู่ล้อมรอบเราร้องชื่อว่าเกาะ เกาะไนมหาสมุทท์นั้นมีหลายที่หลายแห่งเหลือที่จักคนะนาได้ อันนื่งเพนนินซูลานั้นเปนส่วนแผ่นดินที่บ่พอกว้างแลคือเปนหลิมม์ดุยื่นออกไพไนทะเลแลมหาสมุทท์ อันนื่งถ่าแผ่นดินสองส่วนต่อกันนั้นแลที่ต่อนั้นกีด ที่กีดนั้นเราไส่ชื่อว่าอิสสเมตแปลเปนคำไทยว่าที่กิ่วแล ที่สุดปายหลิมม์ที่มันเหลี้ยมม์ยื่นออกไพไนทะเลเราไส่ชื่อว่าเฅปแปลเปนคำไทยว่าแหลมม์
}}
{{ตรคป|
|<br>{{center|ว่าด้วยส่วนน้ำ}}
๏ อันนื่งหนังสือนี้ได้บอกแล้วว่าส่วนน้ำมีหลายอย่างแลส่วนที่ไหย่เหลือส่วนอื่นนั้นคือมหาสมุทท์แล มหาสมุทท์นั้นมีห้าแห่งคือมหาสมุทท์ปซีฟิก แลมหาสมุทท์อัดลันทิก แลมหาสมุทท์อิณเดีย แลมหาสมุทท์อากทิก แลมหาสมุทท์แอนอากทิก แลทะเลนั้นเปนส่วนน้ำหน้อยเหลือมหาสมุทท์แลมีแผ่นดีนอ้อมล้อมเกือบจักไคว่ แลอ่าวน้ำเปนส่วนน้ำเหมือนทะเลแต่ว่าหน้อยเหลือทะเล แลเมื่อส่วนไหย่สองส่วนต่อกันที่ต่อนั้นเปนคองน้ำกีดเราร้องชื่อว่าสะเทรษน้ำสามส่วนนี้คือทะเลแลอ่าวแลสะเทรษน้ำนั้นเคมเหมือนน้ำมหาสมุทท์ แม่น้ำเปนส่วนน้ำกีดที่ไหลจากที่สูง{{ตตฉ|รง|ลง}}สู่มหาสมุทท์ หนองเปนส่วนน้ำที่มีแผ่นดีนล้อมรอบ น้ำสองส่วนนั้นคือแม่น้ำแลหนองเปนส่วนน้ำจืด อันนื่งแม่น้ำทังหลายที่ไหลลงสู่ที่เดียวกันคือห้วยหนองแลแม่น้ำหน้อยทังหลายเราไส่ชื่อว่ากระแสแม่น้ำ
}}
=เชิงอรรถ=
{{รกออ}}
<pre>
[[Category:ภาษาล้านนา]]
</pre>
4iy6vbrw61igmao2314k4lxzcja60g8
แม่แบบ:อ้างหนังสือ
10
57685
189396
2022-08-16T13:45:13Z
Venise12mai1834
8884
นำเข้าจาก [[:w:th:แม่แบบ:Cite_book]]
wikitext
text/x-wiki
<includeonly>{{#invoke:citation/CS1|citation
|CitationClass=book
}}</includeonly><noinclude>
{{documentation}}
</noinclude>
hq4yscm08hccl43rjw83qi7egacgxec
แม่แบบ:Cite book
10
57686
189397
2022-08-16T13:45:33Z
Venise12mai1834
8884
เปลี่ยนทางหน้าไปยัง [[แม่แบบ:อ้างหนังสือ]]
wikitext
text/x-wiki
#REDIRECT [[แม่แบบ:อ้างหนังสือ]]
2x6zy1107r108c1xs7sczy7o3d6ltgf
แม่แบบ:Cite web
10
57687
189399
2022-08-16T13:49:06Z
Venise12mai1834
8884
เปลี่ยนทางหน้าไปยัง [[แม่แบบ:อ้างเว็บ]]
wikitext
text/x-wiki
#REDIRECT [[แม่แบบ:อ้างเว็บ]]
itlfmcs3xab77z998n0uaxv2ewxwr3n
แม่แบบ:อ้างหนังสือ/doc
10
57688
189406
2022-08-16T14:17:00Z
Venise12mai1834
8884
สร้างหน้าด้วย "==วิธีใช้== ใช้โค้ดดังนี้ ===โค้ดที่ใช้บ่อย=== <pre> {{อ้างหนังสือ | author = | year = | title = | chapter = | page = | publisher = | location = | isbn = | ref = }} </pre> ===โค้ดทั้งหมด=== <pre> {{cite book | last = | first = | authorlink = <!--| coauthors = --> | editor = | others = | title = | origdate = | origyear..."
wikitext
text/x-wiki
==วิธีใช้==
ใช้โค้ดดังนี้
===โค้ดที่ใช้บ่อย===
<pre>
{{อ้างหนังสือ
| author =
| year =
| title =
| chapter =
| page =
| publisher =
| location =
| isbn =
| ref =
}}
</pre>
===โค้ดทั้งหมด===
<pre>
{{cite book
| last =
| first =
| authorlink =
<!--| coauthors = -->
| editor =
| others =
| title =
| origdate =
| origyear =
| origmonth =
| url =
| format =
| accessdate =
| accessyear =
| accessmonth =
| edition =
| series =
| volume =
| date =
<!--| year = -->
<!--| month = -->
| publisher =
| location =
| language =
| isbn =
| oclc =
| doi =
| id =
| pages =
| chapter =
| chapterurl =
| quote =
| ref =
}}
</pre>
[[หมวดหมู่:แม่แบบอ้างอิง]]
mprnnah6rivlu1f1muuk2gct05x4ss7
189423
189406
2022-08-16T14:56:45Z
Venise12mai1834
8884
wikitext
text/x-wiki
==วิธีใช้==
ใช้โค้ดดังนี้
===โค้ดที่ใช้บ่อย===
<pre>
{{อ้างหนังสือ
| author =
| year =
| title =
| chapter =
| page =
| publisher =
| location =
| isbn =
| ref =
}}
</pre>
===โค้ดทั้งหมด===
<pre>
{{cite book
| last =
| first =
| authorlink =
<!--| coauthors = -->
| editor =
| others =
| title =
| origdate =
| origyear =
| origmonth =
| url =
| format =
| accessdate =
| accessyear =
| accessmonth =
| edition =
| series =
| volume =
| date =
<!--| year = -->
<!--| month = -->
| publisher =
| location =
| language =
| isbn =
| oclc =
| doi =
| id =
| pages =
| chapter =
| chapterurl =
| quote =
| ref =
}}
</pre>
==ตัวอย่าง==
<pre>
* {{อ้างหนังสือ
| chapter = ศิลาจารึกวัดศรีชุม
| title = ประชุมพงศาวดาร ฉบับกาญจนาภิเษก
| volume = 3
| year = 2542
| publisher = กรมศิลปากร, กองวรรณกรรมและประวัติศาสตร์
| location = กรุงเทพฯ
| isbn = 9744192186
| pages = 35–74
}}
</pre>
* {{อ้างหนังสือ
| chapter = ศิลาจารึกวัดศรีชุม
| title = ประชุมพงศาวดาร ฉบับกาญจนาภิเษก
| volume = 3
| year = 2542
| publisher = กรมศิลปากร, กองวรรณกรรมและประวัติศาสตร์
| location = กรุงเทพฯ
| isbn = 9744192186
| pages = 35–74
}}
[[หมวดหมู่:แม่แบบอ้างอิง]]
ajroxz0jp3zndymoiftvstuk827e6v9
189473
189423
2022-08-16T16:29:53Z
Venise12mai1834
8884
wikitext
text/x-wiki
{{เว็บย่อ|{{มบ|อนส}}}}
==วิธีใช้==
ใช้โค้ดดังนี้
===โค้ดที่ใช้บ่อย===
<pre>
{{อ้างหนังสือ
| author =
| year =
| title =
| chapter =
| page =
| publisher =
| location =
| isbn =
| ref =
}}
</pre>
===โค้ดทั้งหมด===
<pre>
{{cite book
| last =
| first =
| authorlink =
<!--| coauthors = -->
| editor =
| others =
| title =
| origdate =
| origyear =
| origmonth =
| url =
| format =
| accessdate =
| accessyear =
| accessmonth =
| edition =
| series =
| volume =
| date =
<!--| year = -->
<!--| month = -->
| publisher =
| location =
| language =
| isbn =
| oclc =
| doi =
| id =
| pages =
| chapter =
| chapterurl =
| quote =
| ref =
}}
</pre>
==ตัวอย่าง==
<pre>
* {{อ้างหนังสือ
| chapter = ศิลาจารึกวัดศรีชุม
| title = ประชุมพงศาวดาร ฉบับกาญจนาภิเษก
| volume = 3
| year = 2542
| publisher = กรมศิลปากร, กองวรรณกรรมและประวัติศาสตร์
| location = กรุงเทพฯ
| isbn = 9744192186
| pages = 35–74
}}
</pre>
* {{อ้างหนังสือ
| chapter = ศิลาจารึกวัดศรีชุม
| title = ประชุมพงศาวดาร ฉบับกาญจนาภิเษก
| volume = 3
| year = 2542
| publisher = กรมศิลปากร, กองวรรณกรรมและประวัติศาสตร์
| location = กรุงเทพฯ
| isbn = 9744192186
| pages = 35–74
}}
[[หมวดหมู่:แม่แบบอ้างอิง]]
s8xrjarzgnufcpovqbeyeur3ermhg9m
แม่แบบ:ฮาร์เวิร์ด-ตัวระบุ
10
57689
189407
2022-08-16T14:20:24Z
Venise12mai1834
8884
สร้างหน้าด้วย "CITEREF{{#if:||{{anchorencode:{{{1|}}}}}}}{{#if:||{{anchorencode:{{{2|}}}}}}}{{#if:||{{anchorencode:{{{3|}}}}}}}{{#if:||{{anchorencode:{{{4|}}}}}}}{{#if:||{{anchorencode:{{{5|}}}}}}}<noinclude> {{documentation}} </noinclude>"
wikitext
text/x-wiki
CITEREF{{#if:||{{anchorencode:{{{1|}}}}}}}{{#if:||{{anchorencode:{{{2|}}}}}}}{{#if:||{{anchorencode:{{{3|}}}}}}}{{#if:||{{anchorencode:{{{4|}}}}}}}{{#if:||{{anchorencode:{{{5|}}}}}}}<noinclude>
{{documentation}}
</noinclude>
ig1kziqy8yoiyqxckskh3r7zw2vyx80
189415
189407
2022-08-16T14:37:26Z
Venise12mai1834
8884
wikitext
text/x-wiki
{{safesubst<noinclude />:#invoke:Footnotes|sfnref}}<noinclude>
{{documentation}}
</noinclude>
a5bwsbkzmzfw9xjrhfy0ur5p5priatn
แม่แบบ:Harvid
10
57690
189408
2022-08-16T14:20:48Z
Venise12mai1834
8884
เปลี่ยนทางหน้าไปยัง [[แม่แบบ:ฮาร์เวิร์ด-ตัวระบุ]]
wikitext
text/x-wiki
#REDIRECT [[แม่แบบ:ฮาร์เวิร์ด-ตัวระบุ]]
3px6d8fdkq0u7l8jsge0r95g71pqxm6
แม่แบบ:SfnRef
10
57691
189409
2022-08-16T14:22:49Z
Venise12mai1834
8884
เปลี่ยนทางหน้าไปยัง [[แม่แบบ:ฮาร์เวิร์ด-ตัวระบุ]]
wikitext
text/x-wiki
#REDIRECT [[แม่แบบ:ฮาร์เวิร์ด-ตัวระบุ]]
3px6d8fdkq0u7l8jsge0r95g71pqxm6
แม่แบบ:Sfnref
10
57692
189410
2022-08-16T14:23:07Z
Venise12mai1834
8884
เปลี่ยนทางหน้าไปยัง [[แม่แบบ:ฮาร์เวิร์ด-ตัวระบุ]]
wikitext
text/x-wiki
#REDIRECT [[แม่แบบ:ฮาร์เวิร์ด-ตัวระบุ]]
3px6d8fdkq0u7l8jsge0r95g71pqxm6
แม่แบบ:ฮาร์เวิร์ด-ตัวระบุ/doc
10
57693
189411
2022-08-16T14:31:52Z
Venise12mai1834
8884
สร้างหน้าด้วย "{{เว็บย่อ|[[แม่แบบ:harvid]]<br>[[แม่แบบ:SfnRef]]<br>[[แม่แบบ:sfnref]]}} ==วัตถุประสงค์== แม่แบบนี้ใช้กำหนดตัวระบุ (identifier) ในพารามิเตอร์ "ref" ของแม่แบบอ้าง (เช่น [[แม่แบบ:อ้างหนังสือ]]) แทนตัวระบุที่กำ..."
wikitext
text/x-wiki
{{เว็บย่อ|[[แม่แบบ:harvid]]<br>[[แม่แบบ:SfnRef]]<br>[[แม่แบบ:sfnref]]}}
==วัตถุประสงค์==
แม่แบบนี้ใช้กำหนดตัวระบุ (identifier) ในพารามิเตอร์ "ref" ของแม่แบบอ้าง (เช่น [[แม่แบบ:อ้างหนังสือ]]) แทนตัวระบุที่กำหนดขึ้นตามปรกติในพารามิเตอร์นั้น
แม่แบบนี้อาจใช้ร่วมกับ [[แม่แบบ:ฮาร์เวิร์ด-การอ้างในข้อความ]] เพื่อให้ลิงก์มายังรายการอ้างอิงที่ใช้แม่แบบนี้อยู่
==วิธีใช้==
ใส่โค้ดดังต่อไปนี้ลงไปในพารามิเตอร์ "ref" ของแม่แบบอ้าง
<pre>
{{harvid|1=|2=}}
</pre>
* ช่อง 1 มักเป็นชื่อ (อาจเป็นชื่อเต็ม หรือเฉพาะชื่อสกุล) ผู้สร้างสรรค์
* ช่อง 2 มักเป็นปี
==ตัวอย่าง==
<pre>
| ref = {{harvid|Tolkien|2022}}
</pre>
[[หมวดหมู่:แม่แบบอ้างอิง]]
ci0yvshskgnzgp4cnnob9w4yb4uu29u
189412
189411
2022-08-16T14:35:39Z
Venise12mai1834
8884
wikitext
text/x-wiki
{{เว็บย่อ|[[แม่แบบ:harvid]]<br>[[แม่แบบ:SfnRef]]<br>[[แม่แบบ:sfnref]]}}
==วัตถุประสงค์==
แม่แบบนี้ใช้กำหนดตัวระบุ (identifier) ในพารามิเตอร์ "ref" ของแม่แบบอ้าง (เช่น [[แม่แบบ:อ้างหนังสือ]]) แทนตัวระบุที่กำหนดขึ้นตามปรกติในพารามิเตอร์นั้น
แม่แบบนี้อาจใช้ร่วมกับ [[แม่แบบ:ฮาร์เวิร์ด-ข้อความอ้างอิง]] เพื่อให้ลิงก์มายังรายการอ้างอิงที่ใช้แม่แบบนี้อยู่
==วิธีใช้==
ใส่โค้ดดังต่อไปนี้ลงไปในพารามิเตอร์ "ref" ของแม่แบบอ้าง
<pre>
{{harvid|1=|2=}}
</pre>
* ช่อง 1 มักเป็นชื่อ (อาจเป็นชื่อเต็ม หรือเฉพาะชื่อสกุล) ผู้สร้างสรรค์
* ช่อง 2 มักเป็นปี
==ตัวอย่าง==
<pre>
| ref = {{harvid|Tolkien|2022}}
</pre>
[[หมวดหมู่:แม่แบบอ้างอิง]]
lq6kib0qx6iev49ech2tkkg2jjuaisr
189429
189412
2022-08-16T15:08:39Z
Venise12mai1834
8884
wikitext
text/x-wiki
{{เว็บย่อ|[[แม่แบบ:ฮวต]]<br>[[แม่แบบ:harvid]]<br>[[แม่แบบ:SfnRef]]<br>[[แม่แบบ:sfnref]]}}
==วัตถุประสงค์==
แม่แบบนี้ใช้กำหนดตัวระบุ (identifier) ในพารามิเตอร์ "ref" ของแม่แบบอ้าง (เช่น [[แม่แบบ:อ้างหนังสือ]]) แทนตัวระบุที่กำหนดขึ้นตามปรกติในพารามิเตอร์นั้น
แม่แบบนี้อาจใช้ร่วมกับ [[แม่แบบ:ฮาร์เวิร์ด-ข้อความอ้างอิง]] เพื่อให้ลิงก์มายังรายการอ้างอิงที่ใช้แม่แบบนี้อยู่
==วิธีใช้==
ใส่โค้ดดังต่อไปนี้ลงไปในพารามิเตอร์ "ref" ของแม่แบบอ้าง
<pre>
{{harvid|1=|2=}}
</pre>
* ช่อง 1 มักเป็นชื่อ (อาจเป็นชื่อเต็ม หรือเฉพาะชื่อสกุล) ผู้สร้างสรรค์
* ช่อง 2 มักเป็นปี
==ตัวอย่าง==
<pre>
| ref = {{harvid|Tolkien|2022}}
</pre>
[[หมวดหมู่:แม่แบบอ้างอิง]]
87k8dlc8atnqjfouytr8y0r2za5a9dm
แม่แบบ:ฮาร์เวิร์ด-ข้อความอ้างอิง
10
57694
189413
2022-08-16T14:36:16Z
Venise12mai1834
8884
สร้างหน้าด้วย "{{#ifeq:{{{Ref|}}}|none |{{#if:{{{5|}}} |{{{1|}}} et al. ({{{5|}}} |{{#if:{{{4|}}} |{{{1|}}}, {{{2|}}} & {{{3|}}} ({{{4|}}} |{{#if:{{{3|}}} |{{{1|}}} & {{{2|}}} ({{{3|}}} |{{{1|}}} ({{{2|}}} }} }} }} | #<!-- -->{{#if:{{{Ref|}}}<!-- -->|{{{Ref}}}<!-- -->|CITEREF{{{1|}}}{{{2|}}}{{{3|}}}{{{4|}}}{{{5|}}}<!-- -->}}<!-- -->|{{#if:{{{5|}}}<!--..."
wikitext
text/x-wiki
{{#ifeq:{{{Ref|}}}|none
|{{#if:{{{5|}}}
|{{{1|}}} et al. ({{{5|}}}
|{{#if:{{{4|}}}
|{{{1|}}}, {{{2|}}} & {{{3|}}} ({{{4|}}}
|{{#if:{{{3|}}}
|{{{1|}}} & {{{2|}}} ({{{3|}}}
|{{{1|}}} ({{{2|}}}
}}
}}
}}
| [[#<!--
-->{{#if:{{{Ref|}}}<!--
-->|{{{Ref}}}<!--
-->|CITEREF{{{1|}}}{{{2|}}}{{{3|}}}{{{4|}}}{{{5|}}}<!--
-->}}<!--
-->|{{#if:{{{5|}}}<!--
-->| {{{1|}}} et al. ({{{5|}}}<!--
-->| {{#if:{{{4|}}}<!--
-->| {{{1|}}}, {{{2|}}} & {{{3|}}} ({{{4|}}}<!--
-->| {{#if:{{{3|}}}<!--
-->| {{{1|}}} & {{{2|}}} ({{{3|}}}<!--
-->| {{{1|}}} ({{{2|}}}<!--
-->}}<!--
-->}}<!--
-->}}<!--
-->{{#if:{{{loc|}}}||
{{#if:{{{p|}}}||
{{#if:{{{pp|}}}||)}}
}}
}}]]
}}{{#if:{{{loc|}}}
|, {{{loc|}}})
|{{#if:{{{p|}}}
|, p. {{{p|}}})
|{{#if:{{{pp|}}}
|, pp. {{{pp|}}})
}}
}}
}}<noinclude>
{{pp-template|small=yes}}
{{documentation}}
</noinclude>
t9yl5hvzlus8yk5atd5wetb02gu7y6b
189414
189413
2022-08-16T14:36:45Z
Venise12mai1834
8884
wikitext
text/x-wiki
<includeonly>{{#invoke:Footnotes|harvard_citation
|bracket_year_left = (
|bracket_year_right = {{#if:{{{p|}}}{{{page|}}}{{{pp|}}}{{{pages|}}}{{{loc|}}}||)}}
|bracket_right = {{#if:{{{p|}}}{{{page|}}}{{{pp|}}}{{{pages|}}}{{{loc|}}}|)}}
|template=harvtxt
}}</includeonly><noinclude>
{{documentation}}
<!-- Add categories to the /doc subpage, interwikis to Wikidata, not here -->
</noinclude>
3sadgjxenlohbcvxdmytkd4zwwey83o
189431
189414
2022-08-16T15:21:35Z
Venise12mai1834
8884
wikitext
text/x-wiki
{{#ifeq:{{{Ref|}}}|none
|{{#if:{{{5|}}}
|{{{1|}}} และคนอื่น ๆ ({{{5|}}}
|{{#if:{{{4|}}}
|{{{1|}}}, {{{2|}}} & {{{3|}}} ({{{4|}}}
|{{#if:{{{3|}}}
|{{{1|}}} & {{{2|}}} ({{{3|}}}
|{{{1|}}} ({{{2|}}}
}}
}}
}}
| [[#<!--
-->{{#if:{{{Ref|}}}<!--
-->|{{{Ref}}}<!--
-->|CITEREF{{{1|}}}{{{2|}}}{{{3|}}}{{{4|}}}{{{5|}}}<!--
-->}}<!--
-->|{{#if:{{{5|}}}<!--
-->| {{{1|}}} และคนอื่น ๆ ({{{5|}}}<!--
-->| {{#if:{{{4|}}}<!--
-->| {{{1|}}}, {{{2|}}} & {{{3|}}} ({{{4|}}}<!--
-->| {{#if:{{{3|}}}<!--
-->| {{{1|}}} & {{{2|}}} ({{{3|}}}<!--
-->| {{{1|}}} ({{{2|}}}<!--
-->}}<!--
-->}}<!--
-->}}<!--
-->{{#if:{{{loc|}}}||
{{#if:{{{p|}}}||
{{#if:{{{pp|}}}||)}}
}}
}}]]
}}{{#if:{{{loc|}}}
|, {{{loc|}}})
|{{#if:{{{p|}}}
|, หน้า {{{p|}}})
|{{#if:{{{pp|}}}
|, หน้า {{{pp|}}})
}}
}}
}}<noinclude>
{{pp-template|small=yes}}
{{documentation}}
</noinclude>
iomtbqylvxeoaf94tt803zymupb1n83
189432
189431
2022-08-16T15:22:04Z
Venise12mai1834
8884
wikitext
text/x-wiki
{{#ifeq:{{{Ref|}}}|none
|{{#if:{{{5|}}}
|{{{1|}}} และคนอื่น ๆ ({{{5|}}}
|{{#if:{{{4|}}}
|{{{1|}}}, {{{2|}}} & {{{3|}}} ({{{4|}}}
|{{#if:{{{3|}}}
|{{{1|}}} & {{{2|}}} ({{{3|}}}
|{{{1|}}} ({{{2|}}}
}}
}}
}}
| [[#<!--
-->{{#if:{{{Ref|}}}<!--
-->|{{{Ref}}}<!--
-->|CITEREF{{{1|}}}{{{2|}}}{{{3|}}}{{{4|}}}{{{5|}}}<!--
-->}}<!--
-->|{{#if:{{{5|}}}<!--
-->| {{{1|}}} และคนอื่น ๆ ({{{5|}}}<!--
-->| {{#if:{{{4|}}}<!--
-->| {{{1|}}}, {{{2|}}} & {{{3|}}} ({{{4|}}}<!--
-->| {{#if:{{{3|}}}<!--
-->| {{{1|}}} & {{{2|}}} ({{{3|}}}<!--
-->| {{{1|}}} ({{{2|}}}<!--
-->}}<!--
-->}}<!--
-->}}<!--
-->{{#if:{{{loc|}}}||
{{#if:{{{p|}}}||
{{#if:{{{pp|}}}||)}}
}}
}}]]
}}{{#if:{{{loc|}}}
|, {{{loc|}}})
|{{#if:{{{p|}}}
|, หน้า {{{p|}}})
|{{#if:{{{pp|}}}
|, หน้า {{{pp|}}})
}}
}}
}}<noinclude>
{{documentation}}
</noinclude>
tsl36kwkwfrum365jp97xmn1x1epw7i
189500
189432
2022-08-17T11:23:21Z
Venise12mai1834
8884
wikitext
text/x-wiki
{{#ifeq:{{{Ref|}}}|none
|{{#if:{{{5|}}}
|{{{1|}}} และคนอื่น ๆ ({{{5|}}}
|{{#if:{{{4|}}}
|{{{1|}}}, {{{2|}}} & {{{3|}}} ({{{4|}}}
|{{#if:{{{3|}}}
|{{{1|}}} & {{{2|}}} ({{{3|}}}
|{{{1|}}} ({{{2|}}}
}}
}}
}}
| [[#<!--
-->{{#if:{{{Ref|}}}<!--
-->|{{{Ref}}}<!--
-->|CITEREF{{{1|}}}{{{2|}}}{{{3|}}}{{{4|}}}{{{5|}}}<!--
-->}}<!--
-->|{{#if:{{{5|}}}<!--
-->| {{{1|}}} และคนอื่น ๆ ({{{5|}}}<!--
-->| {{#if:{{{4|}}}<!--
-->| {{{1|}}}, {{{2|}}} & {{{3|}}} ({{{4|}}}<!--
-->| {{#if:{{{3|}}}<!--
-->| {{{1|}}} & {{{2|}}} ({{{3|}}}<!--
-->| {{{1|}}} ({{{2|}}}<!--
-->}}<!--
-->}}<!--
-->}}<!--
-->{{#if:{{{loc|}}}||
{{#if:{{{p|}}}||
{{#if:{{{pp|}}}||)}}
}}
}}]]
}}{{#if:{{{loc|}}}
|, {{{loc|}}})
|{{#if:{{{p|}}}
|, น. {{{p|}}})
|{{#if:{{{pp|}}}
|, น. {{{pp|}}})
}}
}}
}}<noinclude>
{{documentation}}
</noinclude>
q03fgo7lqtv6m1bjfl7gdt18pzm0x46
189506
189500
2022-08-17T11:27:28Z
Venise12mai1834
8884
wikitext
text/x-wiki
<noinclude>{{เว็บย่อ|[[แม่แบบ:ฮวอ]]<br>[[แม่แบบ:harvtxt]]}}</noinclude>{{#ifeq:{{{Ref|}}}|none
|{{#if:{{{5|}}}
|{{{1|}}} และคนอื่น ๆ ({{{5|}}}
|{{#if:{{{4|}}}
|{{{1|}}}, {{{2|}}} & {{{3|}}} ({{{4|}}}
|{{#if:{{{3|}}}
|{{{1|}}} & {{{2|}}} ({{{3|}}}
|{{{1|}}} ({{{2|}}}
}}
}}
}}
| [[#<!--
-->{{#if:{{{Ref|}}}<!--
-->|{{{Ref}}}<!--
-->|CITEREF{{{1|}}}{{{2|}}}{{{3|}}}{{{4|}}}{{{5|}}}<!--
-->}}<!--
-->|{{#if:{{{5|}}}<!--
-->| {{{1|}}} และคนอื่น ๆ ({{{5|}}}<!--
-->| {{#if:{{{4|}}}<!--
-->| {{{1|}}}, {{{2|}}} & {{{3|}}} ({{{4|}}}<!--
-->| {{#if:{{{3|}}}<!--
-->| {{{1|}}} & {{{2|}}} ({{{3|}}}<!--
-->| {{{1|}}} ({{{2|}}}<!--
-->}}<!--
-->}}<!--
-->}}<!--
-->{{#if:{{{loc|}}}||
{{#if:{{{p|}}}||
{{#if:{{{pp|}}}||)}}
}}
}}]]
}}{{#if:{{{loc|}}}
|, {{{loc|}}})
|{{#if:{{{p|}}}
|, น. {{{p|}}})
|{{#if:{{{pp|}}}
|, น. {{{pp|}}})
}}
}}
}}<noinclude>
{{documentation}}
</noinclude>
617kq8fmo6iwlway1cpx7u6qtfdc9wp
มอดูล:Footnotes
828
57695
189416
2022-08-16T14:42:23Z
Venise12mai1834
8884
สร้างขึ้นอีกครั้ง เพื่อให้แม่แบบอื่นใช้การได้
Scribunto
text/plain
require('Module:No globals');
local getArgs = require ('Module:Arguments').getArgs;
--[[--------------------------< A R G S _ D E F A U L T >------------------------------------------------------
a table to specify initial values.
]]
local args_default = {
bracket_left = '',
bracket_right = '',
bracket_year_left = '',
bracket_year_right = '',
postscript = '',
page = '',
pages = '',
location = '',
page_sep = ", p. ",
pages_sep = ", pp. ",
ref = '',
template = 'harv', -- if template name not provided in {{#invoke:}} use this
};
--[[--------------------------< T A R G E T _ C H E C K >------------------------------------------------------
look for anchor_id (CITEREF name-list and year or text from |ref=) in anchor_id_list
the 'no target' error may be suppressed with |ignore-err=yes when target cannot be found because target is inside
a template that wraps another template; 'multiple targets' error may not be suppressed
]]
local function target_check (anchor_id, args)
local namespace = mw.title.getCurrentTitle().namespace;
local anchor_id_list_module = mw.loadData ('Module:Footnotes/anchor_id_list');
local anchor_id_list = anchor_id_list_module.anchor_id_list;
local article_whitelist = anchor_id_list_module.article_whitelist;
local template_list = anchor_id_list_module.template_list;
local whitelist_module = mw.loadData ('Module:Footnotes/whitelist');
local whitelist = whitelist_module.whitelist;
local special_patterns = whitelist_module.special_patterns;
local DNB_special_patterns = whitelist_module.DNB_special_patterns;
local DNB_template_names = whitelist_module.DNB_template_names;
if 10 == namespace then
return ''; -- automatic form of |no-tracking=yes; TODO: is this too broad?
end
local tally = anchor_id_list[anchor_id]; -- nil when anchor_id not in list; else a tally
local msg;
local category;
if not tally then
if args.ignore then
return ''; -- if ignore is true then no message, no category
end
if article_whitelist and article_whitelist[anchor_id] then -- if an article-local whitelist and anchor ID is in it
return ''; -- done
end
local wl_anchor_id = anchor_id; -- copy to be modified to index into the whitelist
if args.year then -- for anchor IDs created by this template (not in |ref=) that have a date
if args.year:match ('%d%l$') or -- use the date value to determine if we should remove the disambiguator
args.year:match ('n%.d%.%l$') or
args.year:match ('nd%l$') then
wl_anchor_id = wl_anchor_id:gsub ('%l$', ''); -- remove the disambiguator
end
end
local t_tbl = whitelist[wl_anchor_id]; -- get list of templates associated with this anchor ID
if t_tbl then -- when anchor ID not whitelisted t_tbl is nil
for _, t in ipairs (t_tbl) do -- spin through the list of templates associated with this anchor ID
if template_list[t] then -- if associated template is found in the list of templates in the article
return ''; -- anchor ID is whitlisted and article has matching template so no error
end
end
end
for _, pattern in ipairs (special_patterns) do -- spin through the spcial patterns and try to match
if anchor_id:match (pattern) then
return '';
end
end
for _, dnb_t in ipairs (DNB_template_names or {}) do -- getting desparate now, are there any DNB templates? DNB_template_names may be nil; empty table prevents script error
if template_list[dnb_t] then -- if the article has this DNB template
for _, pattern in ipairs (DNB_special_patterns) do -- spin through the DNB-specifiec wildcard patterns
if anchor_id:match (pattern) then -- and attempt a match
return ''; -- found a match
end
end
end
end
msg = 'no target: ' .. anchor_id; -- anchor_id not found
category = '[[Category:Harv and Sfn no-target errors]]';
elseif 1 < tally then
msg = 'multiple targets (' .. tally .. '×): ' .. anchor_id; -- more than one anchor_id in this article
category = 0 == namespace and '[[Category:Harv and Sfn multiple-target errors]]' or ''; -- only categorize in article space
return '<span class="error harv-error" style="display: inline; font-size:100%"> ' .. args.template .. ' error: ' .. msg .. ' ([[:Category:Harv and Sfn template errors|help]])</span>' .. category;
end
-- category = 0 == namespace and '[[Category:Harv and Sfn template errors]]' or ''; -- only categorize in article space
category = 0 == namespace and category or ''; -- only categorize in article space
--use this version to show error messages
-- return msg and '<span class="error harv-error" style="display: inline; font-size:100%"> ' .. args.template .. ' error: ' .. msg .. ' ([[:Category:Harv and Sfn template errors|help]])</span>' .. category or '';
--use this version to hide error messages
return msg and '<span class="error harv-error" style="display: none; font-size:100%"> ' .. args.template .. ' error: ' .. msg .. ' ([[:Category:Harv and Sfn template errors|help]])</span>' .. category or '';
end
--[[--------------------------< I S _ Y E A R >----------------------------------------------------------------
evaluates param to see if it is one of these forms with or without lowercase letter disambiguator:
YYYY
n.d.
nd
c. YYYY
YYYY–YYYY (separator is endash)
YYYY–YY (separator is endash)
return true when param has a recognized form; false else
]]
local patterns_date= {
'^%d%d%d%d?%l?$',
'^n%.d%.%l?$',
'^nd%l?$',
'^c%. %d%d%d%d?%l?$',
'^%d%d%d%d–%d%d%d%d%l?$',
'^%d%d%d%d–%d%d%l?$',
}
local function is_year (param, args)
args.year = ''; -- used for harv error;
for _, pattern in ipairs (patterns_date) do
if mw.ustring.match (param, pattern) then
args.year = param; -- used for harv error;
return true;
end
end
end
--[[--------------------------< C O R E >----------------------------------------------------------------------
returns an anchor link (CITEREF) formed from one to four author names, year, and insource location (|p=, |pp=, loc=)
]]
local function core( args )
local result;
local err_msg = ''
if args.P5 ~= '' then
if is_year (args.P5, args) then
result = table.concat ({args.P1, ' et al. ', args.bracket_year_left, args.P5, args.bracket_year_right});
else
args.P5 = ''; -- when P5 not a year don't include in anchor
result = table.concat ({args.P1, ' et al.'}); -- and don't render it
end
elseif args.P4 ~= '' then
if is_year (args.P4, args) then
result = table.concat ({args.P1, ', ', args.P2, ' & ', args.P3, ' ', args.bracket_year_left, args.P4, args.bracket_year_right}); -- three names and a year
else
result = table.concat ({args.P1, ' et al.'}); -- four names
end
elseif args.P3 ~= '' then
if is_year (args.P3, args) then
result = table.concat ({args.P1, ' & ', args.P2, ' ', args.bracket_year_left, args.P3, args.bracket_year_right}); -- two names and a year
else
result = table.concat ({args.P1, ', ', args.P2, ' ', ' & ', args.P3}); -- three names
end
elseif args.P2 ~= '' then
if is_year (args.P2, args) then
result = table.concat ({args.P1, ' ', args.bracket_year_left, args.P2, args.bracket_year_right}); -- one name and year
else
result = table.concat ({args.P1, ' & ', args.P2}); -- two names
end
else
result = args.P1; -- one name
end
-- when author-date result ends with a dot (typically when the last positional parameter holds 'n.d.')
-- and when no in-source location (no |p=, |pp=, or |loc=)
-- and when the first or only character in args.postscript is a dot
-- remove the author-date result trailing dot
-- the author-date result trailing dot will be replaced later with the content of args.postscript (usually a dot)
if ('.' == result:sub(-1)) and ('.' == args.postscript:sub(1)) and ('' == args.page) and ('' == args.pages) and ('' == args.location) then
result = result:gsub ('%.$', '');
end
if args.ref ~= 'none' then
local anchor_id;
if args.ref ~= '' then
anchor_id = mw.uri.anchorEncode (args.ref);
err_msg = target_check (anchor_id, args);
result = table.concat ({'[[#', anchor_id, '|', result, ']]'});
else
anchor_id = mw.uri.anchorEncode (table.concat ({'CITEREF', args.P1, args.P2, args.P3, args.P4, args.P5}));
err_msg = target_check (anchor_id, args);
result = table.concat ({'[[#', anchor_id, '|', result, ']]'});
end
end
if args.page ~= '' then
result = table.concat ({result, args.page_sep, args.page});
elseif args.pages ~= ''then
result = table.concat ({result, args.pages_sep, args.pages});
end
if args.location ~= '' then
result = table.concat ({result, ', ', args.location});
end
result = table.concat ({args.bracket_left, result, args.bracket_right, args.postscript}):gsub ('%s+', ' '); -- strip redundant spaces
return result .. err_msg;
end
--[[--------------------------< H Y P H E N _ T O _ D A S H >--------------------------------------------------
Converts a hyphen to a dash under certain conditions. The hyphen must separate
like items; unlike items are returned unmodified. These forms are modified:
letter - letter (A - B)
digit - digit (4-5)
digit separator digit - digit separator digit (4.1-4.5 or 4-1-4-5)
letterdigit - letterdigit (A1-A5) (an optional separator between letter and
digit is supported – a.1-a.5 or a-1-a-5)
digitletter - digitletter (5a - 5d) (an optional separator between letter and
digit is supported – 5.a-5.d or 5-a-5-d)
any other forms are returned unmodified.
str may be a comma- or semicolon-separated list
This code copied from Module:Citation/CS1. The only modification is to require Module:Citation/CS1/Utilities
so that it has access to the functions is_set() and has_accept_as_written()
]]
local function hyphen_to_dash( str )
local utilities = require ('Module:Citation/CS1/Utilities'); -- only modification so that this function has access to is_set() and has_accept_as_written()
if not utilities.is_set (str) then
return str;
end
local accept; -- Boolean
str = str:gsub ('&[nm]dash;', {['–'] = '–', ['—'] = '—'}); -- replace — and – entities with their characters; semicolon mucks up the text.split
str = str:gsub ('-', '-'); -- replace HTML numeric entity with hyphen character
str = str:gsub (' ', ' '); -- replace entity with generic keyboard space character
local out = {};
local list = mw.text.split (str, '%s*[,;]%s*'); -- split str at comma or semicolon separators if there are any
for _, item in ipairs (list) do -- for each item in the list
item, accept = utilities.has_accept_as_written (item); -- remove accept-this-as-written markup when it wraps all of item
if not accept and mw.ustring.match (item, '^%w*[%.%-]?%w+%s*[%-–—]%s*%w*[%.%-]?%w+$') then -- if a hyphenated range or has endash or emdash separators
if item:match ('^%a+[%.%-]?%d+%s*%-%s*%a+[%.%-]?%d+$') or -- letterdigit hyphen letterdigit (optional separator between letter and digit)
item:match ('^%d+[%.%-]?%a+%s*%-%s*%d+[%.%-]?%a+$') or -- digitletter hyphen digitletter (optional separator between digit and letter)
item:match ('^%d+[%.%-]%d+%s*%-%s*%d+[%.%-]%d+$') or -- digit separator digit hyphen digit separator digit
item:match ('^%d+%s*%-%s*%d+$') or -- digit hyphen digit
item:match ('^%a+%s*%-%s*%a+$') then -- letter hyphen letter
item = item:gsub ('(%w*[%.%-]?%w+)%s*%-%s*(%w*[%.%-]?%w+)', '%1–%2'); -- replace hyphen, remove extraneous space characters
else
item = mw.ustring.gsub (item, '%s*[–—]%s*', '–'); -- for endash or emdash separated ranges, replace em with en, remove extraneous whitespace
end
end
table.insert (out, item); -- add the (possibly modified) item to the output table
end
local temp_str = ''; -- concatenate the output table into a comma separated string
temp_str, accept = utilities.has_accept_as_written (table.concat (out, ', ')); -- remove accept-this-as-written markup when it wraps all of concatenated out
if accept then
temp_str = utilities.has_accept_as_written (str); -- when global markup removed, return original str; do it this way to suppress boolean second return value
return temp_str;
else
return temp_str; -- else, return assembled temp_str
end
end
--[[--------------------------< A R G S _ F E T C H >---------------------------------------------------------
Because all of the templates share a common set of parameters, a single common function to fetch those parameters
from frame and parent frame.
]]
local function args_fetch (frame, ps)
local args = args_default; -- create a copy of the default table
local pframe = frame:getParent(); -- point to the template's parameter table
for k, v in pairs (frame.args) do -- override defaults with values provided in the #invoke: if any
args[k] = v;
end
args.postscript = pframe.args.postscript or pframe.args.ps or ps;
if 'none' == args.postscript then
args.postscript = '';
end
args.page = pframe.args.p or pframe.args.page or '';
args.pages = pframe.args.pp or pframe.args.pages or '';
args.pages = ('' ~= args.pages) and hyphen_to_dash (args.pages) or '';
args.location = pframe.args.loc or '';
args.ref = pframe.args.ref or pframe.args.Ref or '';
args.ignore = ('yes' == pframe.args['ignore-false-positive']) or ('yes' == pframe.args['ignore-err']);
for i, v in ipairs ({'P1', 'P2', 'P3', 'P4', 'P5'}) do -- loop through the five positional parameters and trim if set else empty string
args[v] = (pframe.args[i] and mw.text.trim (pframe.args[i])) or '';
end
if args.P5 and not is_year (args.P5, args) then
local i = 6; -- initialize the indexer to the sixth positional parameter
while pframe.args[i] do -- in case there are too many authors loop through the authors looking for a year
local v = mw.text.trim (pframe.args[i]); -- trim
if is_year (v, args) then -- if a year
args.P5 = v; -- overwrite whatever was in args.P5 with year
break; -- and abandon the search
end
i = i + 1; -- bump the indexer
end
end
return args;
end
--[[--------------------------< H A R V A R D _ C I T A T I O N >----------------------------------------------
common entry point for:
{{harvard citation}} aka {{harv}}
{{Harvard citation no brackets}} aka {{harvnb}}
{{harvcol}}
{{harvcolnb}}
{{harvcoltxt}}
{{Harvard citation text}} aka {{harvtxt}}
{{Harvp}}
Distinguishing features (brackets and page separators) are specified in this module's {{#invoke}} in the respective templates.
]]
local function harvard_citation (frame)
local args = args_fetch (frame, ''); -- get the template and invoke parameters; default postscript is empty string
return core (args);
end
--[[--------------------------< S T R I P _ U R L >------------------------------------------------------------
used by sfn() and sfnm(). This function fixes an issue with reference tooltip gadget where the tooltip is not displayed
when an insource locator (|p=, |pp=, |loc=) has an external wikilink that contains a # character
strip uri-reserved characters from urls in |p=, |pp-, and |loc= parameters The researved characters are:
!#$&'()*+,/:;=?@[]
]]
local function strip_url (pages)
local escaped_uri;
if not pages or ('' == pages) then
return pages;
end
for uri in pages:gmatch ('%[(%a[%w%+%.%-]*://%S+)') do -- for each external link get the uri
escaped_uri = uri:gsub ("([%(%)%.%%%+%-%*%?%[%^%$%]])", "%%%1" ); -- save a copy with lua pattern characters escaped
uri = uri:gsub ("[!#%$&'%(%)%*%+,/:;=%?@%[%]%.%%]", ''); -- remove reserved characters and '%' because '%20' (space character) is a lua 'invalid capture index'
pages = pages:gsub (escaped_uri, uri, 1); -- replace original uri with the stripped version
end
return pages;
end
--[[--------------------------< S F N >------------------------------------------------------------------------
entry point for {{sfn}} and {{sfnp}}
]]
local function sfn (frame)
local args = args_fetch (frame, '.'); -- get the template and invoke parameters; default postscript is a dot
local result = core (args); -- go make a CITEREF anchor
-- put it all together and then strip redundant spaces
local name = table.concat ({'FOOTNOTE', args.P1, args.P2, args.P3, args.P4, args.P5, strip_url (args.page), strip_url (args.pages), strip_url (args.location)}):gsub ('%s+', ' ');
return frame:extensionTag ({name='ref', args={name=name}, content=result});
end
--[[--------------------------< S F N M >----------------------------------------------------------------------
common entry point for {{sfnm}} and {{sfnmp}}
Distinguishing features (brackets) are specified in this module's {{#invoke}} in the respective templates.
]]
local function sfnm (frame)
local args = args_default; -- create a copy of the default table
local pframe = frame:getParent(); -- point to the template's parameter table
local n = 1; -- index of source; this is the 'n' in na1, ny, etc
local first_pnum = 1; -- first of a pair of positional parameters
local second_pnum = 2; -- second of a pair of positional parameters
local last_ps = 0; -- index of the last source with |nps= set
local last_index = 0; -- index of the last source; these used to determine which of |ps= or |nps= will terminate the whole rendering
local out = {}; -- table to hold rendered sources
local footnote = {'FOOTNOTE'}; -- all author, date, insource location stuff becomes part of the reference's footnote id; added as we go
for k, v in pairs (frame.args) do -- override defaults with values provided in the #invoke: if any
args[k] = v;
end
while true do
if not pframe.args[table.concat ({n, 'a1'})] and not pframe.args[first_pnum] then
break; -- no na1 or matching positional parameter so done
end
if pframe.args[table.concat ({n, 'a1'})] then -- does this source use named parameters?
for _, v in ipairs ({'P1', 'P2', 'P3', 'P4', 'P5'}) do -- initialize for this source
args[v] = '';
end
for i, v in ipairs ({'P1', 'P2', 'P3', 'P4', 'P5'}) do -- extract author and year parameters for this source
args[v] = pframe.args[table.concat ({n, 'a', i})] or ''; -- attempt to assign author name
if '' == args[v] then -- when there wasn't an author name
args[v] = pframe.args[table.concat ({n, 'y'})] or ''; -- attempt to assign year
break; -- done with author/date for this source
end
end
else -- this source uses positional parameters
args.P1 = mw.text.trim (pframe.args[first_pnum]); -- yes, only one author supported
args.P2 = (pframe.args[second_pnum] and mw.text.trim (pframe.args[second_pnum])) or ''; -- when positional author, year must also be positional
for _, v in ipairs ({'P3', 'P4', 'P5'}) do -- blank the rest of these for this source
args[v] = '';
end
first_pnum = first_pnum + 2; -- source must use positional author and positional year
second_pnum = first_pnum + 1; -- bump these for possible next positional source
end
args.postscript = pframe.args[table.concat ({n, 'ps'})] or '';
if 'none' == args.postscript then -- this for compatibility with other footnote templates; does nothing
args.postscript = '';
end
args.ref = pframe.args[table.concat ({n, 'ref'})] or ''; -- alternate reference for this source
args.page = pframe.args[table.concat ({n, 'p'})] or ''; -- insource locations for this source
args.pages = pframe.args[table.concat ({n, 'pp'})] or '';
args.pages = ('' ~= args.pages) and hyphen_to_dash (args.pages) or '';
args.location = pframe.args[table.concat ({n, 'loc'})] or '';
args.ignore = ('yes' == pframe.args[table.concat ({n, 'ignore-false-positive'})]) or ('yes' == pframe.args[table.concat ({n, 'ignore-err'})]);
table.insert (out, core (args)); -- save the rendering of this source
for k, v in ipairs ({'P1', 'P2', 'P3', 'P4', 'P5'}) do -- create the FOOTNOTE id
if '' ~= args[v] then
table.insert (footnote, args[v]);
end
end
for k, v in ipairs ({'page', 'pages', 'location'}) do -- these done separately so that we can strip uri-reserved characters from extlinked page numbers
if '' ~= args[v] then
table.insert (footnote, strip_url (args[v]))
end
end
last_index = n; -- flags used to select terminal postscript from nps or from end_ps
if '' ~= args.postscript then
last_ps = n;
end
n = n+1; -- bump for the next one
end
local name = table.concat (footnote):gsub ('%s+', ' '); -- put the footnote together and strip redundant space
args.end_ps = pframe.args.postscript or pframe.args.ps or '.'; -- this is the postscript for the whole not for the individual sources
if 'none' == args.end_ps then -- not an original sfnm parameter value; added for compatibility with other footnote templates
args.end_ps = '';
end
local result = table.concat ({table.concat (out, '; '), (last_index == last_ps) and '' or args.end_ps});
return frame:extensionTag ({name='ref', args={name=name}, content=result});
end
--[[--------------------------< S F N R E F >------------------------------------------------------------------
implements {{sfnref}}
]]
local function sfnref (frame)
local args = getArgs (frame);
local out = {};
for i=1, 5 do -- get the first five args if there are five args
if args[i] then
out[i] = args[i];
else
break; -- less than 5 args break out
end
end
if 5 == #out then -- when we have seen five args there may bemore
local i = 6; -- initialize the indexer to the sixth positional parameter
while args[i] do -- in case there are too many authors loop through the authors looking for a year
if is_year (args[i], args) then -- if a year
out[5] = args[i]; -- overwrite whatever was in args[5] with year
break; -- and abandon the search
end
i = i + 1; -- bump the indexer
end
end
return mw.uri.anchorEncode ('CITEREF' .. table.concat (out));
end
--[[--------------------------< E X P O R T E D F U N C T I O N S >------------------------------------------
]]
return {
harvard_citation = harvard_citation,
sfn = sfn,
sfnm = sfnm,
sfnref = sfnref,
};
2x57eg4kn4kd2u38h6p4rteov6l4211
มอดูล:Footnotes/anchor id list
828
57696
189417
2022-08-16T14:43:11Z
Venise12mai1834
8884
สร้างหน้าด้วย "require('Module:No globals'); local data = mw.loadData ('Module:Footnotes/anchor id list/data'); local whitelist = mw.loadData ('Module:Footnotes/whitelist'); local Lang_obj = mw.language.getContentLanguage(); -- used by template_list_add() to uppercase first letter of template name TODO: better way to do that? local redirects_date = { ['date'] = true, ['datetomos'] = true, ['formatdate'] = true, ['isotodmymdy'] = true, ['isotomos'] = t..."
Scribunto
text/plain
require('Module:No globals');
local data = mw.loadData ('Module:Footnotes/anchor id list/data');
local whitelist = mw.loadData ('Module:Footnotes/whitelist');
local Lang_obj = mw.language.getContentLanguage(); -- used by template_list_add() to uppercase first letter of template name TODO: better way to do that?
local redirects_date = {
['date'] = true,
['datetomos'] = true,
['formatdate'] = true,
['isotodmymdy'] = true,
['isotomos'] = true,
}
local redirects_patent = { -- special case cs1-like templates because uses different parameters for name and date in anchor ID
['Cite patent'] = true,
['Citeref patent'] = true,
['Ref patent'] = true,
}
local redirects_sfnref = {
['sfnref'] = true,
['harvid'] = true,
}
local aliases_author = { -- these use pseudo-patterns in the same way as cs1|2; '#' represents 1 or more enumerator digits
'last#',
'author#',
'surname#',
'author-last#',
'author#-last',
'subject#',
'host#',
}
local aliases_contributor = {
'contributor#',
'contributor-last#',
'contributor#-last',
'contributor-surname#',
'contributor#-surname',
}
local aliases_editor = {
'editor#',
'editor-last#',
'editor#-last',
'editor-surname#',
'editor#-surname',
}
local aliases_harvc_author = {
'last#',
'author#',
}
local aliases_inventor = { -- cite patent
'inventor#',
'inventor-last#',
'inventor#-last',
'inventor-surname#',
'inventor#-surname',
'invent#',
'invent-#',
}
local alias_patterns_date = { -- normal lua patterns for most cs1|2-like templates
'|%s*year%s*=%s*',
'|%s*date%s*=%s*',
'|%s*publication%-?date%s*=%s*',
'|%s*air%-?date%s*=%s*',
}
local alias_patterns_harvc_date = { -- normal lua patterns for harvc template
'|%s*anchor%-year%s*=%s*',
'|%s*year%s*=%s*',
}
local alias_patterns_patent_date = { -- normal lua patterns for cite patent templates
'|%s*issue%-date%s*=%s*',
'|%s*gdate%s*=%s*',
'|%s*publication%-date%s*=%s*',
'|%s*pubdate%s*=%s*',
}
local patterns_date = { -- normal lua patterns
'(%d%d%d%d–%d%d%d%d%l?)$', -- YYYY–YYYY four-digit year range at end (Season YYYY–YYYY); with or without dab
'^(%d%d%d%d–%d%d%l?)$', -- YYYY–YY two-digit year range; with or without dab
'^(c%. %d%d%d%d?%l?)$', -- three- or four-digit circa year; with or without dab
'(%d%d%d%d?%l?)$', -- three- or four-digit year at end of date (dmy or mdy); with or without dab
'^(%d%d%d%d?%l?)', -- three- or four-digit year at beginning of date (ymd or YYYY); with or without dab
'^(n%.d%.%l?)$', -- 'no date' with dots; with or without dab
'^(nd%l?)$', -- 'no date' without dots; with or without dab
}
local patterns_tags = {
'<nowiki>.-</nowiki>',
'<!%-%-.-%-%->',
'<pre>.-</pre>',
'<syntaxhighlight.->.-</syntaxhighlight>',
'<source.->.-</source>', -- deprecated alias of syntaxhighlight tag
}
local template_skip = { -- templates to be skipped for whatever reason; mostly because they resemble cs1-like templates
['Citation-attribution'] = true,
}
local Article_content;
local anchor_id_list = {}; -- exported tables
local template_list = {};
local article_whitelist = {};
--[[--------------------------< A R T I C L E _ C O N T E N T _ G E T >----------------------------------------
get article content, remove certain html-like tags and their content so that this code doesn't include any citation
templates inside the tags as valid tagets; they are not.
]]
local function article_content_get ()
if not Article_content then
Article_content = mw.title.getCurrentTitle():getContent() or ''; -- get the content of the article or ''; new pages edited w/ve do not have 'content' until saved; ve does not preview; phab:T221625
for _, tag in ipairs (patterns_tags) do
Article_content = Article_content:gsub (tag, ''); -- remove certain html-like tags and their content
end
end
end
--[[--------------------------< S F N R E F _ G E T >----------------------------------------------------------
make an anchor id from the contents of {{sfnref}} or {{harvid}}. this function assumes that {{sfnref}} and {{harvid}}
are correctly formed.
]]
local function sfnref_get (template)
template = template:gsub ('{{%s*(.-)%s*}}', '%1'); -- strip bounding template markup and trim
local parts = mw.text.split (template, '%s*|%s*'); -- split at the pipe and remove extraneous space characters
local anchor_id = {};
if redirects_sfnref[parts[1]:lower()] then
anchor_id[1] = 'CITEREF';
else
return nil; -- not an sfnref or harvid template
end
local i = 2; -- indexer into parts{} table
local j = 2; -- indexer into anchor_id{} table which already has 'CITEREF' at [1]
while parts[i] and 7 > j do -- loop through what should be just positional parameters for names and year (2-6 four names and a date)
if not parts[i]:find ('=') then -- look for equal sign (named paraneter in a template that doesn't support named parameters)
anchor_id[j] = parts[i]; -- positional parameters are saved
j = j+1; -- bump the anchor_id{} indexer
end
i = i+ 1; -- bump the parts{} indexer
end
return table.concat (anchor_id, '');
end
--[[--------------------------< D A T E _ G E T >--------------------------------------------------------------
extract year from one of |year=, |date=, |publicationdate=, or |publication-date in that order. Does not error
check (that is left to the cs1|2 templates to do)
also gets date from |<date alias>={{date|...}}
]]
local function date_get (template, aliases)
local date;
local rvalue;
for _, pattern in ipairs (aliases) do -- spin through the date alias patterns
rvalue = tostring(template):match (pattern); -- is this |<date alias>= used (tostring() because something makes match() think template is a table)
if rvalue then
rvalue = tostring(template):match (pattern .. '(%b{})'); -- is rvalue a template?
if rvalue then
rvalue = rvalue:gsub ('{{%s*(.-)%s*}}', '%1'); -- strip bounding template markup and trim
local parts = mw.text.split (rvalue, '%s*|%s*'); -- split at the pipe and remove extraneous space characters
if redirects_date[parts[1]:lower()] then -- if parts[1] names {{date}} or redirect
rvalue = parts[2]; -- assume that date template is properly formed, first positional parameter is the date
else
return ''; -- |date= holds some other template than {{date}} or redirect
end
else
rvalue = template:match (pattern .. '([^|}]+)');
if rvalue then -- if rvalue is something
rvalue = mw.text.trim (rvalue); -- trim it
end
if not rvalue or '' == rvalue then -- if rvale was nothing or trimed to nothing
rvalue = nil; -- ensure that it is unset so we can try the next parameter in the list
end
end
if rvalue then
for _, pattern in ipairs (patterns_date) do -- spin through the recognized date formats
date = rvalue:match (pattern); -- attempt to extract year portion according to the pattern
if date then
return date; -- matched so return;
end
end
break; -- found a date but it was malformed so abandon
end
end
end
return ''; -- no date param or date param doesn't hold a recognized date; empty string for concatenation
end
--[[--------------------------< V N A M E S _ G E T >----------------------------------------------------------
extract names from |vauthors= or |veditors=; there is no |vcontributors= parameter.
splits the v parameter value at the comma; correctly handles accept-as-witten markup when used to wrap a comma-
separated names (corporate)
]]
local function vnames_get (params, vparam)
local vnames = {}; -- first four author or editor names go here
local split = {}; -- temp table to assist in decoding accept-as-witten-markup
if params[vparam] then -- test for |vauthors= or |veditor=
split = mw.text.split (params[vparam], '%s*,%s*'); -- this will separate portions of ((Black, Brown, White, an Co.))
local i = 1; -- an indexer
while split[i] do
if split[i]:match ('^%(%(.*[^%)][^%)]$') then -- first segment of comma-separated accept-as-witten; this segment has the opening doubled parens
local name = split[i];
i=i+1; -- bump indexer to next segment
while split[i] do
name = name .. ', ' .. split[i]; -- concatenate with previous segments
if split[i]:match ('^.*%)%)$') then -- if this table member has the closing doubled parens
break; -- and done reassembling so
end
i=i+1; -- bump indexer
end
table.insert (vnames, name); -- and add accept-as-witten name to the vnames table
else
table.insert (vnames, split[i]); -- and add name to the vnames table
end
i=i+1; -- bump indexer
if 5 == i then break; end -- limit to four names
end
for i, vname in ipairs (vnames) do
if not vname:match ('%(%(.-%)%)') then -- without accept-this-value-as-written markup
vnames[i] = vname:gsub ('(.-)%s+%u+$', '%1'); -- extract and save surname(s)
end
end
for i, vname in ipairs (vnames) do -- repeat, this time for accept-this-value-as-written markup
vnames[i] = vname:gsub ('%(%((.-)%)%)', '%1'); -- remove markup if present and save the whole name
end
end
return 0 ~= #vnames and table.concat (vnames) or nil -- return a concatenation of the vnames; nil else
end
--[[--------------------------< N A M E S _ G E T >------------------------------------------------------------
cs1|2 makes anchor id from contributor, author, or editor name-lists in that order
get the names from the cs1|2 template; if there are no contributor names, try author names, then try editor names.
returns concatenated names in enumeration order when successful; nil else
empty name (nameholding parameter n is present without value) and missing name (nameholding parameter n is not
present) are included as empty string with all other names
]]
local function names_get (params, aliases_list)
local names = {}; -- first four author or editor names go here
local enum_alias; -- alias with '#' replaced with a digit
for enum=1, 4 do -- four names only
for i, alias in ipairs (aliases_list) do
if not names[enum] then -- hanven't found a previous alias with this [enum]? see if we can find this alias with this enum
enum_alias = alias:gsub ('#', enum); -- replace '#' to make 'lastn'
if 1 == enum then -- because |last= and last1= are exact aliases
if params[enum_alias] then -- test |last1= first
names[enum] = params[enum_alias]; -- found so save the value assigned to |last1=
break; -- next enum
else
enum_alias = alias:gsub ('#', ''); -- replace '#' to make 'last'
if params[enum_alias] then
names[enum] = params[enum_alias]; -- found so save the value assigned to |last=
break; -- next enum
end
end
else -- here for enum 2, 3, 4
if params[enum_alias] then
names[enum] = params[enum_alias]; -- found so save the value assigned to |lastn=
break; -- next enum
end
end
end
end
end
for enum=1, 4 do -- spin through the names table and
local name = names[enum];
if not name then -- when nameholding parameter n is not present (nil)
name = ''; -- convert to empty string for concatenation
end
name = name:gsub('%(%((.-)%)%)', '%1'); -- remove accept-as-written markup if present
names[enum] = name; -- save the modified name
end
local name_str = table.concat (names); -- concatenate the names
return '' ~= name_str and name_str or nil; -- return the concatenation if not empty string; nil else
end
--[[--------------------------< T E M P L A T E _ S T R I P >--------------------------------------------------
removes the citation or havrc template's {{ and }} markup then removes, in whole, any templates found inside the
citation or harvc template.
Templates are not allowed in parameters that are made part of COinS metadata; yet, they will appear. cs1|2 does
not see the template markup but instead sees the result of the template as html. cs1|2 strips the html which
leaves the displayed value for the anchor id. We can't do that here so, because templates aren't allowed in
parameters, we simply discard any templates found in the cs1|2 template.
this may leave a |lastn= parameter empty which will be treated as if it were really empty as cs1|2 do (three authors,
|last2= empty -> CITEREFLast1Last3YYYY (the harv and sfn render: 'Last1, & Last3 YYYY' with CITEREFLast1Last3YYYY).
]]
local function template_strip (template)
template = template:gsub ('^{{%s*', ''):gsub ('%s*}}$', '', 1); -- remove outer {{ and }} (cs1|2 template delimiters with trailing/leading whitespace)
template = template:gsub ('%b{}', ''); -- remove any templates from the cs1|2 template
return template;
end
--[[--------------------------< E S C A P E _ L U A _ M A G I C _ C H A R S >----------------------------------
Returns a string where all of lua's magic characters have been escaped. This is important because functions like
string.gsub() treat their pattern and replace strings as patterns, not literal strings.
]]
local function escape_lua_magic_chars (argument)
argument = argument:gsub("%%", "%%%%"); -- replace % with %%
argument = argument:gsub("([%^%$%(%)%.%[%]%*%+%-%?])", "%%%1"); -- replace all other lua magic pattern characters
return argument;
end
--[=[-------------------------< W I K I L I N K _ S T R I P >--------------------------------------------------
Wikilink markup does not belong in an anchor id and can / does confuse the code that parses apart citation and
harvc templates so here we remove any wiki markup:
[[link|label]] -> label
[[link]] -> link
]=]
local function wikilink_strip (template)
for wikilink in template:gmatch ('%[%b[]%]') do -- get a wikilink
template = template:gsub ('%[%b[]%]', '__57r1P__', 1); -- install a marker
if wikilink:match ('%[%[.-|(.-)%]%]') then
wikilink = wikilink:match ('%[%[.-|(.-)%]%]'); -- extract label from complex [[link|label]] wikilink
else
wikilink = wikilink:match ('%[%[(.-)%]%]'); -- extract link from simple [[link]] wikilinks
end
wikilink = escape_lua_magic_chars (wikilink); -- in case there are lua magic characters in wikilink
template = template:gsub ('__57r1P__', wikilink, 1); -- replace the marker with the appropriate text
end
return template;
end
--[[--------------------------< T E M P L A T E _ N A M E _ G E T >--------------------------------------------
return the citation or harvc template's name; convert to lower case and trim leading and trailing whitespace;
when the template is a sandbox the subpage portion of the template name is omitted from the returned template name
{{Cite book/new |...}} returns cite book
]]
local function template_name_get (template)
local template_name = template:match ('^{{%s*([^/|}]+)'); -- get template name; ignore subpages ~/new, ~/sandbox; parser functions
if not template_name or template_name:match ('^#') then -- parser functions, magic words don't count as templates
return nil; -- could not get template name from (possibly corrupt) template; extraneous opening { mid template can cause this;
end;
template_name = template_name:gsub ('%s*$', ''); -- trim trailing whitespace; leading whitespace already removed
return Lang_obj:ucfirst (template_name); -- first character in template name must be uppercase (same as canonical template name) TODO: better way to do this?
end
--[[--------------------------< T E M P L A T E _ P A R A M S _ G E T >----------------------------------------
parse apart a template's parameters and store in the params table where key is the parameter's name and value is
the parameter's value; empty parameters are not saved
]]
local function template_params_get (template, params_t)
template = wikilink_strip (template); -- because piped wikilinks confuse code that builds params_t{} and because wikilinks not allowed in an anchor id
-- strip templates after getting |ref= value because |ref={{sfnref}} and |ref={{harvid}} are allowed
template = template_strip (template); -- because template markup can confuse code that builds params_t{} and because templates in name parameters are not allowed
local temp_t = mw.text.split (template, '%s*|%s*'); --split on the pipe
for _, param in ipairs (temp_t) do
if param:find ('=', 1, true) then -- a named parameter?
local k, v = param:match ('%s*([^=]-)%s*=%s*([^|}]+)');
if v then -- there must be a value
if '' ~= v and not v:match ('^%s$') then -- skip when value is empty string or only whitespace
params_t[k] = mw.text.trim (v); -- add trimmed value else
end
end
end
end
end
--[[--------------------------< C I T E R E F _ M A K E _ H A R V C >------------------------------------------
makes anchor_id from {{harvc}} or redirects
]]
local function anchor_id_make_harvc (template)
local date = date_get (template, alias_patterns_harvc_date); -- get date; done here because might be in {{date}}; return date if valid; empty string else
local anchor_id;
local params = {}; -- table of harvc parameters
local id; -- custom anchor id for this {{harvc}} template
id = template:match ('|%s*id%s*=%s*(%b{})'); -- in case |id={{sfnref}}; done here because templates will be stripped
template_params_get (template, params); -- build a table of template parameters and their values; this strips wikilinks and templates
if id then -- when set is {{sfnref}} or {{harvid}} template
return sfnref_get (id); -- returns content of {{sfnref}} or {{harvid}}; nil else
end
if params.id then -- custom anchor for this {{harvc}} template (text)
return params.id; -- |id= value as written
end
anchor_id = names_get (params, aliases_harvc_author); -- get the harvc contributor names
if anchor_id then -- if names were gotten
return 'CITEREF' .. anchor_id .. date;
end
return nil; -- no names; no anchor_id
end
--[[--------------------------< A N C H O R _ I D _ M A K E _ W R A P P E R >----------------------------------
for wrapper templates
inspect externally visible |ref= to decide what to do:
|ref= - empty or missing: get names and date from whitelist defaults; override defaults from externally visible template parameters
|ref=harv - same as empty or missing
|ref={{SfnRef|name|name|name|name|year}} - assemble an anchor id from {{sfnref}} positional parameters
|ref={{Harvid|name|name|name|name|year}} - assemble an anchor id from {{harvid}} positional parameters
|ref=none - skip; do nothing because an anchor id intentionally suppressed; TODO: keep with a type code of '0'?
|ref=<text> - save param value because may match an anchor id override value in {{harv}} template |ref= parameter or {{harvc}} |id= parameter
]]
local function anchor_id_make_wrapper (template)
local ref; -- content of |ref=
local template_name; -- name of the template
local anchor_id; -- the assembled anchor id from this template
local date;
local name_default;
local date_default;
local vol;
local params = {}; -- table of template parameters
template_name = template_name_get (template); -- get first char uppercase trimmed template name; ignore subpages ~/new, ~/sandbox
if not template_name or template_skip[template_name] then
return nil; -- could not extract template name from (possibly corrupted) template (extraneous opening { in the template will cause this)
end
date = date_get (template, alias_patterns_date); -- get date; done here because might be in {{date}}
-- if '' == date then
-- date = whitelist.wrapper_templates[template_name][2] or ''; -- no externally visible date so get default date
-- end
ref = template:match ('|%s*ref%s*=%s*(%b{})'); -- first look for |ref={{sfnref}} or |ref={{harvid}} because we will strip templates from the wrapper template
if not ref then
if template:match ('|%s*ref%s*=([^|}]+)') then -- |ref={{template}} not found; if there is a |ref= param with an assigned value
ref = template:match ('|%s*ref%s*=([^|}]+)'); -- get the value; whitespace is a 'value'
if ref then -- nil when |ref=|... or when |ref=}} (no spaces between assignment operator and pipe or closing brace)
ref = mw.text.trim (ref); -- something, could be just whitespace, so trim leading / trailing whitespace
if '' == ref then -- trimming a string of whitespace makes an empty string
ref = nil; -- make empty ref same as missing ref
end
end
end
end
template_params_get (template, params); -- build a table of template parameters and their values
if whitelist.wrapper_templates[template_name][1] then -- is this wrapper a simple-default wrapper?
name_default = whitelist.wrapper_templates[template_name][1]; -- get the default names
date_default = whitelist.wrapper_templates[template_name][2]; -- get the default date
else
vol = params['volume'] or 'default';
if not whitelist.wrapper_templates[template_name][vol] then -- make sure this volume exists
vol = 'default'; -- doesn't exist, use default volume
end
name_default = whitelist.wrapper_templates[template_name][vol][1]; -- get the default names
date_default = whitelist.wrapper_templates[template_name][vol][2]; -- get the default date
end
if 'harv' == ref or not ref then -- |ref=harv specified or |ref= missing or empty
anchor_id = names_get (params, aliases_contributor) or -- get contributor, author, or editor names
names_get (params, aliases_author) or
vnames_get (params, 'vauthors') or -- |vauthors=
names_get (params, aliases_editor) or
vnames_get (params, 'veditors') or -- |veditors=
name_default; -- default names from whitelist
-- whitelist.wrapper_templates[template_name][1]; -- default names from whitelist
if '' == date then -- if date not provided in the template
date = date_default; -- use the default date from whitelist
end
if anchor_id then -- if names were gotten
anchor_id = 'CITEREF' .. anchor_id .. date;
end
elseif ref:match ('%b{}') then -- ref holds a template
anchor_id = sfnref_get (ref); -- returns content of {{sfnref}} or {{harvid}}; nil else
elseif 'none' == ref then -- |ref=none
return nil; -- anchor id expicitly suppressed
else
anchor_id = ref; -- |ref=<text> may match an anchor id override value in {{harv}} template |ref= parameter
end
return anchor_id; -- anchor_id text; nil else
end
--[[--------------------------< A N C H O R _ I D _ M A K E _ C S 1 2 >----------------------------------------
for cs1|2 template and cs1-like templates
inspect |ref= to decide what to do:
|ref= - empty or missing: get names and date from template parameters; all cs1|2 create CITEREF anchor IDs
|ref=harv - get names and date from template parameters
|ref={{SfnRef|name|name|name|name|year}} - assemble an anchor id from {{sfnref}} positional parameters
|ref={{Harvid|name|name|name|name|year}} - assemble an anchor id from {{harvid}} positional parameters
|ref=none - skip; do nothing because an anchor id intentionally suppressed; TODO: keep with a type code of '0'?
|ref=<text> - save param value because may match an anchor id override value in {{harv}} template |ref= parameter or {{harvc}} |id= parameter
]]
local function anchor_id_make_cs12 (template)
local ref; -- content of |ref=
local template_name; -- name of the template
local anchor_id; -- the assembled anchor id from this template
local date;
local params = {}; -- table of template parameters
template_name = template_name_get (template); -- get first char uppercase trimmed template name; ignore subpages ~/new, ~/sandbox
if not template_name or template_skip[template_name] then
return nil; -- could not extract template name from (possibly corrupted) template (extraneous opening { in the template will cause this)
end
if redirects_patent[template_name] then
date = date_get (template, alias_patterns_patent_date); -- get date; done here because might be in {{date}}
else
date = date_get (template, alias_patterns_date);
end
ref = template:match ('|%s*ref%s*=%s*(%b{})'); -- first look for |ref={{sfnref}} or |ref={{harvid}} because we will strip templates from the cs1|2 template
if not ref then
if template:match ('|%s*ref%s*=([^|}]+)') then -- |ref={{template}} not found; if there is a |ref= param with an assigned value
ref = template:match ('|%s*ref%s*=([^|}]+)'); -- get the value; whitespace is a 'value'
if ref then -- nil when |ref=|... or when |ref=}} (no spaces between assignment operator and pipe or closing brace)
ref = mw.text.trim (ref); -- something, could be just whitespace, so trim leading / trailing whitespace
if '' == ref then -- trimming a string of whitespace makes an empty string
ref = nil; -- make empty ref same as missing ref
end
end
end
end
template_params_get (template, params); -- build a table of template parameters and their values
if not ref then -- |ref= not set, might be cite LSA which doesn't support |ref=
if 'cite lsa' == template_name then
return 'CITEREF' .. (params.last or '') .. (params.year or ''); -- cite LSA always creates an anchor id using only |last= and |year= (no aliases)
end
end
if 'harv' == ref or not ref then -- |ref=harv specified or |ref= missing or empty
if redirects_patent[template_name] then -- if this is a cite patent template
anchor_id = names_get (params, aliases_inventor); -- inventor names only
else -- cs1|2 template
anchor_id = names_get (params, aliases_contributor) or -- get contributor, author, or editor names
names_get (params, aliases_author) or
vnames_get (params, 'vauthors') or -- |vauthors=
names_get (params, aliases_editor) or
vnames_get (params, 'veditors'); -- |veditors=
end
if anchor_id then -- if names were gotten
anchor_id = 'CITEREF' .. anchor_id .. date;
end
elseif ref:match ('%b{}') then -- ref holds a template
anchor_id = sfnref_get (ref); -- returns content of {{sfnref}} or {{harvid}}; nil else
elseif 'none' == ref and not redirects_patent[template_name] then -- |ref=none; not supported by cite patent
return nil; -- anchor id expicitly suppressed
else
anchor_id = ref; -- |ref=<text> may match an anchor id override value in {{harv}} template |ref= parameter
end
return anchor_id; -- anchor_id text; nil else
end
--[[--------------------------< L I S T _ A D D >--------------------------------------------------------------
adds an <item> to <list> table; for anchor IDs, the boolean <encode> argument must be set true; no return value
]]
local function list_add (item, list, encode)
if item then -- if there was an item
if encode then -- for anchor IDs ...
item = mw.uri.anchorEncode (item); -- encode to remove wikimarkup, convert spaces to underscores etc
end
if not list[item] then -- if not already saved
list[item] = 1; -- save it
else -- here when this item already saved
list[item] = list[item] + 1; -- to indicate that there are multiple items
end
end
end
--[[--------------------------< A N C H O R _ I D _ M A K E _ A N C H O R >------------------------------------
make anchor IDs from {{anchor}}; there may be more than one because {{anchor}} is not limited to the number of
anchors it may hold.
]]
local function anchor_id_make_anchor (template, anchor_id_list)
template = template:gsub ('^{{[^|]+|', ''):gsub ('}}$', '', 1); -- remove outer {{ and }} and template name
template = wikilink_strip (template); -- strip any wikilink markup (there shouldn't be any but just in case)
local params = {};
local anchor_id;
for param in template:gmatch ('%b{}') do -- loop through the template; remove and save templates (presumed to be sfnref or harvid)
table.insert (params, param); -- save it
template = template:gsub ('%b{}', '', 1); -- remove it from source template
end
for _, t in ipairs (params) do -- spin through the templates in params
anchor_id = sfnref_get (t); -- attempt to decode {{sfnref}} and {{harvid}}
if anchor_id then -- nil when not {{sfnref}} or {{harvid}}
list_add (anchor_id, anchor_id_list, true); -- add anchor ID to the list
end
end
template = template:gsub ('|%s*|', '|'); -- when pipe follows pipe with or without white space, remove extraneous pipe
template = template:gsub ('^|', ''):gsub('|$', ''); -- remove extraneous leading and trailing pipes
params = mw.text.split (template, '%s*|%s*'); -- split at the pipe and remove extraneous space characters
for _, t in ipairs (params) do -- spin through the anchor IDs
anchor_id = mw.text.trim (t); -- trim white space
if '' ~= anchor_id then -- should always have something
list_add (anchor_id, anchor_id_list, true); -- add anchor ID to the list
end
end
end
--[[--------------------------< T E M P L A T E _ L I S T _ A D D >--------------------------------------------
makes a list of templates use in the article.
]]
local function template_list_add (template)
local template = template:match ('{{%s*(.-)[|}]'); -- keep the case of the template - this is different from template_name_get()
if template and not template:match ('^#') then -- found a template or magic word; ignore magic words
template=mw.text.trim (template); -- trim whitespace
template = Lang_obj:ucfirst (template); -- first character in template name must be uppercase (same as canonical template name) TODO: better way to do this?
list_add (template, template_list); -- add to list with (unused) tally
end
end
--[[--------------------------< A N C H O R _ I D _ L I S T _ M A K E >----------------------------------------
makes a list of anchor ids from cs1|2, cs1|2-like, vcite xxx, harvc, anchor, wikicite templates
Because cs1|2 wrapper templates can, and often do, hide the author and date parameters inside the wrapper,
these parameters are not available in the article's wikisource so {{harv}}, {{sfn}}, and {{harvc}} templates that
link correctly to those wrapper templates will incorrectly show error messages. Use |ignore-err=yes in the {{harv}},
{{sfn}}, and {{harvc}} templates to supress the error message.
creates a list of templates used in the article for use with the whitelist
creates a list of article-local whitelisted anchor IDs from {{sfn whitelist}}
]]
local function anchor_id_list_make ()
article_content_get (); -- attempt to get this article's content
if '' == Article_content then -- when there is no article content
return ''; -- no point in continuing
end
local template; -- place to hold the template that we found
local template_name;
local anchor_id; -- place to hold an anchor id as it is extracted / decoded
local find_pattern = '%f[{]{{[^{]';
local tstart, tend = Article_content:find (find_pattern); -- find the first template; do not find template variables: {{{template var|}}}
while tstart do
template = Article_content:match ('%b{}', tstart); -- get the whole template
if not template then
break; -- template is nil for some reason (last template missing closing }} for example) so declare ourselves done
end
template_name = template_name_get (template); -- get first char uppercase trimmed template name; ignore subpages ~/new, ~/sandbox
template_list_add (template); -- add this template's name to the list
if data.known_templates_cs12 [template_name] then
anchor_id = anchor_id_make_cs12 (template); -- extract an anchor id from this template
list_add (anchor_id, anchor_id_list, true)
elseif data.known_templates_vcite [template_name] then
local ref = template:match ('|%s*ref%s*=%s*(%b{})'); -- first look for |ref={{sfnref}} or |ref={{harvid}} because we will strip templates from the vcite template
if ref then -- |ref={{template}}
anchor_id = sfnref_get (ref); -- returns content of {{sfnref}} or {{harvid}}; nil else
list_add (anchor_id, anchor_id_list, true);
else
local params = {};
template_params_get (template, params); -- build a table of template parameters and their values
anchor_id = params['ref']; -- when both set, vcite uses value from |ref=
if not anchor_id and params['harvid'] then
anchor_id = 'CITEREF' .. params['harvid']; -- in vcite, |harvid= auto-adds 'CITEREF' prefix to the value in |harvid=
end
list_add (anchor_id, anchor_id_list, true);
end
elseif data.known_templates_harvc [template_name] then
anchor_id = anchor_id_make_harvc (template); -- extract an anchor id from this template
list_add (anchor_id, anchor_id_list, true);
elseif data.known_templates_wikicite [template_name] then
local ref = template:match ('|%s*ref%s*=%s*(%b{})'); -- first look for |ref={{sfnref}} or |ref={{harvid}}
if ref then
anchor_id = sfnref_get (ref);
elseif template:match ('|%s*ref%s*=([^|}]+)') then
anchor_id = template:match ('|%s*ref%s*=([^|}]+)'); -- plain-text
elseif template:match ('|%s*id%s*=%s*(%b{})') then
ref = template:match ('|%s*id%s*=%s*(%b{})');
anchor_id = 'Reference-' .. sfnref_get (ref);
elseif template:match ('|%s*id%s*=([^|}]+)') then
anchor_id = 'Reference-' .. template:match ('|%s*id%s*=([^|}]+)'); -- plain-text
else
anchor_id = nil; -- no matches, ensure that anchor_id has no value
end
if anchor_id then
list_add (anchor_id, anchor_id_list, true);
end
elseif data.known_templates_anchor [template_name] then
anchor_id_make_anchor (template, anchor_id_list); -- extract anchor ids from this template if any
elseif data.known_templates_sfn_whitelist [template_name] then
template = template:gsub ('^{{[^|]+|', ''):gsub ('}}$', '', 1); -- remove outer {{ and }} and template name
template = mw.text.trim (template, '%s|'); -- trim leading trailing white space and pipes
template = mw.text.split (template, '%s*|%s*'); -- make a table of the template's parameters
for _, anchor_id in ipairs (template) do -- spin through this template's parameter
if '' ~= anchor_id and not article_whitelist[anchor_id] then
anchor_id = mw.uri.anchorEncode (anchor_id)
article_whitelist[anchor_id] = 1; -- add to the whitelist
end
end
elseif template_name and whitelist.wrapper_templates[template_name] then
anchor_id = anchor_id_make_wrapper (template); -- extract an anchor id from this template if possible
list_add (anchor_id, anchor_id_list, true);
elseif template_name and template_name:match ('^Cit[ea]') then -- not known, not known wrapper; last gasp, try as cs1-like
anchor_id = anchor_id_make_cs12 (template); -- extract an anchor id from this template if possible
list_add (anchor_id, anchor_id_list, true);
end
tstart, tend = Article_content:find (find_pattern, tend); -- search for another template; begin at end of last search
end
mw.logObject (anchor_id_list, 'anchor_id_list');
mw.logObject (template_list, 'template_list');
mw.logObject (article_whitelist, 'article_whitelist');
return anchor_id_list;
end
--[[--------------------------< E X P O R T E D _ T A B L E S >------------------------------------------------
]]
return {
anchor_id_list = anchor_id_list_make(), -- table of anchor ids available in this article
article_whitelist = article_whitelist, -- table of anchor ids with false-positive error message to be suppressed
template_list = template_list, -- table of templates used in this article
}
ibyy77ipwctiz76c90sit32pquvfgtt
มอดูล:Footnotes/anchor id list/data
828
57697
189418
2022-08-16T14:43:51Z
Venise12mai1834
8884
สร้างหน้าด้วย "-- copied from Module:Ref info/data - maybe overkill here? -- for this application make lists from the redirect lists and force all template names first character uppercase require('Module:No globals'); --[[--------------------------< C S 1 _ T E M P L A T E _ P A T T E R N S >------------------------------------ These are patterns for cs1 templates and their redirects. These patterns exclude redirects that are vcite-like which redirects should..."
Scribunto
text/plain
-- copied from Module:Ref info/data - maybe overkill here?
-- for this application make lists from the redirect lists and force all template names first character uppercase
require('Module:No globals');
--[[--------------------------< C S 1 _ T E M P L A T E _ P A T T E R N S >------------------------------------
These are patterns for cs1 templates and their redirects. These patterns exclude redirects that are vcite-like
which redirects should be deleted because vcite is not cs1.
]]
local cs1_template_patterns = { -- lua patterns of the cannonical names and redirects
'[Cc]ite ar[Xx]iv', -- arXiv is the canonical name
'[Cc]ite ArXiv',
'[Cc]ite AV media', -- canonical
'[Cc]ite audio', '[Cc]ite AV', '[Cc]ite AV ?Media', '[Cc]ite av media',
'[Cc]ite cd', '[Cc]ite DVD', '[Cc]ite dvd', '[Cc]ite film',
'[Cc]ite image', '[Cc]ite media', '[Cc]ite movie',
'[Cc]ite music video', '[Cc]ite radio', '[Cc]ite song',
'[Cc]ite ?video', '[Cc]ite visual', '[Cc]ite You[Tt]ube',
'[Cc]ita vídeo', -- non-English redirect; TODO: tally separately?
'[Cc]ite AV media notes', -- canonical
'[Cc]ite album[ %-]notes', '[Cc]ite av media notes',
'[Cc]ite DVD[ %-]notes', '[Cc]ite dvd%-notes', '[Cc]ite liner notes',
'[Cc]ite music release notes', '[Ll]iner notes',
'[Cc]ite bio[Rr]xiv', -- bioRxiv is the canonical form
'[Cc]ite [Bb]ook', -- book is the canonical form
'[Bb]ook cite', '[Bb]ook reference', '[Bb]ook reference url',
'[Cc] book', '[Cc]it book', '[Cc]ite books', '[Cc]ite chapter',
'[Cc]ite ebook', '[Cc]ite manual', '[Cc]ite page',
'[Cc]ite publication', '[Cc]ite score',
'[Cc]ite work', '[Cc]ite%-?book',
'[Bb]okref', '[Cc]itace monografie', '[Cc]itar livro', -- non-English redirects; TODO: tally separately?
'[Cc]iteer boek', '[Oo]uvrage', '[Rr]ef%-llibre', '서적 인용',
'[Cc]ite citeseerx', -- canonical
'[Cc]ite conference', -- canonical
'[Cc]ita conferenza', '[Cc]ite proceedings', '[Cc]onference reference', -- cita conferenza is non-English; TODO: tally separately?
'[Cc]ite ?encyclopedia', -- cite encyclopedia is the canonical name
'[Cc]ite contribution', '[Cc]ite dic', '[Cc]ite dictionary',
'[Cc]ite encyclopaedia', '[Cc]ite encyclopædia', '[Ee]ncyclopedia',
'[Cc]ite [Ee]pisode', -- episode is the canonical form
'[Cc]ite show',
'[Cc]ite interview', -- canonical
'[Cc]ite ?journal', -- cite journal is the canonical form
'[Cc] journal', '[Cc]itation journal', '[Cc]ite abstract',
'[Cc]ite document', '[Cc]ite Journal', '[Cc]ite journal zh',
'[Cc]ite ?paper', '[Vv]cite2 journal',
'[Cc]ita pubblicazione', '[Cc]itace periodika', '[Cc]itar jornal', -- non-English redirects; TODO: tally separately?
'[Cc]itar publicació', '[Cc]ytuj pismo', '[Tt]idskriftsref',
'Навод из стручног часописа', '저널 인용',
'[Cc]ite [Mm]agazine', -- magazine is the canonical form
'[Cc]ite mag', '[Cc]ite magazine article', '[Cc]ite newsletter',
'[Cc]ite periodical',
'[Cc]ite mailing ?list', -- mailing list is the canonical form
'[Cc]ite list',
'[Cc]ite maps?', -- map is the canonical form
'[Cc]ite[ %-]?news', -- cite news is the canonical form
'[Cc] news', '[Cc]it news', '[Cc]itation news', '[Cc]ite article',
'[Cc]ite n', '[Cc]ite new', '[Cc]ite newspaper', '[Cc]ite News',
'[Cc]ite news%-q', '[Cc]ite news2', '[Cc]itenewsauthor', '[Cc]ute news',
'[Cc]itar notícia', '[Hh]aber kaynağı', '[Tt]idningsref', 'استشهاد بخبر', -- non-English redirects; TODO: tally separately?
'뉴스 인용',
'[Cc]ite newsgroup', -- canonical
'[Cc]ite usenet',
'[Cc]ite podcast', -- canonical
'[Cc]ite [Pp]ress release', -- press release is the canonical form
'[Cc]ite media release', '[Cc]ite news release', '[Cc]ite pr',
'[Cc]ite press', '[Cc]ite press release\.', '[Cc]ite press[%-]?release',
'[Cc]ite report', -- canonical
'[Cc]ite serial', -- canonical
'[Cc]ite sign', -- canonical
'[Cc]ite plaque',
'[Cc]ite speech', -- canonical
'[Cc]ite ssrn', -- canonical
'[Cc]ite SSRN',
'[Cc]ite tech ?report', -- techreport is the canonical form
'[Cc]ite standard', '[Cc]ite technical report', '[Tt]echrep reference',
'[Cc]ite thesis', -- canonical
'[Cc]ite dissertation',
'[Cc]itar tese', -- non-English redirect; TODO: tally separately?
'[Cc]ite [Ww]eb', -- web is the canonical form
'[Cc] web', '[Cc]it web', '[Cc]ite blog', '[Cc]ite URL', '[Cc]ite url',
'[Cc]ite w', '[Cc]ite wb', '[Cc]ite we', '[Cc]ite web\.',
'[Cc]ite webpage', '[Cc]ite website', '[Cc]ite website article',
'[Cc]ite%-?web', '[Cc]itweb', '[Cc]w', '[Rr]ef web', '[Ww]eb citation',
'[Ww]eb cite', '[Ww]eb link', '[Ww]eb[ %-]reference', '[Ww]eblink',
'[Cc]hú thích web', '[Cc]ita web', '[Cc]itace elektronické monografie', -- non-English redirects; TODO: tally separately?
'[Cc]itat web', 'مرجع ويب', 'یادکرد وب', '웹 인용',
}
--[[--------------------------< C S 2 _ T E M P L A T E _ P A T T E R N S >------------------------------------
These are patterns for cs2 templates redirects.
]]
local cs2_template_patterns = { -- lua patterns of the cannonical names and redirects
'[Cc]itation',
'[Cc]ite', '[Cc]ite citation', '[Cc]ite study',
'[Cc]ite [Tt]echnical standard',
}
--[[--------------------------< V C I T E _ T E M P L A T E _ P A T T E R N S >--------------------------------
These are patterns for Vcite-family templates and their redirects.
]]
local vcite_template_patterns = {
'[Vv]cite book', -- canonical
'[Vv]ancite book', '[Vv]ancite report', '[Vv]cite encyclopedia',
'[Vv]cite report',
'[Vv]cite journal', -- canonical
'[Cc]it journal', '[Cc]it paper', '[Vv]ancite journal', '[Vv]cite paper',
'[Vv]cite news', -- canonical
'[Vv]ancite news',
'[Vv]cite web', -- canonical
'[Vv]ancite web',
}
--[[--------------------------< H A R V C _ T E M P L A T E _ P A T T E R N S >--------------------------------
These are patterns for the harvc template and its redirects.
]]
local harvc_template_patterns = {
'[Hh]arvc', -- canonical
'[Cc]itec',
}
--[[--------------------------< C S 1 _ L I K E _ T E M P L A T E _ P A T T E R N S >--------------------------
These are patterns for miscellaneous templates and their redirects that 'look like' cs1 templates (begin with cite ...)
Because they 'look like' cs1 templates they are handled as if they were cs1 templates. These templates are NOT
wrapper templates; names and dates are always to be extracted from the article instantiation of the template.
]]
local cs1_like_template_patterns = {
'[Cc]ite LSA', -- canonical
}
--[[--------------------------< W I K I C I T E _ T E M P L A T E _ P A T T E R N S >--------------------------
These are patterns for the wikicite template and its redirects.
]]
local wikicite_template_patterns = {
'[Ww]ikicite', -- canonical
}
--[[--------------------------< A N C H O R _ T E M P L A T E _ P A T T E R N S >------------------------------
These are patterns for the anchor template and its redirects.
]]
local anchor_template_patterns = {
'[Aa]nchors?', -- anchor is canonical form
'[Aa]nchor for redirect',
'[Aa]nchro',
'[Aa]ncor',
}
--[[--------------------------< S F N _ W H I T E L I S T _ P A T T E R N S >----------------------------------
These are patterns for the anchor template and its redirects.
]]
local sfn_whitelist_patterns = {
'[Ss]fn whitelist', -- canonical
'[Hh]arv whitelist',
}
--[[--------------------------< K N O W N _ T E M P L A T E S >------------------------------------------------
These tables are created from the *_template_patterns tables. To make these tables, entries in the source tables
are evaluated to replace lua patterns with the appropriate characters to create names for the output tables.
First charqacter is always uppercase
For example:
[Cc]ite ar[Xx]iv
becomes
Cite arXiv
Cite arxiv
]]
local known_templates_cs12 = {}; -- the exported tables
local known_templates_vcite = {};
local known_templates_harvc = {};
local known_templates_wikicite = {};
local known_templates_anchor = {};
local known_templates_sfn_whitelist = {};
local function add_stripped (list, name)
if not list[name] then
list[name] = true;
end
end
local function pattern_convert (pattern, list)
local lead, tail, c, l, name;
local first_char_patterns = {
'^%[(%a)%a%]', -- leading character (usually uppercase)
'^%[%a(%a)%]', -- leading character (usually lowercase)
}
c = tostring (pattern:match ('%u')); -- tostring() required because I don't know why; lua chokes complaining that c is not a string
name = pattern:gsub ('^%[%a%a%]', c); -- replace bracketed first character [Xx] with selected character from the match
if name:match ('(.-)%[(%a)(%a)%](.*)') then -- mixed case optional letters
lead, c, l, tail = name:match ('(.-)%[(%a)(%a)%](.*)');
add_stripped (list, lead .. c .. tail); -- uppercase
add_stripped (list, lead .. l .. tail); -- lowercase
elseif name:match ('^([^%[]+)(%[ %%%-%]%?)(.+)$') then -- [ %-]?
lead, c, tail = name:match ('^([^%[]+)(%[ %%%-%]%?)(.+)$');
add_stripped (list, lead .. tail); -- neither char
add_stripped (list, lead .. ' ' .. tail); -- space
add_stripped (list, lead .. '-' .. tail); -- hyphen
elseif name:match ('^([^%[]+)(%[%%%-%]%?)(.+)$') then -- [%-]?
lead, c, tail = name:match ('^([^%[]+)(%[%%%-%]%?)(.+)$');
add_stripped (list, lead .. tail); -- no hyphen
add_stripped (list, lead .. '-' .. tail); -- hyphen
elseif name:match ('^([^%[]+)(%[ %%%-%])(.+)$') then -- [ %-]
lead, c, tail = name:match ('^([^%[]+)(%[ %%%-%])(.+)$');
add_stripped (list, lead .. ' ' .. tail); -- space
add_stripped (list, lead .. '-' .. tail); -- hyphen
elseif name:match ('^([^%?]+)(%%%-%?)(.+)$') then -- %-?
lead, c, tail = name:match ('^([^%?]+)(%%%-%?)(.+)$');
add_stripped (list, lead .. tail); -- no hyphen
add_stripped (list, lead .. '-' .. tail); -- hyphen
elseif name:match ('^(.-)(%%%-)(.+)$') then -- %-
lead, c, tail = name:match ('^(.-)(%%%-)(.+)$');
add_stripped (list, lead .. '-' .. tail); -- hyphen
elseif name:match ('^(.-)(.)%?(.*)$') then -- .?
lead, c, tail = name:match ('^(.-)(.)%?(.*)$');
add_stripped (list, lead .. tail); -- no character
add_stripped (list, lead .. c .. tail); -- character
else
add_stripped (list, name); -- no patterns so save as is
end
end
for _, t in ipairs ({
{cs1_template_patterns, known_templates_cs12},
{cs2_template_patterns, known_templates_cs12},
{cs1_like_template_patterns, known_templates_cs12},
{vcite_template_patterns, known_templates_vcite},
{harvc_template_patterns, known_templates_harvc},
{wikicite_template_patterns, known_templates_wikicite},
{anchor_template_patterns, known_templates_anchor},
{sfn_whitelist_patterns, known_templates_sfn_whitelist},
}) do
for _, pattern in ipairs (t[1]) do -- for each patern in *_template_patterns
pattern_convert (pattern, t[2]) -- convert and store in known_templates_*
end
end
--[[--------------------------< E X P O R T S >----------------------------------------------------------------
]]
return
{
known_templates_anchor = known_templates_anchor,
known_templates_cs12 = known_templates_cs12,
known_templates_harvc = known_templates_harvc,
known_templates_vcite = known_templates_vcite,
known_templates_wikicite = known_templates_wikicite,
known_templates_sfn_whitelist = known_templates_sfn_whitelist,
}
bht9pmjzuvuqajea0fn73uv88hds8sh
หมวดหมู่:แม่แบบอ้างอิง
14
57698
189419
2022-08-16T14:45:04Z
Venise12mai1834
8884
สร้างหน้าด้วย "[[หมวดหมู่:แม่แบบวิกิซอร์ซ|อ้างอิง]]"
wikitext
text/x-wiki
[[หมวดหมู่:แม่แบบวิกิซอร์ซ|อ้างอิง]]
3zw60wt7yyt49ndipuw5tebbdy2plik
แม่แบบ:Harvard citation text
10
57699
189425
2022-08-16T15:02:40Z
Venise12mai1834
8884
เปลี่ยนทางหน้าไปยัง [[แม่แบบ:ฮาร์เวิร์ด-ข้อความอ้างอิง]]
wikitext
text/x-wiki
#REDIRECT [[แม่แบบ:ฮาร์เวิร์ด-ข้อความอ้างอิง]]
lwkn0prhdfaudwh0645sd7s164is4r0
แม่แบบ:Harvtxt
10
57700
189426
2022-08-16T15:03:24Z
Venise12mai1834
8884
เปลี่ยนทางหน้าไปยัง [[แม่แบบ:ฮาร์เวิร์ด-ข้อความอ้างอิง]]
wikitext
text/x-wiki
#REDIRECT [[แม่แบบ:ฮาร์เวิร์ด-ข้อความอ้างอิง]]
lwkn0prhdfaudwh0645sd7s164is4r0
แม่แบบ:ฮวต
10
57701
189427
2022-08-16T15:04:01Z
Venise12mai1834
8884
เปลี่ยนทางหน้าไปยัง [[แม่แบบ:ฮาร์เวิร์ด-ตัวระบุ]]
wikitext
text/x-wiki
#REDIRECT [[แม่แบบ:ฮาร์เวิร์ด-ตัวระบุ]]
3px6d8fdkq0u7l8jsge0r95g71pqxm6
แม่แบบ:ฮวอ
10
57702
189428
2022-08-16T15:04:21Z
Venise12mai1834
8884
เปลี่ยนทางหน้าไปยัง [[แม่แบบ:ฮาร์เวิร์ด-ข้อความอ้างอิง]]
wikitext
text/x-wiki
#REDIRECT [[แม่แบบ:ฮาร์เวิร์ด-ข้อความอ้างอิง]]
lwkn0prhdfaudwh0645sd7s164is4r0
แม่แบบ:ฮาร์เวิร์ด-ข้อความอ้างอิง/doc
10
57703
189430
2022-08-16T15:13:27Z
Venise12mai1834
8884
สร้างหน้าด้วย "{{เว็บย่อ|[[แม่แบบ:ฮวอ]]<br>[[แม่แบบ:harvtxt]]}} ==วัตถุประสงค์== แม่แบบนี้ใช้สร้างการอ้างอิงในข้อความไปยังรายการอ้างอิงที่ใช้ [[แม่แบบ:ฮาร์เวิร์ด-ตัวระบุ]] ==วิธีใช้== ใช้โค้ดดัง..."
wikitext
text/x-wiki
{{เว็บย่อ|[[แม่แบบ:ฮวอ]]<br>[[แม่แบบ:harvtxt]]}}
==วัตถุประสงค์==
แม่แบบนี้ใช้สร้างการอ้างอิงในข้อความไปยังรายการอ้างอิงที่ใช้ [[แม่แบบ:ฮาร์เวิร์ด-ตัวระบุ]]
==วิธีใช้==
ใช้โค้ดดังนี้
<pre>{{harvtxt|1=|2=|p=|pp=}}</pre>
* ช่อง 1 ได้แก่ ข้อความในช่องที่ 1 ตามที่ใช้ใน แม่แบบ:ฮาร์เวิร์ด-ตัวระบุ, มักเป็นชื่อ (อาจเป็นชื่อเต็ม หรือเฉพาะชื่อสกุล) ผู้สร้างสรรค์
* ช่อง 2 ได้แก่ ข้อความในช่องที่ 1 ตามที่ใช้ใน แม่แบบ:ฮาร์เวิร์ด-ตัวระบุ, มักเป็นปี
* ช่อง p ได้แก่ เลขหน้า (ในกรณีที่มีหน้าเดียว)
* ช่อง pp ได้แก่ เลขหน้า (ในกรณีที่มีหลายหน้า)
==ตัวอย่าง==
<pre>{{harvtxt|Tolkien|2022|pp=10–20}}</pre>
{{harvtxt|Tolkien|2022|pp=10–20}}
[[หมวดหมู่:แม่แบบอ้างอิง]]
mfgirkjta0yyosbws8kolya2eprjvyr
189504
189430
2022-08-17T11:26:45Z
Venise12mai1834
8884
wikitext
text/x-wiki
{{เว็บย่อ|[[แม่แบบ:ฮวอ]]<br>[[แม่แบบ:harvtxt]]}}
==วัตถุประสงค์==
แม่แบบนี้ใช้สร้างการอ้างอิงในข้อความไปยังรายการอ้างอิงที่ใช้ [[แม่แบบ:ฮาร์เวิร์ด-ตัวระบุ]]
==วิธีใช้==
ใช้โค้ดดังนี้
<pre>{{harvtxt|1=|2=|p=|pp=}}</pre>
* ช่อง 1 ได้แก่ ข้อความในช่องที่ 1 ตามที่ใช้ใน แม่แบบ:ฮาร์เวิร์ด-ตัวระบุ, มักเป็นชื่อ (อาจเป็นชื่อเต็ม หรือเฉพาะชื่อสกุล) ผู้สร้างสรรค์
* ช่อง 2 ได้แก่ ข้อความในช่องที่ 1 ตามที่ใช้ใน แม่แบบ:ฮาร์เวิร์ด-ตัวระบุ, มักเป็นปี
* ช่อง p ได้แก่ เลขหน้า (ในกรณีที่มีหน้าเดียว)
* ช่อง pp ได้แก่ เลขหน้า (ในกรณีที่มีหลายหน้า)
==ตัวอย่าง==
<pre>{{harvtxt|Tolkien|2022|pp=10–20}}</pre>
{{harvtxt|Tolkien|2022|pp=10–20}}
==แม่แบบที่เกี่ยวข้อง==
* [[แม่แบบ:ฮาร์เวิร์ด-ข้อความอ้างอิง]]
* [[แม่แบบ:ฮาร์เวิร์ด-ข้อความอ้างอิง-ไม่วงเล็บ]]
[[หมวดหมู่:แม่แบบอ้างอิง]]
0vb8giscw25p1ls6t7rsvowit7wt5v5
189505
189504
2022-08-17T11:27:02Z
Venise12mai1834
8884
wikitext
text/x-wiki
==วัตถุประสงค์==
แม่แบบนี้ใช้สร้างการอ้างอิงในข้อความไปยังรายการอ้างอิงที่ใช้ [[แม่แบบ:ฮาร์เวิร์ด-ตัวระบุ]]
==วิธีใช้==
ใช้โค้ดดังนี้
<pre>{{harvtxt|1=|2=|p=|pp=}}</pre>
* ช่อง 1 ได้แก่ ข้อความในช่องที่ 1 ตามที่ใช้ใน แม่แบบ:ฮาร์เวิร์ด-ตัวระบุ, มักเป็นชื่อ (อาจเป็นชื่อเต็ม หรือเฉพาะชื่อสกุล) ผู้สร้างสรรค์
* ช่อง 2 ได้แก่ ข้อความในช่องที่ 1 ตามที่ใช้ใน แม่แบบ:ฮาร์เวิร์ด-ตัวระบุ, มักเป็นปี
* ช่อง p ได้แก่ เลขหน้า (ในกรณีที่มีหน้าเดียว)
* ช่อง pp ได้แก่ เลขหน้า (ในกรณีที่มีหลายหน้า)
==ตัวอย่าง==
<pre>{{harvtxt|Tolkien|2022|pp=10–20}}</pre>
{{harvtxt|Tolkien|2022|pp=10–20}}
==แม่แบบที่เกี่ยวข้อง==
* [[แม่แบบ:ฮาร์เวิร์ด-ข้อความอ้างอิง]]
* [[แม่แบบ:ฮาร์เวิร์ด-ข้อความอ้างอิง-ไม่วงเล็บ]]
[[หมวดหมู่:แม่แบบอ้างอิง]]
iw3s0jxvcqnd8l8xs3g9d9sslq3pnej
189507
189505
2022-08-17T11:29:30Z
Venise12mai1834
8884
wikitext
text/x-wiki
==วัตถุประสงค์==
แม่แบบนี้ใช้สร้างการอ้างอิงในข้อความไปยังรายการอ้างอิงที่ใช้ [[แม่แบบ:ฮาร์เวิร์ด-ตัวระบุ]]
==วิธีใช้==
ใช้โค้ดดังนี้
<pre>{{{{PAGENAME}}|1=|2=|p=|pp=}}</pre>
* ช่อง 1 ได้แก่ ข้อความในช่องที่ 1 ตามที่ใช้ใน แม่แบบ:ฮาร์เวิร์ด-ตัวระบุ, มักเป็นชื่อ (อาจเป็นชื่อเต็ม หรือเฉพาะชื่อสกุล) ผู้สร้างสรรค์
* ช่อง 2 ได้แก่ ข้อความในช่องที่ 1 ตามที่ใช้ใน แม่แบบ:ฮาร์เวิร์ด-ตัวระบุ, มักเป็นปี
* ช่อง p ได้แก่ เลขหน้า (ในกรณีที่มีหน้าเดียว)
* ช่อง pp ได้แก่ เลขหน้า (ในกรณีที่มีหลายหน้า)
==ตัวอย่าง==
<pre>{{{{PAGENAME}}|Tolkien|2022|pp=10–20}}</pre>
{{{{PAGENAME}}|Tolkien|2022|pp=10–20}}
==แม่แบบที่เกี่ยวข้อง==
* [[แม่แบบ:ฮาร์เวิร์ด-ข้อความอ้างอิง]]
* [[แม่แบบ:ฮาร์เวิร์ด-ข้อความอ้างอิง-ไม่วงเล็บ]]
[[หมวดหมู่:แม่แบบอ้างอิง]]
lzwkpgbpuofej7khagfmas4i1cp6mxg
189508
189507
2022-08-17T11:30:29Z
Venise12mai1834
8884
wikitext
text/x-wiki
==วัตถุประสงค์==
แม่แบบนี้ใช้สร้างการอ้างอิงในข้อความไปยังรายการอ้างอิงที่ใช้ [[แม่แบบ:ฮาร์เวิร์ด-ตัวระบุ]]
==วิธีใช้==
ใช้โค้ดดังนี้
<pre>{{ใส่ชื่อแม่แบบ|1=|2=|p=|pp=}}</pre>
* ช่อง 1 ได้แก่ ข้อความในช่องที่ 1 ตามที่ใช้ใน แม่แบบ:ฮาร์เวิร์ด-ตัวระบุ, มักเป็นชื่อ (อาจเป็นชื่อเต็ม หรือเฉพาะชื่อสกุล) ผู้สร้างสรรค์
* ช่อง 2 ได้แก่ ข้อความในช่องที่ 1 ตามที่ใช้ใน แม่แบบ:ฮาร์เวิร์ด-ตัวระบุ, มักเป็นปี
* ช่อง p ได้แก่ เลขหน้า (ในกรณีที่มีหน้าเดียว)
* ช่อง pp ได้แก่ เลขหน้า (ในกรณีที่มีหลายหน้า)
==ตัวอย่าง==
<pre>{{ฮาร์เวิร์ด-ข้อความอ้างอิง|Tolkien|2022|pp=10–20}}</pre>
{{ฮาร์เวิร์ด-ข้อความอ้างอิง|Tolkien|2022|pp=10–20}}
==แม่แบบที่เกี่ยวข้อง==
* [[แม่แบบ:ฮาร์เวิร์ด-ข้อความอ้างอิง]]
* [[แม่แบบ:ฮาร์เวิร์ด-ข้อความอ้างอิง-ไม่วงเล็บ]]
[[หมวดหมู่:แม่แบบอ้างอิง]]
lrpieu1d9e320v65r5yb99z5p9rh97i
189509
189508
2022-08-17T11:31:19Z
Venise12mai1834
8884
wikitext
text/x-wiki
==วัตถุประสงค์==
แม่แบบนี้ใช้สร้างการอ้างอิงในข้อความไปยังรายการอ้างอิงที่ใช้ [[แม่แบบ:ฮาร์เวิร์ด-ตัวระบุ]]
==วิธีใช้==
ใช้โค้ดดังนี้
<pre>{{ใส่ชื่อแม่แบบ|1=ใส่ข้อความ|2=ใส่ข้อความ|p=ใส่ข้อความ}}</pre>
* ช่อง 1 ได้แก่ ข้อความในช่องที่ 1 ตามที่ใช้ใน แม่แบบ:ฮาร์เวิร์ด-ตัวระบุ, มักเป็นชื่อ (อาจเป็นชื่อเต็ม หรือเฉพาะชื่อสกุล) ผู้สร้างสรรค์
* ช่อง 2 ได้แก่ ข้อความในช่องที่ 1 ตามที่ใช้ใน แม่แบบ:ฮาร์เวิร์ด-ตัวระบุ, มักเป็นปี
* ช่อง p ได้แก่ เลขหน้า
==ตัวอย่าง==
<pre>{{ฮาร์เวิร์ด-ข้อความอ้างอิง|Tolkien|2022|pp=10–20}}</pre>
{{ฮาร์เวิร์ด-ข้อความอ้างอิง|Tolkien|2022|pp=10–20}}
==แม่แบบที่เกี่ยวข้อง==
* [[แม่แบบ:ฮาร์เวิร์ด-ข้อความอ้างอิง]]
* [[แม่แบบ:ฮาร์เวิร์ด-ข้อความอ้างอิง-ไม่วงเล็บ]]
[[หมวดหมู่:แม่แบบอ้างอิง]]
byhzl6ilsrhn2pzwm6ik0l5cr5n1wme
หมวดหมู่:งานที่ต้นฉบับเป็นภาษาญี่ปุ่น
14
57704
189438
2022-08-16T15:34:24Z
Venise12mai1834
8884
สร้างหน้าด้วย "[[หมวดหมู่:งานแปล|ญี่ปุ่น]] [[หมวดหมู่:ประเทศญี่ปุ่น]]"
wikitext
text/x-wiki
[[หมวดหมู่:งานแปล|ญี่ปุ่น]]
[[หมวดหมู่:ประเทศญี่ปุ่น]]
6yif1y15bwg1fll7dieuig9w93aaks9
189439
189438
2022-08-16T15:35:46Z
Venise12mai1834
8884
wikitext
text/x-wiki
[[หมวดหมู่:งานแปลแบ่งตามภาษาต้นฉบับ|ญี่ปุ่น]]
[[หมวดหมู่:ภาษาญี่ปุ่น]]
giz1pdp5axjjs16vxxj0y7vrex8cm3x
หมวดหมู่:งานแปลแบ่งตามภาษาต้นฉบับ
14
57705
189448
2022-08-16T15:39:14Z
Venise12mai1834
8884
สร้างหน้าด้วย "[[หมวดหมู่:งานแปล]]"
wikitext
text/x-wiki
[[หมวดหมู่:งานแปล]]
6t7wg0jjenm9vf9zahfyim212q0yul3
แม่แบบ:Refbegin
10
57706
189458
2022-08-16T16:03:57Z
Venise12mai1834
8884
เปลี่ยนทางหน้าไปยัง [[แม่แบบ:เริ่มอ้างอิง]]
wikitext
text/x-wiki
#REDIRECT [[แม่แบบ:เริ่มอ้างอิง]]
9xcu550ww0les40insqh0jndf382ydz
แม่แบบ:Refend
10
57707
189459
2022-08-16T16:04:43Z
Venise12mai1834
8884
เปลี่ยนทางหน้าไปยัง [[แม่แบบ:จบอ้างอิง]]
wikitext
text/x-wiki
#REDIRECT [[แม่แบบ:จบอ้างอิง]]
ne696ij0qjg3vx52b8p55064janrrze
แม่แบบ:Refbegin/styles.css
10
57708
189460
2022-08-16T16:06:13Z
Venise12mai1834
8884
สร้างหน้าด้วย "/* {{pp-template}} */ .refbegin { font-size: 90%; margin-bottom: 0.5em; } .refbegin-hanging-indents > ul { margin-left: 0; } .refbegin-hanging-indents > ul > li { margin-left: 0; padding-left: 3.2em; text-indent: -3.2em; } .refbegin-hanging-indents ul, .refbegin-hanging-indents ul li { list-style: none; } @media (max-width: 720px) { .refbegin-hanging-indents > ul > li { padding-left: 1.6em; text-indent: -1.6em; } } .refbegin-column..."
sanitized-css
text/css
/* {{pp-template}} */
.refbegin {
font-size: 90%;
margin-bottom: 0.5em;
}
.refbegin-hanging-indents > ul {
margin-left: 0;
}
.refbegin-hanging-indents > ul > li {
margin-left: 0;
padding-left: 3.2em;
text-indent: -3.2em;
}
.refbegin-hanging-indents ul,
.refbegin-hanging-indents ul li {
list-style: none;
}
@media (max-width: 720px) {
.refbegin-hanging-indents > ul > li {
padding-left: 1.6em;
text-indent: -1.6em;
}
}
.refbegin-columns {
margin-top: 0.3em;
}
/* Reset top margin for lists embedded in columns */
.refbegin-columns ul {
margin-top: 0;
}
/* Avoid elements breaking between columns */
.refbegin-columns li {
page-break-inside: avoid; /* Removed from CSS in favor of break-inside c. 2020 */
break-inside: avoid-column;
}
4q8lm27loa8oa0mutzhmgc4bt8d7qlg
189461
189460
2022-08-16T16:06:36Z
Venise12mai1834
8884
sanitized-css
text/css
/* */
.refbegin {
font-size: 90%;
margin-bottom: 0.5em;
}
.refbegin-hanging-indents > ul {
margin-left: 0;
}
.refbegin-hanging-indents > ul > li {
margin-left: 0;
padding-left: 3.2em;
text-indent: -3.2em;
}
.refbegin-hanging-indents ul,
.refbegin-hanging-indents ul li {
list-style: none;
}
@media (max-width: 720px) {
.refbegin-hanging-indents > ul > li {
padding-left: 1.6em;
text-indent: -1.6em;
}
}
.refbegin-columns {
margin-top: 0.3em;
}
/* Reset top margin for lists embedded in columns */
.refbegin-columns ul {
margin-top: 0;
}
/* Avoid elements breaking between columns */
.refbegin-columns li {
page-break-inside: avoid; /* Removed from CSS in favor of break-inside c. 2020 */
break-inside: avoid-column;
}
3c2hg2zm7r7unbmhagi4dxrgygmppy4
แม่แบบ:รออ
10
57709
189469
2022-08-16T16:27:27Z
Venise12mai1834
8884
เปลี่ยนทางหน้าไปยัง [[แม่แบบ:เริ่มอ้างอิง]]
wikitext
text/x-wiki
#REDIRECT [[แม่แบบ:เริ่มอ้างอิง]]
9xcu550ww0les40insqh0jndf382ydz
แม่แบบ:จออ
10
57710
189470
2022-08-16T16:27:50Z
Venise12mai1834
8884
เปลี่ยนทางหน้าไปยัง [[แม่แบบ:จบอ้างอิง]]
wikitext
text/x-wiki
#REDIRECT [[แม่แบบ:จบอ้างอิง]]
ne696ij0qjg3vx52b8p55064janrrze
แม่แบบ:อนส
10
57711
189471
2022-08-16T16:28:34Z
Venise12mai1834
8884
เปลี่ยนทางหน้าไปยัง [[แม่แบบ:อ้างหนังสือ]]
wikitext
text/x-wiki
#REDIRECT [[แม่แบบ:อ้างหนังสือ]]
2x6zy1107r108c1xs7sczy7o3d6ltgf
แม่แบบ:อว
10
57712
189472
2022-08-16T16:29:02Z
Venise12mai1834
8884
เปลี่ยนทางหน้าไปยัง [[แม่แบบ:อ้างเว็บ]]
wikitext
text/x-wiki
#REDIRECT [[แม่แบบ:อ้างเว็บ]]
itlfmcs3xab77z998n0uaxv2ewxwr3n
แม่แบบ:อ้างวารสาร
10
57713
189483
2022-08-16T16:49:03Z
Venise12mai1834
8884
สร้างหน้าด้วย "<includeonly>{{#invoke:Citation/CS1|citation |CitationClass=journal }}</includeonly><noinclude> {{documentation}} </noinclude>"
wikitext
text/x-wiki
<includeonly>{{#invoke:Citation/CS1|citation
|CitationClass=journal
}}</includeonly><noinclude>
{{documentation}}
</noinclude>
9fcytsszanq7xbwi3p28zsneear9938
แม่แบบ:Cite journal
10
57714
189484
2022-08-16T16:49:34Z
Venise12mai1834
8884
เปลี่ยนทางหน้าไปยัง [[แม่แบบ:อ้างวารสาร]]
wikitext
text/x-wiki
#REDIRECT [[แม่แบบ:อ้างวารสาร]]
3ka8ksy4pgwpd6snuqn8i2ulz3hfpav
แม่แบบ:อวส
10
57715
189485
2022-08-16T16:49:48Z
Venise12mai1834
8884
เปลี่ยนทางหน้าไปยัง [[แม่แบบ:อ้างวารสาร]]
wikitext
text/x-wiki
#REDIRECT [[แม่แบบ:อ้างวารสาร]]
3ka8ksy4pgwpd6snuqn8i2ulz3hfpav
แม่แบบ:อ้างวารสาร/doc
10
57716
189489
2022-08-16T16:57:13Z
Venise12mai1834
8884
สร้างหน้าด้วย "{{เว็บย่อ|{{มบ|อวส}}}} ==วิธีใช้== ใช้โค้ดดังนี้ ===โค้ดที่ใช้บ่อย=== <pre> {{อ้างวารสาร | author = | year = | title = | journal = | volume = | issue = | pages = | url = | ref = }} </pre> ===โค้ดทั้งหมด=== <pre> {{อ้างวารสาร {{cite journal | last1 = | first1 = | author-link1 = | la..."
wikitext
text/x-wiki
{{เว็บย่อ|{{มบ|อวส}}}}
==วิธีใช้==
ใช้โค้ดดังนี้
===โค้ดที่ใช้บ่อย===
<pre>
{{อ้างวารสาร
| author =
| year =
| title =
| journal =
| volume =
| issue =
| pages =
| url =
| ref =
}}
</pre>
===โค้ดทั้งหมด===
<pre>
{{อ้างวารสาร
{{cite journal
| last1 =
| first1 =
| author-link1 =
| last2 =
| first2 =
| author-link2 =
| last3 =
| first3 =
| author-link3 =
| last4 =
| first4 =
| author-link4 =
| last5 =
| first5 =
| author-link5 =
| display-authors =
| author-mask =
| name-list-style =
| date =
| year =
| orig-date =
| editor1-last =
| editor1-first =
| editor1-link =
| editor2-last =
| editor2-first =
| editor2-link =
| editor3-last =
| editor3-first =
| editor3-link =
| editor4-last =
| editor4-first =
| editor4-link =
| editor5-last =
| editor5-first =
| editor5-link =
| display-editors =
| others =
| title =
| script-title =
| trans-title =
| url =
| format =
| department =
| journal =
| type =
| series =
| language =
| edition =
| location =
| publisher =
| publication-place =
| publication-date =
| volume =
| issue =
| page =
| pages =
| at =
| no-pp =
| arxiv =
| asin =
| bibcode =
| biorxiv =
| citeseerx =
| doi =
| doi-broken-date =
| doi-access =
| isbn =
| issn =
| jfm =
| jstor =
| jstor-access =
| lccn =
| mr =
| oclc =
| ol =
| ol-access =
| osti =
| osti-access =
| pmc =
| pmid =
| rfc =
| ssrn =
| zbl =
| id =
| via =
| registration =
| subscription =
| quote =
| postscript =
| ref =
| url-access =
| access-date =
| url-status =
| archive-url =
| archive-date =
}}
}}
</pre>
==ตัวอย่าง==
<pre>
* {{อ้างวารสาร
| author = วงเดือน นาราสัจจ์
| year = 2558
| title = การร่างรัฐธรรมนูญสหรัฐอเมริกา: ปัญหาและความสำเร็จ
| journal = วารสารราชบัณฑิตยสภา
| volume = 40
| issue = 3
| pages = 326–344
| url = https://www.orst.go.th/FILEROOM/CABROYINWEB/DRAWER004/GENERAL/DATA0000/00000037.FLP/html/
}}
</pre>
* {{อ้างวารสาร
| author = วงเดือน นาราสัจจ์
| year = 2558
| title = การร่างรัฐธรรมนูญสหรัฐอเมริกา: ปัญหาและความสำเร็จ
| journal = วารสารราชบัณฑิตยสภา
| volume = 40
| issue = 3
| pages = 326–344
| url = https://www.orst.go.th/FILEROOM/CABROYINWEB/DRAWER004/GENERAL/DATA0000/00000037.FLP/html/
}}
[[หมวดหมู่:แม่แบบอ้างอิง]]
lz4kqbthcjus11dofkwvpouhjabxahh
คุยกับผู้ใช้:Claire de looney
3
57717
189495
2022-08-17T03:48:49Z
New user message
1899
เพิ่ม[[Template:Welcome|สารต้อนรับ]]ในหน้าคุยของผู้ใช้ใหม่
wikitext
text/x-wiki
{{Template:Welcome|realName=|name=Claire de looney}}
-- [[ผู้ใช้:New user message|New user message]] ([[คุยกับผู้ใช้:New user message|คุย]]) 10:48, 17 สิงหาคม 2565 (+07)
mb95rc8o3x2j1hfeicwgrqfo0f3k5ly
แม่แบบ:ฮาร์เวิร์ด-ข้อความอ้างอิง-ไม่วงเล็บ
10
57718
189501
2022-08-17T11:24:52Z
Venise12mai1834
8884
สร้างหน้าด้วย "{{#ifeq:{{{Ref|}}}|none |{{#if:{{{5|}}} |{{{1|}}} และคนอื่น ๆ {{{5|}}} |{{#if:{{{4|}}} |{{{1|}}}, {{{2|}}} & {{{3|}}} {{{4|}}} |{{#if:{{{3|}}} |{{{1|}}} & {{{2|}}} {{{3|}}} |{{{1|}}} {{{2|}}} }} }} }} | #<!-- -->{{#if:{{{Ref|}}}<!-- -->|{{{Ref}}}<!-- -->|CITEREF{{{1|}}}{{{2|}}}{{{3|}}}{{{4|}}}{{{5|}}}<!-- -->}}<!-- -..."
wikitext
text/x-wiki
{{#ifeq:{{{Ref|}}}|none
|{{#if:{{{5|}}}
|{{{1|}}} และคนอื่น ๆ {{{5|}}}
|{{#if:{{{4|}}}
|{{{1|}}}, {{{2|}}} & {{{3|}}} {{{4|}}}
|{{#if:{{{3|}}}
|{{{1|}}} & {{{2|}}} {{{3|}}}
|{{{1|}}} {{{2|}}}
}}
}}
}}
| [[#<!--
-->{{#if:{{{Ref|}}}<!--
-->|{{{Ref}}}<!--
-->|CITEREF{{{1|}}}{{{2|}}}{{{3|}}}{{{4|}}}{{{5|}}}<!--
-->}}<!--
-->|{{#if:{{{5|}}}<!--
-->|{{{1|}}} และคนอื่น ๆ {{{5|}}}<!--
-->|{{#if:{{{4|}}}<!--
-->|{{{1|}}}, {{{2|}}} & {{{3|}}} {{{4|}}}<!--
-->|{{#if:{{{3|}}}<!--
-->|{{{1|}}} & {{{2|}}} {{{3|}}}<!--
-->|{{{1|}}} {{{2|}}}<!--
-->}}<!--
-->}}<!--
-->}}<!--
-->]]
}}{{#if:{{{loc|}}}
|, {{{loc|}}}
|{{#if:{{{p|{{{page|}}}}}}
|, น. {{{p|{{{page}}}}}}
|{{#if:{{{pp|{{{pages|}}}}}}
|, นน. {{{pp|{{{pages}}}}}}
}}
}}
}}<noinclude>
{{Documentation}}
</noinclude>
8wwgoi6xupwxofawyd52qeis3627lz5
189510
189501
2022-08-17T11:32:16Z
Venise12mai1834
8884
wikitext
text/x-wiki
<noinclude>{{เว็บย่อ|[[แม่แบบ:ฮวอม]]<br>[[แม่แบบ:harvnb]]}}</noinclude>{{#ifeq:{{{Ref|}}}|none
|{{#if:{{{5|}}}
|{{{1|}}} และคนอื่น ๆ {{{5|}}}
|{{#if:{{{4|}}}
|{{{1|}}}, {{{2|}}} & {{{3|}}} {{{4|}}}
|{{#if:{{{3|}}}
|{{{1|}}} & {{{2|}}} {{{3|}}}
|{{{1|}}} {{{2|}}}
}}
}}
}}
| [[#<!--
-->{{#if:{{{Ref|}}}<!--
-->|{{{Ref}}}<!--
-->|CITEREF{{{1|}}}{{{2|}}}{{{3|}}}{{{4|}}}{{{5|}}}<!--
-->}}<!--
-->|{{#if:{{{5|}}}<!--
-->|{{{1|}}} และคนอื่น ๆ {{{5|}}}<!--
-->|{{#if:{{{4|}}}<!--
-->|{{{1|}}}, {{{2|}}} & {{{3|}}} {{{4|}}}<!--
-->|{{#if:{{{3|}}}<!--
-->|{{{1|}}} & {{{2|}}} {{{3|}}}<!--
-->|{{{1|}}} {{{2|}}}<!--
-->}}<!--
-->}}<!--
-->}}<!--
-->]]
}}{{#if:{{{loc|}}}
|, {{{loc|}}}
|{{#if:{{{p|{{{page|}}}}}}
|, น. {{{p|{{{page}}}}}}
|{{#if:{{{pp|{{{pages|}}}}}}
|, นน. {{{pp|{{{pages}}}}}}
}}
}}
}}<noinclude>
{{คู่มือการใช้งาน|แม่แบบ:ฮาร์เวิร์ด-ข้อความอ้างอิง/doc}}
</noinclude>
7xpbdve7wwxhte0lt5r9bcyok4eovys
แม่แบบ:ฮวอม
10
57719
189502
2022-08-17T11:25:40Z
Venise12mai1834
8884
เปลี่ยนทางหน้าไปยัง [[แม่แบบ:ฮาร์เวิร์ด-ข้อความอ้างอิง-ไม่วงเล็บ]]
wikitext
text/x-wiki
#REDIRECT [[แม่แบบ:ฮาร์เวิร์ด-ข้อความอ้างอิง-ไม่วงเล็บ]]
kadwvzh5xltyrth5fu1vkqd31rm1mi5
แม่แบบ:Harvnb
10
57720
189503
2022-08-17T11:26:05Z
Venise12mai1834
8884
เปลี่ยนทางหน้าไปยัง [[แม่แบบ:ฮาร์เวิร์ด-ข้อความอ้างอิง-ไม่วงเล็บ]]
wikitext
text/x-wiki
#REDIRECT [[แม่แบบ:ฮาร์เวิร์ด-ข้อความอ้างอิง-ไม่วงเล็บ]]
kadwvzh5xltyrth5fu1vkqd31rm1mi5