@@ -361,17 +361,21 @@ def full_name(self, value):
361361
362362 def collapse_whitespace (self , string ):
363363 # collapse multiple spaces into single space
364- return self .C .regexes .spaces .sub (" " , string .strip ())
365-
364+ string = self .C .regexes .spaces .sub (" " , string .strip ())
365+ if string .endswith ("," ):
366+ string = string [:- 1 ]
367+ return string
368+
366369 def pre_process (self ):
367370 """
368371
369372 This method happens at the beginning of the :py:func:`parse_full_name`
370373 before any other processing of the string aside from unicode
371374 normalization, so it's a good place to do any custom handling in a
372- subclass. Runs :py:func:`parse_nicknames`.
375+ subclass. Runs :py:func:`parse_nicknames` and py:func:`squash_emoji` .
373376
374377 """
378+ self .fix_phd ()
375379 self .parse_nicknames ()
376380 self .squash_emoji ()
377381
@@ -382,6 +386,13 @@ def post_process(self):
382386 """
383387 self .handle_firstnames ()
384388
389+ def fix_phd (self ):
390+ _re = self .C .regexes .phd
391+ match = _re .search (self ._full_name )
392+ if match :
393+ self .suffix_list .append (match .group (0 ))
394+ self ._full_name = _re .sub ('' , self ._full_name )
395+
385396 def parse_nicknames (self ):
386397 """
387398 The content of parenthesis or quotes in the name will be added to the
@@ -780,7 +791,8 @@ def join_on_conjunctions(self, pieces, additional_parts_count=0):
780791 ### Capitalization Support
781792
782793 def cap_word (self , word , attribute ):
783- if (self .is_prefix (word ) and attribute == 'last' ) or self .is_conjunction (word ):
794+ if (self .is_prefix (word ) and attribute in ('last' ,'middle' )) \
795+ or self .is_conjunction (word ):
784796 return word .lower ()
785797 exceptions = self .C .capitalization_exceptions
786798 if lc (word ) in exceptions :
0 commit comments