Skip to content

Commit

Permalink
fix: Don't attempt to select initials when fullname contains non Lati…
Browse files Browse the repository at this point in the history
…n characters
  • Loading branch information
kesara committed Apr 22, 2022
1 parent 50fc7ae commit 3348462
Show file tree
Hide file tree
Showing 14 changed files with 68 additions and 34 deletions.
2 changes: 2 additions & 0 deletions tests/input/draft-v3-features.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
</postal>
</address>
</author>
<author fullname="Armin Bergström">
</author>
<date year="2017" month="04" day="15"/>
<abstract>
<t>
Expand Down
8 changes: 6 additions & 2 deletions tests/valid/draft-v3-features.prepped.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version='1.0' encoding='utf-8'?>
<rfc version="3" category="exp" docName="draft-v3-features" indexInclude="true" ipr="trust200902" prepTime="2022-03-11T03:07:05" scripts="Cherokee,Common,Cyrillic,Greek,Latin" sortRefs="true" submissionType="independent" symRefs="true" tocDepth="3" tocInclude="true">
<!-- xml2rfc v2v3 conversion 3.12.3 -->
<rfc version="3" category="exp" docName="draft-v3-features" indexInclude="true" ipr="trust200902" prepTime="2022-04-21T23:17:55" scripts="Cherokee,Common,Cyrillic,Greek,Latin" sortRefs="true" submissionType="independent" symRefs="true" tocDepth="3" tocInclude="true">
<!-- xml2rfc v2v3 conversion 3.12.4 -->



Expand Down Expand Up @@ -31,6 +31,8 @@
</postal>
</address>
</author>
<author fullname="Armin Bergström">
</author>
<date month="04" year="2017" day="15"/>
<abstract pn="section-abstract">
<t indent="0" pn="section-abstract-1">
Expand Down Expand Up @@ -4312,6 +4314,8 @@ foo = bar
</postal>
</address>
</author>
<author fullname="Armin Bergström">
</author>
</section>
</back>
</rfc>
6 changes: 5 additions & 1 deletion tests/valid/draft-v3-features.text
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@

Network Working Group J. Reschke, Ed.
Internet-Draft
Intended status: Experimental Π. Ὁ. Σάμιος (P. O. Samos)
Intended status: Experimental Πυθαγόρας ὁ Σάμιος (P. O. Samos)
Expires: October 17, 2017 Εργαστήριο γεωμετρία (Geometry Labs)
A. Bergström
April 15, 2017


Expand Down Expand Up @@ -1508,3 +1509,6 @@ Authors' Addresses
Εργαστήριο γεωμετρία
831 03 Πυθαγόρειο
Ελλάδα


