@json-to-office/jto-ops 4.4.4 → 4.5.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.
- package/dist/index.js +9 -9
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -2136,7 +2136,7 @@ var RENDERED_QUALITY_RULES = {
|
|
|
2136
2136
|
renderedRule({
|
|
2137
2137
|
id: "rendered/page-underfilled",
|
|
2138
2138
|
code: QUALITY_CODES.RENDERED_PAGE_UNDERFILLED,
|
|
2139
|
-
description: "A docx page
|
|
2139
|
+
description: "A docx page whose ink stops well above the footer: a middle page less than half filled before the next page begins (`kind: middle-page`), or a last page less than a quarter filled that holds only the tail of the document (`kind: last-page`); `context.fill` is the share used. The first page is never judged.",
|
|
2140
2140
|
category: "composition",
|
|
2141
2141
|
defaultSeverity: "info",
|
|
2142
2142
|
formats: ["docx"]
|
|
@@ -2532,6 +2532,7 @@ function assignInventory(pages, inventory) {
|
|
|
2532
2532
|
|
|
2533
2533
|
// src/rendered-analysis.ts
|
|
2534
2534
|
var MINIMUM_PAGE_FILL = 0.5;
|
|
2535
|
+
var MINIMUM_LAST_PAGE_FILL = 0.25;
|
|
2535
2536
|
function isRenderedGeometryFact(fact) {
|
|
2536
2537
|
return fact.kind === "rendered/geometry";
|
|
2537
2538
|
}
|
|
@@ -2821,9 +2822,8 @@ function draftRenderedFindings(input) {
|
|
|
2821
2822
|
});
|
|
2822
2823
|
if (format === "docx") {
|
|
2823
2824
|
pages.forEach((page, pageIndex) => {
|
|
2824
|
-
if (!page.ink || pageIndex === 0
|
|
2825
|
-
|
|
2826
|
-
}
|
|
2825
|
+
if (!page.ink || pageIndex === 0) return;
|
|
2826
|
+
const last = pageIndex === pages.length - 1;
|
|
2827
2827
|
const rowPt = page.heightPt / page.ink.rows;
|
|
2828
2828
|
let headerBottom = 0;
|
|
2829
2829
|
let footerTop = page.heightPt;
|
|
@@ -2842,7 +2842,7 @@ function draftRenderedFindings(input) {
|
|
|
2842
2842
|
const top = body[0] * rowPt;
|
|
2843
2843
|
const bottom = (body[body.length - 1] + 1) * rowPt;
|
|
2844
2844
|
const fill = Math.round((bottom - top) / (footerTop - top) * 100) / 100;
|
|
2845
|
-
if (fill >= MINIMUM_PAGE_FILL) return;
|
|
2845
|
+
if (fill >= (last ? MINIMUM_LAST_PAGE_FILL : MINIMUM_PAGE_FILL)) return;
|
|
2846
2846
|
let owner;
|
|
2847
2847
|
for (const match of matches) {
|
|
2848
2848
|
if (match.status !== "mapped" || match.entry.repeats) continue;
|
|
@@ -2862,14 +2862,14 @@ function draftRenderedFindings(input) {
|
|
|
2862
2862
|
mapping: section ? "mapped" : "unmapped",
|
|
2863
2863
|
page: pageIndex + 1,
|
|
2864
2864
|
path: section ?? "",
|
|
2865
|
-
message: `Page ${pageIndex + 1} is ${Math.round(fill * 100)}% filled: its content stops ${Math.round(footerTop - bottom)}pt above the footer and the next page begins anyway.`,
|
|
2866
|
-
suggestion: "
|
|
2865
|
+
message: last ? `Page ${pageIndex + 1}, the last, is ${Math.round(fill * 100)}% filled: only the tail of the document reached it.` : `Page ${pageIndex + 1} is ${Math.round(fill * 100)}% filled: its content stops ${Math.round(footerTop - bottom)}pt above the footer and the next page begins anyway.`,
|
|
2866
|
+
suggestion: last ? "Keep the notes and sources with the paragraph before them, or tighten the page before so the document closes on a designed page rather than a stub." : "Merge this section into its neighbour, or give the page the table or chart its argument owes. Do not pad it with prose: a short section on its own page reads as unfinished, a padded one reads as filler.",
|
|
2867
2867
|
evidence: {
|
|
2868
2868
|
summary: "Share of the body area the page paints, header to footer",
|
|
2869
|
-
expected: `\u2265 ${Math.round(MINIMUM_PAGE_FILL * 100)}%`,
|
|
2869
|
+
expected: `\u2265 ${Math.round((last ? MINIMUM_LAST_PAGE_FILL : MINIMUM_PAGE_FILL) * 100)}%`,
|
|
2870
2870
|
actual: fill
|
|
2871
2871
|
},
|
|
2872
|
-
context: { fill }
|
|
2872
|
+
context: { fill, kind: last ? "last-page" : "middle-page" }
|
|
2873
2873
|
})
|
|
2874
2874
|
);
|
|
2875
2875
|
});
|