@pubid/pubid 0.1.19 → 0.1.20
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.
|
@@ -29,7 +29,13 @@ export function checkCase(testCase, impl) {
|
|
|
29
29
|
for (const alias of testCase.nonNormalizedAliases ?? []) {
|
|
30
30
|
try {
|
|
31
31
|
const aliased = impl.parse(alias.spelling);
|
|
32
|
-
|
|
32
|
+
// A multi-round chain walks another render/parse round per
|
|
33
|
+
// recorded `rounds` until it reaches the canonical human.
|
|
34
|
+
let human = aliased.toHuman();
|
|
35
|
+
for (let round = 1; round < (alias.rounds ?? 1); round += 1) {
|
|
36
|
+
human = impl.parse(human).toHuman();
|
|
37
|
+
}
|
|
38
|
+
if (human !== testCase.representations.human) {
|
|
33
39
|
mismatches.push(`${label} alias ${alias.spelling}`);
|
|
34
40
|
}
|
|
35
41
|
}
|
package/dist/corpus/types.d.ts
CHANGED
|
@@ -13,6 +13,9 @@ export interface Representations {
|
|
|
13
13
|
export interface Spelling {
|
|
14
14
|
spelling: string;
|
|
15
15
|
style?: string;
|
|
16
|
+
/** Render/parse rounds the spelling needs to reach the canonical human;
|
|
17
|
+
* present only above 1 (a documented multi-round normalization chain). */
|
|
18
|
+
rounds?: number;
|
|
16
19
|
}
|
|
17
20
|
export interface ErrorExpectation {
|
|
18
21
|
/** Neutral rejection code - never an implementation class. */
|
|
@@ -501,11 +501,15 @@ class IeeeBuilder {
|
|
|
501
501
|
// An explicit joint stage on the draft ("=DFDIS.3") IS the stage —
|
|
502
502
|
// it outranks the ordinal ladder, which classifies IEEE-internal
|
|
503
503
|
// drafts only (docs/IEEE-DRAFT-STAGES.md §1.3).
|
|
504
|
+
let draftVersionPresent = false;
|
|
504
505
|
if (parsed["draft"] !== undefined) {
|
|
505
506
|
let draftData = parsed["draft"];
|
|
506
507
|
if (Array.isArray(draftData)) {
|
|
507
508
|
draftData = mergeParsedArray(draftData);
|
|
508
509
|
}
|
|
510
|
+
// A verbatim draft designator string is a version in itself.
|
|
511
|
+
if (!isObj(draftData))
|
|
512
|
+
draftVersionPresent = true;
|
|
509
513
|
if (isObj(draftData) && draftData["draft_iso_stage"] !== undefined) {
|
|
510
514
|
const stage = extractValue(draftData["draft_iso_stage"]) ?? "";
|
|
511
515
|
// The doubled-D alias ("DFDIS") carries its own draft marker;
|
|
@@ -516,9 +520,21 @@ class IeeeBuilder {
|
|
|
516
520
|
: stage;
|
|
517
521
|
}
|
|
518
522
|
if (isObj(draftData) && draftData["draft_version"] !== undefined) {
|
|
523
|
+
draftVersionPresent = true;
|
|
519
524
|
const dv = draftData["draft_version"];
|
|
520
525
|
const version = Array.isArray(dv) ? dv.map((v) => extractValue(v) ?? "").join("") : extractValue(dv);
|
|
521
526
|
if (version !== undefined) {
|
|
527
|
+
// A draft version that IS an ISO stage token ("/DCD1" and
|
|
528
|
+
// "/CD1" both capture "CD1") takes that stage on a plain IEEE
|
|
529
|
+
// document (docs/IEEE-DRAFT-STAGES.md §1.3, "DDIS" = DIS); a
|
|
530
|
+
// joint ISO-led stage-word draft keeps its generic project
|
|
531
|
+
// stage.
|
|
532
|
+
const pubs = parsed["publishers"];
|
|
533
|
+
const copubs = isObj(pubs) ? pubs["copublishers"] : undefined;
|
|
534
|
+
const joint = copubs !== undefined && (Array.isArray(copubs) ? copubs.length > 0 : true);
|
|
535
|
+
const stageMatch = /^(FDIS|FCD|CDV|DIS|CD|WD|PWI|NP)\d*$/.exec(version);
|
|
536
|
+
if (!joint && stageMatch !== null)
|
|
537
|
+
return stageMatch[1];
|
|
522
538
|
// relaton's hyphenated "/D-2" spelling captures the dash inside
|
|
523
539
|
// draft_version; the stage registry keys on "D2". A date-embedded
|
|
524
540
|
// version ("3-2017-07") keys on its leading ordinal.
|
|
@@ -534,7 +550,7 @@ class IeeeBuilder {
|
|
|
534
550
|
return "P";
|
|
535
551
|
if (typeValue === "Std")
|
|
536
552
|
return "Std";
|
|
537
|
-
if (typeValue === "Draft Std" &&
|
|
553
|
+
if (typeValue === "Draft Std" && !draftVersionPresent && parsed["digit_draft"] === undefined) {
|
|
538
554
|
return "D1";
|
|
539
555
|
}
|
|
540
556
|
if (/^No\.?$/.test(typeValue))
|
|
@@ -1259,6 +1259,15 @@ export function nistGrammarImplementation() {
|
|
|
1259
1259
|
const { cleaned, format } = preprocessNist(input);
|
|
1260
1260
|
const base = cleaned.replace(/\s*\(all parts\)\s*$/, "");
|
|
1261
1261
|
const tree = toBuilderTree(cachedRuntime(base));
|
|
1262
|
+
// The reference's language_code rule captures its separator with
|
|
1263
|
+
// the code (".uppl"); the baked nist artifact labels the code
|
|
1264
|
+
// alone. Restore the reference's slice for a trailing dot-prefixed
|
|
1265
|
+
// code, so the renderer prints the canonical double-dot face
|
|
1266
|
+
// ("NIST.SP.955-S..uppl").
|
|
1267
|
+
const dotted = /\.([a-z]{2,4})$/.exec(base);
|
|
1268
|
+
if (dotted && tree["translation"] === dotted[1]) {
|
|
1269
|
+
tree["translation"] = `.${dotted[1]}`;
|
|
1270
|
+
}
|
|
1262
1271
|
const marked = base !== cleaned
|
|
1263
1272
|
? { ...tree, all_parts: true }
|
|
1264
1273
|
: tree;
|
|
@@ -266,8 +266,11 @@ export function preprocessNist(input) {
|
|
|
266
266
|
// normalize_legacy_corpus_spellings: catalogue forms the grammar and
|
|
267
267
|
// the renderers cannot round-trip on their own. Each rule mirrors an
|
|
268
268
|
// already-parseable spelling of the same document.
|
|
269
|
-
// The mr
|
|
270
|
-
//
|
|
269
|
+
// The reference's mr translation CODE keeps its own leading dot
|
|
270
|
+
// (".uppl") and its renderer adds the separator dot, so the canonical
|
|
271
|
+
// face is "955-S..uppl". The grammar reads the collapsed single-dot
|
|
272
|
+
// spelling and captures the dot with the code; collapse here so a
|
|
273
|
+
// double-dot input reads the same way.
|
|
271
274
|
cleaned = cleaned.replace(/\.\./g, ".");
|
|
272
275
|
// Trailing-dot addendum spelling; the canonical render comes from
|
|
273
276
|
// the lowercase ".add" parse ("NBS.TN.467pt1.Add." -> ".add").
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pubid/pubid",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.20",
|
|
4
4
|
"description": "TypeScript PubID identifiers: resolution, normalization and canonical hashes for every identifier in the pubid-testsuite corpus (41 standards bodies), with a conformance runner mirroring the Ruby reference",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|