@publisle/research 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/NOTICE.md +31 -0
- package/README.md +14 -2
- package/compiler/Dockerfile +18 -0
- package/compiler/README.md +80 -0
- package/compiler/cacert.pem +2950 -0
- package/compiler/install-texlive.sh +38 -0
- package/compiler/release.json +13 -0
- package/dist/article.d.ts +10 -0
- package/dist/article.d.ts.map +1 -0
- package/dist/article.js +425 -0
- package/dist/article.js.map +1 -0
- package/dist/bibtex.d.ts +2 -0
- package/dist/bibtex.d.ts.map +1 -0
- package/dist/bibtex.js +2 -0
- package/dist/bibtex.js.map +1 -0
- package/dist/citeproc.d.ts +28 -0
- package/dist/csl.d.ts +35 -0
- package/dist/csl.d.ts.map +1 -0
- package/dist/csl.js +315 -0
- package/dist/csl.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -0
- package/dist/jats.d.ts +14 -0
- package/dist/jats.d.ts.map +1 -0
- package/dist/jats.js +197 -0
- package/dist/jats.js.map +1 -0
- package/dist/latex.d.ts +5 -0
- package/dist/latex.d.ts.map +1 -0
- package/dist/latex.js +19 -0
- package/dist/latex.js.map +1 -0
- package/dist/locales.d.ts +2 -0
- package/dist/locales.d.ts.map +1 -0
- package/dist/locales.js +67 -0
- package/dist/locales.js.map +1 -0
- package/dist/node.d.ts +66 -0
- package/dist/node.d.ts.map +1 -0
- package/dist/node.js +542 -0
- package/dist/node.js.map +1 -0
- package/dist/package.d.ts +19 -0
- package/dist/package.d.ts.map +1 -0
- package/dist/package.js +48 -0
- package/dist/package.js.map +1 -0
- package/dist/pdf.d.ts +10 -0
- package/dist/pdf.d.ts.map +1 -0
- package/dist/pdf.js +207 -0
- package/dist/pdf.js.map +1 -0
- package/dist/portable-citations.d.ts +27 -0
- package/dist/portable-citations.d.ts.map +1 -0
- package/dist/portable-citations.js +185 -0
- package/dist/portable-citations.js.map +1 -0
- package/dist/profiles.d.ts +10 -0
- package/dist/profiles.d.ts.map +1 -0
- package/dist/profiles.js +166 -0
- package/dist/profiles.js.map +1 -0
- package/dist/remote.d.ts +24 -0
- package/dist/remote.d.ts.map +1 -0
- package/dist/remote.js +139 -0
- package/dist/remote.js.map +1 -0
- package/dist/resolve.d.ts +10 -0
- package/dist/resolve.d.ts.map +1 -0
- package/dist/resolve.js +62 -0
- package/dist/resolve.js.map +1 -0
- package/package.json +53 -3
- package/src/article.ts +478 -0
- package/src/bibtex.ts +1 -0
- package/src/citeproc.d.ts +28 -0
- package/src/csl.ts +367 -0
- package/src/index.ts +29 -0
- package/src/jats.ts +242 -0
- package/src/latex.ts +21 -0
- package/src/locales.ts +126 -0
- package/src/node.ts +752 -0
- package/src/package.ts +83 -0
- package/src/pdf.ts +225 -0
- package/src/portable-citations.ts +250 -0
- package/src/profiles.ts +188 -0
- package/src/remote.ts +163 -0
- package/src/resolve.ts +91 -0
- package/vendor/jats/JATS-Archiving-1-3-MathML2-DTD/BITS-embedded-index2.ent +308 -0
- package/vendor/jats/JATS-Archiving-1-3-MathML2-DTD/BITS-question-answer2.ent +531 -0
- package/vendor/jats/JATS-Archiving-1-3-MathML2-DTD/JATS-XHTMLtablesetup1-3.ent +629 -0
- package/vendor/jats/JATS-Archiving-1-3-MathML2-DTD/JATS-ali-namespace1-3.ent +293 -0
- package/vendor/jats/JATS-Archiving-1-3-MathML2-DTD/JATS-archivearticle1-3.dtd +1085 -0
- package/vendor/jats/JATS-Archiving-1-3-MathML2-DTD/JATS-archivecustom-classes1-3.ent +409 -0
- package/vendor/jats/JATS-Archiving-1-3-MathML2-DTD/JATS-archivecustom-mixes1-3.ent +601 -0
- package/vendor/jats/JATS-Archiving-1-3-MathML2-DTD/JATS-archivecustom-models1-3.ent +1613 -0
- package/vendor/jats/JATS-Archiving-1-3-MathML2-DTD/JATS-archivecustom-modules1-3.ent +404 -0
- package/vendor/jats/JATS-Archiving-1-3-MathML2-DTD/JATS-articlemeta1-3.ent +2552 -0
- package/vendor/jats/JATS-Archiving-1-3-MathML2-DTD/JATS-backmatter1-3.ent +540 -0
- package/vendor/jats/JATS-Archiving-1-3-MathML2-DTD/JATS-chars1-3.ent +664 -0
- package/vendor/jats/JATS-Archiving-1-3-MathML2-DTD/JATS-common-atts1-3.ent +360 -0
- package/vendor/jats/JATS-Archiving-1-3-MathML2-DTD/JATS-common1-3.ent +4659 -0
- package/vendor/jats/JATS-Archiving-1-3-MathML2-DTD/JATS-default-classes1-3.ent +1595 -0
- package/vendor/jats/JATS-Archiving-1-3-MathML2-DTD/JATS-default-mixes1-3.ent +630 -0
- package/vendor/jats/JATS-Archiving-1-3-MathML2-DTD/JATS-display1-3.ent +1299 -0
- package/vendor/jats/JATS-Archiving-1-3-MathML2-DTD/JATS-format1-3.ent +997 -0
- package/vendor/jats/JATS-Archiving-1-3-MathML2-DTD/JATS-funding1-3.ent +1100 -0
- package/vendor/jats/JATS-Archiving-1-3-MathML2-DTD/JATS-journalmeta1-3.ent +593 -0
- package/vendor/jats/JATS-Archiving-1-3-MathML2-DTD/JATS-link1-3.ent +604 -0
- package/vendor/jats/JATS-Archiving-1-3-MathML2-DTD/JATS-list1-3.ent +663 -0
- package/vendor/jats/JATS-Archiving-1-3-MathML2-DTD/JATS-math1-3.ent +563 -0
- package/vendor/jats/JATS-Archiving-1-3-MathML2-DTD/JATS-mathmlsetup1-3.ent +491 -0
- package/vendor/jats/JATS-Archiving-1-3-MathML2-DTD/JATS-modules1-3.ent +769 -0
- package/vendor/jats/JATS-Archiving-1-3-MathML2-DTD/JATS-nlmcitation1-3.ent +428 -0
- package/vendor/jats/JATS-Archiving-1-3-MathML2-DTD/JATS-notat1-3.ent +412 -0
- package/vendor/jats/JATS-Archiving-1-3-MathML2-DTD/JATS-para1-3.ent +648 -0
- package/vendor/jats/JATS-Archiving-1-3-MathML2-DTD/JATS-phrase1-3.ent +664 -0
- package/vendor/jats/JATS-Archiving-1-3-MathML2-DTD/JATS-references1-3.ent +1428 -0
- package/vendor/jats/JATS-Archiving-1-3-MathML2-DTD/JATS-related-object1-3.ent +435 -0
- package/vendor/jats/JATS-Archiving-1-3-MathML2-DTD/JATS-section1-3.ent +463 -0
- package/vendor/jats/JATS-Archiving-1-3-MathML2-DTD/JATS-xmlspecchars1-3.ent +528 -0
- package/vendor/jats/JATS-Archiving-1-3-MathML2-DTD/catalog-jats-v1-3-no-base.xml +999 -0
- package/vendor/jats/JATS-Archiving-1-3-MathML2-DTD/catalog-jats-v1-3-with-base.xml +986 -0
- package/vendor/jats/JATS-Archiving-1-3-MathML2-DTD/iso8879/isobox.ent +61 -0
- package/vendor/jats/JATS-Archiving-1-3-MathML2-DTD/iso8879/isocyr1.ent +88 -0
- package/vendor/jats/JATS-Archiving-1-3-MathML2-DTD/iso8879/isocyr2.ent +47 -0
- package/vendor/jats/JATS-Archiving-1-3-MathML2-DTD/iso8879/isodia.ent +35 -0
- package/vendor/jats/JATS-Archiving-1-3-MathML2-DTD/iso8879/isolat1.ent +83 -0
- package/vendor/jats/JATS-Archiving-1-3-MathML2-DTD/iso8879/isolat2.ent +142 -0
- package/vendor/jats/JATS-Archiving-1-3-MathML2-DTD/iso8879/isonum.ent +97 -0
- package/vendor/jats/JATS-Archiving-1-3-MathML2-DTD/iso8879/isopub.ent +105 -0
- package/vendor/jats/JATS-Archiving-1-3-MathML2-DTD/iso9573-13/isoamsa.ent +167 -0
- package/vendor/jats/JATS-Archiving-1-3-MathML2-DTD/iso9573-13/isoamsb.ent +143 -0
- package/vendor/jats/JATS-Archiving-1-3-MathML2-DTD/iso9573-13/isoamsc.ent +43 -0
- package/vendor/jats/JATS-Archiving-1-3-MathML2-DTD/iso9573-13/isoamsn.ent +114 -0
- package/vendor/jats/JATS-Archiving-1-3-MathML2-DTD/iso9573-13/isoamso.ent +73 -0
- package/vendor/jats/JATS-Archiving-1-3-MathML2-DTD/iso9573-13/isoamsr.ent +204 -0
- package/vendor/jats/JATS-Archiving-1-3-MathML2-DTD/iso9573-13/isogrk3.ent +64 -0
- package/vendor/jats/JATS-Archiving-1-3-MathML2-DTD/iso9573-13/isomfrk.ent +75 -0
- package/vendor/jats/JATS-Archiving-1-3-MathML2-DTD/iso9573-13/isomopf.ent +49 -0
- package/vendor/jats/JATS-Archiving-1-3-MathML2-DTD/iso9573-13/isomscr.ent +75 -0
- package/vendor/jats/JATS-Archiving-1-3-MathML2-DTD/iso9573-13/isotech.ent +182 -0
- package/vendor/jats/JATS-Archiving-1-3-MathML2-DTD/mathml/mmlalias.ent +564 -0
- package/vendor/jats/JATS-Archiving-1-3-MathML2-DTD/mathml/mmlextra.ent +122 -0
- package/vendor/jats/JATS-Archiving-1-3-MathML2-DTD/mathml2-qname-1.mod +286 -0
- package/vendor/jats/JATS-Archiving-1-3-MathML2-DTD/mathml2.dtd +2206 -0
- package/vendor/jats/JATS-Archiving-1-3-MathML2-DTD/xhtml-inlstyle-1.mod +34 -0
- package/vendor/jats/JATS-Archiving-1-3-MathML2-DTD/xhtml-table-1.mod +333 -0
- package/vendor/jats/JATS-Archiving-1-3-MathML2-DTD/xmlchars/isogrk1.ent +70 -0
- package/vendor/jats/JATS-Archiving-1-3-MathML2-DTD/xmlchars/isogrk2.ent +41 -0
- package/vendor/jats/JATS-Archiving-1-3-MathML2-DTD/xmlchars/isogrk4.ent +66 -0
- package/vendor/jats/PROVENANCE.json +6 -0
- package/vendor/locales/PROVENANCE.json +5 -0
- package/vendor/locales/README.md +23 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Block, BlockType, Document } from "@publisle/schema";
|
|
2
|
+
import type { PublishingTemplate, TemplateRegistry, SourcePackage, LatexEngine } from "@publisle/template-sdk";
|
|
3
|
+
export type { LatexEngine } from "@publisle/template-sdk";
|
|
4
|
+
export type LatexPackage = SourcePackage;
|
|
5
|
+
export interface LatexPackageOptions {
|
|
6
|
+
/** Standard article templates default to UA-2. false explicitly disables tagging. */
|
|
7
|
+
readonly pdfUa?: "ua-1" | "ua-2" | false;
|
|
8
|
+
readonly template?: string | PublishingTemplate;
|
|
9
|
+
readonly templates?: TemplateRegistry;
|
|
10
|
+
readonly engine?: LatexEngine;
|
|
11
|
+
readonly style?: string;
|
|
12
|
+
readonly fonts?: Readonly<Record<string, string>>;
|
|
13
|
+
readonly csl?: import("./csl.js").CslOptions;
|
|
14
|
+
readonly data?: Readonly<Record<string, unknown>>;
|
|
15
|
+
}
|
|
16
|
+
export declare function createSubmissionPackage(document: Document<Block<BlockType, unknown>>, options?: LatexPackageOptions): SourcePackage;
|
|
17
|
+
/** Compatibility name for LaTeX submission generation. Templates are supplied by the host. */
|
|
18
|
+
export declare const createLatexPackage: typeof createSubmissionPackage;
|
|
19
|
+
//# sourceMappingURL=package.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package.d.ts","sourceRoot":"","sources":["../src/package.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACnE,OAAO,KAAK,EACV,kBAAkB,EAClB,gBAAgB,EAChB,aAAa,EAEb,WAAW,EACZ,MAAM,wBAAwB,CAAC;AAOhC,YAAY,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,MAAM,MAAM,YAAY,GAAG,aAAa,CAAC;AACzC,MAAM,WAAW,mBAAmB;IAClC,qFAAqF;IACrF,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,KAAK,CAAC;IACzC,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,kBAAkB,CAAC;IAChD,QAAQ,CAAC,SAAS,CAAC,EAAE,gBAAgB,CAAC;IACtC,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;IAC9B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,KAAK,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAClD,QAAQ,CAAC,GAAG,CAAC,EAAE,OAAO,UAAU,EAAE,UAAU,CAAC;IAC7C,QAAQ,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CACnD;AACD,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,QAAQ,CAAC,KAAK,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC,EAC7C,OAAO,GAAE,mBAAwB,GAChC,aAAa,CAkDf;AACD,8FAA8F;AAC9F,eAAO,MAAM,kBAAkB,gCAA0B,CAAC"}
|
package/dist/package.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { template as articleTemplate, arabicTemplate, } from "@publisle/template-article";
|
|
2
|
+
import { citationClusters } from "./article.js";
|
|
3
|
+
import { resolveDocument } from "./resolve.js";
|
|
4
|
+
export function createSubmissionPackage(document, options = {}) {
|
|
5
|
+
const resolved = resolveDocument(document, options.style ?? "numeric", options.csl);
|
|
6
|
+
if (resolved.unresolved.length)
|
|
7
|
+
throw new Error(`Unresolved citations: ${resolved.unresolved.join(", ")}`);
|
|
8
|
+
const registry = {
|
|
9
|
+
article: articleTemplate,
|
|
10
|
+
"article-arabic": arabicTemplate,
|
|
11
|
+
...options.templates,
|
|
12
|
+
};
|
|
13
|
+
const template = typeof options.template === "object"
|
|
14
|
+
? options.template
|
|
15
|
+
: Object.hasOwn(registry, options.template ?? "article")
|
|
16
|
+
? registry[options.template ?? "article"]
|
|
17
|
+
: undefined;
|
|
18
|
+
if (!template)
|
|
19
|
+
throw new Error(`Unknown export template: ${typeof options.template === "string" ? options.template : "unspecified"}`);
|
|
20
|
+
if (options.engine && !template.engines.includes(options.engine))
|
|
21
|
+
throw new Error(`Unsupported engine for ${template.id}`);
|
|
22
|
+
const citationMap = new Map(citationClusters(resolved.article).map((cluster, index) => [
|
|
23
|
+
cluster,
|
|
24
|
+
resolved.citations[index] ?? "",
|
|
25
|
+
]));
|
|
26
|
+
const context = {
|
|
27
|
+
citationText: (cluster) => citationMap.get(cluster) ?? "",
|
|
28
|
+
...{
|
|
29
|
+
style: options.style ?? "numeric",
|
|
30
|
+
citations: resolved.citations,
|
|
31
|
+
citationForm: resolved.form,
|
|
32
|
+
bibliography: resolved.bibliography,
|
|
33
|
+
...(options.pdfUa === undefined ? {} : { pdfUa: options.pdfUa }),
|
|
34
|
+
...(options.engine ? { engine: options.engine } : {}),
|
|
35
|
+
...(options.fonts ? { fonts: options.fonts } : {}),
|
|
36
|
+
...(options.data ? { data: options.data } : {}),
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
const diagnostics = template.validate(resolved.article, context);
|
|
40
|
+
const result = template.render(resolved.article, context);
|
|
41
|
+
return {
|
|
42
|
+
...result,
|
|
43
|
+
diagnostics: [...resolved.losses, ...diagnostics, ...result.diagnostics],
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
/** Compatibility name for LaTeX submission generation. Templates are supplied by the host. */
|
|
47
|
+
export const createLatexPackage = createSubmissionPackage;
|
|
48
|
+
//# sourceMappingURL=package.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package.js","sourceRoot":"","sources":["../src/package.ts"],"names":[],"mappings":"AAQA,OAAO,EACL,QAAQ,IAAI,eAAe,EAC3B,cAAc,GACf,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAc/C,MAAM,UAAU,uBAAuB,CACrC,QAA6C,EAC7C,UAA+B,EAAE;IAEjC,MAAM,QAAQ,GAAG,eAAe,CAC9B,QAAQ,EACR,OAAO,CAAC,KAAK,IAAI,SAAS,EAC1B,OAAO,CAAC,GAAG,CACZ,CAAC;IACF,IAAI,QAAQ,CA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
|
+
import type { ResolvedDocument } from "./resolve.js";
|
|
3
|
+
/** @deprecated Use exportPdf from @publisle/research/node for Unicode and page layout. */
|
|
4
|
+
export declare function toPdf(resolved: ResolvedDocument, options?: {
|
|
5
|
+
readonly allowLossy?: boolean;
|
|
6
|
+
}): {
|
|
7
|
+
readonly pdf: Uint8Array;
|
|
8
|
+
readonly losses: readonly ResearchLoss[];
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=pdf.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pdf.d.ts","sourceRoot":"","sources":["../src/pdf.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAiB,YAAY,EAAE,qBAAqB;AAChE,OAAO,KAAK,EAAE,gBAAgB,EAAE,qBAAqB;AAoGrD,0FAA0F;AAC1F,wBAAgB,KAAK,CACnB,QAAQ,EAAE,gBAAgB,EAC1B,OAAO,GAAE;IAAE,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,CAAA;CAAO,GAC9C;IACD,QAAQ,CAAC,GAAG,EAAE,UAAU,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,SAAS,YAAY,EAAE,CAAC;CAC1C,CAoHA"}
|
package/dist/pdf.js
ADDED
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
const WIN_ANSI = {
|
|
2
|
+
0x20ac: 0x80,
|
|
3
|
+
0x201a: 0x82,
|
|
4
|
+
0x0192: 0x83,
|
|
5
|
+
0x201e: 0x84,
|
|
6
|
+
0x2026: 0x85,
|
|
7
|
+
0x2020: 0x86,
|
|
8
|
+
0x2021: 0x87,
|
|
9
|
+
0x02c6: 0x88,
|
|
10
|
+
0x2030: 0x89,
|
|
11
|
+
0x0160: 0x8a,
|
|
12
|
+
0x2039: 0x8b,
|
|
13
|
+
0x0152: 0x8c,
|
|
14
|
+
0x017d: 0x8e,
|
|
15
|
+
0x2018: 0x91,
|
|
16
|
+
0x2019: 0x92,
|
|
17
|
+
0x201c: 0x93,
|
|
18
|
+
0x201d: 0x94,
|
|
19
|
+
0x2022: 0x95,
|
|
20
|
+
0x2013: 0x96,
|
|
21
|
+
0x2014: 0x97,
|
|
22
|
+
0x02dc: 0x98,
|
|
23
|
+
0x2122: 0x99,
|
|
24
|
+
0x0161: 0x9a,
|
|
25
|
+
0x203a: 0x9b,
|
|
26
|
+
0x0153: 0x9c,
|
|
27
|
+
0x017e: 0x9e,
|
|
28
|
+
0x0178: 0x9f,
|
|
29
|
+
};
|
|
30
|
+
function encode(value, losses) {
|
|
31
|
+
let encoded = "";
|
|
32
|
+
let replaced = false;
|
|
33
|
+
for (const char of value) {
|
|
34
|
+
const code = char.codePointAt(0) ?? 0;
|
|
35
|
+
let byte = code;
|
|
36
|
+
if (code >= 0x100)
|
|
37
|
+
byte = WIN_ANSI[code] ?? -1;
|
|
38
|
+
else if (code >= 0x80 && code <= 0x9f)
|
|
39
|
+
byte = -1;
|
|
40
|
+
if (byte < 32 || byte > 255) {
|
|
41
|
+
replaced = true;
|
|
42
|
+
byte = 0x3f;
|
|
43
|
+
}
|
|
44
|
+
encoded +=
|
|
45
|
+
byte === 0x28 || byte === 0x29 || byte === 0x5c
|
|
46
|
+
? `\\${String.fromCharCode(byte)}`
|
|
47
|
+
: byte >= 32 && byte <= 126
|
|
48
|
+
? String.fromCharCode(byte)
|
|
49
|
+
: `\\${byte.toString(8).padStart(3, "0")}`;
|
|
50
|
+
}
|
|
51
|
+
if (replaced &&
|
|
52
|
+
!losses.some((loss) => loss.code === "pdf-unencodable-character"))
|
|
53
|
+
losses.push({
|
|
54
|
+
code: "pdf-unencodable-character",
|
|
55
|
+
message: "PDF text uses Helvetica WinAnsi. Characters outside that encoding are drawn as question marks.",
|
|
56
|
+
});
|
|
57
|
+
return encoded;
|
|
58
|
+
}
|
|
59
|
+
function plain(inlines, resolved, cursor) {
|
|
60
|
+
return inlines
|
|
61
|
+
.map((inline) => {
|
|
62
|
+
if (inline.type === "break")
|
|
63
|
+
return " ";
|
|
64
|
+
if (inline.type === "citation") {
|
|
65
|
+
const text = resolved.citations[cursor.index] ?? "";
|
|
66
|
+
cursor.index += 1;
|
|
67
|
+
return text;
|
|
68
|
+
}
|
|
69
|
+
if (inline.type === "math")
|
|
70
|
+
return inline.value;
|
|
71
|
+
if (inline.type === "link")
|
|
72
|
+
return `${inline.value} (${inline.url})`;
|
|
73
|
+
return inline.value;
|
|
74
|
+
})
|
|
75
|
+
.join("");
|
|
76
|
+
}
|
|
77
|
+
function wrap(text, size) {
|
|
78
|
+
const limit = Math.max(8, Math.floor((595 - 144) / (size * 0.56)));
|
|
79
|
+
const words = text.split(/\s+/u).filter((word) => word.length > 0);
|
|
80
|
+
const lines = [];
|
|
81
|
+
let current = "";
|
|
82
|
+
for (const word of words) {
|
|
83
|
+
const next = current.length === 0 ? word : `${current} ${word}`;
|
|
84
|
+
if (next.length <= limit)
|
|
85
|
+
current = next;
|
|
86
|
+
else {
|
|
87
|
+
if (current.length > 0)
|
|
88
|
+
lines.push(current);
|
|
89
|
+
current = word.length <= limit ? word : word.slice(0, limit);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
if (current.length > 0)
|
|
93
|
+
lines.push(current);
|
|
94
|
+
return lines.length === 0 ? [""] : lines;
|
|
95
|
+
}
|
|
96
|
+
/** @deprecated Use exportPdf from @publisle/research/node for Unicode and page layout. */
|
|
97
|
+
export function toPdf(resolved, options = {}) {
|
|
98
|
+
const losses = [...resolved.losses];
|
|
99
|
+
const cursor = { index: 0 };
|
|
100
|
+
const lines = [];
|
|
101
|
+
const add = (text, size) => {
|
|
102
|
+
for (const line of wrap(text, size))
|
|
103
|
+
lines.push({ text: line, size });
|
|
104
|
+
};
|
|
105
|
+
add(resolved.article.title ?? "Untitled", 16);
|
|
106
|
+
if (resolved.article.authors.length > 0)
|
|
107
|
+
add(resolved.article.authors.join(", "), 11);
|
|
108
|
+
let bibliographyWritten = false;
|
|
109
|
+
const writeBibliography = () => {
|
|
110
|
+
if (bibliographyWritten)
|
|
111
|
+
return;
|
|
112
|
+
bibliographyWritten = true;
|
|
113
|
+
add("References", 13);
|
|
114
|
+
for (const item of resolved.bibliography)
|
|
115
|
+
add(item.text, 11);
|
|
116
|
+
};
|
|
117
|
+
for (const block of resolved.article.blocks) {
|
|
118
|
+
if (block.kind === "heading")
|
|
119
|
+
add(plain(block.inlines, resolved, cursor), 13);
|
|
120
|
+
else if (block.kind === "paragraph")
|
|
121
|
+
add(plain(block.inlines, resolved, cursor), 11);
|
|
122
|
+
else if (block.kind === "list") {
|
|
123
|
+
block.items.forEach((item, index) => {
|
|
124
|
+
const marker = block.ordered ? `${String(index + 1)}. ` : "- ";
|
|
125
|
+
add(`${marker}${plain(item, resolved, cursor)}`, 11);
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
else if (block.kind === "quote") {
|
|
129
|
+
for (const paragraph of block.paragraphs)
|
|
130
|
+
add(plain(paragraph, resolved, cursor), 11);
|
|
131
|
+
}
|
|
132
|
+
else if (block.kind === "code" || block.kind === "math")
|
|
133
|
+
add(block.value, 10);
|
|
134
|
+
else if (block.kind === "figure") {
|
|
135
|
+
losses.push({
|
|
136
|
+
code: "pdf-figure-as-text",
|
|
137
|
+
message: "Textual PDF renders figure descriptions only.",
|
|
138
|
+
});
|
|
139
|
+
add(`${block.alt} ${plain(block.caption, resolved, cursor)}`, 11);
|
|
140
|
+
}
|
|
141
|
+
else if (block.kind === "table") {
|
|
142
|
+
if (!losses.some((loss) => loss.code === "table-rendered-as-text"))
|
|
143
|
+
losses.push({
|
|
144
|
+
code: "table-rendered-as-text",
|
|
145
|
+
message: "Textual PDF renders tables as text rows.",
|
|
146
|
+
});
|
|
147
|
+
if (block.caption)
|
|
148
|
+
add(plain(block.caption, resolved, cursor), 11);
|
|
149
|
+
for (const row of block.rows)
|
|
150
|
+
add(row.map((cell) => plain(cell, resolved, cursor)).join(" | "), 10);
|
|
151
|
+
}
|
|
152
|
+
else if (block.kind === "footnote") {
|
|
153
|
+
add(`${block.id} ${block.paragraphs.map((paragraph) => plain(paragraph, resolved, cursor)).join(" ")}`, 10);
|
|
154
|
+
}
|
|
155
|
+
else
|
|
156
|
+
writeBibliography();
|
|
157
|
+
}
|
|
158
|
+
writeBibliography();
|
|
159
|
+
const pages = [];
|
|
160
|
+
let page = [];
|
|
161
|
+
let y = 780;
|
|
162
|
+
for (const line of lines) {
|
|
163
|
+
if (y < 72) {
|
|
164
|
+
pages.push(page);
|
|
165
|
+
page = [];
|
|
166
|
+
y = 780;
|
|
167
|
+
}
|
|
168
|
+
page.push(`BT /F1 ${String(line.size)} Tf 1 0 0 1 72 ${String(y)} Tm (${encode(line.text, losses)}) Tj ET`);
|
|
169
|
+
y -= line.size + 4;
|
|
170
|
+
}
|
|
171
|
+
pages.push(page);
|
|
172
|
+
const objects = [];
|
|
173
|
+
const pageIds = [];
|
|
174
|
+
let id = 4;
|
|
175
|
+
const contents = [];
|
|
176
|
+
for (const commands of pages) {
|
|
177
|
+
const pageId = id++;
|
|
178
|
+
const contentId = id++;
|
|
179
|
+
pageIds.push(pageId);
|
|
180
|
+
const stream = commands.join("\n");
|
|
181
|
+
contents.push({ page: pageId, content: contentId, stream });
|
|
182
|
+
}
|
|
183
|
+
objects.push("1 0 obj << /Type /Catalog /Pages 2 0 R >> endobj\n");
|
|
184
|
+
objects.push(`2 0 obj << /Type /Pages /Count ${String(pageIds.length)} /Kids [${pageIds.map((pageId) => `${String(pageId)} 0 R`).join(" ")}] >> endobj\n`);
|
|
185
|
+
objects.push("3 0 obj << /Type /Font /Subtype /Type1 /BaseFont /Helvetica /Encoding /WinAnsiEncoding >> endobj\n");
|
|
186
|
+
for (const item of contents) {
|
|
187
|
+
objects.push(`${String(item.page)} 0 obj << /Type /Page /Parent 2 0 R /MediaBox [0 0 595 842] /Contents ${String(item.content)} 0 R /Resources << /Font << /F1 3 0 R >> >> >> endobj\n`);
|
|
188
|
+
objects.push(`${String(item.content)} 0 obj << /Length ${String(item.stream.length)} >> stream\n${item.stream}\nendstream endobj\n`);
|
|
189
|
+
}
|
|
190
|
+
let pdf = "%PDF-1.4\n";
|
|
191
|
+
const offsets = [0];
|
|
192
|
+
for (const object of objects) {
|
|
193
|
+
offsets.push(pdf.length);
|
|
194
|
+
pdf += object;
|
|
195
|
+
}
|
|
196
|
+
const xref = pdf.length;
|
|
197
|
+
pdf += `xref\n0 ${String(objects.length + 1)}\n`;
|
|
198
|
+
pdf += "0000000000 65535 f \n";
|
|
199
|
+
for (const offset of offsets.slice(1))
|
|
200
|
+
pdf += `${offset.toString().padStart(10, "0")} 00000 n \n`;
|
|
201
|
+
pdf += `trailer << /Size ${String(objects.length + 1)} /Root 1 0 R >>\nstartxref\n${String(xref)}\n%%EOF\n`;
|
|
202
|
+
if (!options.allowLossy &&
|
|
203
|
+
losses.some((loss) => loss.code === "pdf-unencodable-character"))
|
|
204
|
+
throw new Error("Legacy PDF cannot encode this text. Use exportPdf or explicitly allowLossy.");
|
|
205
|
+
return { pdf: new TextEncoder().encode(pdf), losses };
|
|
206
|
+
}
|
|
207
|
+
//# sourceMappingURL=pdf.js.map
|
package/dist/pdf.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pdf.js","sourceRoot":"","sources":["../src/pdf.ts"],"names":[],"mappings":"AAGA,MAAM,QAAQ,GAAqC;IACjD,MAAM,EAAE,IAAI;IACZ,MAAM,EAAE,IAAI;IACZ,MAAM,EAAE,IAAI;IACZ,MAAM,EAAE,IAAI;IACZ,MAAM,EAAE,IAAI;IACZ,MAAM,EAAE,IAAI;IACZ,MAAM,EAAE,IAAI;IACZ,MAAM,EAAE,IAAI;IACZ,MAAM,EAAE,IAAI;IACZ,MAAM,EAAE,IAAI;IACZ,MAAM,EAAE,IAAI;IACZ,MAAM,EAAE,IAAI;IACZ,MAAM,EAAE,IAAI;IACZ,MAAM,EAAE,IAAI;IACZ,MAAM,EAAE,IAAI;IACZ,MAAM,EAAE,IAAI;IACZ,MAAM,EAAE,IAAI;I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ion: number;
|
|
6
|
+
fullCSL: boolean;
|
|
7
|
+
plugins: boolean;
|
|
8
|
+
}>;
|
|
9
|
+
export interface PortableCitations {
|
|
10
|
+
readonly classification: "rendered" | "fallback-with-diagnostic" | "rejected";
|
|
11
|
+
readonly capabilities: typeof PORTABLE_CITATION_CAPABILITIES;
|
|
12
|
+
readonly citations: readonly string[];
|
|
13
|
+
readonly bibliography: readonly {
|
|
14
|
+
id: string;
|
|
15
|
+
label: string;
|
|
16
|
+
text: string;
|
|
17
|
+
}[];
|
|
18
|
+
readonly unresolved: readonly string[];
|
|
19
|
+
readonly diagnostics: readonly {
|
|
20
|
+
code: string;
|
|
21
|
+
message: string;
|
|
22
|
+
}[];
|
|
23
|
+
}
|
|
24
|
+
/** A bounded role shared with the independent Python implementation, not a full CSL processor. */
|
|
25
|
+
export declare function portableCitationLimit(document: unknown, style: string, locale: string): string | undefined;
|
|
26
|
+
export declare function resolvePortableCitations(document: unknown, style?: string, locale?: string): PortableCitations;
|
|
27
|
+
//# sourceMappingURL=portable-citations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"portable-citations.d.ts","sourceRoot":"","sources":["../src/portable-citations.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,8BAA8B;;;;;;;EAIzC,CAAC;AAEH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,cAAc,EAAE,UAAU,GAAG,0BAA0B,GAAG,UAAU,CAAC;IAC9E,QAAQ,CAAC,YAAY,EAAE,OAAO,8BAA8B,CAAC;IAC7D,QAAQ,CAAC,SAAS,EAAE,SAAS,MAAM,EAAE,CAAC;IACtC,QAAQ,CAAC,YAAY,EAAE,SAAS;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAC9E,QAAQ,CAAC,UAAU,EAAE,SAAS,MAAM,EAAE,CAAC;IACvC,QAAQ,CAAC,WAAW,EAAE,SAAS;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CACpE;AAYD,kGAAkG;AAClG,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,OAAO,EACjB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,GACb,MAAM,GAAG,SAAS,CAkLpB;AAED,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,OAAO,EACjB,KAAK,SAAY,EACjB,MAAM,SAAU,GACf,iBAAiB,CA+BnB"}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import subset from "@publisle/contracts/citation-subset" with { type: "json" };
|
|
2
|
+
import { isPlainObject } from "@publisle/schema";
|
|
3
|
+
import { resolveDocument } from "./resolve.js";
|
|
4
|
+
export const PORTABLE_CITATION_CAPABILITIES = Object.freeze({
|
|
5
|
+
...subset.capabilities,
|
|
6
|
+
styles: Object.freeze([...subset.capabilities.styles]),
|
|
7
|
+
locales: Object.freeze([...subset.capabilities.locales]),
|
|
8
|
+
});
|
|
9
|
+
const matches = (pattern, value) => new RegExp(pattern, "u").exec(value)?.[0] === value;
|
|
10
|
+
// eslint-disable-next-line no-control-regex -- controls are excluded from this plain-text subset
|
|
11
|
+
const forbiddenText = /[<>\u0000-\u001f\u007f-\u009f\ud800-\udfff]/u;
|
|
12
|
+
const text = (value) => typeof value === "string" &&
|
|
13
|
+
value.length <= subset.limits.text &&
|
|
14
|
+
!forbiddenText.test(value);
|
|
15
|
+
const normalize = (value) => value.replace(/\s+/gu, " ").trim();
|
|
16
|
+
/** A bounded role shared with the independent Python implementation, not a full CSL processor. */
|
|
17
|
+
export function portableCitationLimit(document, style, locale) {
|
|
18
|
+
if (!subset.capabilities.styles.includes(style))
|
|
19
|
+
return "Only built-in numeric and author-date styles are supported.";
|
|
20
|
+
if (!subset.capabilities.locales.includes(locale))
|
|
21
|
+
return "This citation locale is outside the shared subset.";
|
|
22
|
+
if (!isPlainObject(document) ||
|
|
23
|
+
document["schemaVersion"] !== 1 ||
|
|
24
|
+
!Array.isArray(document["blocks"]) ||
|
|
25
|
+
document["blocks"].length > subset.limits.blocks ||
|
|
26
|
+
document["dependencies"] !== undefined)
|
|
27
|
+
return "Expected an unlocked v1 citation document within the shared budget.";
|
|
28
|
+
const entries = [];
|
|
29
|
+
const suppressed = new Set();
|
|
30
|
+
let clusters = 0;
|
|
31
|
+
const inline = (nodes, depth = 0) => {
|
|
32
|
+
if (!Array.isArray(nodes) ||
|
|
33
|
+
nodes.length > subset.limits.clusters ||
|
|
34
|
+
depth > 16)
|
|
35
|
+
return false;
|
|
36
|
+
return nodes.every((node) => {
|
|
37
|
+
if (!isPlainObject(node) ||
|
|
38
|
+
typeof node["type"] !== "string" ||
|
|
39
|
+
!subset.inlineTypes.includes(node["type"]))
|
|
40
|
+
return false;
|
|
41
|
+
if (["strong", "emphasis", "strikethrough"].includes(node["type"]))
|
|
42
|
+
return inline(node["children"], depth + 1);
|
|
43
|
+
if (node["type"] !== "citationReference")
|
|
44
|
+
return ["hardBreak", "softBreak"].includes(node["type"])
|
|
45
|
+
? node["value"] === undefined || text(node["value"])
|
|
46
|
+
: text(node["value"]);
|
|
47
|
+
clusters += 1;
|
|
48
|
+
const items = node["items"];
|
|
49
|
+
if (clusters > subset.limits.clusters ||
|
|
50
|
+
!Array.isArray(items) ||
|
|
51
|
+
!items.length ||
|
|
52
|
+
items.length > subset.limits.items)
|
|
53
|
+
return false;
|
|
54
|
+
const ids = new Set();
|
|
55
|
+
if (![node["prefix"], node["suffix"]].every((value) => value === undefined || text(value)))
|
|
56
|
+
return false;
|
|
57
|
+
return items.every((item) => {
|
|
58
|
+
if (!isPlainObject(item) ||
|
|
59
|
+
!text(item["id"]) ||
|
|
60
|
+
!item["id"] ||
|
|
61
|
+
ids.has(item["id"]))
|
|
62
|
+
return false;
|
|
63
|
+
ids.add(item["id"]);
|
|
64
|
+
if (item["suppressAuthor"] === true)
|
|
65
|
+
suppressed.add(item["id"]);
|
|
66
|
+
if (Object.keys(item).some((key) => !["id", "locator", "label", "suppressAuthor"].includes(key)))
|
|
67
|
+
return false;
|
|
68
|
+
return ((item["locator"] === undefined ||
|
|
69
|
+
(text(item["locator"]) &&
|
|
70
|
+
matches(subset.rangePattern, item["locator"]))) &&
|
|
71
|
+
(item["label"] === undefined ||
|
|
72
|
+
(text(item["label"]) &&
|
|
73
|
+
subset.locatorLabels.includes(item["label"]))) &&
|
|
74
|
+
(item["suppressAuthor"] === undefined ||
|
|
75
|
+
typeof item["suppressAuthor"] === "boolean"));
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
};
|
|
79
|
+
for (const block of document["blocks"]) {
|
|
80
|
+
if (!isPlainObject(block) ||
|
|
81
|
+
block["schemaVersion"] !== 1 ||
|
|
82
|
+
typeof block["type"] !== "string" ||
|
|
83
|
+
!subset.blockTypes.includes(block["type"]) ||
|
|
84
|
+
!isPlainObject(block["data"]))
|
|
85
|
+
return "This citation document shape is outside the shared subset.";
|
|
86
|
+
const data = block["data"];
|
|
87
|
+
if (block["type"] === "publisle:bibliography") {
|
|
88
|
+
if (!Array.isArray(data["entries"]))
|
|
89
|
+
return "Bibliography entries must be an array.";
|
|
90
|
+
if (entries.length + data["entries"].length > subset.limits.entries)
|
|
91
|
+
return "Too many bibliography entries.";
|
|
92
|
+
for (const entry of data["entries"]) {
|
|
93
|
+
if (!isPlainObject(entry) ||
|
|
94
|
+
Object.keys(entry).some((key) => !subset.entryFields.includes(key)) ||
|
|
95
|
+
!text(entry["id"]) ||
|
|
96
|
+
!entry["id"])
|
|
97
|
+
return "Unsupported bibliography entry.";
|
|
98
|
+
for (const [key, value] of Object.entries(entry))
|
|
99
|
+
if (key !== "authors" && !text(value))
|
|
100
|
+
return "Bibliography fields must be bounded plain text.";
|
|
101
|
+
for (const [key, value] of Object.entries(entry))
|
|
102
|
+
if (key !== "id" &&
|
|
103
|
+
typeof value === "string" &&
|
|
104
|
+
new RegExp(subset.quotationPattern, "u").test(value))
|
|
105
|
+
return "CSL quotation processing is outside the shared subset.";
|
|
106
|
+
const authors = entry["authors"] === undefined ? [] : entry["authors"];
|
|
107
|
+
if (!Array.isArray(authors) ||
|
|
108
|
+
authors.length > subset.limits.authors ||
|
|
109
|
+
!authors.every((author) => text(author) && matches(subset.namePattern, author)))
|
|
110
|
+
return "Names require the shared Family or Family, Given representation.";
|
|
111
|
+
if (entry["issued"] !== undefined &&
|
|
112
|
+
(!text(entry["issued"]) ||
|
|
113
|
+
!matches(subset.yearPattern, entry["issued"])))
|
|
114
|
+
return "Only four-digit Common Era years are supported.";
|
|
115
|
+
if (entry["page"] !== undefined &&
|
|
116
|
+
(!text(entry["page"]) || !matches(subset.rangePattern, entry["page"])))
|
|
117
|
+
return "Page ranges are outside the shared subset.";
|
|
118
|
+
if (typeof entry["raw"] === "string" &&
|
|
119
|
+
entry["raw"].trimStart().startsWith("@"))
|
|
120
|
+
return "BibTeX acquisition is outside the portable citation role.";
|
|
121
|
+
if (!entry["title"] && !entry["raw"])
|
|
122
|
+
return "A title or literal reference is required.";
|
|
123
|
+
if (style === "author-date" && !authors.length && !entry["issued"])
|
|
124
|
+
return "Author-date references need an author or year.";
|
|
125
|
+
entries.push(entry);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
else if (!inline(data["content"]))
|
|
129
|
+
return "Inline citation content is outside the shared subset.";
|
|
130
|
+
}
|
|
131
|
+
if (entries.length > subset.limits.entries)
|
|
132
|
+
return "Too many bibliography entries.";
|
|
133
|
+
if (style === "author-date") {
|
|
134
|
+
const first = new Map();
|
|
135
|
+
for (const entry of entries)
|
|
136
|
+
if (!first.has(String(entry["id"])))
|
|
137
|
+
first.set(String(entry["id"]), entry);
|
|
138
|
+
for (const id of suppressed)
|
|
139
|
+
if (first.has(id) && !first.get(id)?.["issued"])
|
|
140
|
+
return "Author suppression requires a year in the shared subset.";
|
|
141
|
+
}
|
|
142
|
+
// Avoid claiming the general CSL given-name/coauthor disambiguation algorithm.
|
|
143
|
+
const ambiguities = new Map();
|
|
144
|
+
for (const entry of entries) {
|
|
145
|
+
const authors = (entry["authors"] ?? []);
|
|
146
|
+
const short = (authors.length >= 3 ? authors.slice(0, 1) : authors).map((name) => name.split(",")[0]);
|
|
147
|
+
const key = JSON.stringify([short, authors.length >= 3, entry["issued"]]);
|
|
148
|
+
const full = JSON.stringify(authors);
|
|
149
|
+
if (style === "author-date" &&
|
|
150
|
+
ambiguities.has(key) &&
|
|
151
|
+
ambiguities.get(key) !== full)
|
|
152
|
+
return "Given-name and coauthor disambiguation is outside the shared subset.";
|
|
153
|
+
ambiguities.set(key, full);
|
|
154
|
+
}
|
|
155
|
+
return undefined;
|
|
156
|
+
}
|
|
157
|
+
export function resolvePortableCitations(document, style = "numeric", locale = "en-US") {
|
|
158
|
+
const limit = portableCitationLimit(document, style, locale);
|
|
159
|
+
if (limit)
|
|
160
|
+
return {
|
|
161
|
+
classification: "rejected",
|
|
162
|
+
capabilities: PORTABLE_CITATION_CAPABILITIES,
|
|
163
|
+
citations: [],
|
|
164
|
+
bibliography: [],
|
|
165
|
+
unresolved: [],
|
|
166
|
+
diagnostics: [{ code: "unsupported-citation-feature", message: limit }],
|
|
167
|
+
};
|
|
168
|
+
const source = document;
|
|
169
|
+
// Metadata does not participate in this citation-only role.
|
|
170
|
+
const resolved = resolveDocument({ schemaVersion: 1, blocks: source.blocks }, style, { locale });
|
|
171
|
+
return {
|
|
172
|
+
classification: resolved.losses.length
|
|
173
|
+
? "fallback-with-diagnostic"
|
|
174
|
+
: "rendered",
|
|
175
|
+
capabilities: PORTABLE_CITATION_CAPABILITIES,
|
|
176
|
+
citations: resolved.citations.map(normalize),
|
|
177
|
+
bibliography: resolved.bibliography.map((item) => ({
|
|
178
|
+
...item,
|
|
179
|
+
text: normalize(item.text),
|
|
180
|
+
})),
|
|
181
|
+
unresolved: resolved.unresolved,
|
|
182
|
+
diagnostics: resolved.losses,
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
//# sourceMappingURL=portable-citations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"portable-citations.js","sourceRoot":"","sources":["../src/portable-citations.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,qCAAqC,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AAC/E,OAAO,EAAE,aAAa,EAAiB,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C,MAAM,CAAC,MAAM,8BAA8B,GAAG,MAAM,CAAC,MAAM,CAAC;IAC1D,GAAG,MAAM,CAAC,YAAY;IACtB,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;IACtD,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;CACzD,CAAC,CAAC;AAWH,MAAM,OAAO,GAAG,CAAC,OAAe,EAAE,KAAa,EAAE,EAAE,CACjD,IAAI,MAAM,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC;AACtD,iGAAiG;AACjG,MAAM,aAAa,GAAG,8CAA8C,CAAC;AACrE,MAAM,IAAI,GAAG,CAAC,KAAc,EAAmB,EAAE,CAC/C,OAAO,KAAK,KAAK,QAAQ;IACzB,KAAK,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI;IAClC,CAAC,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAC7B,MAAM,SAAS,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;AAExE,kGAAkG;AAClG,MAAM,UAAU,qBAAqB,CACnC,QAAiB,EACj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AAC,MAAM,EAAE,EAC3C,KAAK,EACL,EAAE,MAAM,EAAE,CACX,CAAC;IACF,OAAO;QACL,cAAc,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM;YACpC,CAAC,CAAC,0BAA0B;YAC5B,CAAC,CAAC,UAAU;QACd,YAAY,EAAE,8BAA8B;QAC5C,SAAS,EAAE,QAAQ,CAAC,SAAS,CAAC,GAAG,CAAC,SAAS,CAAC;QAC5C,YAAY,EAAE,QAAQ,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;YACjD,GAAG,IAAI;YACP,IAAI,EAAE,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC;SAC3B,CAAC,CAAC;QACH,UAAU,EAAE,QAAQ,CAAC,UAAU;QAC/B,WAAW,EAAE,QAAQ,CAAC,MAAM;KAC7B,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type PublicationProfile } from "@publisle/schema";
|
|
2
|
+
export type { PublicationProfile } from "@publisle/profiles";
|
|
3
|
+
export interface ResearchPaperProfileOptions {
|
|
4
|
+
/** Match this heading label instead of the default "Abstract" title/"abstract" label. */
|
|
5
|
+
readonly abstractLabel?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare function researchPaperProfile(options?: ResearchPaperProfileOptions): PublicationProfile;
|
|
8
|
+
/** Optional citation targets and section roles. Metadata stays informational. */
|
|
9
|
+
export declare function scholarlyProfile(): PublicationProfile;
|
|
10
|
+
//# sourceMappingURL=profiles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profiles.d.ts","sourceRoot":"","sources":["../src/profiles.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,kBAAkB,EAIxB,MAAM,kBAAkB,CAAC;AAG1B,YAAY,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAE7D,MAAM,WAAW,2BAA2B;IAC1C,yFAAyF;IACzF,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;CACjC;AAsDD,wBAAgB,oBAAoB,CAClC,OAAO,GAAE,2BAAgC,GACxC,kBAAkB,CA0DpB;AAkBD,iFAAiF;AACjF,wBAAgB,gBAAgB,IAAI,kBAAkB,CAwCrD"}
|