react-cheminfo 0.140.0 → 0.141.0

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.
Files changed (196) hide show
  1. package/README.md +14 -8
  2. package/lib/citation/core/citationMarkup.d.ts +14 -0
  3. package/lib/citation/core/citationMarkup.d.ts.map +1 -0
  4. package/lib/citation/core/citationMarkup.js +27 -0
  5. package/lib/citation/core/citationMarkup.js.map +1 -0
  6. package/lib/citation/core/clipboard.d.ts +7 -6
  7. package/lib/citation/core/clipboard.d.ts.map +1 -1
  8. package/lib/citation/core/clipboard.js +19 -14
  9. package/lib/citation/core/clipboard.js.map +1 -1
  10. package/lib/citation/core/download.d.ts +4 -2
  11. package/lib/citation/core/download.d.ts.map +1 -1
  12. package/lib/citation/core/download.js +5 -3
  13. package/lib/citation/core/download.js.map +1 -1
  14. package/lib/citation/core/formats.d.ts +14 -3
  15. package/lib/citation/core/formats.d.ts.map +1 -1
  16. package/lib/citation/core/formats.js +31 -13
  17. package/lib/citation/core/formats.js.map +1 -1
  18. package/lib/citation/core/index.d.ts +3 -3
  19. package/lib/citation/core/index.d.ts.map +1 -1
  20. package/lib/citation/core/index.js +2 -2
  21. package/lib/citation/core/index.js.map +1 -1
  22. package/lib/citation/core/reference.d.ts +15 -0
  23. package/lib/citation/core/reference.d.ts.map +1 -1
  24. package/lib/citation/core/reference.js +24 -0
  25. package/lib/citation/core/reference.js.map +1 -1
  26. package/lib/citation/core/styles.d.ts +35 -0
  27. package/lib/citation/core/styles.d.ts.map +1 -0
  28. package/lib/citation/core/styles.js +21 -0
  29. package/lib/citation/core/styles.js.map +1 -0
  30. package/lib/citation/core/works.d.ts +2 -3
  31. package/lib/citation/core/works.d.ts.map +1 -1
  32. package/lib/citation/core/works.js +5 -6
  33. package/lib/citation/core/works.js.map +1 -1
  34. package/lib/citation/ui/CitationHtml.d.ts +13 -0
  35. package/lib/citation/ui/CitationHtml.d.ts.map +1 -0
  36. package/lib/citation/ui/CitationHtml.js +42 -0
  37. package/lib/citation/ui/CitationHtml.js.map +1 -0
  38. package/lib/citation/ui/CitationPreview.d.ts +7 -4
  39. package/lib/citation/ui/CitationPreview.d.ts.map +1 -1
  40. package/lib/citation/ui/CitationPreview.js +17 -21
  41. package/lib/citation/ui/CitationPreview.js.map +1 -1
  42. package/lib/citation/ui/CopyFormatEntries.js +1 -1
  43. package/lib/citation/ui/CopyFormatEntries.js.map +1 -1
  44. package/lib/citation/ui/entries.d.ts +1 -1
  45. package/lib/citation/ui/entries.d.ts.map +1 -1
  46. package/lib/citation/ui/entries.js +1 -1
  47. package/lib/citation/ui/entries.js.map +1 -1
  48. package/lib/citation/ui/useCopyFeedback.d.ts +1 -2
  49. package/lib/citation/ui/useCopyFeedback.d.ts.map +1 -1
  50. package/lib/citation/ui/useCopyFeedback.js.map +1 -1
  51. package/lib/credits/core/credits.d.ts +13 -0
  52. package/lib/credits/core/credits.d.ts.map +1 -1
  53. package/lib/credits/core/credits.js +17 -0
  54. package/lib/credits/core/credits.js.map +1 -1
  55. package/lib/csl/core/cslItems.d.ts +97 -0
  56. package/lib/csl/core/cslItems.d.ts.map +1 -0
  57. package/lib/csl/core/cslItems.js +166 -0
  58. package/lib/csl/core/cslItems.js.map +1 -0
  59. package/lib/csl/core/cslStyles.d.ts +30 -0
  60. package/lib/csl/core/cslStyles.d.ts.map +1 -0
  61. package/lib/csl/core/cslStyles.js +48 -0
  62. package/lib/csl/core/cslStyles.js.map +1 -0
  63. package/lib/csl/core/formatCsl.d.ts +35 -0
  64. package/lib/csl/core/formatCsl.d.ts.map +1 -0
  65. package/lib/csl/core/formatCsl.js +100 -0
  66. package/lib/csl/core/formatCsl.js.map +1 -0
  67. package/lib/csl/core/referenceItem.d.ts +14 -0
  68. package/lib/csl/core/referenceItem.d.ts.map +1 -0
  69. package/lib/csl/core/referenceItem.js +60 -0
  70. package/lib/csl/core/referenceItem.js.map +1 -0
  71. package/lib/csl/core/styles/americanChemicalSociety.d.ts +8 -0
  72. package/lib/csl/core/styles/americanChemicalSociety.d.ts.map +1 -0
  73. package/lib/csl/core/styles/americanChemicalSociety.js +311 -0
  74. package/lib/csl/core/styles/americanChemicalSociety.js.map +1 -0
  75. package/lib/csl/core/styles/americanInstituteOfPhysics.d.ts +8 -0
  76. package/lib/csl/core/styles/americanInstituteOfPhysics.d.ts.map +1 -0
  77. package/lib/csl/core/styles/americanInstituteOfPhysics.js +172 -0
  78. package/lib/csl/core/styles/americanInstituteOfPhysics.js.map +1 -0
  79. package/lib/csl/core/styles/americanMathematicalSocietyNumeric.d.ts +8 -0
  80. package/lib/csl/core/styles/americanMathematicalSocietyNumeric.d.ts.map +1 -0
  81. package/lib/csl/core/styles/americanMathematicalSocietyNumeric.js +174 -0
  82. package/lib/csl/core/styles/americanMathematicalSocietyNumeric.js.map +1 -0
  83. package/lib/csl/core/styles/americanPhysicsSociety.d.ts +8 -0
  84. package/lib/csl/core/styles/americanPhysicsSociety.d.ts.map +1 -0
  85. package/lib/csl/core/styles/americanPhysicsSociety.js +227 -0
  86. package/lib/csl/core/styles/americanPhysicsSociety.js.map +1 -0
  87. package/lib/csl/core/styles/angewandteChemie.d.ts +8 -0
  88. package/lib/csl/core/styles/angewandteChemie.d.ts.map +1 -0
  89. package/lib/csl/core/styles/angewandteChemie.js +187 -0
  90. package/lib/csl/core/styles/angewandteChemie.js.map +1 -0
  91. package/lib/csl/core/styles/beilsteinJournalOfOrganicChemistry.d.ts +8 -0
  92. package/lib/csl/core/styles/beilsteinJournalOfOrganicChemistry.d.ts.map +1 -0
  93. package/lib/csl/core/styles/beilsteinJournalOfOrganicChemistry.js +280 -0
  94. package/lib/csl/core/styles/beilsteinJournalOfOrganicChemistry.js.map +1 -0
  95. package/lib/csl/core/styles/elsevierWithTitles.d.ts +8 -0
  96. package/lib/csl/core/styles/elsevierWithTitles.d.ts.map +1 -0
  97. package/lib/csl/core/styles/elsevierWithTitles.js +156 -0
  98. package/lib/csl/core/styles/elsevierWithTitles.js.map +1 -0
  99. package/lib/csl/core/styles/helveticaChimicaActa.d.ts +8 -0
  100. package/lib/csl/core/styles/helveticaChimicaActa.d.ts.map +1 -0
  101. package/lib/csl/core/styles/helveticaChimicaActa.js +189 -0
  102. package/lib/csl/core/styles/helveticaChimicaActa.js.map +1 -0
  103. package/lib/csl/core/styles/ieee.d.ts +8 -0
  104. package/lib/csl/core/styles/ieee.d.ts.map +1 -0
  105. package/lib/csl/core/styles/ieee.js +527 -0
  106. package/lib/csl/core/styles/ieee.js.map +1 -0
  107. package/lib/csl/core/styles/instituteOfPhysicsNumeric.d.ts +8 -0
  108. package/lib/csl/core/styles/instituteOfPhysicsNumeric.d.ts.map +1 -0
  109. package/lib/csl/core/styles/instituteOfPhysicsNumeric.js +135 -0
  110. package/lib/csl/core/styles/instituteOfPhysicsNumeric.js.map +1 -0
  111. package/lib/csl/core/styles/localeEnUs.d.ts +8 -0
  112. package/lib/csl/core/styles/localeEnUs.d.ts.map +1 -0
  113. package/lib/csl/core/styles/localeEnUs.js +872 -0
  114. package/lib/csl/core/styles/localeEnUs.js.map +1 -0
  115. package/lib/csl/core/styles/nature.d.ts +8 -0
  116. package/lib/csl/core/styles/nature.d.ts.map +1 -0
  117. package/lib/csl/core/styles/nature.js +197 -0
  118. package/lib/csl/core/styles/nature.js.map +1 -0
  119. package/lib/csl/core/styles/royalSocietyOfChemistry.d.ts +8 -0
  120. package/lib/csl/core/styles/royalSocietyOfChemistry.d.ts.map +1 -0
  121. package/lib/csl/core/styles/royalSocietyOfChemistry.js +267 -0
  122. package/lib/csl/core/styles/royalSocietyOfChemistry.js.map +1 -0
  123. package/lib/csl/core/styles/springerMathphysBrackets.d.ts +8 -0
  124. package/lib/csl/core/styles/springerMathphysBrackets.d.ts.map +1 -0
  125. package/lib/csl/core/styles/springerMathphysBrackets.js +159 -0
  126. package/lib/csl/core/styles/springerMathphysBrackets.js.map +1 -0
  127. package/lib/csl/core/styles/springerPhysicsBrackets.d.ts +8 -0
  128. package/lib/csl/core/styles/springerPhysicsBrackets.d.ts.map +1 -0
  129. package/lib/csl/core/styles/springerPhysicsBrackets.js +166 -0
  130. package/lib/csl/core/styles/springerPhysicsBrackets.js.map +1 -0
  131. package/lib/csl/core/styles/styleLoaders.d.ts +6 -0
  132. package/lib/csl/core/styles/styleLoaders.d.ts.map +1 -0
  133. package/lib/csl/core/styles/styleLoaders.js +23 -0
  134. package/lib/csl/core/styles/styleLoaders.js.map +1 -0
  135. package/lib/csl/core/styles/synthesis.d.ts +8 -0
  136. package/lib/csl/core/styles/synthesis.d.ts.map +1 -0
  137. package/lib/csl/core/styles/synthesis.js +196 -0
  138. package/lib/csl/core/styles/synthesis.js.map +1 -0
  139. package/lib/csl/core/styles/tetrahedron.d.ts +8 -0
  140. package/lib/csl/core/styles/tetrahedron.d.ts.map +1 -0
  141. package/lib/csl/core/styles/tetrahedron.js +22 -0
  142. package/lib/csl/core/styles/tetrahedron.js.map +1 -0
  143. package/lib/csl.d.ts +17 -0
  144. package/lib/csl.d.ts.map +1 -0
  145. package/lib/csl.js +15 -0
  146. package/lib/csl.js.map +1 -0
  147. package/package.json +3 -1
  148. package/src/citation/core/citationMarkup.ts +28 -0
  149. package/src/citation/core/clipboard.ts +26 -17
  150. package/src/citation/core/download.ts +7 -5
  151. package/src/citation/core/formats.ts +41 -16
  152. package/src/citation/core/index.ts +3 -6
  153. package/src/citation/core/reference.ts +25 -0
  154. package/src/citation/core/styles.ts +34 -0
  155. package/src/citation/core/works.ts +7 -9
  156. package/src/citation/ui/CitationHtml.tsx +42 -0
  157. package/src/citation/ui/CitationPreview.tsx +36 -35
  158. package/src/citation/ui/CopyFormatEntries.tsx +1 -1
  159. package/src/citation/ui/entries.tsx +2 -2
  160. package/src/citation/ui/useCopyFeedback.ts +1 -2
  161. package/src/credits/core/credits.ts +17 -0
  162. package/src/csl/core/citeproc.d.ts +43 -0
  163. package/src/csl/core/cslItems.ts +208 -0
  164. package/src/csl/core/cslStyles.ts +52 -0
  165. package/src/csl/core/formatCsl.ts +135 -0
  166. package/src/csl/core/referenceItem.ts +75 -0
  167. package/src/csl/core/styles/americanChemicalSociety.ts +310 -0
  168. package/src/csl/core/styles/americanInstituteOfPhysics.ts +171 -0
  169. package/src/csl/core/styles/americanMathematicalSocietyNumeric.ts +173 -0
  170. package/src/csl/core/styles/americanPhysicsSociety.ts +226 -0
  171. package/src/csl/core/styles/angewandteChemie.ts +186 -0
  172. package/src/csl/core/styles/beilsteinJournalOfOrganicChemistry.ts +279 -0
  173. package/src/csl/core/styles/elsevierWithTitles.ts +155 -0
  174. package/src/csl/core/styles/helveticaChimicaActa.ts +188 -0
  175. package/src/csl/core/styles/ieee.ts +526 -0
  176. package/src/csl/core/styles/instituteOfPhysicsNumeric.ts +134 -0
  177. package/src/csl/core/styles/localeEnUs.ts +871 -0
  178. package/src/csl/core/styles/nature.ts +196 -0
  179. package/src/csl/core/styles/royalSocietyOfChemistry.ts +266 -0
  180. package/src/csl/core/styles/springerMathphysBrackets.ts +158 -0
  181. package/src/csl/core/styles/springerPhysicsBrackets.ts +165 -0
  182. package/src/csl/core/styles/styleLoaders.ts +38 -0
  183. package/src/csl/core/styles/synthesis.ts +195 -0
  184. package/src/csl/core/styles/tetrahedron.ts +21 -0
  185. package/src/csl.ts +31 -0
  186. package/styles/chrome.css +30 -6
  187. package/lib/citation/core/render.d.ts +0 -21
  188. package/lib/citation/core/render.d.ts.map +0 -1
  189. package/lib/citation/core/render.js +0 -74
  190. package/lib/citation/core/render.js.map +0 -1
  191. package/lib/citation/core/segments.d.ts +0 -62
  192. package/lib/citation/core/segments.d.ts.map +0 -1
  193. package/lib/citation/core/segments.js +0 -210
  194. package/lib/citation/core/segments.js.map +0 -1
  195. package/src/citation/core/render.ts +0 -78
  196. package/src/citation/core/segments.ts +0 -254