Armin Bergström
13 changes: 10 additions & 3 deletions tests/valid/draft-v3-features.v3.py36.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@
<title>xml2rfc V3 Feature Tests</title>
<meta content="Julian Reschke" name="author">
<meta content="Πυθαγόρας ὁ Σάμιος (Pythagoras of Samos)" name="author">
<meta content="Armin Bergström" name="author">
<meta content="
This document tests features introduced in xml2rfc v3 vocabulary.
" name="description">
<meta content="xml2rfc 3.12.3" name="generator">
<meta content="xml2rfc 3.12.4" name="generator">
<meta content="draft-v3-features" name="ietf.draft">
<link href="tests/input/draft-v3-features.xml" rel="alternate" type="application/rfc+xml">
<link href="#copyright" rel="license">
Expand All @@ -28,7 +29,7 @@
<td class="right">April 2017</td>
</tr></thead>
<tfoot><tr>
<td class="left">Reschke &amp; Samos</td>
<td class="left">Reschke, et al.</td>
<td class="center">Expires October 17, 2017</td>
<td class="right">[Page]</td>
</tr></tfoot>
Expand Down Expand Up @@ -56,10 +57,13 @@
</div>
<div class="author">
<div class="author-name">
<span class="non-ascii">Π. Ὁ. Σάμιος</span> (<span class="ascii">P. O. Samos</span>)</div>
<span class="non-ascii">Πυθαγόρας ὁ Σάμιος</span> (<span class="ascii">P. O. Samos</span>)</div>
<div class="org">
<span class="non-ascii">Εργαστήριο γεωμετρία</span> (<span class="ascii">Geometry Labs</span>)</div>
</div>
<div class="author">
<div class="author-name">A. Bergström</div>
</div>
</dd>
</dl>
</div>
Expand Down Expand Up @@ -5274,6 +5278,9 @@ <h2 id="name-authors-addresses">
<div dir="auto" class="left"><span class="country-name">Ελλάδα</span></div>
</div>
</address>
<address class="vcard">
<div dir="auto" class="left"><span class="fn nameRole">Armin Bergström</span></div>
</address>
</section>
</div>
<script>const toc = document.getElementById("toc");
Expand Down
13 changes: 10 additions & 3 deletions tests/valid/draft-v3-features.v3.py37.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@
<title>xml2rfc V3 Feature Tests</title>
<meta content="Julian Reschke" name="author">
<meta content="Πυθαγόρας ὁ Σάμιος (Pythagoras of Samos)" name="author">
<meta content="Armin Bergström" name="author">
<meta content="
This document tests features introduced in xml2rfc v3 vocabulary.
" name="description">
<meta content="xml2rfc 3.12.3" name="generator">
<meta content="xml2rfc 3.12.4" name="generator">
<meta content="draft-v3-features" name="ietf.draft">
<link href="tests/input/draft-v3-features.xml" rel="alternate" type="application/rfc+xml">
<link href="#copyright" rel="license">
Expand All @@ -28,7 +29,7 @@
<td class="right">April 2017</td>
</tr></thead>
<tfoot><tr>
<td class="left">Reschke &amp; Samos</td>
<td class="left">Reschke, et al.</td>
<td class="center">Expires October 17, 2017</td>
<td class="right">[Page]</td>
</tr></tfoot>
Expand Down Expand Up @@ -56,10 +57,13 @@
</div>
<div class="author">
<div class="author-name">
<span class="non-ascii">Π. Ὁ. Σάμιος</span> (<span class="ascii">P. O. Samos</span>)</div>
<span class="non-ascii">Πυθαγόρας ὁ Σάμιος</span> (<span class="ascii">P. O. Samos</span>)</div>
<div class="org">
<span class="non-ascii">Εργαστήριο γεωμετρία</span> (<span class="ascii">Geometry Labs</span>)</div>
</div>
<div class="author">
<div class="author-name">A. Bergström</div>
</div>
</dd>
</dl>
</div>
Expand Down Expand Up @@ -5274,6 +5278,9 @@ <h2 id="name-authors-addresses">
<div dir="auto" class="left"><span class="country-name">Ελλάδα</span></div>
</div>
</address>
<address class="vcard">
<div dir="auto" class="left"><span class="fn nameRole">Armin Bergström</span></div>
</address>
</section>
</div>
<script>const toc = document.getElementById("toc");
Expand Down
13 changes: 10 additions & 3 deletions tests/valid/draft-v3-features.v3.py38.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@
<title>xml2rfc V3 Feature Tests</title>
<meta content="Julian Reschke" name="author">
<meta content="Πυθαγόρας ὁ Σάμιος (Pythagoras of Samos)" name="author">
<meta content="Armin Bergström" name="author">
<meta content="
This document tests features introduced in xml2rfc v3 vocabulary.
" name="description">
<meta content="xml2rfc 3.12.3" name="generator">
<meta content="xml2rfc 3.12.4" name="generator">
<meta content="draft-v3-features" name="ietf.draft">
<link href="tests/input/draft-v3-features.xml" rel="alternate" type="application/rfc+xml">
<link href="#copyright" rel="license">
Expand All @@ -28,7 +29,7 @@
<td class="right">April 2017</td>
</tr></thead>
<tfoot><tr>
<td class="left">Reschke &amp; Samos</td>
<td class="left">Reschke, et al.</td>
<td class="center">Expires October 17, 2017</td>
<td class="right">[Page]</td>
</tr></tfoot>
Expand Down Expand Up @@ -56,10 +57,13 @@
</div>
<div class="author">
<div class="author-name">
<span class="non-ascii">Π. Ὁ. Σάμιος</span> (<span class="ascii">P. O. Samos</span>)</div>
<span class="non-ascii">Πυθαγόρας ὁ Σάμιος</span> (<span class="ascii">P. O. Samos</span>)</div>
<div class="org">
<span class="non-ascii">Εργαστήριο γεωμετρία</span> (<span class="ascii">Geometry Labs</span>)</div>
</div>
<div class="author">
<div class="author-name">A. Bergström</div>
</div>
</dd>
</dl>
</div>
Expand Down Expand Up @@ -5274,6 +5278,9 @@ <h2 id="name-authors-addresses">
<div dir="auto" class="left"><span class="country-name">Ελλάδα</span></div>
</div>
</address>
<address class="vcard">
<div dir="auto" class="left"><span class="fn nameRole">Armin Bergström</span></div>
</address>
</section>
</div>
<script>const toc = document.getElementById("toc");
Expand Down
4 changes: 2 additions & 2 deletions tests/valid/elements.bom.text
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@


