From 4394fdf59c05b35d294eb67c4fab619687191ca7 Mon Sep 17 00:00:00 2001
From: Albert Krewinkel <albert@zeitkraut.de>
Date: Tue, 22 Mar 2022 14:38:52 +0100
Subject: [PATCH] JATS writer: encode author "others" as `<etal/>`

Citeproc adopted the BibTeX convention to use the author name "others"
when there are additional authors that are not named. JATS uses the
`<etal>` element for this.
---
 src/Text/Pandoc/Writers/JATS/References.hs | 4 +++-
 test/command/7042.md                       | 6 ++++--
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/Text/Pandoc/Writers/JATS/References.hs b/src/Text/Pandoc/Writers/JATS/References.hs
index 49ddaf276..382931a86 100644
--- a/src/Text/Pandoc/Writers/JATS/References.hs
+++ b/src/Text/Pandoc/Writers/JATS/References.hs
@@ -144,7 +144,9 @@ toNameElements :: Name -> Doc Text
 toNameElements name =
   if not (isEmpty nameTags)
   then inTags' "name" [] nameTags
-  else nameLiteral name `inNameTag` "string-name"
+  else if nameLiteral name == Just "others"  -- indicates an "et al."
+       then "<etal/>"
+       else nameLiteral name `inNameTag` "string-name"
     where
       inNameTag mVal tag = case mVal of
         Nothing  -> empty
diff --git a/test/command/7042.md b/test/command/7042.md
index de0294da3..5c4b90d48 100644
--- a/test/command/7042.md
+++ b/test/command/7042.md
@@ -15,10 +15,11 @@ references:
   author:
   - family: Negidius
     given: Numerius
+  - literal: others
   container-title: Public Library of Tests
   id: access-date
   issued: 1911-10-03
-  title: Entry with access date
+  title: Entry with access date and et al.
   type: article-journal
 - author:
   - family: Beethoven
@@ -93,8 +94,9 @@ references:
       <element-citation publication-type="article-journal">
         <person-group person-group-type="author">
           <name><surname>Negidius</surname><given-names>Numerius</given-names></name>
+          <etal/>
         </person-group>
-        <article-title>Entry with access date</article-title>
+        <article-title>Entry with access date and et al.</article-title>
         <source>Public Library of Tests</source>
         <year iso-8601-date="1911-10-03">1911</year><month>10</month><day>03</day>
         <date-in-citation content-type="access-date"><year iso-8601-date="1999-01-22">1999</year><month>01</month><day>22</day></date-in-citation>