package/README.md CHANGED
@@ -52,6 +52,7 @@ only when it drags a heavy dependency behind it.
52
52
  | `react-cheminfo/mass` | the mass spectrum chart, peak table and editor | React, ms-spectrum, jcampconverter, xy-parser |
53
53
  | `react-cheminfo/xps` | the XPS chart, peak, fit and composition tables, editor | React, xps-analysis, ml-gsd, xy-parser |
54
54
  | `react-cheminfo/xtb` | GFN2-xTB as a geometry relaxer | nothing on import; xtb-wasm on the first call |
55
+ | `react-cheminfo/csl` | CSL JSON read, citations formatted in a journal's CSL style | nothing on import; citeproc and the style first |
55
56
  | `react-cheminfo/host` | data handed over by a page that frames the tool | nothing on import; ajv once the page is framed |
56
57
  | `react-cheminfo/demo` | a tool playing a steps slide's demo, with a cursor | nothing; loaded only on a page with `?demo=` |
57
58
  | `react-cheminfo/host-testing` | a stand-in host and SciPeaks' messages, for e2e tests | nothing; Node only |
@@ -180,7 +181,8 @@ through a wildcard subpath exactly as `react-science` serves its own.
180
181
  | **An empty tool** | — | `EmptyGuide`, `EmptyGuideSection`, `ShortcutList`, `ShortcutKeys` |
