@json-to-office/core-docx 6.6.0 → 6.8.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/dist/core/generateFromIr.d.ts +1 -0
- package/dist/core/generateFromIr.d.ts.map +1 -1
- package/dist/core/generator.d.ts +1 -0
- package/dist/core/generator.d.ts.map +1 -1
- package/dist/core/imageResources.d.ts +1 -0
- package/dist/core/imageResources.d.ts.map +1 -1
- package/dist/index.js +156 -34
- package/dist/index.js.map +1 -1
- package/dist/plugin/example/index.js +115 -16
- package/dist/plugin/example/index.js.map +1 -1
- package/dist/plugin/types.d.ts +1 -0
- package/dist/plugin/types.d.ts.map +1 -1
- package/dist/quality/facts.d.ts +8 -0
- package/dist/quality/facts.d.ts.map +1 -1
- package/dist/quality/rules.d.ts +15 -7
- package/dist/quality/rules.d.ts.map +1 -1
- package/dist/renderers/docxjs/index.d.ts.map +1 -1
- package/dist/renderers/office-open/emit.d.ts +2 -1
- package/dist/renderers/office-open/emit.d.ts.map +1 -1
- package/dist/renderers/office-open/index.d.ts.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/fixFloatingImageIds.d.ts +1 -0
- package/dist/utils/fixFloatingImageIds.d.ts.map +1 -1
- package/dist/utils/imageUtils.d.ts +1 -0
- package/dist/utils/imageUtils.d.ts.map +1 -1
- package/dist/utils/packageDocument.d.ts +1 -0
- package/dist/utils/packageDocument.d.ts.map +1 -1
- package/package.json +6 -6
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
* same IR, which is what makes the IR comparable, cacheable and snapshottable.
|
|
14
14
|
*/
|
|
15
15
|
/// <reference types="node" />
|
|
16
|
+
/// <reference types="node" />
|
|
16
17
|
import type { GenerationWarning, ServicesConfig } from '@json-to-office/shared';
|
|
17
18
|
import type { FontRuntimeOpts } from '@json-to-office/shared';
|
|
18
19
|
import { compileDocument, type UnsupportedComponent } from '../ir/compiler';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateFromIr.d.ts","sourceRoot":"","sources":["../../src/core/generateFromIr.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG
|
|
1
|
+
{"version":3,"file":"generateFromIr.d.ts","sourceRoot":"","sources":["../../src/core/generateFromIr.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;;;AAGH,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAChF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAU9D,OAAO,EAAE,eAAe,EAAE,KAAK,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAC5E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AAE1D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAKlE,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAC1E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,MAAM,WAAW,uBAAuB;IACtC,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IAC3C,QAAQ,CAAC,EAAE,cAAc,CAAC;IAC1B,KAAK,CAAC,EAAE,eAAe,CAAC;IACxB,QAAQ,CAAC,EAAE,iBAAiB,EAAE,CAAC;IAC/B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,oDAAoD;IACpD,QAAQ,CAAC,EAAE,cAAc,CAAC;IAC1B;;;;;;OAMG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B;;;;;;;;OAQG;IACH,OAAO,CAAC,EAAE,sBAAsB,CAAC;IACjC,iEAAiE;IACjE,QAAQ,CAAC,EAAE,gBAAgB,CAAC,gBAAgB,EAAE,eAAe,CAAC,CAAC;CAChE;AAED,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,iBAAiB,EAAE,CAAC;CAC/B;AAED;;;;;GAKG;AACH,qBAAa,wBAAyB,SAAQ,KAAK;IACjD,SAAgB,IAAI,0BAA0B;IAC9C,SAAgB,UAAU,EAAE,SAAS,oBAAoB,EAAE,CAAC;gBAEhD,UAAU,EAAE,SAAS,oBAAoB,EAAE;CAiBxD;AAED,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,WAAW,CAAC;IACnB,QAAQ,EAAE,iBAAiB,EAAE,CAAC;IAC9B,QAAQ,EAAE,UAAU,CAAC,OAAO,eAAe,CAAC,CAAC,UAAU,CAAC,CAAC;IACzD,WAAW,EAAE,oBAAoB,EAAE,CAAC;CACrC;AAED;;;;;;;GAOG;AACH,wBAAsB,mBAAmB,CACvC,QAAQ,EAAE,yBAAyB,EACnC,OAAO,GAAE,uBAA4B,EACrC,SAAS,CAAC,EAAE,iBAAiB,EAAE,GAC9B,OAAO,CAAC,YAAY,CAAC,CAOvB;AA0GD,0EAA0E;AAC1E,wBAAsB,mBAAmB,CACvC,QAAQ,EAAE,yBAAyB,EACnC,OAAO,GAAE,uBAA4B,GACpC,OAAO,CAAC,sBAAsB,CAAC,CAcjC"}
|
package/dist/core/generator.d.ts
CHANGED
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
* it part of the contract again.
|
|
13
13
|
*/
|
|
14
14
|
/// <reference types="node" />
|
|
15
|
+
/// <reference types="node" />
|
|
15
16
|
import { ComponentDefinition, ReportProps, ReportComponentDefinition } from '../types';
|
|
16
17
|
import { ThemeConfig } from '../styles';
|
|
17
18
|
import type { ServicesConfig, FontRuntimeOpts } from '@json-to-office/shared';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../src/core/generator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG
|
|
1
|
+
{"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../src/core/generator.ts"],"names":[],"mappings":"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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"imageResources.d.ts","sourceRoot":"","sources":["../../src/core/imageResources.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG
|
|
1
|
+
{"version":3,"file":"imageResources.d.ts","sourceRoot":"","sources":["../../src/core/imageResources.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;;;AAMH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAOpD,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,4EAA4E;IAC5E,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,mDAAmD;IACnD,SAAS,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;CAC/C;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,cAAe,SAAQ,WAAW,CAAC,MAAM,EAAE,WAAW,CAAC;IACtE,gDAAgD;IAChD,QAAQ,CAAC,QAAQ,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClD;AAED,yEAAyE;AACzE,wBAAsB,kBAAkB,CACtC,UAAU,EAAE,QAAQ,CAAC,mBAAmB,GAAG,SAAS,CAAC,GACpD,OAAO,CAAC,cAAc,CAAC,CA2BzB"}
|
package/dist/index.js
CHANGED
|
@@ -3792,7 +3792,9 @@ function createDocxJsRenderer() {
|
|
|
3792
3792
|
function buildDocument(ir, resources = /* @__PURE__ */ new Map()) {
|
|
3793
3793
|
return new Document({
|
|
3794
3794
|
styles: emitStyles(ir.styles),
|
|
3795
|
-
sections: ir.sections.map(
|
|
3795
|
+
sections: ir.sections.map(
|
|
3796
|
+
(section2, index) => sectionOptions(section2, resources, index === ir.sections.length - 1)
|
|
3797
|
+
),
|
|
3796
3798
|
...coreProperties(ir),
|
|
3797
3799
|
features: {
|
|
3798
3800
|
updateFields: ir.settings.updateFields,
|
|
@@ -3948,7 +3950,7 @@ function collectImagePlacements(ir) {
|
|
|
3948
3950
|
}
|
|
3949
3951
|
return placements;
|
|
3950
3952
|
}
|
|
3951
|
-
function sectionOptions(section2, resources) {
|
|
3953
|
+
function sectionOptions(section2, resources, closesDocument = false) {
|
|
3952
3954
|
const { page, columns } = section2.properties;
|
|
3953
3955
|
const options = {
|
|
3954
3956
|
properties: {
|
|
@@ -3987,7 +3989,7 @@ function sectionOptions(section2, resources) {
|
|
|
3987
3989
|
}
|
|
3988
3990
|
} : {}
|
|
3989
3991
|
},
|
|
3990
|
-
children: sectionChildren(section2, resources)
|
|
3992
|
+
children: sectionChildren(section2, resources, closesDocument)
|
|
3991
3993
|
};
|
|
3992
3994
|
const headers = chromeSlots(section2.headers, Header, resources);
|
|
3993
3995
|
if (headers) options.headers = headers;
|
|
@@ -4009,12 +4011,13 @@ function chromeSlots(set, Part, resources) {
|
|
|
4009
4011
|
function partChildren(part, resources) {
|
|
4010
4012
|
return part.children.map((block2) => emitBlock(block2, resources));
|
|
4011
4013
|
}
|
|
4012
|
-
function sectionChildren(section2, resources) {
|
|
4014
|
+
function sectionChildren(section2, resources, closesDocument = false) {
|
|
4013
4015
|
const blocks = section2.children.map((block2) => emitBlock(block2, resources));
|
|
4014
4016
|
const bookmark = section2.bookmark;
|
|
4015
|
-
|
|
4017
|
+
const endsInFrame = closesDocument && lastBlockIsFrame(section2);
|
|
4018
|
+
if (!bookmark && !endsInFrame) return blocks;
|
|
4016
4019
|
const out = [...blocks];
|
|
4017
|
-
if (bookmark
|
|
4020
|
+
if (bookmark?.opens) {
|
|
4018
4021
|
const start = new BookmarkStart2(bookmark.name, bookmark.id);
|
|
4019
4022
|
const first = out[0];
|
|
4020
4023
|
if (first instanceof Paragraph2) {
|
|
@@ -4023,20 +4026,26 @@ function sectionChildren(section2, resources) {
|
|
|
4023
4026
|
out.unshift(anchorParagraph(start));
|
|
4024
4027
|
}
|
|
4025
4028
|
}
|
|
4026
|
-
if (bookmark
|
|
4029
|
+
if (bookmark?.closes) {
|
|
4027
4030
|
const end = new BookmarkEnd2(bookmark.id);
|
|
4028
4031
|
const last = out[out.length - 1];
|
|
4029
|
-
if (last instanceof Paragraph2) {
|
|
4032
|
+
if (last instanceof Paragraph2 && !endsInFrame) {
|
|
4030
4033
|
last.addChildElement(end);
|
|
4031
4034
|
} else {
|
|
4032
4035
|
out.push(anchorParagraph(end));
|
|
4033
4036
|
}
|
|
4037
|
+
} else if (endsInFrame) {
|
|
4038
|
+
out.push(anchorParagraph());
|
|
4034
4039
|
}
|
|
4035
4040
|
return out;
|
|
4036
4041
|
}
|
|
4042
|
+
function lastBlockIsFrame(section2) {
|
|
4043
|
+
const last = section2.children[section2.children.length - 1];
|
|
4044
|
+
return last?.kind === "paragraph" && last.frame !== void 0;
|
|
4045
|
+
}
|
|
4037
4046
|
function anchorParagraph(anchor) {
|
|
4038
4047
|
return new Paragraph2({
|
|
4039
|
-
children: [anchor],
|
|
4048
|
+
children: anchor ? [anchor] : [],
|
|
4040
4049
|
spacing: { before: 0, after: 0, line: 20, lineRule: LineRuleType2.EXACT }
|
|
4041
4050
|
});
|
|
4042
4051
|
}
|
|
@@ -4855,7 +4864,7 @@ function borders2(value) {
|
|
|
4855
4864
|
}
|
|
4856
4865
|
return out;
|
|
4857
4866
|
}
|
|
4858
|
-
function section(value, ctx) {
|
|
4867
|
+
function section(value, ctx, closesDocument = false) {
|
|
4859
4868
|
const { page, columns } = value.properties;
|
|
4860
4869
|
return {
|
|
4861
4870
|
properties: {
|
|
@@ -4907,7 +4916,7 @@ function section(value, ctx) {
|
|
|
4907
4916
|
}
|
|
4908
4917
|
} : {}
|
|
4909
4918
|
},
|
|
4910
|
-
children: sectionChildren2(value, ctx),
|
|
4919
|
+
children: sectionChildren2(value, ctx, closesDocument),
|
|
4911
4920
|
...value.headers ? { headers: headerFooterSet(value.headers, ctx) } : {},
|
|
4912
4921
|
...value.footers ? { footers: headerFooterSet(value.footers, ctx) } : {}
|
|
4913
4922
|
};
|
|
@@ -4920,8 +4929,16 @@ function headerFooterSet(set, ctx) {
|
|
|
4920
4929
|
}
|
|
4921
4930
|
return out;
|
|
4922
4931
|
}
|
|
4923
|
-
function sectionChildren2(value, ctx) {
|
|
4932
|
+
function sectionChildren2(value, ctx, closesDocument = false) {
|
|
4924
4933
|
const blocks = value.children.map((child) => block(child, ctx));
|
|
4934
|
+
const last = value.children[value.children.length - 1];
|
|
4935
|
+
if (closesDocument && last?.kind === "paragraph" && last.frame !== void 0)
|
|
4936
|
+
blocks.push({
|
|
4937
|
+
paragraph: {
|
|
4938
|
+
children: [],
|
|
4939
|
+
spacing: { before: 0, after: 0, line: 20, lineRule: "exact" }
|
|
4940
|
+
}
|
|
4941
|
+
});
|
|
4925
4942
|
const bookmark = value.bookmark;
|
|
4926
4943
|
if (!bookmark) return blocks;
|
|
4927
4944
|
return [
|
|
@@ -5090,7 +5107,9 @@ async function buildDocumentOptions(ir, charts = [], svgRasterFallback) {
|
|
|
5090
5107
|
};
|
|
5091
5108
|
return {
|
|
5092
5109
|
styles: emitStyles2(ir.styles),
|
|
5093
|
-
sections: ir.sections.map(
|
|
5110
|
+
sections: ir.sections.map(
|
|
5111
|
+
(value, index) => section(value, ctx, index === ir.sections.length - 1)
|
|
5112
|
+
),
|
|
5094
5113
|
...coreProperties2(ir),
|
|
5095
5114
|
features: {
|
|
5096
5115
|
updateFields: ir.settings.updateFields,
|
|
@@ -13693,6 +13712,55 @@ function textSizeFact(node, props, path4, typography, role) {
|
|
|
13693
13712
|
...size.authored && { sizePath: `${path4}/props/font/size` }
|
|
13694
13713
|
};
|
|
13695
13714
|
}
|
|
13715
|
+
function statisticSizeFacts(props, path4, typography) {
|
|
13716
|
+
const named = STATISTIC_SIZE_POINTS[String(props.size)];
|
|
13717
|
+
const styled = (id) => finiteNumber(asRecord2(typography.styles[id])?.size);
|
|
13718
|
+
const numberPoints = named ?? STATISTIC_SIZE_POINTS.medium;
|
|
13719
|
+
const painted = props.size === "small" || props.size === "large" ? numberPoints : styled("StatisticNumber") ?? numberPoints;
|
|
13720
|
+
const present = (value) => value !== void 0 && value !== null && String(value).trim() !== "";
|
|
13721
|
+
const facts = [];
|
|
13722
|
+
const add = (suffix, role, fontSizePt) => facts.push({
|
|
13723
|
+
id: `docx:text-size:${path4}:${suffix}`,
|
|
13724
|
+
kind: "docx/text-size",
|
|
13725
|
+
path: path4,
|
|
13726
|
+
role,
|
|
13727
|
+
fontSizePt,
|
|
13728
|
+
authored: false
|
|
13729
|
+
});
|
|
13730
|
+
if (present(props.number)) add("number", "statistic", painted);
|
|
13731
|
+
if (present(props.unit) || present(props.trend) || present(props.trendValue))
|
|
13732
|
+
add(
|
|
13733
|
+
"suffix",
|
|
13734
|
+
"statistic-suffix",
|
|
13735
|
+
Math.max(12, Math.round(numberPoints)) / 2
|
|
13736
|
+
);
|
|
13737
|
+
if (present(props.description))
|
|
13738
|
+
add(
|
|
13739
|
+
"description",
|
|
13740
|
+
"statistic-description",
|
|
13741
|
+
styled("StatisticDescription") ?? 10
|
|
13742
|
+
);
|
|
13743
|
+
return facts;
|
|
13744
|
+
}
|
|
13745
|
+
function tocSizeFacts(props, path4, typography) {
|
|
13746
|
+
const depth = asRecord2(props.depth);
|
|
13747
|
+
const from = finiteNumber(depth?.from) ?? 1;
|
|
13748
|
+
const to = finiteNumber(depth?.to) ?? 3;
|
|
13749
|
+
const facts = [];
|
|
13750
|
+
for (let level = from; level <= to; level++) {
|
|
13751
|
+
const size = finiteNumber(asRecord2(typography.styles[`TOC${level}`])?.size);
|
|
13752
|
+
if (size === void 0) continue;
|
|
13753
|
+
facts.push({
|
|
13754
|
+
id: `docx:text-size:${path4}:toc${level}`,
|
|
13755
|
+
kind: "docx/text-size",
|
|
13756
|
+
path: path4,
|
|
13757
|
+
role: `toc${level}`,
|
|
13758
|
+
fontSizePt: size,
|
|
13759
|
+
authored: false
|
|
13760
|
+
});
|
|
13761
|
+
}
|
|
13762
|
+
return facts;
|
|
13763
|
+
}
|
|
13696
13764
|
function tableTextSizeFacts(props, authored, path4, typography, page) {
|
|
13697
13765
|
const facts = [];
|
|
13698
13766
|
const sizeOf = (holder) => finiteNumber(asRecord2(asRecord2(holder)?.font)?.size);
|
|
@@ -13906,6 +13974,16 @@ function prepareDocxQualityDocument(document, options = {}) {
|
|
|
13906
13974
|
(value) => `#${resolveDesignColor2(value, visualColors)}`
|
|
13907
13975
|
) ?? SERIES_COLOR_TOKENS.filter((token) => paletteHexes[token] !== void 0);
|
|
13908
13976
|
const authoredPropsAt = (pointer) => asRecord2(asRecord2(nodeAtPointer(context.document, pointer))?.props);
|
|
13977
|
+
const ownSize = (fact) => {
|
|
13978
|
+
if (!fact?.sizePath) return fact;
|
|
13979
|
+
const written = finiteNumber(
|
|
13980
|
+
asRecord2(authoredPropsAt(fact.path)?.font)?.size
|
|
13981
|
+
);
|
|
13982
|
+
if (written !== void 0) return fact;
|
|
13983
|
+
const inherited2 = { ...fact, authored: false };
|
|
13984
|
+
delete inherited2.sizePath;
|
|
13985
|
+
return inherited2;
|
|
13986
|
+
};
|
|
13909
13987
|
const roleSizesPt = {};
|
|
13910
13988
|
for (const key of Object.keys(typography.styles)) {
|
|
13911
13989
|
const size = effectiveFontSize(
|
|
@@ -14059,10 +14137,22 @@ function prepareDocxQualityDocument(document, options = {}) {
|
|
|
14059
14137
|
const fact = lineBoxFact(node, props, path4, typography, context.document);
|
|
14060
14138
|
if (fact) addFact(fact);
|
|
14061
14139
|
if (typeof props.text === "string" && props.text.trim() !== "") {
|
|
14062
|
-
const fact2 = textSizeFact(node, props, path4, typography);
|
|
14140
|
+
const fact2 = ownSize(textSizeFact(node, props, path4, typography));
|
|
14063
14141
|
if (fact2) addFact({ ...fact2, generated: authoredPath(path4) !== path4 });
|
|
14064
14142
|
}
|
|
14065
14143
|
}
|
|
14144
|
+
if (node.name === "list" && Array.isArray(props.items) && props.items.length > 0) {
|
|
14145
|
+
const fact = ownSize(textSizeFact(node, props, path4, typography, "list"));
|
|
14146
|
+
if (fact) addFact({ ...fact, generated: authoredPath(path4) !== path4 });
|
|
14147
|
+
}
|
|
14148
|
+
if (node.name === "statistic") {
|
|
14149
|
+
for (const fact of statisticSizeFacts(props, path4, typography))
|
|
14150
|
+
addFact({ ...fact, generated: authoredPath(path4) !== path4 });
|
|
14151
|
+
}
|
|
14152
|
+
if (node.name === "toc") {
|
|
14153
|
+
for (const fact of tocSizeFacts(props, path4, typography))
|
|
14154
|
+
addFact({ ...fact, generated: authoredPath(path4) !== path4 });
|
|
14155
|
+
}
|
|
14066
14156
|
if (node.name === "image" || node.name === "visual") {
|
|
14067
14157
|
for (const fact of svgTextFacts(props, path4)) addFact(fact);
|
|
14068
14158
|
const drawn = drawnRatio(props);
|
|
@@ -14087,6 +14177,7 @@ function prepareDocxQualityDocument(document, options = {}) {
|
|
|
14087
14177
|
kind: "docx/heading",
|
|
14088
14178
|
path: `${path4}/props/level`,
|
|
14089
14179
|
level,
|
|
14180
|
+
generated: authoredPath(path4) !== path4,
|
|
14090
14181
|
keepNext: props.keepNext === true || props.keepNext === void 0 && styleKeepNext === true,
|
|
14091
14182
|
...previousHeadingLevel !== void 0 && {
|
|
14092
14183
|
previousLevel: previousHeadingLevel
|
|
@@ -14127,7 +14218,10 @@ function prepareDocxQualityDocument(document, options = {}) {
|
|
|
14127
14218
|
index,
|
|
14128
14219
|
words: texts.filter((fact) => bodyRoles.has(fact.role)).reduce((total, fact) => total + wordsOf(fact.text), 0),
|
|
14129
14220
|
exhibits: own.filter((fact) => exhibitKinds.has(fact.kind)).length,
|
|
14130
|
-
headings: texts.filter((fact) => fact.role === "heading").length
|
|
14221
|
+
headings: texts.filter((fact) => fact.role === "heading").length,
|
|
14222
|
+
// Anything the reader sees on the section's own pages: a heading, a
|
|
14223
|
+
// contents field, body copy. Running heads repeat onto any page.
|
|
14224
|
+
rendersText: texts.some((fact) => fact.role !== "chrome")
|
|
14131
14225
|
});
|
|
14132
14226
|
if (hasColumnsComponent(rec)) return;
|
|
14133
14227
|
const page = pageBox(
|
|
@@ -14203,10 +14297,15 @@ function isCaptioned(facts, image) {
|
|
|
14203
14297
|
return facts.some((fact) => {
|
|
14204
14298
|
if (fact.kind !== "docx/text") return false;
|
|
14205
14299
|
const text = fact;
|
|
14206
|
-
const
|
|
14300
|
+
const node = text.path.replace(/\/props(?:\/.*)?$/, "");
|
|
14301
|
+
const beside = siblingOf(node) === siblingOf(image) && Math.abs(indexIn(node) - indexIn(image)) === 1;
|
|
14302
|
+
const near = beside || text.path.startsWith(`${image}/`) || image.startsWith(`${node}/`);
|
|
14207
14303
|
return near && (text.role === "caption" || CAPTION_LABEL.test(text.text));
|
|
14208
14304
|
});
|
|
14209
14305
|
}
|
|
14306
|
+
function indexIn(pointer) {
|
|
14307
|
+
return Number(pointer.slice(pointer.lastIndexOf("/") + 1));
|
|
14308
|
+
}
|
|
14210
14309
|
function siblingOf(pointer) {
|
|
14211
14310
|
return pointer.slice(0, pointer.lastIndexOf("/"));
|
|
14212
14311
|
}
|
|
@@ -14726,14 +14825,18 @@ var docxHeadingHierarchyRule = {
|
|
|
14726
14825
|
},
|
|
14727
14826
|
// The fact path already addresses `.../props/level`; RFC 6902
|
|
14728
14827
|
// `add` replaces an existing member, so this works whether the
|
|
14729
|
-
// level was explicit or defaulted.
|
|
14730
|
-
|
|
14731
|
-
|
|
14732
|
-
|
|
14733
|
-
|
|
14734
|
-
|
|
14735
|
-
|
|
14736
|
-
|
|
14828
|
+
// level was explicit or defaulted. A block's heading maps to the
|
|
14829
|
+
// invocation or a slot instead, and an `add` there would replace
|
|
14830
|
+
// the block itself: its level is the definition's to change.
|
|
14831
|
+
...!fact.generated && {
|
|
14832
|
+
fixes: [
|
|
14833
|
+
{
|
|
14834
|
+
op: "add",
|
|
14835
|
+
path: fact.path,
|
|
14836
|
+
value: previousLevel + 1
|
|
14837
|
+
}
|
|
14838
|
+
]
|
|
14839
|
+
}
|
|
14737
14840
|
}
|
|
14738
14841
|
];
|
|
14739
14842
|
})
|
|
@@ -15231,7 +15334,12 @@ var docxRequiredChromeRule = {
|
|
|
15231
15334
|
relatedPaths: [fact.invocation],
|
|
15232
15335
|
message: `${fact.block} states no ${fact.role} in its "${fact.slot}" slot; the ${profile?.id ?? "selected"} profile expects one on every ${fact.block}.`,
|
|
15233
15336
|
suggestion: `Fill the "${fact.slot}" slot. The theme already styles it.`,
|
|
15234
|
-
context: { block: fact.block, slot: fact.slot, role: fact.role }
|
|
15337
|
+
context: { block: fact.block, slot: fact.slot, role: fact.role },
|
|
15338
|
+
evidence: {
|
|
15339
|
+
actual: "empty",
|
|
15340
|
+
expected: fact.role,
|
|
15341
|
+
values: { source: "profile", required }
|
|
15342
|
+
}
|
|
15235
15343
|
}));
|
|
15236
15344
|
}
|
|
15237
15345
|
};
|
|
@@ -15298,7 +15406,12 @@ var docxRunningHeadRule = {
|
|
|
15298
15406
|
path: fact.path,
|
|
15299
15407
|
message: `Section ${fact.index + 1} carries no ${parts}; the ${profile?.id ?? "selected"} profile expects a running head on every section after the cover.`,
|
|
15300
15408
|
suggestion: "Invoke a running-head block at the top of the first body section: its section effect fills every later section with the title and n / N.",
|
|
15301
|
-
context: { section: fact.index, missing }
|
|
15409
|
+
context: { section: fact.index, missing },
|
|
15410
|
+
evidence: {
|
|
15411
|
+
actual: required.filter((part) => fact[part]),
|
|
15412
|
+
expected: required,
|
|
15413
|
+
values: { source: "profile", fromSection: from }
|
|
15414
|
+
}
|
|
15302
15415
|
}
|
|
15303
15416
|
];
|
|
15304
15417
|
});
|
|
@@ -15346,7 +15459,7 @@ var docxTypeScaleRule = {
|
|
|
15346
15459
|
};
|
|
15347
15460
|
var docxSizeCountRule = {
|
|
15348
15461
|
id: "docx/size-count",
|
|
15349
|
-
description: "More distinct text sizes than maximumSizes allows, blocks included. Off until a profile or policy enables it.",
|
|
15462
|
+
description: "More distinct text sizes across the document than maximumSizes allows, blocks, statistics, lists and contents included; counted per document, which bounds every page. Off until a profile or policy enables it.",
|
|
15350
15463
|
code: QUALITY_CODES.TYPE_SIZE_COUNT,
|
|
15351
15464
|
category: "consistency",
|
|
15352
15465
|
defaultSeverity: "warning",
|
|
@@ -15443,7 +15556,7 @@ var docxSectionContentRule = {
|
|
|
15443
15556
|
(fact) => fact.kind === "docx/section"
|
|
15444
15557
|
);
|
|
15445
15558
|
return sections.flatMap((fact) => {
|
|
15446
|
-
if (fact.
|
|
15559
|
+
if (!fact.rendersText && fact.exhibits === 0)
|
|
15447
15560
|
return [
|
|
15448
15561
|
{
|
|
15449
15562
|
path: fact.path,
|
|
@@ -15555,7 +15668,7 @@ var docxImageAspectRule = {
|
|
|
15555
15668
|
};
|
|
15556
15669
|
var docxContentsRule = {
|
|
15557
15670
|
id: "docx/contents-missing",
|
|
15558
|
-
description: "
|
|
15671
|
+
description: "minimumHeadings headings or more with no table of contents. Off at 0.",
|
|
15559
15672
|
code: QUALITY_CODES.CONTENTS_MISSING,
|
|
15560
15673
|
category: "hierarchy",
|
|
15561
15674
|
defaultSeverity: "info",
|
|
@@ -15628,7 +15741,7 @@ var DOCX_QUALITY_PROFILES = {
|
|
|
15628
15741
|
"client-report": {
|
|
15629
15742
|
id: "client-report",
|
|
15630
15743
|
formats: ["docx"],
|
|
15631
|
-
description: "Client or public-administration report: a running head with page numbers on every section after the cover, a takeaway and a source wherever a block declares them, no heading skipped, every size on the theme scale with at most
|
|
15744
|
+
description: "Client or public-administration report: a running head with page numbers on every section after the cover, a takeaway and a source wherever a block declares them, no heading skipped, every size on the theme scale with at most eleven in play, a readable measure, no empty or untitled section, every heading bound to what follows and every figure named, no page rendered empty or left half blank under the running head, and at least one chart or table.",
|
|
15632
15745
|
rules: {
|
|
15633
15746
|
"docx/required-chrome": {
|
|
15634
15747
|
parameters: { required: ["takeaway", "source"] }
|
|
@@ -15641,7 +15754,14 @@ var DOCX_QUALITY_PROFILES = {
|
|
|
15641
15754
|
},
|
|
15642
15755
|
"docx/heading-hierarchy": { severity: "warning" },
|
|
15643
15756
|
"docx/type-scale": { enabled: true },
|
|
15644
|
-
|
|
15757
|
+
// Measured 2026-09-15 with statistics, lists and contents counted: a
|
|
15758
|
+
// client report built from the house blocks paints up to eleven sizes —
|
|
15759
|
+
// body, heading 1 and 2, subtitle, display, table cells and headers,
|
|
15760
|
+
// source and chrome, and the kpi-row's figure, its unit and its label
|
|
15761
|
+
// (28, 14 and 10pt, or 20 and 10 in a row of four). Every one of the
|
|
15762
|
+
// reports of the #360 checkpoint and the #409 verification set came in
|
|
15763
|
+
// at eleven or fewer; a size past the house set is an ad-hoc one.
|
|
15764
|
+
"docx/size-count": { enabled: true, parameters: { maximumSizes: 11 } },
|
|
15645
15765
|
"docx/role-drift": { enabled: true },
|
|
15646
15766
|
// The report blocks place every figure in a captioned block, so a page
|
|
15647
15767
|
// with no text under the running head is a stray break or an empty
|
|
@@ -15672,7 +15792,7 @@ var DOCX_QUALITY_PROFILES = {
|
|
|
15672
15792
|
"technical-report": {
|
|
15673
15793
|
id: "technical-report",
|
|
15674
15794
|
formats: ["docx"],
|
|
15675
|
-
description: "Technical report or memo: numbered sections under a running head with page numbers on every section after the cover, a source wherever a block declares one, no heading skipped, every size on the theme scale with at most nine in play, a readable measure, no empty or untitled section, every heading bound to what follows, every figure named, a contents page
|
|
15795
|
+
description: "Technical report or memo: numbered sections under a running head with page numbers on every section after the cover, a source wherever a block declares one, no heading skipped, every size on the theme scale with at most nine in play, a readable measure, no empty or untitled section, every heading bound to what follows, every figure named, a contents page from eight headings, no page rendered empty or left half blank, and at least one chart or table.",
|
|
15676
15796
|
rules: {
|
|
15677
15797
|
// A figure or table in a technical report cites where its numbers come
|
|
15678
15798
|
// from; the takeaway is the client report's ask, the caption is the
|
|
@@ -15686,8 +15806,10 @@ var DOCX_QUALITY_PROFILES = {
|
|
|
15686
15806
|
},
|
|
15687
15807
|
"docx/heading-hierarchy": { severity: "warning" },
|
|
15688
15808
|
"docx/type-scale": { enabled: true },
|
|
15689
|
-
//
|
|
15690
|
-
//
|
|
15809
|
+
// Measured 2026-09-15: a technical report built from the house blocks
|
|
15810
|
+
// paints eight sizes (no kpi-row; the contents entries at body size),
|
|
15811
|
+
// and every one of the #409 verification set came in at eight or
|
|
15812
|
+
// fewer. Nine leaves room for one deliberate size of the author's.
|
|
15691
15813
|
"docx/size-count": { enabled: true, parameters: { maximumSizes: 9 } },
|
|
15692
15814
|
"docx/role-drift": { enabled: true },
|
|
15693
15815
|
"rendered/empty-page": { severity: "warning" },
|