Skip to content

Commit

Permalink
fix(resources): allow two-part hybrid names
Browse files Browse the repository at this point in the history
  • Loading branch information
larsgw committed Mar 20, 2024
1 parent 4c85c5b commit 8e3b836
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/resources/parse-text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,8 @@ function parseName (name: string, rank: Rank, parent: WorkingTaxon): WorkingTaxo
}

// Hybrids
if (rank === 'species' && /^x /.test(name)) {
name = '\u00D7' + name.slice(2)
if (rank === 'species' && /(^| )x /.test(name)) {
name = name.replace(/(^| )x /, '\u00D7')
}

// Divide the name into the main scientific name (only the epithet for taxa
Expand Down
12 changes: 12 additions & 0 deletions test/resources.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,16 @@ Microdynerus Thomson, 1874
`, 'T1')
assert.strictEqual(resource.taxa['T1:1:3'].scientificName, 'Microdynerus microdynerus (Dalla Torre, 1889)')
})

await t.test('parses hybrids', (t) => {
const [resource] = resources.parseTextFile(`---
levels: [species]
---
Rumex conglomeratus x maritimus
Tilia x vulgaris
`, 'T1')
assert.strictEqual(resource.taxa['T1:1:1'].scientificName, 'Rumex conglomeratus×maritimus')
assert.strictEqual(resource.taxa['T1:1:2'].scientificName, 'Tilia ×vulgaris')
})
})

0 comments on commit 8e3b836

Please sign in to comment.