jats-xml 1.1.5 → 1.1.6

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.
@@ -1 +1 @@
1
- {"version":3,"file":"repairKnownXmlDefects.d.ts","sourceRoot":"","sources":["../src/repairKnownXmlDefects.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,MAAM,oBAAoB,GAAG;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AASF,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAE5E;AAED,MAAM,MAAM,sBAAsB,GAAG;IACnC,MAAM,EAAE,oBAAoB,CAAC;IAC7B,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,2BAA2B,GAAG;IACxC,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,sBAAsB,EAAE,CAAC;CACnC,CAAC;AAEF;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,2BAA2B,CAW9E"}
1
+ {"version":3,"file":"repairKnownXmlDefects.d.ts","sourceRoot":"","sources":["../src/repairKnownXmlDefects.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,MAAM,oBAAoB,GAAG;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AAiCF,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAE5E;AAED,MAAM,MAAM,sBAAsB,GAAG;IACnC,MAAM,EAAE,oBAAoB,CAAC;IAC7B,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,2BAA2B,GAAG;IACxC,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,sBAAsB,EAAE,CAAC;CACnC,CAAC;AAgBF;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,2BAA2B,CAgB9E"}
@@ -4,9 +4,41 @@ const KNOWN_XML_DEFECT_REPAIRS = [
4
4
  to: '<fn id="n1" fn-type="equal">',
5
5
  },
6
6
  ];
7
+ /**
8
+ * Truncated accent markup in surnames, e.g. Meth&#x2019;{e</surname> where a closing
9
+ * brace was lost from LaTeX-style &#x2019;{e} (right single quote + braced letter).
10
+ */
11
+ const TRUNCATED_ACUTE_ACCENT_SURNAME_RE = /&#(?:x2019|8217|2019);\{([a-zA-Z])(?=\s*<\/surname>)/g;
12
+ const ACUTE_ACCENT = {
13
+ a: 'á',
14
+ e: 'é',
15
+ i: 'í',
16
+ o: 'ó',
17
+ u: 'ú',
18
+ A: 'Á',
19
+ E: 'É',
20
+ I: 'Í',
21
+ O: 'Ó',
22
+ U: 'Ú',
23
+ };
24
+ const TRUNCATED_ACUTE_ACCENT_SURNAME_REPAIR = {
25
+ from: 'truncated accent in <surname> (e.g. Meth&#x2019;{e)',
26
+ to: 'accented character (e.g. Methé)',
27
+ };
7
28
  export function knownXmlDefectRepairMessage(from, to) {
8
29
  return `replaced ${from} with ${to}`;
9
30
  }
31
+ function repairTruncatedAcuteAccentsInSurname(xml) {
32
+ let count = 0;
33
+ const next = xml.replace(TRUNCATED_ACUTE_ACCENT_SURNAME_RE, (match, letter) => {
34
+ const accented = ACUTE_ACCENT[letter];
35
+ if (!accented)
36
+ return match;
37
+ count += 1;
38
+ return accented;
39
+ });
40
+ return { xml: next, count };
41
+ }
10
42
  /**
11
43
  * Apply KNOWN_XML_DEFECT_REPAIRS in order. Each rule uses a single literal
12
44
  * `from` → `to` substitution (all occurrences of `from`).
@@ -22,5 +54,10 @@ export function repairKnownXmlDefects(xml) {
22
54
  next = parts.join(repair.to);
23
55
  applied.push({ repair, count });
24
56
  }
57
+ const accentRepair = repairTruncatedAcuteAccentsInSurname(next);
58
+ next = accentRepair.xml;
59
+ if (accentRepair.count > 0) {
60
+ applied.push({ repair: TRUNCATED_ACUTE_ACCENT_SURNAME_REPAIR, count: accentRepair.count });
61
+ }
25
62
  return { xml: next, applied };
26
63
  }
package/dist/version.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- declare const version = "1.1.5";
1
+ declare const version = "1.1.6";
2
2
  export default version;
3
3
  //# sourceMappingURL=version.d.ts.map
package/dist/version.js CHANGED
@@ -1,2 +1,2 @@
1
- const version = '1.1.5';
1
+ const version = '1.1.6';
2
2
  export default version;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jats-xml",
3
- "version": "1.1.5",
3
+ "version": "1.1.6",
4
4
  "description": "Types and utilities for working with JATS in Typescript",
5
5
  "author": "Rowan Cockett <rowan@continuousfoundation.org>",
6
6
  "homepage": "https://github.com/continuous-foundation/jats",
@@ -27,12 +27,12 @@
27
27
  "scripts": {
28
28
  "copy:version": "echo \"const version = '\"$npm_package_version\"';\nexport default version;\" > src/version.ts",
29
29
  "clean": "rm -rf dist",
30
- "test": "npm run copy:version && vitest run",
31
- "test:watch": "npm run copy:version && vitest watch",
30
+ "test": "bun run copy:version && bun test",
31
+ "test:watch": "bun run copy:version && bun test --watch",
32
32
  "lint": "eslint \"src/**/*.ts*\" -c ./.eslintrc.cjs",
33
33
  "lint:format": "prettier --check \"src/**/*.{ts,tsx,md}\"",
34
34
  "build:esm": "tsc",
35
- "build": "npm-run-all -l clean copy:version -p build:esm"
35
+ "build": "bun run clean && bun run copy:version && bun run build:esm"
36
36
  },
37
37
  "bugs": {
38
38
  "url": "https://github.com/continuous-foundation/jats/issues"
@@ -41,11 +41,12 @@
41
41
  "adm-zip": "^0.5.10",
42
42
  "character-entities": "^2.0.2",
43
43
  "doi-utils": "^2.0.6",
44
- "jats-tags": "^1.1.5",
45
- "jats-utils": "^1.1.5",
44
+ "jats-tags": "^1.1.6",
45
+ "jats-utils": "^1.1.6",
46
46
  "myst-cli-utils": "^2.0.11",
47
47
  "myst-common": "^1.7.5",
48
48
  "myst-frontmatter": "^1.7.5",
49
+ "myst-spec": "^0.0.5",
49
50
  "node-fetch": "^3.3.1",
50
51
  "unist-util-remove": "4.0.0",
51
52
  "unist-util-select": "^4.0.0",