Network Working Group A. Author
Internet-Draft ר. אבן (R. Even)
Internet-Draft רוני אבן (R. Even)
Obsoletes: 1234, 5678, 9012, 3456, 7890 (if וואווי (Huawei)
approved) 田. 様 (H. Tanaka)
approved) 田中花子 様 (H. Tanaka)
Intended status: Informational
Expires: 13 January 2019 N. Org

Expand Down
4 changes: 2 additions & 2 deletions tests/valid/elements.pages.text
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@


Network Working Group A. Author
Internet-Draft ר. אבן (R. Even)
Internet-Draft רוני אבן (R. Even)
Obsoletes: 1234, 5678, 9012, 3456, 7890 (if וואווי (Huawei)
approved) 田. 様 (H. Tanaka)
approved) 田中花子 様 (H. Tanaka)
Intended status: Informational
Expires: January 13, 2019 N. Org

Expand Down
4 changes: 2 additions & 2 deletions tests/valid/elements.text
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@


Network Working Group A. Author
Internet-Draft ר. אבן (R. Even)
Internet-Draft רוני אבן (R. Even)
Obsoletes: 1234, 5678, 9012, 3456, 7890 (if וואווי (Huawei)
approved) 田. 様 (H. Tanaka)
approved) 田中花子 様 (H. Tanaka)
Intended status: Informational
Expires: January 13, 2019 N. Org

