@citestyle/styles 0.0.2
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/LICENSE +21 -0
- package/README.md +113 -0
- package/package.json +37 -0
- package/types.d.ts +4 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Proximify
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
# @citestyle/styles
|
|
2
|
+
|
|
3
|
+
Pre-compiled popular CSL styles, ready to use. Each style is ~3-5KB and imports shared helpers from `@citestyle/core`.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @citestyle/styles
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Available Styles
|
|
12
|
+
|
|
13
|
+
| Import path | Style |
|
|
14
|
+
|---|---|
|
|
15
|
+
| `@citestyle/styles/apa` | American Psychological Association 7th edition |
|
|
16
|
+
| `@citestyle/styles/mla` | Modern Language Association 9th edition |
|
|
17
|
+
| `@citestyle/styles/chicago-author-date` | Chicago Manual of Style 17th edition (author-date) |
|
|
18
|
+
| `@citestyle/styles/ieee` | IEEE |
|
|
19
|
+
| `@citestyle/styles/vancouver` | Vancouver |
|
|
20
|
+
| `@citestyle/styles/harvard` | Harvard (Cite Them Right) |
|
|
21
|
+
| `@citestyle/styles/ama` | American Medical Association 11th edition |
|
|
22
|
+
| `@citestyle/styles/turabian` | Turabian 9th edition |
|
|
23
|
+
| `@citestyle/styles/nature` | Nature |
|
|
24
|
+
| `@citestyle/styles/science` | Science |
|
|
25
|
+
|
|
26
|
+
## Usage
|
|
27
|
+
|
|
28
|
+
### Direct (without registry)
|
|
29
|
+
|
|
30
|
+
```js
|
|
31
|
+
import * as apa from '@citestyle/styles/apa'
|
|
32
|
+
|
|
33
|
+
const item = {
|
|
34
|
+
id: '1',
|
|
35
|
+
type: 'article-journal',
|
|
36
|
+
title: 'A theory of everything',
|
|
37
|
+
author: [{ family: 'Einstein', given: 'Albert' }],
|
|
38
|
+
issued: { 'date-parts': [[2024]] },
|
|
39
|
+
'container-title': 'Physical Review Letters',
|
|
40
|
+
volume: '130',
|
|
41
|
+
page: '1-10',
|
|
42
|
+
DOI: '10.1103/example',
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const entry = apa.bibliography(item)
|
|
46
|
+
console.log(entry.text)
|
|
47
|
+
console.log(entry.html)
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### With registry (recommended for documents)
|
|
51
|
+
|
|
52
|
+
```js
|
|
53
|
+
import * as ieee from '@citestyle/styles/ieee'
|
|
54
|
+
import { createRegistry } from '@citestyle/registry'
|
|
55
|
+
|
|
56
|
+
const registry = createRegistry(ieee)
|
|
57
|
+
registry.addItems([item1, item2, item3])
|
|
58
|
+
|
|
59
|
+
const citation = registry.cite([{ id: '1' }])
|
|
60
|
+
console.log(citation.text) // [1]
|
|
61
|
+
|
|
62
|
+
const bibliography = registry.getBibliography()
|
|
63
|
+
bibliography.forEach(e => console.log(e.html))
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Style metadata
|
|
67
|
+
|
|
68
|
+
Every style exports a `meta` object:
|
|
69
|
+
|
|
70
|
+
```js
|
|
71
|
+
import * as apa from '@citestyle/styles/apa'
|
|
72
|
+
|
|
73
|
+
console.log(apa.meta.id) // "apa"
|
|
74
|
+
console.log(apa.meta.title) // "American Psychological Association 7th edition"
|
|
75
|
+
console.log(apa.meta.class) // "in-text"
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Custom Styles
|
|
79
|
+
|
|
80
|
+
For styles not included here, compile any CSL file with `@citestyle/compiler`:
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
npm install @citestyle/compiler
|
|
84
|
+
citestyle compile my-style.csl -o my-style.js
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Then import the output module the same way:
|
|
88
|
+
|
|
89
|
+
```js
|
|
90
|
+
import * as myStyle from './my-style.js'
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## Output Format
|
|
94
|
+
|
|
95
|
+
Every `bibliography(item)` call returns:
|
|
96
|
+
|
|
97
|
+
```js
|
|
98
|
+
{
|
|
99
|
+
text: '...', // Plain text
|
|
100
|
+
html: '...', // Semantic HTML with CSS classes and linked DOIs
|
|
101
|
+
parts: {...}, // Decomposed fields for custom layouts
|
|
102
|
+
links: {...}, // Extracted DOI, URL, PDF links
|
|
103
|
+
}
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Every `citation(cites)` call returns:
|
|
107
|
+
|
|
108
|
+
```js
|
|
109
|
+
{
|
|
110
|
+
text: '...', // Plain text (e.g., "(Smith, 2024)")
|
|
111
|
+
html: '...', // HTML with <span class="csl-citation">
|
|
112
|
+
}
|
|
113
|
+
```
|
package/package.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@citestyle/styles",
|
|
3
|
+
"version": "0.0.2",
|
|
4
|
+
"description": "Pre-compiled popular CSL styles (~3-5KB each)",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
"./apa": "./apa.js",
|
|
8
|
+
"./mla": "./mla.js",
|
|
9
|
+
"./chicago-author-date": "./chicago-author-date.js",
|
|
10
|
+
"./ieee": "./ieee.js",
|
|
11
|
+
"./vancouver": "./vancouver.js",
|
|
12
|
+
"./harvard": "./harvard.js",
|
|
13
|
+
"./ama": "./ama.js",
|
|
14
|
+
"./turabian": "./turabian.js",
|
|
15
|
+
"./nature": "./nature.js",
|
|
16
|
+
"./science": "./science.js"
|
|
17
|
+
},
|
|
18
|
+
"typesVersions": {
|
|
19
|
+
"*": {
|
|
20
|
+
"*": [
|
|
21
|
+
"./types.d.ts"
|
|
22
|
+
]
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"*.js",
|
|
27
|
+
"types.d.ts",
|
|
28
|
+
"README.md"
|
|
29
|
+
],
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"@citestyle/core": "0.0.2"
|
|
32
|
+
},
|
|
33
|
+
"license": "MIT",
|
|
34
|
+
"scripts": {
|
|
35
|
+
"build": "echo 'TODO: compile styles from CSL sources'"
|
|
36
|
+
}
|
|
37
|
+
}
|
package/types.d.ts
ADDED