@larsgw/formica 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/lib/resources/parse-text.js +3 -3
- package/package.json +1 -1
- package/src/resources/parse-text.ts +3 -3
- package/test/resources.js +27 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
## [0.3.1](https://github.com/identification-resources/formica/compare/v0.3.0...v0.3.1) (2023-09-04)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **resources:** allow correction of synonyms of lowest taxa ([c737d5b](https://github.com/identification-resources/formica/commit/c737d5b09d5e5b24f4cc2c8cff88c9ada8d0ab7b))
|
|
7
|
+
* **resources:** fix regression in c737d5b ([d4e52e9](https://github.com/identification-resources/formica/commit/d4e52e95ed1a35dabbd80b9f9aace1a824fdae98))
|
|
8
|
+
* **resources:** handle corrections to synonyms ([21ed9b7](https://github.com/identification-resources/formica/commit/21ed9b79f77e1e6d0639d96ed9822d5212a85a2e)), closes [#4](https://github.com/identification-resources/formica/issues/4)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
1
12
|
# [0.3.0](https://github.com/identification-resources/formica/compare/v0.2.1...v0.3.0) (2023-08-20)
|
|
2
13
|
|
|
3
14
|
|
|
@@ -361,7 +361,7 @@ function parseHeader(header) {
|
|
|
361
361
|
}
|
|
362
362
|
function validateResource(config, content) {
|
|
363
363
|
// Check for too much indentation
|
|
364
|
-
var longerIndent = new RegExp("^( ){".concat(config.levels.length - 1, "}(?! [+=>] ) "), 'm');
|
|
364
|
+
var longerIndent = new RegExp("^( ){".concat(config.levels.length - 1, "}(?! [+=>] | > ) "), 'm');
|
|
365
365
|
var longerIndentMatch = content.match(longerIndent);
|
|
366
366
|
if (longerIndentMatch !== null) {
|
|
367
367
|
var offset = longerIndentMatch.index;
|
|
@@ -402,8 +402,8 @@ function parseResourceContent(content, resource, oldIds) {
|
|
|
402
402
|
}
|
|
403
403
|
var lineIndent = line.match(/^ */)[0].length;
|
|
404
404
|
if (lineIndent > groupIndent) {
|
|
405
|
-
// Do not count synonyms as parents
|
|
406
|
-
if (data[previousId] && data[previousId].taxonomicStatus === 'accepted') {
|
|
405
|
+
// Do not count synonyms as parents (unless this is correcting a typo in the synonym)
|
|
406
|
+
if (data[previousId] && data[previousId].taxonomicStatus === 'accepted' || /^( {2})+> /.test(line)) {
|
|
407
407
|
parents.push(previousId);
|
|
408
408
|
}
|
|
409
409
|
else {
|
package/package.json
CHANGED
|
@@ -372,7 +372,7 @@ function parseHeader (header: string): ResourceMetadata {
|
|
|
372
372
|
|
|
373
373
|
function validateResource (config: ResourceMetadata, content: string) {
|
|
374
374
|
// Check for too much indentation
|
|
375
|
-
const longerIndent = new RegExp(`^( ){${config.levels.length - 1}}(?! [+=>] ) `, 'm')
|
|
375
|
+
const longerIndent = new RegExp(`^( ){${config.levels.length - 1}}(?! [+=>] | > ) `, 'm')
|
|
376
376
|
const longerIndentMatch = content.match(longerIndent)
|
|
377
377
|
if (longerIndentMatch !== null) {
|
|
378
378
|
const offset = longerIndentMatch.index
|
|
@@ -425,8 +425,8 @@ function parseResourceContent (content: ResourceDiff, resource: Resource, oldIds
|
|
|
425
425
|
const lineIndent = (line.match(/^ */) as string[])[0].length
|
|
426
426
|
|
|
427
427
|
if (lineIndent > groupIndent) {
|
|
428
|
-
// Do not count synonyms as parents
|
|
429
|
-
if (data[previousId] && data[previousId].taxonomicStatus === 'accepted') {
|
|
428
|
+
// Do not count synonyms as parents (unless this is correcting a typo in the synonym)
|
|
429
|
+
if (data[previousId] && data[previousId].taxonomicStatus === 'accepted' || /^( {2})+> /.test(line)) {
|
|
430
430
|
parents.push(previousId)
|
|
431
431
|
} else {
|
|
432
432
|
parents.push(null)
|
package/test/resources.js
CHANGED
|
@@ -4,7 +4,33 @@ const assert = require('assert')
|
|
|
4
4
|
const { resources } = require('../lib')
|
|
5
5
|
|
|
6
6
|
test('resources', async (t) => {
|
|
7
|
-
await t.test('
|
|
7
|
+
await t.test('parses author with initials', (t) => {
|
|
8
|
+
const [resource] = resources.parseTextFile(`---
|
|
9
|
+
levels: [family, genus, species]
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
Dolichurus haemorrhous A. Costa, 1886
|
|
13
|
+
Dolichurus A. Costa, 1886
|
|
14
|
+
Dolichurus indet.
|
|
15
|
+
Sphecidae A. Costa, 1886
|
|
16
|
+
Sphecidae indet.
|
|
17
|
+
`, 'T1')
|
|
18
|
+
assert.deepStrictEqual(Object.values(resource.taxa).map(taxon => taxon.scientificNameAuthorship), Array(3).fill('A. Costa, 1886'))
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
await t.test('does not validate name with correction', (t) => {
|
|
22
|
+
const [resource] = resources.parseTextFile(`---
|
|
23
|
+
levels: [species]
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
Clytochrysus lapidarius (Panzer, 1804)
|
|
27
|
+
= Crabo chrysostomus Lepeletier & Brullé, 1835
|
|
28
|
+
> Crabro chrysostomus Lepeletier & Brullé, 1835
|
|
29
|
+
`, 'T1')
|
|
30
|
+
assert.strictEqual(resource.taxa['T1:1:1'].scientificName, 'Clytochrysus lapidarius (Panzer, 1804)')
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
await t.test('errors for missing leaf taxa', (t) => {
|
|
8
34
|
assert.throws(() => {
|
|
9
35
|
resources.parseTextFile(`---
|
|
10
36
|
levels: [family, genus, species]
|