jats-xml 0.0.2 → 0.0.3

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/README.md CHANGED
@@ -1,3 +1,76 @@
1
1
  # jats-xml
2
2
 
3
- Types and utilities for working with JATS XML documents.
3
+ Types and utilities for working with JATS XML documents in Node and Typescript.
4
+
5
+ Read and write JATS XML from node or see summries from the command line.
6
+
7
+ To use from the command line, use the `-g` to create a global install, which will provide a `jats` CLI:
8
+
9
+ ```
10
+ npm install -g jats-xml
11
+ jats -v
12
+ ```
13
+
14
+ ## What is JATS?
15
+
16
+ JATS is a NISO standard for Journal Article Tags Schema, which is a way to define the XML structure of a scientific article semantically. This includes the `front`-matter (authors, funding, title, abstract, etc.), the `body` of the article (sections, figures, equations, tables, etc.), and `back`-matter (references, footnotes, etc.). The JATS can also contain `sub-articles`.
17
+
18
+ The standard documents are hosted by the NIH <https://jats.nlm.nih.gov/>. There are three flavours, this library currently uses in most cases the most precriptive tag set (for article authoring). Another helpful resource is <https://jats4r.org/>, which provides other examples and recomendations for JATS.
19
+
20
+ Note that most publishers do **not** provide the XML as a first class output - they should, it is an important part of open-science to have the content programatically accessible and interoperable. It is only [FAIR](https://www.go-fair.org/fair-principles/) 😉.
21
+
22
+ ## From the command line
23
+
24
+ Commands available:
25
+
26
+ `download`: attempt to find the JATS file and download it locally.
27
+
28
+ ```bash
29
+ jats download https://docs.python.org/3.7 article.jats
30
+ ```
31
+
32
+ Note, currently this just downloads the XML, **not** the associated files.
33
+
34
+ `sumamry`: summarize the contents of the JATS, given a URL, DOI, or local file
35
+
36
+ ```bash
37
+ jats summary https://elifesciences.org/articles/81952
38
+ jats summary 10.1371/journal.pclm.0000068
39
+ jats summary /local/article.jats
40
+ ```
41
+
42
+ This will provide a summary, including a list of what the JATS file contains.
43
+
44
+ ![Output of `jats summary`](images/jats-output.png)
45
+
46
+ ## Working in Typescript
47
+
48
+ All tags are accessible as types/enums. There is also documentation from each node-type
49
+
50
+ ```typescript
51
+ import { Tags } from 'jats-xml';
52
+
53
+ Tags.journalId;
54
+ ```
55
+
56
+ ## Reading JATS in Node
57
+
58
+ ```typescript
59
+ import 'fs' from 'fs';
60
+ import { Inventory, toDate } from 'jats-xml';
61
+ import { toText } from 'myst-common';
62
+ import { select, selectAll } from 'unist-util-select';
63
+
64
+ const data = fs.readFileSync('article.jats').toString();
65
+ const jats = new JATS(data);
66
+ // Easy access to properties
67
+ jats.doi
68
+ jats.body // A tree of the body (or front/back)
69
+ toDate(jats.publicationDate) // as a Javascript Date object
70
+ select('[id=fig1]', jats.body) // select a figure by an ID
71
+ selectAll('fig', jats.body) // Or selectAll figures
72
+ ```
73
+
74
+ ## Write JATS in Node
75
+
76
+ TODO!
@@ -9,6 +9,6 @@ const version_1 = __importDefault(require("../version"));
9
9
  const parse_1 = require("./parse");
10
10
  const program = new commander_1.default.Command();
11
11
  (0, parse_1.addDownloadCLI)(program);
12
- program.version(`v${version_1.default}`, '-v, --version', 'Print the current version of jtex');
12
+ program.version(`v${version_1.default}`, '-v, --version', 'Print the current version of jats-xml');
13
13
  program.option('-d, --debug', 'Log out any errors to the console.');
14
14
  program.parse(process.argv);
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const version = '0.0.2';
3
+ const version = '0.0.3';
4
4
  exports.default = version;
@@ -4,6 +4,6 @@ import version from '../version';
4
4
  import { addDownloadCLI } from './parse';
5
5
  const program = new commander.Command();
6
6
  addDownloadCLI(program);
7
- program.version(`v${version}`, '-v, --version', 'Print the current version of jtex');
7
+ program.version(`v${version}`, '-v, --version', 'Print the current version of jats-xml');
8
8
  program.option('-d, --debug', 'Log out any errors to the console.');
9
9
  program.parse(process.argv);
@@ -1,2 +1,2 @@
1
- const version = '0.0.2';
1
+ const version = '0.0.3';
2
2
  export default version;
package/dist/jats.js CHANGED
@@ -9094,7 +9094,7 @@ var require_lib4 = __commonJS({
9094
9094
  var import_commander2 = __toESM(require_commander());
9095
9095
 
9096
9096
  // src/version.ts
9097
- var version = "0.0.2";
9097
+ var version = "0.0.3";
9098
9098
  var version_default = version;
9099
9099
 
9100
9100
  // src/cli/parse.ts
@@ -10419,7 +10419,7 @@ function addDownloadCLI(program2) {
10419
10419
  // src/cli/index.ts
10420
10420
  var program = new import_commander2.default.Command();
10421
10421
  addDownloadCLI(program);
10422
- program.version(`v${version_default}`, "-v, --version", "Print the current version of jtex");
10422
+ program.version(`v${version_default}`, "-v, --version", "Print the current version of jats-xml");
10423
10423
  program.option("-d, --debug", "Log out any errors to the console.");
10424
10424
  program.parse(process.argv);
10425
10425
  /*! http://mths.be/fromcodepoint v0.1.0 by @mathias */
@@ -1,3 +1,3 @@
1
- declare const version = "0.0.2";
1
+ declare const version = "0.0.3";
2
2
  export default version;
3
3
  //# sourceMappingURL=version.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jats-xml",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "Types and utilities for working with JATS in Typescript",
5
5
  "author": "Rowan Cockett <rowan@curvenote.com>",
6
6
  "homepage": "https://github.com/executablebooks/mystjs/tree/main/packages/jats-xml",
@@ -38,7 +38,7 @@
38
38
  "unlink": "npm uninstall -g jats-xml;",
39
39
  "link": "npm run unlink; npm link;",
40
40
  "dev": "npm run link && esbuild src/cli/index.ts --bundle --outfile=dist/jats.js --platform=node --watch",
41
- "test": "copy:version && jest",
41
+ "test": "npm run copy:version && jest",
42
42
  "test:watch": "jest --watchAll",
43
43
  "lint": "eslint \"src/**/*.ts\" -c .eslintrc.js --max-warnings 1",
44
44
  "lint:format": "prettier --check src/*.ts src/**/*.ts",