@pubid/pubid 0.1.46 → 0.1.47
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/dist/flavors/iec/index.js +46 -1
- package/dist/flavors/iec/model.js +35 -5
- package/package.json +1 -1
|
@@ -650,6 +650,46 @@ for (const klass of [
|
|
|
650
650
|
klass.urnGenerator = IecUrnGenerator;
|
|
651
651
|
}
|
|
652
652
|
}
|
|
653
|
+
// --- the standalone no-part dotted face reject (pubid#727) --------------
|
|
654
|
+
// A supplement's OWN dotted sub-number has nowhere to print on the
|
|
655
|
+
// standalone (no-part, self-base) face: the standalone renderer prints
|
|
656
|
+
// the base number and the supplement number only, so the parsed dot was
|
|
657
|
+
// dropped at render and parse(render) != parse. No IEC source prints a
|
|
658
|
+
// no-part standalone face with a dotted number — the facet is attested
|
|
659
|
+
// only on the on-base draft faces ("IEC 60038-2/DAM 2.3:2022") — so the
|
|
660
|
+
// shape is rejected at parse instead of being built unrenderable (the
|
|
661
|
+
// #726 ruling for unattested dotted shapes; the TS mirror of the gem's
|
|
662
|
+
// reject_standalone_dotted_supplement walk over the built base chain).
|
|
663
|
+
// The check is the SHAPE, not a grammar route: one condition covers the
|
|
664
|
+
// standalone branch ("IEC/AMD 1.2:2017"), the publisher-less plain route
|
|
665
|
+
// ("AMD 1.2:2017") and a dotted layer under an undotted second
|
|
666
|
+
// supplement ("IEC/AMD 1.2:2017/COR 1:2018"). The single-document draft
|
|
667
|
+
// faces ("IEC CD 1.2:2017"), the DAM-family decodes ("IEC/DAM 1.2") and
|
|
668
|
+
// the on-base faces (a real base) keep their dot on a printable layer
|
|
669
|
+
// and pass. from_hash deliberately still deserializes the shape (no
|
|
670
|
+
// stored row carries it; residue pinned).
|
|
671
|
+
const STANDALONE_DOTTED_SUPPLEMENT_MESSAGE = 'the standalone no-part supplement face carries a dotted sub-number ' +
|
|
672
|
+
'(e.g. "IEC/AMD 1.2:2017"): no IEC source prints one, and the ' +
|
|
673
|
+
"standalone face has no layer to print the dot on, so the stored " +
|
|
674
|
+
"sub-number would be dropped at render — the dotted sub-number is " +
|
|
675
|
+
"attested only on the on-base draft forms";
|
|
676
|
+
const SUPPLEMENT_POLYMORPHIC_NAMES = new Set([
|
|
677
|
+
"pubid:iec:amendment",
|
|
678
|
+
"pubid:iec:corrigendum",
|
|
679
|
+
"pubid:iec:interpretation-sheet",
|
|
680
|
+
]);
|
|
681
|
+
function rejectStandaloneDottedSupplement(id) {
|
|
682
|
+
let node = id;
|
|
683
|
+
while (node !== undefined && SUPPLEMENT_POLYMORPHIC_NAMES.has(node.constructor.polymorphicName)) {
|
|
684
|
+
const layer = node;
|
|
685
|
+
const iteration = layer["stage_iteration"];
|
|
686
|
+
const base = layer["base"];
|
|
687
|
+
if (iteration !== undefined && (base === undefined || layer["synthetic_base"] === true)) {
|
|
688
|
+
throw new ParseFailed(STANDALONE_DOTTED_SUPPLEMENT_MESSAGE, 0);
|
|
689
|
+
}
|
|
690
|
+
node = base;
|
|
691
|
+
}
|
|
692
|
+
}
|
|
653
693
|
export function iecGrammarImplementation() {
|
|
654
694
|
const builder = new IecBuilder();
|
|
655
695
|
return {
|
|
@@ -693,7 +733,12 @@ export function iecGrammarImplementation() {
|
|
|
693
733
|
catch {
|
|
694
734
|
throw new ParseFailed("IEC: parse failed", 0);
|
|
695
735
|
}
|
|
696
|
-
|
|
736
|
+
const built = builder.build(tree);
|
|
737
|
+
// The shape check runs on the BUILT object (ruby Identifier.parse
|
|
738
|
+
// walks the base chain after ensure_base) — BSI's delegation and
|
|
739
|
+
// every parse route raise through this entry; from_hash stays open.
|
|
740
|
+
rejectStandaloneDottedSupplement(built);
|
|
741
|
+
return built;
|
|
697
742
|
},
|
|
698
743
|
};
|
|
699
744
|
}
|
|
@@ -186,8 +186,13 @@ export class IecIdentifier extends BaseIdentifier {
|
|
|
186
186
|
typedStage;
|
|
187
187
|
/** Ruby SingleIdentifier#publisher_portion. */
|
|
188
188
|
publisherPortion() {
|
|
189
|
-
|
|
190
|
-
|
|
189
|
+
// The supplement table does not materialize the empty copublishers
|
|
190
|
+
// collection (the single table's initializeEmpty does) — ruby
|
|
191
|
+
// nil-guards the same read (`copublishers&.any?`, pubid#727: the
|
|
192
|
+
// standalone faces crashed here instead of rendering).
|
|
193
|
+
const copublishers = this.copublishers ?? [];
|
|
194
|
+
const publishers = copublishers.length > 0
|
|
195
|
+
? [this.publisher ?? "IEC", ...copublishers]
|
|
191
196
|
: [this.publisher ?? "IEC"];
|
|
192
197
|
let pub = publishers.join("/");
|
|
193
198
|
const abbr = this.typedStage?.abbr ?? "";
|
|
@@ -400,9 +405,34 @@ function iecSupplementClass(kind) {
|
|
|
400
405
|
render() {
|
|
401
406
|
const base = this.base;
|
|
402
407
|
if (base === undefined || this.synthetic_base === true) {
|
|
403
|
-
// Standalone draft supplement (not in the corpus; Ruby parity
|
|
404
|
-
|
|
405
|
-
|
|
408
|
+
// Standalone draft supplement (not in the corpus; Ruby parity
|
|
409
|
+
// shape). Ruby render_supplement_standalone: the publisher join
|
|
410
|
+
// with NO stage abbreviation (the slash stays the copublisher
|
|
411
|
+
// separator), then the stage token over the self-base number and
|
|
412
|
+
// the supplement's own number ("IEC Amd 1-1:2017"). The published
|
|
413
|
+
// stages print the capitalized abbreviation ("Amd"), the draft
|
|
414
|
+
// stages their own token ("DCOR") — the ruby typed_stage.abbr
|
|
415
|
+
// first element. The publisher rides the attribute default ("IEC"
|
|
416
|
+
// fills it on every parse and from_hash route; ruby renders the
|
|
417
|
+
// nil-publisher hand-built case with no publisher part, a shape
|
|
418
|
+
// no parse or deserialization route reaches).
|
|
419
|
+
const parts = [];
|
|
420
|
+
const copublishers = this.copublishers ?? [];
|
|
421
|
+
const publishers = [this.publisher ?? "IEC", ...copublishers];
|
|
422
|
+
parts.push(publishers.join("/"));
|
|
423
|
+
const stageAbbr = this.typedStage?.abbr ?? abbr;
|
|
424
|
+
const leadAbbr = this.typedStage?.stageCode === "published"
|
|
425
|
+
? stageAbbr.charAt(0) + stageAbbr.slice(1).toLowerCase()
|
|
426
|
+
: stageAbbr;
|
|
427
|
+
// The self-base holds the supplement's own number (ruby's
|
|
428
|
+
// synthetic base stores it before the render reads it).
|
|
429
|
+
let numberStr = String(base?.number ?? this.number ?? "");
|
|
430
|
+
if (this.number !== undefined)
|
|
431
|
+
numberStr += `-${this.number}`;
|
|
432
|
+
if (this.subpart !== undefined)
|
|
433
|
+
numberStr += `-${this.subpart}`;
|
|
434
|
+
parts.push(`${leadAbbr} ${numberStr}`);
|
|
435
|
+
let result = parts.join(" ");
|
|
406
436
|
if (this.date !== undefined)
|
|
407
437
|
result += `:${this.date.render()}`;
|
|
408
438
|
if (this.edition !== undefined)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pubid/pubid",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.47",
|
|
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",
|