Skip to content

Commit

Permalink
randering of subspecies names in botany
Browse files Browse the repository at this point in the history
  • Loading branch information
proceps committed Nov 15, 2024
1 parent c69997a commit e91542f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions lib/utilities/italicize.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,24 @@ module Utilities::Italicize

# Used to italicize strings, whitespace (presently) matters
# Ultimately turn into Tokens to better handle whitespace
COMBINATION_INJECTIONS = [
COMBINATION_INJECTIONS = [
' (',
') ', # no trailing whitespace as it could be terminating in case of subgenus?
' [sic]',
' subsp.',
' var.',
' subvar.',
' f.',
' subf.',
' sect.', # not covered in original combination
' ser.', # not covered in original combination
' ser.', # not covered in original combination
'GENUS NOT SPECIFIED',
'SPECIES NOT SPECIFIED',
'[',
']',
'† ', # fossil dagger
' ×', # hybrid ×
# 'Candidatus' ?
# 'Candidatus' ?
].freeze

COMBINATION_INJECTION_REGEX = COMBINATION_INJECTIONS.collect{|a| Regexp.escape(a) }.join('|').freeze
Expand All @@ -29,7 +30,7 @@ def self.taxon_name(string)
st = string.dup
return nil if st.nil? || st == ''

# May need to revert to this 1:1 form if we find that an individual COMBINATION_INJECTS element are found > 1 per name
# May need to revert to this 1:1 form if we find that an individual COMBINATION_INJECTS element are found > 1 per name
# TaxonName::COMBINATION_INJECTIONS.collect{|a| Regexp.escape(a) }.each do |r|
# string.gsub!(/(#{r})/, '</i>\1<i>')
# end
Expand Down
2 changes: 1 addition & 1 deletion spec/models/taxon_name_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@

expect(variety.root.id).to eq(species.root.id)
expect(variety.cached_author_year).to eq('McAtee')
expect(variety.cached_html).to eq('<i>Aus</i> (<i>Aus</i>) <i>aaa bbb</i> var. <i>ccc</i>')
expect(variety.cached_html).to eq('<i>Aus</i> (<i>Aus</i>) <i>aaa</i> subsp. <i>bbb</i> var. <i>ccc</i>')

basionym = FactoryBot.create(:icn_variety, name: 'basionym', parent_id: variety.ancestor_at_rank('species').id, verbatim_author: 'Linnaeus') # source_id: nil,
r = FactoryBot.create(:taxon_name_relationship, subject_taxon_name: basionym, object_taxon_name: variety, type: 'TaxonNameRelationship::Icn::Unaccepting::Synonym::Homotypic::Basionym')
Expand Down

0 comments on commit e91542f

Please sign in to comment.