Expand Down
6 changes: 3 additions & 3 deletions tests/valid/elements.v3.py36.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<meta content="
This is the abstract.
" name="description">
<meta content="xml2rfc 3.10.0" name="generator">
<meta content="xml2rfc 3.12.4" name="generator">
<meta content="elements-00" name="ietf.draft">
<link href="tests/input/elements.xml" rel="alternate" type="application/rfc+xml">
<link href="#copyright" rel="license">
Expand Down Expand Up @@ -59,13 +59,13 @@
</div>
<div class="author">
<div class="author-name">
<span class="non-ascii">ר. אבן</span> (<span class="ascii">R. Even</span>)</div>
<span class="non-ascii">רוני אבן</span> (<span class="ascii">R. Even</span>)</div>
<div class="org">
<span class="non-ascii">וואווי</span> (<span class="ascii">Huawei</span>)</div>
</div>
<div class="author">
<div class="author-name">
<span class="non-ascii">田.</span> (<span class="ascii">H. Tanaka</span>)</div>
<span class="non-ascii">田中花子</span> (<span class="ascii">H. Tanaka</span>)</div>
</div>
<div class="author">
<div class="author-name">N. Org</div>
Expand Down
6 changes: 3 additions & 3 deletions tests/valid/elements.v3.py37.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<meta content="
This is the abstract.
" name="description">
<meta content="xml2rfc 3.10.0" name="generator">
<meta content="xml2rfc 3.12.4" name="generator">
<meta content="elements-00" name="ietf.draft">
<link href="tests/input/elements.xml" rel="alternate" type="application/rfc+xml">
<link href="#copyright" rel="license">
Expand Down Expand Up @@ -59,13 +59,13 @@
</div>
<div class="author">
<div class="author-name">
<span class="non-ascii">ר. אבן</span> (<span class="ascii">R. Even</span>)</div>
<span class="non-ascii">רוני אבן</span> (<span class="ascii">R. Even</span>)</div>
<div class="org">
<span class="non-ascii">וואווי</span> (<span class="ascii">Huawei</span>)</div>
</div>
<div class="author">
<div class="author-name">
<span class="non-ascii">田.</span> (<span class="ascii">H. Tanaka</span>)</div>
<span class="non-ascii">田中花子</span> (<span class="ascii">H. Tanaka</span>)</div>
</div>
<div class="author">
<div class="author-name">N. Org</div>
Expand Down
6 changes: 3 additions & 3 deletions tests/valid/elements.v3.py38.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<meta content="
This is the abstract.
" name="description">
<meta content="xml2rfc 3.10.0" name="generator">
<meta content="xml2rfc 3.12.4" name="generator">
<meta content="elements-00" name="ietf.draft">
<link href="tests/input/elements.xml" rel="alternate" type="application/rfc+xml">
<link href="#copyright" rel="license">
Expand Down Expand Up @@ -59,13 +59,13 @@
</div>
<div class="author">
<div class="author-name">
<span class="non-ascii">ר. אבן</span> (<span class="ascii">R. Even</span>)</div>
<span class="non-ascii">רוני אבן</span> (<span class="ascii">R. Even</span>)</div>
<div class="org">
<span class="non-ascii">וואווי</span> (<span class="ascii">Huawei</span>)</div>
</div>
<div class="author">
<div class="author-name">
<span class="non-ascii">田.</span> (<span class="ascii">H. Tanaka</span>)</div>
<span class="non-ascii">田中花子</span> (<span class="ascii">H. Tanaka</span>)</div>
</div>
<div class="author">
<div class="author-name">N. Org</div>
Expand Down
4 changes: 2 additions & 2 deletions tests/valid/elements.wip.text
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@


Network Working Group A. Author
Internet-Draft ר. אבן (R. Even)
Internet-Draft רוני אבן (R. Even)
Obsoletes: 1234, 5678, 9012, 3456, 7890 (if וואווי (Huawei)
approved) 田. 様 (H. Tanaka)
approved) 田中花子 様 (H. Tanaka)
Intended status: Informational
Expires: 13 January 2019 N. Org

Expand Down
13 changes: 8 additions & 5 deletions xml2rfc/util/name.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,14 @@ def short_author_name_parts(a):
else:
fullname = a.get('fullname') or ''
if fullname:
if len(fullname.split())>1:
parts = fullname.split()
initials = ' '.join([ "%s."%n[0].upper() for n in parts[:-1] ])
surname = parts[-1]
parts = [initials, surname ]
if is_script(fullname, 'Latin'):
if len(fullname.split())>1:
parts = fullname.split()
initials = ' '.join([ "%s."%n[0].upper() for n in parts[:-1] ])
surname = parts[-1]
parts = [initials, surname ]
else:
parts = [ None, fullname ]
else:
parts = [ None, fullname ]
else:
Expand Down

0 comments on commit 3348462

Please sign in to comment.