Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Don't attempt to select initials when fullname contains non Latin characters #760

Merged
merged 1 commit into from
May 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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'):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this isn't important, as we are pivoting away from the use of initials, but I'm not sure that a Latin writing system is a necessary indicator for the use of basic initials heuristics. E.g., Cyrillic or Greek use the same initials heuristics (I think), while in general that is of course not true. So I think I'd like to have some documentation what exactly this change does.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure where we would put such documentation - ultimately this is something the style guide will describe and may that's the documentation? From an implementation point of view, this is a rats-nest, and this fix is showing to get us what we need for the short term (an RFC containing a Japanese name is on the threshold of release). I suggest we approach this with incremental changes as real cases arrive.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works for me.

There should be something that I can tell kramdown-rfc users about what these attributes mean and how they can be successfully used; this is what I meant with "documentation". That information would probably live in Github issues for quite a while.

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