@@ -347,6 +347,16 @@ fn phrase_leads_with_rank_marker(n: &ParsedName) -> bool {
347347 . eq_ignore_ascii_case ( marker. trim_end_matches ( '.' ) )
348348}
349349
350+ /// The Prokaryotic Code abbreviates subgenus "subgen." (Rules 10c, 34c), where the rank's own
351+ /// marker is the botanical "subg.".
352+ const BACTERIAL_SUBGENUS_MARKER : & str = "subgen." ;
353+
354+ /// The marker of a bacterial subgenus, which is not the rank's own.
355+ fn bacterial_subgenus_marker ( n : & ParsedName ) -> Option < & ' static str > {
356+ ( n. rank == Rank :: Subgenus && n. code == Some ( NomCode :: Bacterial ) )
357+ . then_some ( BACTERIAL_SUBGENUS_MARKER )
358+ }
359+
350360/// Java `NameFormatter.appendRankMarker(sb, rank, ifRank, nothoPrefix)` (both the 3- and
351361/// 4-arg overloads; the 3-arg one passes `if_rank = None`). Returns true if a marker was
352362/// appended.
@@ -731,9 +741,15 @@ fn build_name(n: &ParsedName, f: &Flags) -> Option<String> {
731741 ) ;
732742 }
733743 sb. push ( ' ' ) ;
734- // we show zoological infragenerics in brackets, but use rank markers for
735- // botanical names (unless its no defined rank)
736- if n. code == Some ( NomCode :: Zoological ) {
744+ // Only a subgenus and an unranked infrageneric go in brackets, with no
745+ // marker: "infragen." is no marker anyone writes ("Calathus (Lindrothius)
746+ // Kurnakov, 1961", "Agaricus (Hypholoma) Fr."). A subgenus only when
747+ // zoological: of no code it keeps the marker it was written with, as a
748+ // botanical one must (ICN Art. 21.1). Every other rank shows its marker
749+ // ("Achillea sect. Ptarmica").
750+ if n. rank == Rank :: InfragenericName
751+ || ( n. rank == Rank :: Subgenus && n. code == Some ( NomCode :: Zoological ) )
752+ {
737753 sb. push ( '(' ) ;
738754 append_qualifier ( & mut sb, n, NamePart :: Infrageneric , f. show_qualifier ) ;
739755 if f. hybrid_marker && has_notho ( n, NamePart :: Infrageneric ) {
@@ -750,12 +766,14 @@ fn build_name(n: &ParsedName, f: &Flags) -> Option<String> {
750766 // If we know the rank we use explicit rank markers — this is how
751767 // botanical infrageneric names are formed, see
752768 // http://www.iapt-taxon.org/nomen/main.php?page=art21
753- if append_rank_marker (
754- & mut sb,
755- n. rank ,
756- None ,
757- f. hybrid_marker && has_notho ( n, NamePart :: Infrageneric ) ,
758- ) {
769+ let notho = f. hybrid_marker && has_notho ( n, NamePart :: Infrageneric ) ;
770+ if let Some ( marker) = bacterial_subgenus_marker ( n) {
771+ if notho {
772+ sb. push_str ( NOTHO_PREFIX ) ;
773+ }
774+ sb. push_str ( marker) ;
775+ sb. push ( ' ' ) ;
776+ } else if append_rank_marker ( & mut sb, n. rank , None , notho) {
759777 sb. push ( ' ' ) ;
760778 }
761779 }
@@ -767,8 +785,13 @@ fn build_name(n: &ParsedName, f: &Flags) -> Option<String> {
767785 append_genus ( & mut sb, n, f. hybrid_marker , f. show_qualifier , html) ;
768786 }
769787 if f. infrageneric {
770- // additional subgenus shown for binomial. Always shown in brackets
788+ // additional subgenus shown for binomial. Always shown in brackets, with
789+ // its marker in bacteriology (Prokaryotic Code Rule 10c)
771790 sb. push_str ( " (" ) ;
791+ if n. code == Some ( NomCode :: Bacterial ) {
792+ sb. push_str ( BACTERIAL_SUBGENUS_MARKER ) ;
793+ sb. push ( ' ' ) ;
794+ }
772795 append_qualifier ( & mut sb, n, NamePart :: Infrageneric , f. show_qualifier ) ;
773796 append_in_italics ( & mut sb, infrageneric_epithet, html) ;
774797 sb. push ( ')' ) ;
@@ -1145,11 +1168,11 @@ mod tests {
11451168
11461169 #[ test]
11471170 fn infrageneric_botanical_uses_rank_marker_and_minimal_drops_genus ( ) {
1148- // "subg." normalises to the "subgen ." marker; minimal shows only the terminal epithet.
1171+ // the botanical "subg ." marker; minimal shows only the terminal epithet.
11491172 let n = p ( "Astragalus subg. Cercidothrix" ) ;
11501173 assert_eq ! (
11511174 n. canonical_name( ) . as_deref( ) ,
1152- Some ( "Astragalus subgen . Cercidothrix" )
1175+ Some ( "Astragalus subg . Cercidothrix" )
11531176 ) ;
11541177 assert_eq ! ( n. canonical_name_minimal( ) . as_deref( ) , Some ( "Cercidothrix" ) ) ;
11551178 }
@@ -1292,6 +1315,63 @@ mod tests {
12921315 ) ;
12931316 }
12941317
1318+ #[ test]
1319+ fn only_a_subgenus_or_an_unranked_infrageneric_goes_in_brackets ( ) {
1320+ use crate :: model:: NomCode ;
1321+ let canonical = |name : & str , code| {
1322+ parse ( name, None , None , code)
1323+ . unwrap ( )
1324+ . canonical_name ( )
1325+ . unwrap ( )
1326+ } ;
1327+ assert_eq ! (
1328+ canonical( "Agaricus trib. Pholiota Fr." , None ) ,
1329+ "Agaricus (Pholiota) Fr."
1330+ ) ;
1331+ assert_eq ! (
1332+ canonical( "Hieracium unr. Verbasciformia" , Some ( NomCode :: Botanical ) ) ,
1333+ "Hieracium (Verbasciformia)"
1334+ ) ;
1335+ assert_eq ! (
1336+ canonical( "Carabus subgen. Megodontus" , Some ( NomCode :: Zoological ) ) ,
1337+ "Carabus (Megodontus)"
1338+ ) ;
1339+ // of no code a subgenus keeps its marker
1340+ assert_eq ! (
1341+ canonical( "Carabus subgen. Megodontus" , None ) ,
1342+ "Carabus subg. Megodontus"
1343+ ) ;
1344+ // the Prokaryotic Code's "subgen.", in a species' brackets too (Rule 10c)
1345+ assert_eq ! (
1346+ canonical(
1347+ "Acetobacter subg. Gluconoacetobacter" ,
1348+ Some ( NomCode :: Bacterial )
1349+ ) ,
1350+ "Acetobacter subgen. Gluconoacetobacter"
1351+ ) ;
1352+ let complete = |name : & str , code| {
1353+ parse ( name, None , None , code)
1354+ . unwrap ( )
1355+ . canonical_name_complete ( )
1356+ . unwrap ( )
1357+ } ;
1358+ assert_eq ! (
1359+ complete(
1360+ "Acetobacter (Gluconoacetobacter) liquefaciens" ,
1361+ Some ( NomCode :: Bacterial )
1362+ ) ,
1363+ "Acetobacter (subgen. Gluconoacetobacter) liquefaciens"
1364+ ) ;
1365+ assert_eq ! (
1366+ complete( "Acetobacter (Gluconoacetobacter) liquefaciens" , None ) ,
1367+ "Acetobacter (Gluconoacetobacter) liquefaciens"
1368+ ) ;
1369+ assert_eq ! (
1370+ canonical( "Achillea sect. Ptarmica" , None ) ,
1371+ "Achillea sect. Ptarmica"
1372+ ) ;
1373+ }
1374+
12951375 #[ test]
12961376 fn complete_html_italicises_name_parts ( ) {
12971377 assert_eq ! (
@@ -1311,7 +1391,7 @@ mod tests {
13111391 p( "Astragalus subg. Cercidothrix" )
13121392 . canonical_name_complete_html( )
13131393 . as_deref( ) ,
1314- Some ( "<i>Astragalus</i> subgen . <i>Cercidothrix</i>" )
1394+ Some ( "<i>Astragalus</i> subg . <i>Cercidothrix</i>" )
13151395 ) ;
13161396 }
13171397}
0 commit comments