181
182
  | **Waiting for data** | — | `DataDropZone` |
182
183
  | **Languages** | `LANGUAGES`, `DEFAULT_LANGUAGE`, `LANGUAGE_LABELS`, `isLanguage`, `MessageCatalog`, `CHROME_CATALOG`, `setMessageSession`, `loadCatalogs`, `startTranslateMode`, `LANGUAGE_PARAM`, `withLanguageParam` | `useT`, `useChromeT`, `useLanguage`, `LanguageSelect`, `SiteLanguage` |
183
- | **Citation** | `formatCitation`, `formatCitations`, `citationSegments`, `downloadCitation`, `citedReferences`, `doiUrl`, `referenceVenue` | `CiteButton`, `CitationMenu`, `CitationPreview` |
184
+ | **Citation** | `formatCitation`, `formatCitations`, `formatEach`, `downloadCitation`, `citedReferences`, `doiUrl`, `referenceVenue` | `CiteButton`, `CitationMenu`, `CitationPreview` |
185
+ | **CSL** | `readCslText`, `formatCslCitations`, `formatCslEntries`, `referenceToCsl`, `itemLabel`, `CSL_STYLE_IDS` (all `/csl`) | — |
184
186
  | **Contact** | `CONTACT_FORM_URLS`, `contactFormUrl`, `contactUrl` | `ContactButton` |
185
187
  | **Share & embed** | `parseShareConfig`, `applyShareConfig`, `buildShareUrl`, `buildEmbedCode`, `isHidden`, `visibleShareParts`, `applySharePreset`, `findSharePreset`, the param codecs, `syncPreferencesWithUrl`, `preferenceEffect`, `pinnedPreferenceSearch`, `applyPreferencesFromSearch`, `writePreferencesToSearch`, sealed links: `openSealedAddress`, `sealShareUrl`, `sealQuery`, `unsealQuery`, links to an example: `opensOnLinks`, `defaultOpensOn`, `opensOnSearch`, `createExampleMark`, `packLinkValue`, `unpackLinkValue` | `ShareDialog`, `ShareButton`, `HiddenPartsProvider`, `PagePart`, `useIsHidden`, `SealedLinkRefused`, `ShareOpensOn`, `useOpensOnShare` |
186
188
  | **Routing & head** | `createTabRouter`, `readRoute`, `writeRoute`, `subscribeToRoute`, `adoptLegacyHashAddress`, `writeDocumentMeta`, `pageLocation`, `pageHistory` | `useTabRoute` |
@@ -267,9 +269,11 @@ import { CiteButton } from 'react-cheminfo/ui';
267
269
  ```
268
270
 
269
271
  - **HTML** and **Markdown**, each in the four styles chemists are asked for —
270
- ACS, Nature, RSC and Wiley. An HTML copy is written to the clipboard in both
271
- flavours, so Word and Google Docs keep the emphasis while a plain editor
272
- receives a clean line; that is why plain text is not a separate entry.
272
+ ACS, Nature, RSC and Angewandte — formatted by citeproc-js in the journals'
273
+ CSL styles, exactly as Zotero formats them. An HTML copy is written to the
274
+ clipboard in both flavours, so Word and Google Docs keep the emphasis while a
275
+ plain editor receives a clean line; that is why plain text is not a separate
276
+ entry.
273
277
  - **BibTeX**, **RIS** and the **DOI link**, which carry no style.
274
278
  - **RIS and BibTeX files**, served with the MIME types Zotero, Mendeley and
275
279
  EndNote recognise, so opening the saved file imports it.
@@ -278,8 +282,10 @@ import { CiteButton } from 'react-cheminfo/ui';
278
282
  menu, for a header that has run out of room. The label stays what the pointer
279
283
  and a screen reader are told.
280
284
 
281
- Adding a style means one function in `citation/core/segments.ts` and one entry
282
- in `CITATION_STYLES` — the three output formats and the preview follow.
285
+ Adding a style means one entry in `CITATION_STYLES`, naming a CSL style that
286
+ `react-cheminfo/csl` holds (`CSL_STYLE_IDS`) — the three output formats and the
287
+ preview follow. A style it does not hold is added to `scripts/csl-styles.mjs`,
288
+ which writes it from a checkout of the CSL styles repository.
283
289
 
284
290
  A site is often built on more than one work — the tool it wraps, and the
285
291
  platform it runs on — and a reader handed two references has to be told what is
@@ -328,8 +334,8 @@ import { PLATFORM_WORK, TEACHING_WORK } from 'react-cheminfo/core';
328
334
 
329
335
  A dataset is cited too. Give the reference `kind: 'dataset'` and a
330
336
  `repository` in place of the journal, volume and pages: every style writes it
331
- the way it writes data, BibTeX as a `@misc` entry and RIS as a `DATA` record,
332
- and its entry opens the dataset rather than an article.
337
+ the way its CSL style writes data, BibTeX as a `@misc` entry and RIS as a
338
+ `DATA` record, and its entry opens the dataset rather than an article.
333
339
 
334
340
  ```tsx
335
341
  const RECORD: DatasetReference = {
@@ -0,0 +1,14 @@
1
+ /**
2
+ * A reference formatted by citeproc-js, written for the places it is pasted
3
+ * into: Markdown for a README or an issue, keeping the style's italics and
4
+ * bold.
5
+ */
6
+ /**
7
+ * A formatted reference as one line of Markdown: italics and bold kept, a
8
+ * raised or lowered run kept as the HTML Markdown allows, every other tag
9
+ * dropped and its text kept.
10
+ * @param html - What citeproc-js wrote.
11
+ * @returns The Markdown.
12
+ */
13
+ export declare function markdownOfHtml(html: string): string;
14
+ //# sourceMappingURL=citationMarkup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"citationMarkup.d.ts","sourceRoot":"","sources":["../../../src/citation/core/citationMarkup.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAYnD"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * A reference formatted by citeproc-js, written for the places it is pasted
3
+ * into: Markdown for a README or an issue, keeping the style's italics and
4
+ * bold.
5
+ */
6
+ import { unescapeXml } from "../../drawing/render/markup.js";
7
+ /**
8
+ * A formatted reference as one line of Markdown: italics and bold kept, a
9
+ * raised or lowered run kept as the HTML Markdown allows, every other tag
10
+ * dropped and its text kept.
11
+ * @param html - What citeproc-js wrote.
12
+ * @returns The Markdown.
13
+ */
14
+ export function markdownOfHtml(html) {
15
+ const marked = html.replaceAll(/<(?<closing>\/?)(?<tag>[a-z]+)[^>]*>/gi, (_, closing, tag) => {
16
+ const name = tag.toLowerCase();
17
+ if (name === 'i' || name === 'em')
18
+ return '*';
19
+ if (name === 'b' || name === 'strong')
20
+ return '**';
21
+ if (name === 'sup' || name === 'sub')
22
+ return `<${closing}${name}>`;
23
+ return '';
24
+ });
25
+ return unescapeXml(marked);
26
+ }
27
+ //# sourceMappingURL=citationMarkup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"citationMarkup.js","sourceRoot":"","sources":["../../../src/citation/core/citationMarkup.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAE7D;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAAC,IAAY;IACzC,MAAM,MAAM,GAAG,IAAI,CAAC,UAAU,CAC5B,wCAAwC,EACxC,CAAC,CAAC,EAAE,OAAe,EAAE,GAAW,EAAE,EAAE;QAClC,MAAM,IAAI,GAAG,GAAG,CAAC,WAAW,EAAE,CAAC;QAC/B,IAAI,IAAI,KAAK,GAAG,IAAI,IAAI,KAAK,IAAI;YAAE,OAAO,GAAG,CAAC;QAC9C,IAAI,IAAI,KAAK,GAAG,IAAI,IAAI,KAAK,QAAQ;YAAE,OAAO,IAAI,CAAC;QACnD,IAAI,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK;YAAE,OAAO,IAAI,OAAO,GAAG,IAAI,GAAG,CAAC;QACnE,OAAO,EAAE,CAAC;IACZ,CAAC,CACF,CAAC;IACF,OAAO,WAAW,CAAC,MAAM,CAAC,CAAC;AAC7B,CAAC"}
@@ -1,23 +1,24 @@
1
1
  import type { CitationFormatId } from './formats.ts';
2
2
  import type { Reference } from './reference.ts';
3
- import type { CitationStyleId } from './segments.ts';
4
3
  /**
5
4
  * Put every reference a site asks for on the clipboard, in one value. HTML goes
6
5
  * on in both flavours, so a paste into Word or Google Docs keeps the emphasis of
7
6
  * the style while a plain text editor still receives readable lines rather than
8
- * the markup.
7
+ * the markup. The write starts with the click and the citations follow while
8
+ * they are formatted, which is what Safari asks of a copy.
9
9
  * @param references - References to copy, in reading order.
10
10
  * @param format - Format to copy them in.
11
- * @param style - Journal style, for the formats that have one.
11
+ * @param style - The CSL style of a format written as a journal writes it.
12
12
  * @returns Resolves once the clipboard holds the citations.
13
+ * @throws {Error} When the clipboard took nothing.
13
14
  */
14
- export declare function copyCitations(references: readonly Reference[], format: CitationFormatId, style?: CitationStyleId): Promise<void>;
15
+ export declare function copyCitations(references: readonly Reference[], format: CitationFormatId, style?: string): Promise<void>;
15
16
  /**
16
17
  * Put one reference on the clipboard.
17
18
  * @param reference - Reference to copy.
18
19
  * @param format - Format to copy it in.
19
- * @param style - Journal style, for the formats that have one.
20
+ * @param style - The CSL style of a format written as a journal writes it.
20
21
  * @returns Resolves once the clipboard holds the citation.
21
22
  */
22
- export declare function copyCitation(reference: Reference, format: CitationFormatId, style?: CitationStyleId): Promise<void>;
23
+ export declare function copyCitation(reference: Reference, format: CitationFormatId, style?: string): Promise<void>;
23
24
  //# sourceMappingURL=clipboard.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"clipboard.d.ts","sourceRoot":"","sources":["../../../src/citation/core/clipboard.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAGrD;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAC3B,UAAU,EAAE,SAAS,SAAS,EAAE,EAChC,MAAM,EAAE,gBAAgB,EACxB,KAAK,CAAC,EAAE,eAAe,GACtB,OAAO,CAAC,IAAI,CAAC,CAaf;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAC1B,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,gBAAgB,EACxB,KAAK,CAAC,EAAE,eAAe,GACtB,OAAO,CAAC,IAAI,CAAC,CAEf"}
1
+ {"version":3,"file":"clipboard.d.ts","sourceRoot":"","sources":["../../../src/citation/core/clipboard.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAGhD;;;;;;;;;;;GAWG;AACH,wBAAsB,aAAa,CACjC,UAAU,EAAE,SAAS,SAAS,EAAE,EAChC,MAAM,EAAE,gBAAgB,EACxB,KAAK,CAAC,EAAE,MAAM,GACb,OAAO,CAAC,IAAI,CAAC,CAkBf;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAC1B,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,gBAAgB,EACxB,KAAK,CAAC,EAAE,MAAM,GACb,OAAO,CAAC,IAAI,CAAC,CAEf"}
@@ -1,33 +1,38 @@
1
+ import { writeClipboardItem } from "../../clipboard/core/clipboardItem.js";
2
+ import { writeToClipboard } from "../../clipboard/core/writeToClipboard.js";
1
3
  import { formatCitations } from "./works.js";
2
4
  /**
3
5
  * Put every reference a site asks for on the clipboard, in one value. HTML goes
4
6
  * on in both flavours, so a paste into Word or Google Docs keeps the emphasis of
5
7
  * the style while a plain text editor still receives readable lines rather than
6
- * the markup.
8
+ * the markup. The write starts with the click and the citations follow while
9
+ * they are formatted, which is what Safari asks of a copy.
7
10
  * @param references - References to copy, in reading order.
8
11
  * @param format - Format to copy them in.
9
- * @param style - Journal style, for the formats that have one.
12
+ * @param style - The CSL style of a format written as a journal writes it.
10
13
  * @returns Resolves once the clipboard holds the citations.
14
+ * @throws {Error} When the clipboard took nothing.
11
15
  */
12
- export function copyCitations(references, format, style) {
16
+ export async function copyCitations(references, format, style) {
13
17
  const value = formatCitations(references, format, style);
14
- if (format !== 'html' || typeof ClipboardItem === 'undefined') {
15
- return navigator.clipboard.writeText(value);
18
+ const text = format === 'html' ? formatCitations(references, 'text', style) : value;
19
+ const representations = {
20
+ 'text/plain': text.then((written) => new Blob([written], { type: 'text/plain' })),
21
+ };
22
+ if (format === 'html') {
23
+ representations['text/html'] = value.then((written) => new Blob([written], { type: 'text/html' }));
24
+ }
25
+ if (await writeClipboardItem(representations))
26
+ return;
27
+ if (!(await writeToClipboard(await text))) {
28
+ throw new Error('The clipboard refused the citation');
16
29
  }
17
- return navigator.clipboard.write([
18
- new ClipboardItem({
19
- 'text/html': new Blob([value], { type: 'text/html' }),
20
- 'text/plain': new Blob([formatCitations(references, 'text', style)], {
21
- type: 'text/plain',
22
- }),
23
- }),
24
- ]);
25
30
  }
26
31
  /**
27
32
  * Put one reference on the clipboard.
28
33
  * @param reference - Reference to copy.
29
34
  * @param format - Format to copy it in.
30
- * @param style - Journal style, for the formats that have one.
35
+ * @param style - The CSL style of a format written as a journal writes it.
31
36
  * @returns Resolves once the clipboard holds the citation.
32
37
  */
33
38
  export function copyCitation(reference, format, style) {
@@ -1 +1 @@
1
- {"version":3,"file":"clipboard.js","sourceRoot":"","sources":["../../../src/citation/core/clipboard.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE7C;;;;;;;;;GASG;AACH,MAAM,UAAU,aAAa,CAC3B,UAAgC,EAChC,MAAwB,EACxB,KAAuB;IAEvB,MAAM,KAAK,GAAG,eAAe,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;IACzD,IAAI,MAAM,KAAK,MAAM,IAAI,OAAO,aAAa,KAAK,WAAW,EAAE,CAAC;QAC9D,OAAO,SAAS,CAAC,SAAS,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IAC9C,CAAC;IACD,OAAO,SAAS,CAAC,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CAAC;IACF,IAAI,MAAM,KAAK,MAAM,EAAE,CAAC;QACtB,eAAe,CAAC,WAAW,CAAC,GAAG,KAAK,CAAC,IAAI,CACvC,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,IAAI,CAAC,CAAC,OAAO,CAAC,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC,CACxD,CAAC;IACJ,CAAC;IACD,IAAI,MAAM,kBAAkB,CAAC,eAAe,CAAC;QAAE,OAAO;IACtD,IAAI,CAAC,CAAC,MAAM,gBAAgB,CAAC,MAAM,IAAI,CAAC,CAAC,EAAE,CAAC;QAC1C,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;IACxD,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAC1B,SAAoB,EACpB,MAAwB,EACxB,KAAc;IAEd,OAAO,aAAa,CAAC,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;AACnD,CAAC"}
@@ -8,12 +8,14 @@ import type { Reference } from './reference.ts';
8
8
  * installed.
9
9
  * @param references - References to save, in reading order.
10
10
  * @param download - File to write, from `CITATION_DOWNLOADS`.
11
+ * @returns Resolves once the file is handed to the browser.
11
12
  */
12
- export declare function downloadCitations(references: readonly Reference[], download: CitationDownload): void;
13
+ export declare function downloadCitations(references: readonly Reference[], download: CitationDownload): Promise<void>;
13
14
  /**
14
15
  * Save one reference as the file a reference manager imports.
15
16
  * @param reference - Reference to save.
16
17
  * @param download - File to write, from `CITATION_DOWNLOADS`.
18
+ * @returns Resolves once the file is handed to the browser.
17
19
  */
18
- export declare function downloadCitation(reference: Reference, download: CitationDownload): void;
20
+ export declare function downloadCitation(reference: Reference, download: CitationDownload): Promise<void>;
19
21
  //# sourceMappingURL=download.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"download.d.ts","sourceRoot":"","sources":["../../../src/citation/core/download.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAGhD;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,SAAS,SAAS,EAAE,EAChC,QAAQ,EAAE,gBAAgB,GACzB,IAAI,CAMN;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC9B,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,gBAAgB,GACzB,IAAI,CAEN"}
1
+ {"version":3,"file":"download.d.ts","sourceRoot":"","sources":["../../../src/citation/core/download.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAGhD;;;;;;;;;GASG;AACH,wBAAsB,iBAAiB,CACrC,UAAU,EAAE,SAAS,SAAS,EAAE,EAChC,QAAQ,EAAE,gBAAgB,GACzB,OAAO,CAAC,IAAI,CAAC,CAMf;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC9B,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,gBAAgB,GACzB,OAAO,CAAC,IAAI,CAAC,CAEf"}
@@ -8,17 +8,19 @@ import { citationsFilename, formatCitations } from "./works.js";
8
8
  * installed.
9
9
  * @param references - References to save, in reading order.
10
10
  * @param download - File to write, from `CITATION_DOWNLOADS`.
11
+ * @returns Resolves once the file is handed to the browser.
11
12
  */
12
- export function downloadCitations(references, download) {
13
- const content = formatCitations(references, download.format);
13
+ export async function downloadCitations(references, download) {
14
+ const content = await formatCitations(references, download.format);
14
15
  downloadBlob(new Blob([content], { type: download.mimeType }), citationsFilename(references, download.extension));
15
16
  }
16
17
  /**
17
18
  * Save one reference as the file a reference manager imports.
18
19
  * @param reference - Reference to save.
19
20
  * @param download - File to write, from `CITATION_DOWNLOADS`.
21
+ * @returns Resolves once the file is handed to the browser.
20
22
  */
21
23
  export function downloadCitation(reference, download) {
22
- downloadCitations([reference], download);
24
+ return downloadCitations([reference], download);
23
25
  }
24
26
  //# sourceMappingURL=download.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"download.js","sourceRoot":"","sources":["../../../src/citation/core/download.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AAInE,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAEhE;;;;;;;;GAQG;AACH,MAAM,UAAU,iBAAiB,CAC/B,UAAgC,EAChC,QAA0B;IAE1B,MAAM,OAAO,GAAG,eAAe,CAAC,UAAU,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC7D,YAAY,CACV,IAAI,IAAI,CAAC,CAAC,OAAO,CAAC,EAAE,EAAE,IAAI,EAAE,QAAQ,CAAC,QAAQ,EAAE,CAAC,EAChD,iBAAiB,CAAC,UAAU,EAAE,QAAQ,CAAC,SAAS,CAAC,CAClD,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAC9B,SAAoB,EACpB,QAA0B;IAE1B,iBAAiB,CAAC,CAAC,SAAS,CAAC,EAAE,QAAQ,CAAC,CAAC;AAC3C,CAAC"}
1
+ {"version":3,"file":"download.js","sourceRoot":"","sources":["../../../src/citation/core/download.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AAInE,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAEhE;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,UAAgC,EAChC,QAA0B;IAE1B,MAAM,OAAO,GAAG,MAAM,eAAe,CAAC,UAAU,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;IACnE,YAAY,CACV,IAAI,IAAI,CAAC,CAAC,OAAO,CAAC,EAAE,EAAE,IAAI,EAAE,QAAQ,CAAC,QAAQ,EAAE,CAAC,EAChD,iBAAiB,CAAC,UAAU,EAAE,QAAQ,CAAC,SAAS,CAAC,CAClD,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAC9B,SAAoB,EACpB,QAA0B;IAE1B,OAAO,iBAAiB,CAAC,CAAC,SAAS,CAAC,EAAE,QAAQ,CAAC,CAAC;AAClD,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import type { Reference } from './reference.ts';
2
- import type { CitationStyleId } from './segments.ts';
2
+ import type { CitationStyleId } from './styles.ts';
3
3
  /** The formats the reference can be copied in. */
4
4
  export type CitationFormatId = 'text' | 'html' | 'markdown' | 'bibtex' | 'ris' | 'doi';
5
5
  /** One entry of the copy menu. */
@@ -84,8 +84,19 @@ export declare function citationFilename(reference: Reference, extension: string
84
84
  * Render a reference in one of the citation formats.
85
85
  * @param reference - Reference to render.
86
86
  * @param format - Format to render it in.
87
- * @param style - Journal style, for the formats that have one.
87
+ * @param style - The CSL style of a format written as a journal writes it.
88
88
  * @returns The citation, ready to be copied to the clipboard.
89
89
  */
90
- export declare function formatCitation(reference: Reference, format: CitationFormatId, style?: CitationStyleId): string;
90
+ export declare function formatCitation(reference: Reference, format: CitationFormatId, style?: string): Promise<string>;
91
+ /**
92
+ * Render each reference in one of the citation formats: the written ones —
93
+ * text, HTML, Markdown — by citeproc-js in a CSL style, as Zotero writes them,
94
+ * the others as reference managers import them.
95
+ * @param references - References to render, in reading order.
96
+ * @param format - Format to render them in.
97
+ * @param style - The CSL style of a format written as a journal writes it.
98
+ * @returns One citation per reference, in the same order.
99
+ * @throws {Error} For a format or a style there is not.
100
+ */
101
+ export declare function formatEach(references: readonly Reference[], format: CitationFormatId, style?: string): Promise<string[]>;
91
102
  //# sourceMappingURL=formats.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"formats.d.ts","sourceRoot":"","sources":["../../../src/citation/core/formats.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAG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rl } from "./reference.js";
2
- import { renderHtml, renderMarkdown, renderText } from "./render.js";
3
- import { citationSegments, nameFamilyFirst, pageRange } from "./segments.js";
1
+ import { formatCslEntries } from "../../csl/core/formatCsl.js";
2
+ import { referenceToCsl } from "../../csl/core/referenceItem.js";
3
+ import { markdownOfHtml } from "./citationMarkup.js";
4
+ import { doiUrl, nameFamilyFirst, pageRange } from "./reference.js";
4
5
  /**
5
6
  * Every format offered, in the order the menu lists them. Plain text is not
6
7
  * one of them: an HTML copy carries it as its second flavour, so a paste into
@@ -14,7 +15,7 @@ export const CITATION_FORMATS = [
14
15
  { id: 'doi', label: 'DOI link', hint: 'URL', styled: false },
15
16
  ];
16
17
  /** The style a format that has one is written in unless another is picked. */
17
- export const DEFAULT_CITATION_STYLE = 'acs';
18
+ export const DEFAULT_CITATION_STYLE = 'american-chemical-society';
18
19
  /**
19
20
  * The files offered for download. Zotero, Mendeley and EndNote all import
20
21
  * both, and their connectors recognise the MIME types below on their own.
@@ -48,23 +49,40 @@ export function citationFilename(reference, extension) {
48
49
  * Render a reference in one of the citation formats.
49
50
  * @param reference - Reference to render.
50
51
  * @param format - Format to render it in.
51
- * @param style - Journal style, for the formats that have one.
52
+ * @param style - The CSL style of a format written as a journal writes it.
52
53
  * @returns The citation, ready to be copied to the clipboard.
53
54
  */
54
- export function formatCitation(reference, format, style = DEFAULT_CITATION_STYLE) {
55
+ export async function formatCitation(reference, format, style = DEFAULT_CITATION_STYLE) {
56
+ const [written] = await formatEach([reference], format, style);
57
+ return written ?? '';
58
+ }
59
+ /**
60
+ * Render each reference in one of the citation formats: the written ones —
61
+ * text, HTML, Markdown — by citeproc-js in a CSL style, as Zotero writes them,
62
+ * the others as reference managers import them.
63
+ * @param references - References to render, in reading order.
64
+ * @param format - Format to render them in.
65
+ * @param style - The CSL style of a format written as a journal writes it.
66
+ * @returns One citation per reference, in the same order.
67
+ * @throws {Error} For a format or a style there is not.
68
+ */
69
+ export async function formatEach(references, format, style = DEFAULT_CITATION_STYLE) {
55
70
  switch (format) {
56
71
  case 'text':
57
- return renderText(citationSegments(reference, style));
72
+ return formatCslEntries(references.map(referenceToCsl), style, 'text');
58
73
  case 'html':
59
- return renderHtml(citationSegments(reference, style));
60
- case 'markdown':
61
- return renderMarkdown(citationSegments(reference, style));
74
+ return formatCslEntries(references.map(referenceToCsl), style, 'html');
75
+ case 'markdown': {
76
+ const items = references.map(referenceToCsl);
77
+ const entries = await formatCslEntries(items, style, 'html');
78
+ return entries.map(markdownOfHtml);
79
+ }
62
80
  case 'bibtex':
63
- return formatBibTeX(reference);
81
+ return references.map(formatBibTeX);
64
82
  case 'ris':
65
- return formatRis(reference);
83
+ return references.map(formatRis);
66
84
  case 'doi':
67
- return doiUrl(reference);
85
+ return references.map(doiUrl);
68
86
  default:
69
87
  throw new Error(`unknown citation format: ${String(format)}`);
70
88
  }
@@ -1 +1 @@
1
- {"version":3,"file":"formats.js","sourceRoot":"","sources":["../../../src/citation/core/formats.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAErE,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAoB7E;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,mBAAmB,EAAE,MAAM,EAAE,IAAI,EAAE;IACtE,EAAE,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,eAAe,EAAE,MAAM,EAAE,IAAI,EAAE;IAC1E,EAAE,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE;IAC/D,EAAE,EAAE,EAAE,KAAK,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OAAmC;IACrD,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAS,EAAE,CAAC,CAAC,IAAI,EAAE,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AACzE,CAAC;AAKD,SAAS,UAAU,CAAC,SAAoB,EAAE,SAAiB;IACzD,OAAO,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;AAChE,CAAC;AAED,SAAS,SAAS,CAAC,SAAoB;IACrC,MAAM,KAAK,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IACnC,MAAM,MAAM,GAAG,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC;IAChE,OAAO,GAAG,MAAM,CAAC,UAAU,CAAC,YAAY,EAAE,EAAE,CAAC,GAAG,SAAS,CAAC,IAAI,EAAE,CAAC;AACnE,CAAC"}
@@ -1,7 +1,7 @@
1
1
  export { copyCitation, copyCitations } from './clipboard.ts';
2
2
  export { downloadCitation, downloadCitations } from './download.ts';
3
3
  export type { CitationDownload, CitationFormat, CitationFormatId, } from './formats.ts';
4
- export { CITATION_DOWNLOADS, CITATION_FORMATS, DEFAULT_CITATION_STYLE, citationFilename, formatCitation, } from './formats.ts';
4
+ export { CITATION_DOWNLOADS, CITATION_FORMATS, DEFAULT_CITATION_STYLE, citationFilename, formatCitation, formatEach, } from './formats.ts';
5
5
  export { GFN2_XTB_PAPER, GFN2_XTB_WORK } from './gfn2Paper.ts';
6
6
  export { OPEN_CHEMISTRY_PAPER, OPEN_CHEMISTRY_WORK, } from './openChemistryPaper.ts';
7
7
  export { NMRIUM_PAPER, NMRIUM_WORK } from './nmriumPaper.ts';
@@ -9,8 +9,8 @@ export { OPENCHEMLIB_PAPER, OPENCHEMLIB_WORK } from './openchemlibPaper.ts';
9
9
  export { PLATFORM_PAPER, PLATFORM_WORK } from './platformPaper.ts';
10
10
  export type { ArticleReference, DatasetReference, Reference, ReferenceAuthor, } from './reference.ts';
11
11
  export { doiUrl, referenceVenue } from './reference.ts';
12
- export type { CitationSegment, CitationStyle, CitationStyleId, } from './segments.ts';
13
- export { CITATION_STYLES, citationSegments } from './segments.ts';
12
+ export type { CitationStyle, CitationStyleId } from './styles.ts';
13
+ export { CITATION_STYLES } from './styles.ts';
14
14
  export { TEACHING_PAPER, TEACHING_WORK } from './teachingPaper.ts';
15
15
  export type { CitedWork } from './works.ts';
16
16
  export { citationsFilename, citedReferences, formatCitations, } from './works.ts';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/citation/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AACpE,YAAY,EACV,gBAAgB,EAChB,cAAc,EACd,gBAAgB,GACjB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,sBAAsB,EACtB,gBAAgB,EAChB,cAAc,GACf,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/D,OAAO,EACL,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC5E,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnE,YAAY,EACV,gBAAgB,EAChB,gBAAgB,EAChB,SAAS,EACT,eAAe,GAChB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACxD,YAAY,EACV,eAAe,EACf,aAAa,EACb,eAAe,GAChB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnE,YAAY,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,eAAe,GAChB,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/citation/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AACpE,YAAY,EACV,gBAAgB,EAChB,cAAc,EACd,gBAAgB,GACjB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,sBAAsB,EACtB,gBAAgB,EAChB,cAAc,EACd,UAAU,GACX,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/D,OAAO,EACL,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC5E,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnE,YAAY,EACV,gBAAgB,EAChB,gBAAgB,EAChB,SAAS,EACT,eAAe,GAChB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACxD,YAAY,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnE,YAAY,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,eAAe,GAChB,MAAM,YAAY,CAAC"}
@@ -1,13 +1,13 @@
1
1
  export { copyCitation, copyCitations } from "./clipboard.js";
2
2
  export { downloadCitation, downloadCitations } from "./download.js";
3
- export { CITATION_DOWNLOADS, CITATION_FORMATS, DEFAULT_CITATION_STYLE, citationFilename, formatCitation, } from "./formats.js";
3
+ export { CITATION_DOWNLOADS, CITATION_FORMATS, DEFAULT_CITATION_STYLE, citationFilename, formatCitation, formatEach, } from "./formats.js";
4
4
  export { GFN2_XTB_PAPER, GFN2_XTB_WORK } from "./gfn2Paper.js";
5
5
  export { OPEN_CHEMISTRY_PAPER, OPEN_CHEMISTRY_WORK, } from "./openChemistryPaper.js";
6
6
  export { NMRIUM_PAPER, NMRIUM_WORK } from "./nmriumPaper.js";
7
7
  export { OPENCHEMLIB_PAPER, OPENCHEMLIB_WORK } from "./openchemlibPaper.js";
8
8
  export { PLATFORM_PAPER, PLATFORM_WORK } from "./platformPaper.js";
9
9
  export { doiUrl, referenceVenue } from "./reference.js";
10
- export { CITATION_STYLES, citationSegments } from "./segments.js";
10
+ export { CITATION_STYLES } from "./styles.js";
11
11
  export { TEACHING_PAPER, TEACHING_WORK } from "./teachingPaper.js";
12
12
  export { citationsFilename, citedReferences, formatCitations, } from "./works.js";
13
13
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/citation/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM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E,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC5E,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAOnE,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAExD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnE,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,eAAe,GAChB,MAAM,YAAY,CAAC"}
@@ -64,4 +64,19 @@ export declare function doiUrl(reference: Reference): string;
64
64
  * @returns The journal or the repository.
65
65
  */
66
66
  export declare function referenceVenue(reference: Reference): string;
67
+ /**
68
+ * The pages of an article, as BibTeX and RIS write them.
69
+ * @param reference - The article.
70
+ * @param dash - What joins the two ends.
71
+ * @returns One number for a journal that paginates by article number, the
72
+ * range otherwise.
73
+ */
74
+ export declare function pageRange(reference: ArticleReference, dash?: string): string;
75
+ /**
76
+ * An author with the family name first, `Vanderveen, J. R.`, or the name of an
77
+ * organisation alone.
78
+ * @param author - The author.
79
+ * @returns The name, as a reference list writes it.
80
+ */
81
+ export declare function nameFamilyFirst(author: ReferenceAuthor): string;
67
82
  //# sourceMappingURL=reference.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"reference.d.ts","sourceRoot":"","sources":["../../../src/citation/core/reference.ts"],"names":[],"mappings":"AAAA,mEAAmE;AACnE,MAAM,WAAW,eAAe;IAC9B,uEAAuE;IACvE,KAAK,EAAE,MAAM,CAAC;IACd,kEAAkE;IAClE,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,oEAAoE;AACpE,MAAM,WAAW,gBAAgB;IAC/B;;;OAGG;IACH,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,OAAO,EAAE,SAAS,eAAe,EAAE,CAAC;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,iDAAiD;IACjD,OAAO,EAAE,MAAM,CAAC;IAChB,oDAAoD;IACpD,mBAAmB,EAAE,MAAM,CAAC;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,wBAAwB;IACxB,IAAI,EAAE,SAAS,CAAC;IAChB,OAAO,EAAE,SAAS,eAAe,EAAE,CAAC;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,gDAAgD;IAChD,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;CACb;AAED,0EAA0E;AAC1E,MAAM,MAAM,SAAS,GAAG,gBAAgB,GAAG,gBAAgB,CAAC;AAE5D;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,SAAS,EAAE,SAAS,GAAG,MAAM,CAEnD;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,SAAS,EAAE,SAAS,GAAG,MAAM,CAI3D"}
1
+ {"version":3,"file":"reference.d.ts","sourceRoot":"","sources":["../../../src/citation/core/reference.ts"],"names":[],"mappings":"AAAA,mEAAmE;AACnE,MAAM,WAAW,eAAe;IAC9B,uEAAuE;IACvE,KAAK,EAAE,MAAM,CAAC;IACd,kEAAkE;IAClE,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,oEAAoE;AACpE,MAAM,WAAW,gBAAgB;IAC/B;;;OAGG;IACH,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,OAAO,EAAE,SAAS,eAAe,EAAE,CAAC;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,iDAAiD;IACjD,OAAO,EAAE,MAAM,CAAC;IAChB,oDAAoD;IACpD,mBAAmB,EAAE,MAAM,CAAC;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,wBAAwB;IACxB,IAAI,EAAE,SAAS,CAAC;IAChB,OAAO,EAAE,SAAS,eAAe,EAAE,CAAC;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,gDAAgD;IAChD,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;CACb;AAED,0EAA0E;AAC1E,MAAM,MAAM,SAAS,GAAG,gBAAgB,GAAG,gBAAgB,CAAC;AAE5D;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,SAAS,EAAE,SAAS,GAAG,MAAM,CAEnD;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,SAAS,EAAE,SAAS,GAAG,MAAM,CAI3D;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,SAAS,EAAE,gBAAgB,EAAE,IAAI,SAAM,GAAG,MAAM,CAIzE;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,eAAe,GAAG,MAAM,CAI/D"}
@@ -17,4 +17,28 @@ export function referenceVenue(reference) {
17
17
  ? reference.repository
18
18
  : reference.journalAbbreviation;
19
19
  }
20
+ /**
21
+ * The pages of an article, as BibTeX and RIS write them.
22
+ * @param reference - The article.
23
+ * @param dash - What joins the two ends.
24
+ * @returns One number for a journal that paginates by article number, the
25
+ * range otherwise.
26
+ */
27
+ export function pageRange(reference, dash = '–') {
28
+ const { firstPage, lastPage } = reference;
29
+ if (firstPage === lastPage)
30
+ return firstPage;
31
+ return `${firstPage}${dash}${lastPage}`;
32
+ }
33
+ /**
34
+ * An author with the family name first, `Vanderveen, J. R.`, or the name of an
35
+ * organisation alone.
36
+ * @param author - The author.
37
+ * @returns The name, as a reference list writes it.
38
+ */
39
+ export function nameFamilyFirst(author) {
40
+ return author.given === ''
41
+ ? author.family
42
+ : `${author.family}, ${author.given}`;
43
+ }
20
44
  //# sourceMappingURL=reference.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"reference.js","sourceRoot":"","sources":["../../../src/citation/core/reference.ts"],"names":[],"mappings":"AAyDA;;;;GAIG;AACH,MAAM,UAAU,MAAM,CAAC,SAAoB;IACzC,OAAO,mBAAmB,SAAS,CAAC,GAAG,EAAE,CAAC;AAC5C,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,SAAoB;IACjD,OAAO,SAAS,CAAC,IAAI,KAAK,SAAS;QACjC,CAAC,CAAC,SAAS,CAAC,UAAU;QACtB,CAAC,CAAC,SAAS,CAAC,mBAAmB,CAAC;AACpC,CAAC"}
1
+ {"version":3,"file":"reference.js","sourceRoot":"","sources":["../../../src/citation/core/reference.ts"],"names":[],"mappings":"AAyDA;;;;GAIG;AACH,MAAM,UAAU,MAAM,CAAC,SAAoB;IACzC,OAAO,mBAAmB,SAAS,CAAC,GAAG,EAAE,CAAC;AAC5C,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,SAAoB;IACjD,OAAO,SAAS,CAAC,IAAI,KAAK,SAAS;QACjC,CAAC,CAAC,SAAS,CAAC,UAAU;QACtB,CAAC,CAAC,SAAS,CAAC,mBAAmB,CAAC;AACpC,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,SAAS,CAAC,SAA2B,EAAE,IAAI,GAAG,GAAG;IAC/D,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,SAAS,CAAC;IAC1C,IAAI,SAAS,KAAK,QAAQ;QAAE,OAAO,SAAS,CAAC;IAC7C,OAAO,GAAG,SAAS,GAAG,IAAI,GAAG,QAAQ,EAAE,CAAC;AAC1C,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAAC,MAAuB;IACrD,OAAO,MAAM,CAAC,KAAK,KAAK,EAAE;QACxB,CAAC,CAAC,MAAM,CAAC,MAAM;QACf,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,KAAK,MAAM,CAAC,KAAK,EAAE,CAAC;AAC1C,CAAC"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * The journal styles a Cite menu copies a reference in: each a CSL style
3
+ * formatted by citeproc-js, as Zotero formats it, named by the CSL id that
4
+ * `react-cheminfo/csl` loads, beside journals that ask for it.
5
+ */
6
+ /** One entry of the style submenu. */
7
+ export interface CitationStyle {
8
+ /** The CSL style, `american-chemical-society`. */
9
+ id: string;
10
+ /** Name of the style. */
11
+ label: string;
12
+ /** Journals that ask for it, shown on the right of the entry. */
13
+ hint: string;
14
+ }
15
+ /** Every style offered, in the order the menu lists them. */
16
+ export declare const CITATION_STYLES: readonly [{
17
+ readonly id: "american-chemical-society";
18
+ readonly label: "ACS";
19
+ readonly hint: "JACS, Org. Lett.";
20
+ }, {
21
+ readonly id: "nature";
22
+ readonly label: "Nature";
23
+ readonly hint: "Nature, Nat. Chem.";
24
+ }, {
25
+ readonly id: "royal-society-of-chemistry";
26
+ readonly label: "RSC";
27
+ readonly hint: "Chem. Sci., Green Chem.";
28
+ }, {
29
+ readonly id: "angewandte-chemie";
30
+ readonly label: "Angewandte";
31
+ readonly hint: "Angew. Chem., ChemMedChem";
32
+ }];
33
+ /** A style of the menu, by its CSL id. */
34
+ export type CitationStyleId = (typeof CITATION_STYLES)[number]['id'];
35
+ //# sourceMappingURL=styles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../src/citation/core/styles.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,sCAAsC;AACtC,MAAM,WAAW,aAAa;IAC5B,kDAAkD;IAClD,EAAE,EAAE,MAAM,CAAC;IACX,yBAAyB;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,iEAAiE;IACjE,IAAI,EAAE,MAAM,CAAC;CACd;AAED,6DAA6D;AAC7D,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;EAaiB,CAAC;AAE9C,0CAA0C;AAC1C,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * The journal styles a Cite menu copies a reference in: each a CSL style
3
+ * formatted by citeproc-js, as Zotero formats it, named by the CSL id that
4
+ * `react-cheminfo/csl` loads, beside journals that ask for it.
5
+ */
6
+ /** Every style offered, in the order the menu lists them. */
7
+ export const CITATION_STYLES = [
8
+ { id: 'american-chemical-society', label: 'ACS', hint: 'JACS, Org. Lett.' },
9
+ { id: 'nature', label: 'Nature', hint: 'Nature, Nat. Chem.' },
10
+ {
11
+ id: 'royal-society-of-chemistry',
12
+ label: 'RSC',
13
+ hint: 'Chem. Sci., Green Chem.',
14
+ },
15
+ {
16
+ id: 'angewandte-chemie',
17
+ label: 'Angewandte',
18
+ hint: 'Angew. Chem., ChemMedChem',
19
+ },
20
+ ];
21
+ //# sourceMappingURL=styles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"styles.js","sourceRoot":"","sources":["../../../src/citation/core/styles.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAYH,6DAA6D;AAC7D,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,EAAE,EAAE,EAAE,2BAA2B,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,kBAAkB,EAAE;IAC3E,EAAE,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,oBAAoB,EAAE;IAC7D;QACE,EAAE,EAAE,4BAA4B;QAChC,KAAK,EAAE,KAAK;QACZ,IAAI,EAAE,yBAAyB;KAChC;IACD;QACE,EAAE,EAAE,mBAAmB;QACvB,KAAK,EAAE,YAAY;QACnB,IAAI,EAAE,2BAA2B;KAClC;CAC0C,CAAC"}