@openpresentation/opf 0.31.0 → 0.32.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/README.md +1 -1
- package/dist/browser.js +18 -18
- package/dist/{chart-data-Ci9s_NDN.d.ts → chart-data-oIZQlFGi.d.ts} +4 -2
- package/dist/{chunk-UKWNHK62.js → chunk-2E6CDYL2.js} +23 -6
- package/dist/{chunk-HRKV43GC.js → chunk-BBVW5ZC2.js} +3 -3
- package/dist/{chunk-7UO6H32I.js → chunk-CLRYHWQN.js} +162 -22
- package/dist/chunk-DGS47ONG.js +1 -0
- package/dist/{chunk-F5QC7E2O.js → chunk-F7DN33UL.js} +28 -8
- package/dist/{chunk-KELC4K62.js → chunk-HKUV7NEN.js} +1 -1
- package/dist/{chunk-XG4JKFZ6.js → chunk-IT7FQKED.js} +6 -6
- package/dist/{chunk-SYCHWS7C.js → chunk-J63CIRIV.js} +4 -4
- package/dist/{chunk-5Q4IYLMW.js → chunk-LEF4X4KI.js} +274 -33
- package/dist/{chunk-5OMZW44K.js → chunk-NEJ32O7X.js} +1 -1
- package/dist/chunk-NVAJASOD.js +14764 -0
- package/dist/{chunk-XSCZZWYI.js → chunk-ONVFUVQ5.js} +99 -15
- package/dist/{chunk-M7YZU3DX.js → chunk-OXLA4HXQ.js} +615 -58
- package/dist/{chunk-P5E3FNYO.js → chunk-PB7ME64J.js} +1 -1
- package/dist/{chunk-ARFAQNOH.js → chunk-SW676APJ.js} +2 -2
- package/dist/{chunk-I6G32TB5.js → chunk-SZFO3MAJ.js} +5 -5
- package/dist/{chunk-W7KPMUJF.js → chunk-XFHXQCXL.js} +58 -5
- package/dist/{chunk-KOCXV7H3.js → chunk-XQO2CT6Q.js} +2 -2
- package/dist/{chunk-WHDOOLIO.js → chunk-YFJIIIOL.js} +3 -3
- package/dist/composition-Ds6WHyO7.d.ts +5620 -0
- package/dist/composition.d.ts +2 -2
- package/dist/composition.js +1 -1
- package/dist/conversion-5FUDQPED.js +24 -0
- package/dist/{conversion-Bh-skyMc.d.ts → conversion-CdzrTxib.d.ts} +56 -9
- package/dist/convert.d.ts +2 -2
- package/dist/convert.js +7 -7
- package/dist/data.d.ts +2 -2
- package/dist/data.js +2 -2
- package/dist/{deck-report-DQMsvyBI.d.ts → deck-report-CKDNQ2t4.d.ts} +2 -2
- package/dist/deck.d.ts +5 -5
- package/dist/deck.js +11 -11
- package/dist/diagram-engine-eager.js +6 -0
- package/dist/diagram-engine-lazy.js +2 -0
- package/dist/diff.js +4 -4
- package/dist/docs.js +25 -19
- package/dist/examples.js +4759 -995
- package/dist/format.js +2 -2
- package/dist/ids.js +4 -4
- package/dist/index.d.ts +15 -12
- package/dist/index.js +23 -22
- package/dist/markdown.d.ts +2 -2
- package/dist/markdown.js +8 -8
- package/dist/node-engine.d.ts +6 -6
- package/dist/node-engine.js +20 -20
- package/dist/{pagination-DyAKYpXu.d.ts → pagination-DRZ_JNFY.d.ts} +74 -4
- package/dist/pagination.d.ts +3 -3
- package/dist/pagination.js +4 -4
- package/dist/patch.js +3 -3
- package/dist/precompiled.js +2 -2
- package/dist/{presentation-8jLSTFqL.d.ts → presentation-DnD7mfmf.d.ts} +106 -27
- package/dist/repo-readme.js +1 -1
- package/dist/schema-engine-ajv.js +1 -1
- package/dist/schema-engine-precompiled.js +2 -2
- package/dist/schema.js +3 -3
- package/dist/schemas.d.ts +6 -0
- package/dist/schemas.js +1 -1
- package/dist/source.d.ts +4 -3
- package/dist/source.js +10 -10
- package/dist/spec/schemas/layout.schema.json +58 -8
- package/dist/spec/schemas/narrative.schema.json +2 -1
- package/dist/spec/schemas/opf.schema.json +122 -23
- package/dist/spec/schemas/theme.schema.json +9 -3
- package/dist/types.d.ts +69 -18
- package/dist/{validation-types-mNmfcY9A.d.ts → validation-types-DxyYPebs.d.ts} +1 -1
- package/dist/validator.d.ts +4 -4
- package/dist/validator.js +3 -3
- package/dist/yaml.d.ts +2 -2
- package/dist/yaml.js +7 -7
- package/package.json +15 -6
- package/dist/chunk-W3SEWSO5.js +0 -8043
- package/dist/chunk-ZROVYWGU.js +0 -1
- package/dist/composition-C-hd_Ci3.d.ts +0 -3207
- package/dist/conversion-7OPM5MMJ.js +0 -24
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { original } from './chunk-JBARNYFR.js';
|
|
2
|
-
import { schemas, schemaEntries } from './chunk-
|
|
3
|
-
import { promotedRegionKeys, VARIABLE_KINDS, resolveChartData, chartPaletteForFill, chartSeriesPalette,
|
|
2
|
+
import { schemas, schemaEntries } from './chunk-LEF4X4KI.js';
|
|
3
|
+
import { promotedRegionKeys, VARIABLE_KINDS, resolveChartData, chartPaletteForFill, chartSeriesPalette, chartSchemeSeries, CHART_SERIES_MIN_LIGHTNESS_STEP, normalizeHexColor, resolveChartColors, colorContrast, imageBackground, CODE_NOMINAL_SIZE, QUOTE_NOMINAL_SIZE, TABLE_NOMINAL_SIZE, LIST_NOMINAL_SIZE, PROSE_NOMINAL_SIZE, quoteMarksFor, quoteLanguage, emphasisSurface, textInkBox, tableGrid, metricValueColor, timelineTextColor, LOGO_SHAPES, visitContentPayloads, readingRows, visualReadingOrder, intrinsicImageSize, resolveReference, layoutTable, resolveColorRef, resolveDesignRecords, resolveFontFamilies, checkCatalogsOption, provenanceOf, unresolvedReference, OPFUnresolvedReferenceError, resolveColorRoles, layoutVariantApplies, resolveCanvasDimensions, resolveSlideVariables, layoutColorVariant, deckBackgroundIsFixed, normalizeColorVariant, isRecord, hasContentVariables, isTemplate, instantiateForValidation, layoutTemplateIssues, resolveScriptFonts, defaultSlideBackground, catalogReferenceSites, parseReference, catalogGroupDeclared, pointerPath, unusedDatasets, MAX_COMPOSITION_DEPTH, datasetDiagnostics, pathFor, catalogRecords, collectCitations, numberingFindings, walkCitationRuns, chartDrawDiagnostics, resolveTableData, resolveChartOptions, chartOptionTarget, codeHighlightLines, chartNumberFixesByCell, catalogKinds, catalogGroupSource, registeredCatalog, OPFCompositionError, composeSlide } from './chunk-NVAJASOD.js';
|
|
4
4
|
import { schemaEngine } from '#schema-engine';
|
|
5
5
|
import { parseTree, printParseErrorCode, getNodePath } from 'jsonc-parser';
|
|
6
6
|
|
|
@@ -115,8 +115,8 @@ function bestMatchErrors(engine, rootId, errors) {
|
|
|
115
115
|
if (analysis) analyses.push(analysis);
|
|
116
116
|
}
|
|
117
117
|
if (!analyses.length) return errors;
|
|
118
|
-
const
|
|
119
|
-
const outer = analyses.filter((analysis) => !analyses.some((other) =>
|
|
118
|
+
const within2 = (inner, other) => other !== inner && [...inner.span].every((entry2) => other.span.has(entry2)) && (other.span.size > inner.span.size || errors.indexOf(other.union) > errors.indexOf(inner.union));
|
|
119
|
+
const outer = analyses.filter((analysis) => !analyses.some((other) => within2(analysis, other)));
|
|
120
120
|
const replaced = new Map(outer.map((analysis) => [analysis.union, analysis]));
|
|
121
121
|
const drop = new Set(outer.flatMap((analysis) => [...analysis.span]));
|
|
122
122
|
const result = [];
|
|
@@ -277,9 +277,13 @@ var contentKindSpecs = {
|
|
|
277
277
|
timeline: {
|
|
278
278
|
fields: ["timeline"],
|
|
279
279
|
required: ["timeline"]
|
|
280
|
+
},
|
|
281
|
+
diagram: {
|
|
282
|
+
fields: ["diagram"],
|
|
283
|
+
required: ["diagram"]
|
|
280
284
|
}
|
|
281
285
|
};
|
|
282
|
-
var captionableKinds = /* @__PURE__ */ new Set(["image", "chart", "table", "video"]);
|
|
286
|
+
var captionableKinds = /* @__PURE__ */ new Set(["image", "chart", "table", "video", "diagram"]);
|
|
283
287
|
var imageOptionFields = ["fit", "focus", "aspectRatio", "shape", "cornerRadius", "border", "opacity", "recolor", "overlay", "placement"];
|
|
284
288
|
var columnSpans = {
|
|
285
289
|
left: [0],
|
|
@@ -361,6 +365,7 @@ function inferredKinds(value) {
|
|
|
361
365
|
if (hasOwn(value, "metric")) kinds.push("metric");
|
|
362
366
|
if (hasOwn(value, "quote")) kinds.push("quote");
|
|
363
367
|
if (hasOwn(value, "timeline")) kinds.push("timeline");
|
|
368
|
+
if (hasOwn(value, "diagram")) kinds.push("diagram");
|
|
364
369
|
return kinds;
|
|
365
370
|
}
|
|
366
371
|
function isImplicitBlocksComposition(value, inferred, options2) {
|
|
@@ -698,7 +703,11 @@ function dataIssues(value) {
|
|
|
698
703
|
};
|
|
699
704
|
add(datasetDiagnostics(value));
|
|
700
705
|
const payload = (node, path) => {
|
|
701
|
-
if (isRecord(node.chart))
|
|
706
|
+
if (isRecord(node.chart)) {
|
|
707
|
+
const resolved = resolveChartData(node.chart, value, { path: pathFor(path, "chart") });
|
|
708
|
+
add(resolved.diagnostics);
|
|
709
|
+
add(chartDrawDiagnostics(node.chart, resolved, pathFor(path, "chart"), { language: typeof value.language === "string" ? value.language : void 0 }));
|
|
710
|
+
}
|
|
702
711
|
if (isRecord(node.table)) add(resolveTableData(node.table, value, { path: pathFor(path, "table") }).diagnostics);
|
|
703
712
|
};
|
|
704
713
|
value.slides.forEach((slide, index) => {
|
|
@@ -1143,6 +1152,9 @@ function colorDifference(a, b) {
|
|
|
1143
1152
|
const [l1, a1, b1] = lab(a), [l2, a2, b2] = lab(b);
|
|
1144
1153
|
return Math.hypot(l1 - l2, a1 - a2, b1 - b2);
|
|
1145
1154
|
}
|
|
1155
|
+
function lightnessDifference(a, b) {
|
|
1156
|
+
return Math.abs(lab(a)[0] - lab(b)[0]);
|
|
1157
|
+
}
|
|
1146
1158
|
var CVD_MATRICES = {
|
|
1147
1159
|
// Machado, Oliveira and Fernandes (2009), severity 1.0, applied to linear sRGB.
|
|
1148
1160
|
protanopia: [
|
|
@@ -1271,15 +1283,23 @@ function colorChoice(levels, scheme, variables = {}) {
|
|
|
1271
1283
|
}
|
|
1272
1284
|
return {};
|
|
1273
1285
|
}
|
|
1286
|
+
function colorLevels(slideDesign, layout, deckDesign, theme, scheme, variables = {}) {
|
|
1287
|
+
if (!layoutColorVariant(layout) || deckBackgroundIsFixed(deckDesign, theme.background)) return [slideDesign, deckDesign, theme];
|
|
1288
|
+
const below = colorChoice([deckDesign, theme], scheme, variables);
|
|
1289
|
+
const deck = resolveColorRoles(scheme, { background: below.background, variant: below.variant });
|
|
1290
|
+
const variant = layoutColorVariant(layout, { background: deck.map.bg1, dark: deck.dark });
|
|
1291
|
+
const accents = variant.accents ?? below.variant?.accents;
|
|
1292
|
+
return [slideDesign, { variant: accents ? { ...variant, accents } : variant }, deckDesign, theme];
|
|
1293
|
+
}
|
|
1274
1294
|
function resolveDesign(document, index, context) {
|
|
1275
|
-
const deck = rec(document.design), own4 = rec(rec(
|
|
1295
|
+
const deck = rec(document.design), own4 = rec(rec(Array.isArray(document.slides) ? document.slides[index] : void 0).design);
|
|
1276
1296
|
const { options: options2, diagnostics, resolved } = context;
|
|
1277
1297
|
const { theme, colorScheme, fontScheme, fontSchemePath } = resolved;
|
|
1278
1298
|
const fontPath = `/${fontSchemePath.split(".").join("/")}`;
|
|
1279
1299
|
const fontDiagnostic = diagnostics.find((diagnostic) => diagnostic.kind === "fontSchemes");
|
|
1280
1300
|
const dimensions = { width: options2.width, height: options2.height };
|
|
1281
1301
|
const variables = rec(document.variables);
|
|
1282
|
-
const choice = colorChoice(
|
|
1302
|
+
const choice = colorChoice(colorLevels(own4, resolved.layout, deck, theme, colorScheme, variables), colorScheme, variables);
|
|
1283
1303
|
const roles = resolveColorRoles(colorScheme, { background: choice.background, variant: choice.variant });
|
|
1284
1304
|
const dark = roles.dark;
|
|
1285
1305
|
const text2 = roles.text;
|
|
@@ -1359,7 +1379,8 @@ function backdropColors(backdrop, box, size, layer) {
|
|
|
1359
1379
|
}
|
|
1360
1380
|
case "image": {
|
|
1361
1381
|
const opacity = layer?.opacity ?? backdrop.opacity;
|
|
1362
|
-
const
|
|
1382
|
+
const ramp = layer?.grays ? [.../* @__PURE__ */ new Set([layer.grays[0], ...[0, 32, 64, 96, 128, 160, 192, 224, 255].filter((v) => v > layer.grays[0] && v < layer.grays[1]), layer.grays[1]])].map((v) => toHex([v, v, v])) : GREY_RAMP;
|
|
1383
|
+
const colors = ramp.map((grey) => {
|
|
1363
1384
|
let color = blend(grey, backdrop.base, opacity);
|
|
1364
1385
|
if (layer?.overlay) color = blend(layer.overlay.color, color, layer.overlay.opacity);
|
|
1365
1386
|
return color;
|
|
@@ -1588,6 +1609,7 @@ var formatRules = [
|
|
|
1588
1609
|
rule("number-format-invalid", "format", "error", "A number format cannot be read.", "A format code that no engine can parse is drawn as the plain number or fails to export.", { standard: "Excel number format codes, as far as OPF supports them" }),
|
|
1589
1610
|
rule("variable-invalid-value", "format", "error", "A variable value does not match its declared type.", "A number variable given text, or a date given a non-date, cannot be filled into the deck.", { standard: SCHEMA }),
|
|
1590
1611
|
rule("variable-unknown-builtin", "format", "error", "A token names a built-in variable that does not exist.", "The `deck.`, `speaker.`, `organization.` and `slide.` names (and `speakers`) are reserved for built-in variables; a name under them that is not a built-in can never be filled, so the token would show literally. The slide-scoped `slide.number`, `slide.section` and `deck.slideCount` are inline tokens only, so `var:slide.*` and `var:deck.slideCount` are reported too; organization logos are whole-field references only (`var:organization.logo.icon`), so a `{{organization.logo}}` token, an unknown logo shape or an unknown organization id is reported.", { standard: SCHEMA }),
|
|
1612
|
+
rule("table-highlight-unknown-name", "format", "error", "A table highlight names a row the table does not have.", "`table.highlight` emphasizes body rows by their first-column text; a name that matches no row highlights nothing, so the table is not drawn as authored.", { standard: SCHEMA }),
|
|
1591
1613
|
rule("chart-highlight-unknown-name", "format", "error", "A chart highlight names a series or category the chart does not have.", "`chart.highlight` emphasises marks by name; a name that matches no series or category in the chart data highlights nothing, so the chart is not drawn as authored.", { standard: SCHEMA }),
|
|
1592
1614
|
rule("variable-format", "format", "error", "A variable cannot be formatted.", "A number or date format that does not apply to the value leaves the token unreadable.", { standard: SCHEMA }),
|
|
1593
1615
|
rule(
|
|
@@ -1645,7 +1667,7 @@ var referenceRules = [
|
|
|
1645
1667
|
"references",
|
|
1646
1668
|
"error",
|
|
1647
1669
|
"A layout template's regions are not valid.",
|
|
1648
|
-
"Region names are unique across the whole record and may not be tag, auto or a promoted-region word (left, center, right, top, middle, bottom), so a Markdown block's region= stays unambiguous; title and subtitle name the heading regions, which take only a size; a subtitle region needs a title region; a region accepts at least one content kind; a region with flow 'none' holds one block; overflowRegion must name a body region. composeSlide refuses such a record.",
|
|
1670
|
+
"Region names are unique across the whole record and may not be tag, auto or a promoted-region word (left, center, right, top, middle, bottom), so a Markdown block's region= stays unambiguous; title and subtitle name the heading regions, which take only a size, an anchor and (the title) a rule; a subtitle region needs a title region; a region accepts at least one content kind; a region with flow 'none' holds one block; overflowRegion must name a body region. composeSlide refuses such a record.",
|
|
1649
1671
|
{ standard: "spec/schemas/layout.schema.json and the region rules (docs/layout-templates.md)" }
|
|
1650
1672
|
),
|
|
1651
1673
|
rule(
|
|
@@ -1696,6 +1718,7 @@ var dataRules = [
|
|
|
1696
1718
|
),
|
|
1697
1719
|
rule("chart-mapping-adapted", "content", "warning", "A chart mapping entry is ignored.", "A mapping that names a column the chart type cannot use is left out of the chart.", { standard: SCHEMA }),
|
|
1698
1720
|
rule("chart-highlight-adapted", "content", "warning", "A chart highlight is adapted by the chart type.", "A highlight the chart type cannot show as authored (a category highlight on a chart without categories, for example) is adapted by every engine, so the emphasis is not exactly what was written.", { standard: SCHEMA }),
|
|
1721
|
+
rule("chart-series-dropped", "content", "warning", "A chart series is not drawn by the chart type.", "A treemap, histogram, Pareto, waterfall, funnel, map or single-series pie plots one value series, and a scatter plots no X column without numbers. Every engine leaves the same columns out (LH-60), so the warning names them instead of losing them silently.", { standard: SCHEMA, approximations: "Read from the drawn chart (chartDrawPlan): a world chart over categories that are mostly not places is drawn as columns, a box-and-whisker chart with one value per category as one box per series and a pie or doughnut of several series as nested rings, and none of those drops a series." }),
|
|
1699
1722
|
rule("code-highlight-out-of-range", "content", "warning", "A code highlight marks a line the code does not have.", "Marked lines count from 1 by line break in code.source; an entry past the last line marks nothing.", { standard: SCHEMA }),
|
|
1700
1723
|
rule("code-highlight-range-reversed", "content", "warning", "A code highlight range ends before it starts.", "A range written end before start marks nothing; write the smaller line number first.", { standard: SCHEMA }),
|
|
1701
1724
|
rule("variable-builtin-missing", "content", "warning", "A built-in variable has no value in this document.", "A `{{deck.*}}`, `{{speaker.*}}` or `{{organization.*}}` token whose field the document does not set resolves to nothing, so the text shows a gap; a `var:organization.logo` reference to an organization without a logo draws no image. `{{slide.section}}` is checked per slide: a slide without a `section` that uses it, in its own text or in the header or footer it inherits, is reported at that slide.", { standard: SCHEMA }),
|
|
@@ -1719,13 +1742,13 @@ var onImageRule = rule(
|
|
|
1719
1742
|
"text-on-image",
|
|
1720
1743
|
"accessibility",
|
|
1721
1744
|
"info",
|
|
1722
|
-
"Text sits on a background picture
|
|
1723
|
-
"Contrast over a photograph depends on the photograph.
|
|
1745
|
+
"Text sits on a background picture: a note when core draws its automatic scrim behind it, otherwise its contrast cannot be guaranteed.",
|
|
1746
|
+
"Contrast over a photograph depends on the photograph. Core draws an automatic scrim behind text on a picture background that has no overlay, at the lowest opacity that keeps it at 4.5:1 over any picture, and this note names it. With an edge-band overlay, or the scrim turned off (overlay: false), only a full-frame overlay that guarantees readability for every possible image certifies the result from the document.",
|
|
1724
1747
|
{
|
|
1725
1748
|
standard: "WCAG 2.2 SC 1.4.3 Contrast (Minimum), level AA",
|
|
1726
1749
|
thresholds: ["contrastNormal", "contrastLarge"],
|
|
1727
1750
|
cost: "composition",
|
|
1728
|
-
approximations: "Core
|
|
1751
|
+
approximations: "Core reads picture pixels only through a host that measures them (ComposeSlideOptions.pictureLuminance). Otherwise the picture is bounded by a gray ramp from black to white, composited through the image opacity and a full-frame design.background overlay or the automatic scrim over the text it covers; the text passes only when every step of that ramp passes. An edge-banded overlay is not counted."
|
|
1729
1752
|
}
|
|
1730
1753
|
);
|
|
1731
1754
|
var altRule = rule(
|
|
@@ -1792,7 +1815,7 @@ var chartColorRule = rule(
|
|
|
1792
1815
|
{
|
|
1793
1816
|
standard: "WCAG 2.2 SC 1.4.1 Use of Color, level A",
|
|
1794
1817
|
thresholds: ["minSeriesColorDifference"],
|
|
1795
|
-
approximations: "Uses the engine's series palette (ValidateOptions.chartPalette; default chartSeriesPalette of each slide
|
|
1818
|
+
approximations: "Uses the engine's series palette (ValidateOptions.chartPalette; default chartSeriesPalette of each slide color scheme (accent1 to accent6, then their tints), adjusted for the slide background and softened like the engines draw them, LH-105) in series order: series i takes colour i, pie/doughnut/treemap/funnel slices take colours per category. Pairs are compared by CIE76 distance after simulating protanopia, deuteranopia, tritanopia (Machado 2009, severity 1) and greyscale. Neighbouring series (and neighbouring slices, the last beside the first) must also differ by at least 11 in CIE L* (the lightness step the engines keep when they adjust a palette), since lightness is the cue left without hue (LH-35); a pair under it is reported as a lightness pair. Single-series charts and chart types without a series legend are skipped."
|
|
1796
1819
|
}
|
|
1797
1820
|
);
|
|
1798
1821
|
var chartAltRule = rule(
|
|
@@ -1808,10 +1831,10 @@ var chartColorsRule = rule(
|
|
|
1808
1831
|
"accessibility",
|
|
1809
1832
|
"warning",
|
|
1810
1833
|
"A chart colour cannot be used as authored.",
|
|
1811
|
-
"`chart.colors` sets the colour of series 1, 2, 3 and so on. A colour that cannot be resolved (a `var:` colour variable the deck does not define, or a name that is not a colour) is ignored and the deck palette colour of that position is used. A colour with under 3:1 contrast against the chart
|
|
1834
|
+
"`chart.colors` sets the colour of series 1, 2, 3 and so on. A colour that cannot be resolved (a `var:` colour variable the deck does not define, or a name that is not a colour) is ignored and the deck palette colour of that position is used. A colour with under 3:1 contrast against the slide background the chart stands on is kept for its hue but drawn lighter or darker, so the chart does not show the colour that was written.",
|
|
1812
1835
|
{
|
|
1813
1836
|
standard: "WCAG 2.2 SC 1.4.11 Non-text Contrast, level AA",
|
|
1814
|
-
approximations: "Resolves each entry like any colour reference (hex, colour-scheme slot or role, `var:` variable) against the slide's scheme and compares it with the chart panel
|
|
1837
|
+
approximations: "Resolves each entry like any colour reference (hex, colour-scheme slot or role, `var:` variable) against the slide's scheme and compares it with the slide background (no chart has a panel, LH-105; a chart in a card stands on the card, which is not measured) by WCAG contrast; 3:1 is the threshold the engines enforce. Translucent colours and unresolved backgrounds are not measured. Colours that look alike to colour-vision deficiency are reported by opf/chart-color-only, which judges the authored colours."
|
|
1815
1838
|
}
|
|
1816
1839
|
);
|
|
1817
1840
|
var languageRule = rule(
|
|
@@ -1969,6 +1992,94 @@ var languageTagRule = rule(
|
|
|
1969
1992
|
approximations: "Checks the root `language` (a tag string, or the `bcp47` of an inline Language object) and `lang` on the TextRun objects of titles, subtitles, tags, text, lists, tables, quotes, metrics and timelines. A region is assigned when the runtime's CLDR data names it (ISO 3166-1 codes and UN M.49 areas such as 419); private-use regions (`AA`, `QM`-`QZ`, `XA`-`XZ`) and `ZZ` are accepted, as are private-use (`x-...`) tags. Only the spelling of a tag is checked, not whether the language subtag is assigned or whether the language suits the text. The schema rejects tags with characters other than letters, digits and hyphens (`en_US` is a schema error, with no suggestion), and `en-UK` as the deck language is already an error of the schema rule, so those are not reported twice."
|
|
1970
1993
|
}
|
|
1971
1994
|
);
|
|
1995
|
+
var SHRUNK_RATIO = 0.7;
|
|
1996
|
+
var CENTERED_BODY_LINES = 2;
|
|
1997
|
+
var CENTERED_BODY_CHARACTERS = 120;
|
|
1998
|
+
var CENTERED_NOTE_CHARACTERS = 80;
|
|
1999
|
+
var TIGHT_GAP_INCHES = 0.25;
|
|
2000
|
+
var TIGHT_MARGIN_INCHES = 0.5;
|
|
2001
|
+
var MONOTONY_RUN = 4;
|
|
2002
|
+
var textShrunkRule = rule(
|
|
2003
|
+
"text-shrunk",
|
|
2004
|
+
"layout",
|
|
2005
|
+
"info",
|
|
2006
|
+
`Text is fitted far below its role's starting size (under ${SHRUNK_RATIO * 100}%).`,
|
|
2007
|
+
"Composition starts each type role at a size meant to be read across a room (prose 28 px, a list 32 px, a table 25 px, a quote 40 px, code 22 px on the 720 px reference slide) and shrinks text that does not fit. Text that ends far below that size still fits, but the slide carries more than it can show at a comfortable size; it is usually two slides.",
|
|
2008
|
+
{
|
|
2009
|
+
cost: "composition",
|
|
2010
|
+
standard: `The type roles of composition (docs/dynamic-composition.md); the fitted size composeSlide computed, compared with ${SHRUNK_RATIO} of the role size.`,
|
|
2011
|
+
approximations: "Reads the fitted size of text and list blocks, the quote body, the code body and the smallest body cell of a table, on the 720 px reference slide. Headings, metrics and timelines have their own scales and are not checked. A block whose runs set `fontSize` is the author's choice and is skipped; text that overflows is opf/text-overflow. One finding per slide, at the block shrunk the most; `measured.blocks` counts the shrunk blocks."
|
|
2012
|
+
}
|
|
2013
|
+
);
|
|
2014
|
+
var centeredBodyRule = rule(
|
|
2015
|
+
"centered-body",
|
|
2016
|
+
"layout",
|
|
2017
|
+
"info",
|
|
2018
|
+
`A paragraph or list of more than ${CENTERED_BODY_LINES} lines or ${CENTERED_BODY_CHARACTERS} characters is centered.`,
|
|
2019
|
+
"Each line of centered text starts at a different place, so the eye has to search for the next line. Centering suits a title, a metric or a statement of a line or two; a paragraph or a list reads faster from a straight start edge.",
|
|
2020
|
+
{
|
|
2021
|
+
cost: "composition",
|
|
2022
|
+
standard: `Typographic convention for running text: a straight start edge. The alignment and the line count are those composeSlide computed; more than ${CENTERED_BODY_LINES} lines or ${CENTERED_BODY_CHARACTERS} characters.`,
|
|
2023
|
+
approximations: "Checks text and list blocks whose composed alignment is center. Titles, subtitles, tags, metrics, quotes and timelines are not checked, nor a short note of at most 80 characters, whatever it wraps to in a narrow cell. A text block alone on the slide or alone in its layout region (a statement, or the note of the metrics layout) is reported only past 3 lines, and on a cover, section or closing layout not at all. One finding per slide, at the longest block; `measured.blocks` counts the long centered blocks."
|
|
2024
|
+
}
|
|
2025
|
+
);
|
|
2026
|
+
var tightSpacingRule = rule(
|
|
2027
|
+
"tight-spacing",
|
|
2028
|
+
"layout",
|
|
2029
|
+
"info",
|
|
2030
|
+
`Blocks are closer than ${TIGHT_GAP_INCHES} in to each other or ${TIGHT_MARGIN_INCHES} in to the slide edge.`,
|
|
2031
|
+
"Space between blocks tells the audience which things belong together, and a margin keeps content clear of the edge that projectors, screen-sharing and printing crop. Blocks closer together than the engine's own default gap read as one crowded block.",
|
|
2032
|
+
{
|
|
2033
|
+
cost: "composition",
|
|
2034
|
+
standard: `Measured on the composed boxes (the card frame, the picture frame, else the cell) of sibling blocks and groups, on the 13.33 x 7.5 in reference slide: a gap under ${TIGHT_GAP_INCHES} in (the default gap is 1/30 of the short side, 0.25 in) or a margin under ${TIGHT_MARGIN_INCHES} in (the default padding is 0.6 in).`,
|
|
2035
|
+
approximations: "Only a gap the author set is checked: `composition.gap` on the slide, its layout record or a group. Without one the default gap of the engine applies (1/30 of the shorter side of the container: 0.25 in on the slide, less in a short nested group) and is not reported. Only blocks of one parent are compared, and only when they face each other across one axis. Headings, header and footer furniture, pictures placed on a slide edge and blocks in a bleed region are exempt. A cell is measured, not the ink inside it, so text that does not fill its cell looks further apart than reported. At most one gap and one margin finding per slide, the tightest of each."
|
|
2036
|
+
}
|
|
2037
|
+
);
|
|
2038
|
+
var layoutMonotonyRule = rule(
|
|
2039
|
+
"layout-monotony",
|
|
2040
|
+
"layout",
|
|
2041
|
+
"info",
|
|
2042
|
+
`${MONOTONY_RUN} or more content slides in a row use the same layout record.`,
|
|
2043
|
+
"A run of slides with one arrangement looks the same from slide to slide, so the audience stops noticing that the content changed. The structure of the content (a comparison, a sequence, a number, a picture) usually asks for different layouts.",
|
|
2044
|
+
{
|
|
2045
|
+
standard: `Counted on the slide sequence: ${MONOTONY_RUN} or more consecutive visible slides with body content and the same \`layout\`.`,
|
|
2046
|
+
approximations: "Compares the layout reference of each slide (a catalog prefix is ignored). Cover, section and closing slides, slides with no body content and slides without a layout record (automatic composition) break a run and are not counted; hidden slides are skipped. One finding per run, at its first slide."
|
|
2047
|
+
}
|
|
2048
|
+
);
|
|
2049
|
+
var straightQuotesRule = rule(
|
|
2050
|
+
"straight-quotes",
|
|
2051
|
+
"content",
|
|
2052
|
+
"info",
|
|
2053
|
+
`Text uses straight quotation marks (" or ') where the language has typographic ones.`,
|
|
2054
|
+
"Straight marks are a typewriter substitute. Typeset text uses the quotation marks of its language (\u201C\u2026\u201D in English, \xAB\u2026\xBB in French, \u201E\u2026\u201C in German), and a deck that mixes them with the marks the engine draws around quotes looks unfinished.",
|
|
2055
|
+
{
|
|
2056
|
+
standard: "The quotation marks of the deck language, as the engines draw them around a quote (QUOTE_MARKS in core).",
|
|
2057
|
+
approximations: "Checks titles, subtitles, tags, body text, list items and descriptions, and quotes; not table cells, metrics, timelines, code or runs with `code: true`. A `\"` after a digit is an inch mark and a `'` between letters or after a digit is an apostrophe or a foot mark; single quotes count only as a pair around words. A language with no typographic marks of its own (one OPF draws ASCII quotes for) is not checked. When only double quotes are found, the finding carries a patch to the language's marks."
|
|
2058
|
+
}
|
|
2059
|
+
);
|
|
2060
|
+
var PIE_MAX_SLICES = 5;
|
|
2061
|
+
var chartDualAxisRule = rule(
|
|
2062
|
+
"chart-dual-axis",
|
|
2063
|
+
"content",
|
|
2064
|
+
"info",
|
|
2065
|
+
"A combo chart plots a series on a secondary value axis.",
|
|
2066
|
+
"Two value scales in one plot invite the reader to compare heights that are not comparable: where the lines cross, and which is higher, depends only on how each axis was scaled. Two charts side by side, each with its own axis, read more truly than one chart with two scales (Few, Show Me the Numbers).",
|
|
2067
|
+
{
|
|
2068
|
+
standard: "Stephen Few, Show Me the Numbers (2012), on dual-scaled graphs.",
|
|
2069
|
+
approximations: "Reports a `combo` chart whose `secondaryAxis` names at least one plotted line series (the axis core resolves). A combo chart on one axis is not reported."
|
|
2070
|
+
}
|
|
2071
|
+
);
|
|
2072
|
+
var chartPieManySlicesRule = rule(
|
|
2073
|
+
"chart-pie-many-slices",
|
|
2074
|
+
"content",
|
|
2075
|
+
"info",
|
|
2076
|
+
`A pie or doughnut chart has more than ${PIE_MAX_SLICES} slices.`,
|
|
2077
|
+
"People compare angles and areas poorly, and past a few slices the small ones cannot be told apart or labelled. Bars along one axis show the same parts of a whole and let them be compared and ranked (Few, Show Me the Numbers).",
|
|
2078
|
+
{
|
|
2079
|
+
standard: `Stephen Few, Show Me the Numbers (2012), on pie charts; more than ${PIE_MAX_SLICES} categories.`,
|
|
2080
|
+
approximations: "Counts the rows (categories) of a `pie` or `doughnut` chart as its data resolves; a doughnut of several series (nested rings) counts the categories of a ring. Treemaps and funnels are not checked."
|
|
2081
|
+
}
|
|
2082
|
+
);
|
|
1972
2083
|
var implementedRules = [
|
|
1973
2084
|
contrastRule,
|
|
1974
2085
|
onImageRule,
|
|
@@ -1997,7 +2108,14 @@ var implementedRules = [
|
|
|
1997
2108
|
emptyTextRule,
|
|
1998
2109
|
unusedBeatRule,
|
|
1999
2110
|
emptySlideRule,
|
|
2000
|
-
languageTagRule
|
|
2111
|
+
languageTagRule,
|
|
2112
|
+
textShrunkRule,
|
|
2113
|
+
centeredBodyRule,
|
|
2114
|
+
tightSpacingRule,
|
|
2115
|
+
layoutMonotonyRule,
|
|
2116
|
+
straightQuotesRule,
|
|
2117
|
+
chartDualAxisRule,
|
|
2118
|
+
chartPieManySlicesRule
|
|
2001
2119
|
];
|
|
2002
2120
|
var infos = [...formatRules, ...referenceRules, ...policyRules, ...dataRules, ...implementedRules];
|
|
2003
2121
|
var validationRules = Object.freeze(
|
|
@@ -2028,38 +2146,31 @@ var isLarge = (sizePx, bold) => {
|
|
|
2028
2146
|
const pt = sizePx * PX_TO_PT;
|
|
2029
2147
|
return pt >= 18 || bold && pt >= 14;
|
|
2030
2148
|
};
|
|
2149
|
+
var within = (box, area) => box.x >= area.x - 0.5 && box.y >= area.y - 0.5 && box.x + box.width <= area.x + area.width + 0.5 && box.y + box.height <= area.y + area.height + 0.5;
|
|
2031
2150
|
function slideBackdrop(context, box) {
|
|
2032
2151
|
const { design, composition } = context;
|
|
2033
2152
|
const image = composition?.backgroundImage;
|
|
2034
2153
|
if (image) {
|
|
2035
|
-
const
|
|
2036
|
-
|
|
2154
|
+
const scrim = box ? image.scrims?.find((entry2) => within(box, entry2.text)) : void 0;
|
|
2155
|
+
const overlay = image.overlay && !image.overlay.edge ? { color: resolveTextColor(image.overlay.color, design, "#000000") ?? "#000000", opacity: image.overlay.opacity } : scrim ? { color: scrim.color, opacity: scrim.opacity } : void 0;
|
|
2156
|
+
return backdropColors({ kind: "image", opacity: image.opacity ?? 1, base: "#FFFFFF" }, box, design.dimensions, { overlay, ...scrim?.grays ? { grays: scrim.grays } : {} });
|
|
2037
2157
|
}
|
|
2038
2158
|
return backdropColors(design.backdrop, box, design.dimensions);
|
|
2039
2159
|
}
|
|
2040
|
-
function inkBox(item, measurement) {
|
|
2041
|
-
const fit = item.text;
|
|
2042
|
-
if (!fit || !Array.isArray(fit.lines) || !fit.lines.length || !item.textStyle || item.quoteLayout || item.metricLayout || item.timelineLayout) return item.box;
|
|
2043
|
-
try {
|
|
2044
|
-
const measure = textWidthMeasurer(item.textStyle, measurement);
|
|
2045
|
-
const width = Math.min(item.box.width, Math.max(...fit.lines.map((line2) => measure(line2, fit.fontSize))));
|
|
2046
|
-
const height = Math.min(item.box.height, fit.lines.length * fit.lineHeight);
|
|
2047
|
-
const x = item.alignment === "center" ? item.box.x + (item.box.width - width) / 2 : item.alignment === "right" ? item.box.x + item.box.width - width : item.box.x;
|
|
2048
|
-
return { x, y: item.box.y, width, height };
|
|
2049
|
-
} catch {
|
|
2050
|
-
return item.box;
|
|
2051
|
-
}
|
|
2052
|
-
}
|
|
2053
2160
|
function collectSamples(context) {
|
|
2054
2161
|
const measurement = context.measurement;
|
|
2055
2162
|
const { design, composition } = context;
|
|
2056
2163
|
if (!composition) return [];
|
|
2057
2164
|
const samples = [];
|
|
2058
|
-
const surface = { colors: [design.
|
|
2165
|
+
const surface = { colors: [design.neutrals.card.hex], unknown: false };
|
|
2166
|
+
const emphasis = composition.emphasis ? emphasisSurface(design.colorScheme, { dark: design.dark, map: design.map, background: design.colors.background }) : void 0;
|
|
2167
|
+
const surfaceDesign = emphasis ? { ...design, colors: { ...design.colors, background: emphasis.fill, surface: emphasis.roles.surface, text: emphasis.roles.text, mutedText: emphasis.roles.textSecondary, primary: emphasis.roles.primary, secondary: emphasis.roles.secondary, accent: emphasis.roles.accent } } : void 0;
|
|
2168
|
+
const emphasisBackdrop = emphasis ? { colors: [emphasis.fill], unknown: false } : void 0;
|
|
2059
2169
|
const scale = Math.min(design.dimensions.width, design.dimensions.height) / 720;
|
|
2060
2170
|
for (const item of composition.items) {
|
|
2171
|
+
const itemDesign = item.emphasis && surfaceDesign ? surfaceDesign : design;
|
|
2061
2172
|
if (["chart", "image", "video", "code"].includes(item.field) || item.type === "chart" || item.type === "image" || item.type === "video" || item.type === "code") continue;
|
|
2062
|
-
const backdrop = item.frameBox ? surface : slideBackdrop(context,
|
|
2173
|
+
const backdrop = item.emphasis && emphasisBackdrop ? emphasisBackdrop : item.frameBox ? surface : slideBackdrop(context, textInkBox(item, measurement));
|
|
2063
2174
|
const itemPath = pointerOfDotted(item.path);
|
|
2064
2175
|
const heading = item.field === "title" || item.field === "subtitle" || item.field === "tag";
|
|
2065
2176
|
const baseSize = (item.text?.fontSize ?? 25 * scale) / scale;
|
|
@@ -2069,20 +2180,20 @@ function collectSamples(context) {
|
|
|
2069
2180
|
const grid = tableGrid(item.value, item.path);
|
|
2070
2181
|
for (const row of grid.rows)
|
|
2071
2182
|
for (const cell of row) {
|
|
2072
|
-
const fillRef = resolveTextColor(cell.style.fill,
|
|
2073
|
-
const fill = fillRef || (cell.header ?
|
|
2183
|
+
const fillRef = resolveTextColor(cell.style.fill, itemDesign, "");
|
|
2184
|
+
const fill = fillRef || (cell.header ? itemDesign.colors.primary : itemDesign.colors.surface);
|
|
2074
2185
|
const cellBackdrop = { colors: [fill], unknown: false };
|
|
2075
2186
|
const cellPath = pointerOfDotted(cell.valuePath);
|
|
2076
2187
|
const stylePath = pointerOfDotted(cell.path) + "/style/color";
|
|
2077
2188
|
if (cell.style.color != null) {
|
|
2078
|
-
const color = resolveTextColor(cell.style.color,
|
|
2189
|
+
const color = resolveTextColor(cell.style.color, itemDesign, itemDesign.colors.text);
|
|
2079
2190
|
if (color) samples.push({ path: stylePath, color, sizePx: 15, bold: cell.header, backdrop: cellBackdrop, source: "override", colorPath: stylePath, label: "Table cell text" });
|
|
2080
2191
|
}
|
|
2081
2192
|
if (Array.isArray(cell.value))
|
|
2082
2193
|
cell.value.forEach((run, index) => {
|
|
2083
2194
|
const colorRef = rec(run).color;
|
|
2084
2195
|
if (typeof colorRef !== "string") return;
|
|
2085
|
-
const color = resolveTextColor(colorRef,
|
|
2196
|
+
const color = resolveTextColor(colorRef, itemDesign, itemDesign.colors.text);
|
|
2086
2197
|
if (color) samples.push({ path: `${cellPath}/${index}/color`, color, sizePx: rec(run).fontSize ? Number(rec(run).fontSize) / PX_TO_PT : 15, bold: Boolean(rec(run).bold) || cell.header, backdrop: cellBackdrop, source: "override", colorPath: `${cellPath}/${index}/color`, label: "Table cell text" });
|
|
2087
2198
|
});
|
|
2088
2199
|
}
|
|
@@ -2090,6 +2201,8 @@ function collectSamples(context) {
|
|
|
2090
2201
|
}
|
|
2091
2202
|
const parts2 = [];
|
|
2092
2203
|
const layoutOf = item.quoteLayout ?? item.metricLayout ?? item.timelineLayout;
|
|
2204
|
+
const valueColor = item.metricLayout ? metricValueColor(itemDesign.colors.primary, item.frameBox && !item.emphasis ? design.neutrals.card.hex : itemDesign.colors.background, itemDesign.colors.text) : itemDesign.colors.primary;
|
|
2205
|
+
const valueRole = (role) => role === "value" || role === "unit" && item.metricLayout?.arrangement === "inline-unit";
|
|
2093
2206
|
if (layoutOf)
|
|
2094
2207
|
for (const part of layoutOf.parts) {
|
|
2095
2208
|
if (!part.fit || part.visible === false) continue;
|
|
@@ -2097,11 +2210,11 @@ function collectSamples(context) {
|
|
|
2097
2210
|
parts2.push({
|
|
2098
2211
|
path: typeof part.path === "string" && part.path.startsWith("slides.") ? pointerOfDotted(part.path) : itemPath,
|
|
2099
2212
|
sizePx: part.fit.fontSize / scale,
|
|
2100
|
-
color: role === "footer" ?
|
|
2213
|
+
color: role === "footer" ? itemDesign.colors.mutedText : valueRole(role) && item.metricLayout ? valueColor : item.timelineLayout ? timelineTextColor(part, { background: itemDesign.colors.background, primary: itemDesign.colors.primary, text: itemDesign.colors.text, mutedText: itemDesign.colors.mutedText }) : itemDesign.colors.text,
|
|
2101
2214
|
label: item.field === "quote" ? role === "footer" ? "Quote attribution" : "Quote" : item.field === "metric" ? role === "value" ? "Metric value" : "Metric label" : "Timeline text"
|
|
2102
2215
|
});
|
|
2103
2216
|
}
|
|
2104
|
-
else parts2.push({ path: itemPath, sizePx: baseSize, color:
|
|
2217
|
+
else parts2.push({ path: itemPath, sizePx: baseSize, color: itemDesign.colors.text, label: heading || item.field === "text" ? label : item.field === "items" || item.field === "bullets" ? "List text" : label });
|
|
2105
2218
|
for (const part of parts2) samples.push({ path: part.path, color: part.color, sizePx: part.sizePx, bold, backdrop, source: "default", label: part.label });
|
|
2106
2219
|
const owners = textValues({ [item.field]: item.value }, "");
|
|
2107
2220
|
for (const owner of owners) {
|
|
@@ -2110,7 +2223,7 @@ function collectSamples(context) {
|
|
|
2110
2223
|
const base = pointer2(...splitPointer(itemPath), ...relative);
|
|
2111
2224
|
for (const run of runsOf({ ...owner, path: base })) {
|
|
2112
2225
|
if (typeof run.style.color !== "string") continue;
|
|
2113
|
-
const color = resolveTextColor(run.style.color,
|
|
2226
|
+
const color = resolveTextColor(run.style.color, itemDesign, itemDesign.colors.text);
|
|
2114
2227
|
if (!color) continue;
|
|
2115
2228
|
const size = typeof run.style.fontSize === "number" ? run.style.fontSize / PX_TO_PT : baseSize;
|
|
2116
2229
|
samples.push({ path: `${run.path}/color`, color, sizePx: size, bold: Boolean(run.style.bold) || bold, backdrop, source: "override", colorPath: `${run.path}/color`, label: "Coloured text" });
|
|
@@ -2142,7 +2255,7 @@ var contrastRules = [
|
|
|
2142
2255
|
path: sample.path,
|
|
2143
2256
|
slide,
|
|
2144
2257
|
message: `${sample.label} sits on a background picture. Contrast cannot be guaranteed from the document (against the lightest or darkest possible pixels it is as low as ${worst.ratio.toFixed(1)}:1; ${needed}:1 is needed at this size).`,
|
|
2145
|
-
help: "Add a full-frame overlay to the image background (design.background.overlay: a
|
|
2258
|
+
help: `${slide.composition?.backgroundImage?.overlay ? "Add" : "Remove overlay: false so core draws its automatic scrim behind the text, add"} a full-frame overlay to the image background (design.background.overlay: a color and an opacity high enough that text passes on any picture), use a solid or gradient background behind text, or place text on a card.`,
|
|
2146
2259
|
measured: { ratio: round(worst.ratio), needed, textColor: sample.color }
|
|
2147
2260
|
});
|
|
2148
2261
|
}
|
|
@@ -2172,6 +2285,17 @@ var contrastRules = [
|
|
|
2172
2285
|
});
|
|
2173
2286
|
if (sample.source === "default") aggregated.set(key2, { diagnostic, extra: 0 });
|
|
2174
2287
|
}
|
|
2288
|
+
const scrim = slide.composition?.backgroundImage?.scrims?.[0];
|
|
2289
|
+
if (scrim && !imageReported.done) {
|
|
2290
|
+
const background = slide.composition.backgroundImage.path;
|
|
2291
|
+
context.report(onImageRule, {
|
|
2292
|
+
path: /^(slides\.\d+\.)?design\.background$/.test(background) ? pointerOfDotted(background) : `${slide.path}/title`,
|
|
2293
|
+
slide,
|
|
2294
|
+
message: `Text sits on a background picture. Core draws an automatic scrim behind it (the slide background color ${scrim.color} at ${Math.round(scrim.opacity * 100)}%, ${scrim.form === "band" ? "a band across the text" : `a gradient from the ${scrim.edge} edge`}), so it reads at ${scrim.target}:1 or better over ${scrim.basis === "sampled" ? "the picture under it" : "any picture"}.`,
|
|
2295
|
+
help: "Set design.background.overlay to choose your own scrim, or overlay: false to show the picture without one; contrast then depends on the picture.",
|
|
2296
|
+
measured: { ratio: round(scrim.contrast), needed: scrim.target, scrimOpacity: scrim.opacity, textColor: slide.design.colors.text }
|
|
2297
|
+
});
|
|
2298
|
+
}
|
|
2175
2299
|
for (const { diagnostic, extra } of aggregated.values())
|
|
2176
2300
|
if (extra) {
|
|
2177
2301
|
diagnostic.message += ` ${extra} more text element${extra === 1 ? "" : "s"} on this slide ${extra === 1 ? "has" : "have"} the same problem.`;
|
|
@@ -2404,9 +2528,9 @@ var chartRules = [
|
|
|
2404
2528
|
const slices = perCategory.test(type);
|
|
2405
2529
|
const count = slices ? data.rows.length : data.columns.length - 1;
|
|
2406
2530
|
if (count < 2) continue;
|
|
2407
|
-
const surface = slide.design.colors.
|
|
2531
|
+
const surface = slide.design.colors.background;
|
|
2408
2532
|
const paletteContext = chartColorContext(slide.design);
|
|
2409
|
-
const palette = chartPaletteForFill(surface, context.chartPalette ?? chartSeriesPalette(slide.design.colorScheme, chart.colors, paletteContext), {
|
|
2533
|
+
const palette = chartPaletteForFill(surface, context.chartPalette ?? chartSeriesPalette(slide.design.colorScheme, chart.colors, paletteContext), { legible: context.chartPalette === void 0 ? chartSchemeSeries(chart.colors, slide.design.colorScheme, paletteContext) : void 0, soften: context.chartPalette === void 0 });
|
|
2410
2534
|
if (!palette.length) continue;
|
|
2411
2535
|
const used = Array.from({ length: Math.min(count, 24) }, (_, i) => palette[i % palette.length]);
|
|
2412
2536
|
const pairs = [];
|
|
@@ -2418,6 +2542,10 @@ var chartRules = [
|
|
|
2418
2542
|
if (difference < worst.difference) worst = { model, difference };
|
|
2419
2543
|
}
|
|
2420
2544
|
if (worst.difference < context.thresholds.minSeriesColorDifference) pairs.push({ a, b, ...worst });
|
|
2545
|
+
else if (b === a + 1 || slices && a === 0 && b === used.length - 1 && used.length > 2) {
|
|
2546
|
+
const lightness = lightnessDifference(used[a], used[b]);
|
|
2547
|
+
if (lightness < CHART_SERIES_MIN_LIGHTNESS_STEP) pairs.push({ a, b, model: "lightness", difference: lightness });
|
|
2548
|
+
}
|
|
2421
2549
|
}
|
|
2422
2550
|
const cycles = count > palette.length;
|
|
2423
2551
|
if (!pairs.length && !cycles) continue;
|
|
@@ -2441,7 +2569,7 @@ var chartRules = [
|
|
|
2441
2569
|
for (const payload of slidePayloads(slide.slide, slide.path)) {
|
|
2442
2570
|
const chart = rec(payload.node.chart);
|
|
2443
2571
|
if (!Array.isArray(chart.colors)) continue;
|
|
2444
|
-
const surface = normalizeHexColor(slide.design.colors.
|
|
2572
|
+
const surface = normalizeHexColor(slide.design.colors.background);
|
|
2445
2573
|
const resolved = resolveChartColors(chart.colors, slide.design.colorScheme, chartColorContext(slide.design));
|
|
2446
2574
|
resolved.forEach((color, index) => {
|
|
2447
2575
|
const path = `${payload.path === slide.path ? slide.path : payload.path}/chart/colors/${index}`;
|
|
@@ -2460,8 +2588,8 @@ var chartRules = [
|
|
|
2460
2588
|
context.report(chartColorsRule, {
|
|
2461
2589
|
path,
|
|
2462
2590
|
slide,
|
|
2463
|
-
message: `Chart colour ${index + 1} (${color}) has ${contrast.toFixed(1)}:1 contrast against the
|
|
2464
|
-
help: "Choose a colour that already has at least 3:1 contrast against the slide
|
|
2591
|
+
message: `Chart colour ${index + 1} (${color}) has ${contrast.toFixed(1)}:1 contrast against the slide background (${surface}); it is drawn lighter or darker to reach 3:1.`,
|
|
2592
|
+
help: "Choose a colour that already has at least 3:1 contrast against the slide background, so the chart shows the colour you wrote.",
|
|
2465
2593
|
measured: { contrast: round(contrast), panel: surface }
|
|
2466
2594
|
});
|
|
2467
2595
|
});
|
|
@@ -2828,7 +2956,7 @@ var contentRules = [
|
|
|
2828
2956
|
if (slide.slide.layout === "blank") continue;
|
|
2829
2957
|
const has = (value) => value !== void 0 && value !== null && !(typeof value === "string" && value.trim() === "") && !(Array.isArray(value) && value.length === 0);
|
|
2830
2958
|
const hasText = slide.texts.some((tv) => plainText(tv.value).trim() !== "");
|
|
2831
|
-
const hasObject = slidePayloads(slide.slide, slide.path).some((p) => ["image", "video", "chart", "table", "code", "metric", "quote", "timeline"].some((field) => has(p.node[field])));
|
|
2959
|
+
const hasObject = slidePayloads(slide.slide, slide.path).some((p) => ["image", "video", "chart", "table", "code", "metric", "quote", "timeline", "diagram"].some((field) => has(p.node[field])));
|
|
2832
2960
|
const hasBackgroundImage = imageBackground(rec(slide.slide.design).background) !== void 0;
|
|
2833
2961
|
if (hasText || hasObject || hasBackgroundImage) continue;
|
|
2834
2962
|
context.report(emptySlideRule, { path: slide.path, slide, message: `Slide ${slide.index + 1} has no title and no content.`, help: "Add content, delete the slide, or give it the blank layout if it is intentionally empty." });
|
|
@@ -2843,8 +2971,318 @@ var layoutContentRules = [
|
|
|
2843
2971
|
...contentRules
|
|
2844
2972
|
];
|
|
2845
2973
|
|
|
2974
|
+
// src/rules-layout-findings.ts
|
|
2975
|
+
var round3 = (value, places = 1) => Math.round(value * 10 ** places) / 10 ** places;
|
|
2976
|
+
var PX_PER_INCH = 96;
|
|
2977
|
+
var canvasScale = (composition) => Math.min(composition.width, composition.height) / 720;
|
|
2978
|
+
var HEADINGS = /* @__PURE__ */ new Set(["title", "subtitle", "tag"]);
|
|
2979
|
+
var layoutId = (slide) => typeof slide.layout === "string" && slide.layout ? slide.layout.slice(slide.layout.indexOf(":") + 1) : void 0;
|
|
2980
|
+
var FRAMING_LAYOUTS = /* @__PURE__ */ new Set(["cover", "section", "closing"]);
|
|
2981
|
+
function setsRunSize(value, depth2 = 0) {
|
|
2982
|
+
if (depth2 > 6 || value === null || typeof value !== "object") return false;
|
|
2983
|
+
if (Array.isArray(value)) return value.some((entry2) => setsRunSize(entry2, depth2 + 1));
|
|
2984
|
+
const object2 = value;
|
|
2985
|
+
if (typeof object2.fontSize === "number") return true;
|
|
2986
|
+
return ["text", "description", "rows", "columns", "value"].some((key2) => setsRunSize(object2[key2], depth2 + 1));
|
|
2987
|
+
}
|
|
2988
|
+
var ROLE_SIZE = { text: PROSE_NOMINAL_SIZE, items: LIST_NOMINAL_SIZE, bullets: LIST_NOMINAL_SIZE, table: TABLE_NOMINAL_SIZE, quote: QUOTE_NOMINAL_SIZE, code: CODE_NOMINAL_SIZE };
|
|
2989
|
+
function fittedSize(item, slide, document) {
|
|
2990
|
+
const body = (parts2) => {
|
|
2991
|
+
const fit = parts2?.find((part) => part.role === "body")?.fit;
|
|
2992
|
+
return fit && !fit.overflow ? fit.fontSize : void 0;
|
|
2993
|
+
};
|
|
2994
|
+
if (item.field === "quote") return body(item.quoteLayout?.parts);
|
|
2995
|
+
if (item.field === "code") return body(item.codeLayout?.parts);
|
|
2996
|
+
if (item.field === "table") {
|
|
2997
|
+
try {
|
|
2998
|
+
const table = layoutTable(item.value, item.box, { scale: canvasScale(slide.composition), minFontSize: item.composition.minFontSize, fontFamily: slide.design.fonts.body, textMeasurement: slide.measurement, path: item.path, presentation: document });
|
|
2999
|
+
if (table.overflow) return void 0;
|
|
3000
|
+
const sizes = table.rows.flatMap((row) => row.cells.filter((cell) => !cell.header).map((cell) => cell.fit.fontSize));
|
|
3001
|
+
return sizes.length ? Math.min(...sizes) : void 0;
|
|
3002
|
+
} catch {
|
|
3003
|
+
return void 0;
|
|
3004
|
+
}
|
|
3005
|
+
}
|
|
3006
|
+
return item.text && !item.text.overflow ? item.text.fontSize : void 0;
|
|
3007
|
+
}
|
|
3008
|
+
var textShrunk = {
|
|
3009
|
+
info: textShrunkRule,
|
|
3010
|
+
run(context) {
|
|
3011
|
+
for (const slide of context.slides) {
|
|
3012
|
+
const composition = slide.composition;
|
|
3013
|
+
if (!composition) continue;
|
|
3014
|
+
const scale = canvasScale(composition);
|
|
3015
|
+
let worst;
|
|
3016
|
+
let count = 0;
|
|
3017
|
+
for (const item of composition.items) {
|
|
3018
|
+
const role = ROLE_SIZE[item.field];
|
|
3019
|
+
if (role === void 0 || HEADINGS.has(item.field) || setsRunSize(item.value)) continue;
|
|
3020
|
+
const size = fittedSize(item, slide, context.document);
|
|
3021
|
+
if (size === void 0) continue;
|
|
3022
|
+
const ratio = size / (role * scale);
|
|
3023
|
+
if (ratio >= SHRUNK_RATIO - 1e-6) continue;
|
|
3024
|
+
count++;
|
|
3025
|
+
if (!worst || ratio < worst.ratio) worst = { item, size, role, ratio };
|
|
3026
|
+
}
|
|
3027
|
+
if (!worst) continue;
|
|
3028
|
+
const sizePx = round3(worst.size / scale);
|
|
3029
|
+
const others = count > 1 ? ` ${count - 1} more block${count === 2 ? "" : "s"} on this slide ${count === 2 ? "is" : "are"} also below ${SHRUNK_RATIO * 100}% of the role size.` : "";
|
|
3030
|
+
context.report(textShrunkRule, {
|
|
3031
|
+
path: pointerOfDotted(worst.item.path),
|
|
3032
|
+
slide,
|
|
3033
|
+
message: `The ${worst.item.field === "items" || worst.item.field === "bullets" ? "list" : worst.item.field} is fitted at ${sizePx} px, ${Math.round(worst.ratio * 100)}% of its ${worst.role} px starting size (reference slide); the slide is likely too dense.${others}`,
|
|
3034
|
+
help: "Split the slide (opf paginate), move detail to the speaker notes, or shorten the text so it can be drawn nearer its role size.",
|
|
3035
|
+
measured: { sizePx, rolePx: worst.role, ratio: round3(worst.ratio, 2), minimumRatio: SHRUNK_RATIO, blocks: count }
|
|
3036
|
+
});
|
|
3037
|
+
}
|
|
3038
|
+
}
|
|
3039
|
+
};
|
|
3040
|
+
function itemText(item) {
|
|
3041
|
+
const value = item.value;
|
|
3042
|
+
if (typeof value === "string" || Array.isArray(value) && item.field === "text") return plainText(value);
|
|
3043
|
+
if (!Array.isArray(value)) return "";
|
|
3044
|
+
return value.map((entry2) => {
|
|
3045
|
+
if (typeof entry2 === "string" || Array.isArray(entry2)) return plainText(entry2);
|
|
3046
|
+
const text2 = rec(entry2).text, description = rec(entry2).description;
|
|
3047
|
+
return [text2, description].map((part) => typeof part === "string" || Array.isArray(part) ? plainText(part) : "").join(" ");
|
|
3048
|
+
}).join("\n");
|
|
3049
|
+
}
|
|
3050
|
+
var centeredBody = {
|
|
3051
|
+
info: centeredBodyRule,
|
|
3052
|
+
run(context) {
|
|
3053
|
+
for (const slide of context.slides) {
|
|
3054
|
+
const composition = slide.composition;
|
|
3055
|
+
if (!composition) continue;
|
|
3056
|
+
const body = composition.items.filter((item2) => !HEADINGS.has(item2.field));
|
|
3057
|
+
const framing = FRAMING_LAYOUTS.has(layoutId(slide.slide) ?? "");
|
|
3058
|
+
const lone = (item2) => body.length === 1 || item2.region !== void 0 && body.filter((other) => other.region === item2.region).length === 1;
|
|
3059
|
+
let worst;
|
|
3060
|
+
let count = 0;
|
|
3061
|
+
for (const item2 of body) {
|
|
3062
|
+
if (item2.alignment !== "center" || !["text", "items", "bullets"].includes(item2.field) || !item2.text) continue;
|
|
3063
|
+
const lines2 = item2.text.lines.length, characters2 = itemText(item2).trim().length;
|
|
3064
|
+
if (characters2 <= CENTERED_NOTE_CHARACTERS) continue;
|
|
3065
|
+
if (item2.field === "text" && lone(item2) ? framing || lines2 <= CENTERED_BODY_LINES + 1 : lines2 <= CENTERED_BODY_LINES && characters2 <= CENTERED_BODY_CHARACTERS) continue;
|
|
3066
|
+
count++;
|
|
3067
|
+
if (!worst || lines2 > worst.lines) worst = { item: item2, lines: lines2, characters: characters2 };
|
|
3068
|
+
}
|
|
3069
|
+
if (!worst) continue;
|
|
3070
|
+
const { item, lines, characters } = worst;
|
|
3071
|
+
const others = count > 1 ? ` ${count - 1} more long centered block${count === 2 ? " is" : "s are"} on this slide.` : "";
|
|
3072
|
+
context.report(centeredBodyRule, {
|
|
3073
|
+
path: pointerOfDotted(item.path),
|
|
3074
|
+
slide,
|
|
3075
|
+
message: `A centered ${item.field === "text" ? "paragraph" : "list"} of ${lines} line${lines === 1 ? "" : "s"} (${characters} characters); every line starts at a different place, which is harder to read.${others}`,
|
|
3076
|
+
help: 'Align body text to the start (contentAlignment "left" on the slide or block design), or shorten it to a statement of one or two lines.',
|
|
3077
|
+
measured: { lines, characters, maximumLines: CENTERED_BODY_LINES, maximumCharacters: CENTERED_BODY_CHARACTERS, blocks: count }
|
|
3078
|
+
});
|
|
3079
|
+
}
|
|
3080
|
+
}
|
|
3081
|
+
};
|
|
3082
|
+
var blockPath = (item) => {
|
|
3083
|
+
const parts2 = item.path.split(".");
|
|
3084
|
+
return parts2.length > 2 && /^\d+$/.test(parts2.at(-2) ?? "") ? parts2.slice(0, -1).join(".") : item.path;
|
|
3085
|
+
};
|
|
3086
|
+
var parentPath = (path) => path.split(".").slice(0, -2).join(".");
|
|
3087
|
+
function facingGap(a, b) {
|
|
3088
|
+
const across = Math.min(a.x + a.width, b.x + b.width) - Math.max(a.x, b.x);
|
|
3089
|
+
const down = Math.min(a.y + a.height, b.y + b.height) - Math.max(a.y, b.y);
|
|
3090
|
+
if (across > 0 && down > 0) return void 0;
|
|
3091
|
+
if (across > 0) return Math.max(a.y, b.y) - Math.min(a.y + a.height, b.y + b.height);
|
|
3092
|
+
if (down > 0) return Math.max(a.x, b.x) - Math.min(a.x + a.width, b.x + b.width);
|
|
3093
|
+
return void 0;
|
|
3094
|
+
}
|
|
3095
|
+
var tightSpacing = {
|
|
3096
|
+
info: tightSpacingRule,
|
|
3097
|
+
run(context) {
|
|
3098
|
+
for (const slide of context.slides) {
|
|
3099
|
+
const composition = slide.composition;
|
|
3100
|
+
if (!composition) continue;
|
|
3101
|
+
const scale = canvasScale(composition);
|
|
3102
|
+
const gapLimit = TIGHT_GAP_INCHES * PX_PER_INCH * scale, marginLimit = TIGHT_MARGIN_INCHES * PX_PER_INCH * scale;
|
|
3103
|
+
const bled = new Set((composition.regions ?? []).filter((region) => region.bleed).map((region) => region.name));
|
|
3104
|
+
const spaced = composition.items.filter((item) => !HEADINGS.has(item.field)).map((item) => ({ path: blockPath(item), box: item.frameBox ?? item.image?.box ?? item.box, exempt: item.region !== void 0 && bled.has(item.region) || item.image?.placement !== void 0 }));
|
|
3105
|
+
for (const group of composition.groups) spaced.push({ path: group.path, box: group.box, exempt: false });
|
|
3106
|
+
let margin;
|
|
3107
|
+
for (const entry2 of spaced) {
|
|
3108
|
+
if (entry2.exempt) continue;
|
|
3109
|
+
const { x, y, width, height } = entry2.box;
|
|
3110
|
+
const distance3 = Math.min(x, y, composition.width - x - width, composition.height - y - height);
|
|
3111
|
+
if (distance3 < marginLimit - 0.01 && (!margin || distance3 < margin.distance)) margin = { entry: entry2, distance: distance3 };
|
|
3112
|
+
}
|
|
3113
|
+
let gap;
|
|
3114
|
+
const siblings = /* @__PURE__ */ new Map();
|
|
3115
|
+
for (const entry2 of spaced) siblings.set(parentPath(entry2.path), [...siblings.get(parentPath(entry2.path)) ?? [], entry2]);
|
|
3116
|
+
const groupGap = new Map(composition.groups.map((group) => [group.path, group.composition.gap]));
|
|
3117
|
+
const authoredGap = (parent) => (groupGap.has(parent) ? groupGap.get(parent) : composition.composition.gap) !== void 0;
|
|
3118
|
+
for (const [parent, list] of siblings) {
|
|
3119
|
+
if (!authoredGap(parent)) continue;
|
|
3120
|
+
for (let i = 0; i < list.length; i++)
|
|
3121
|
+
for (let j = i + 1; j < list.length; j++) {
|
|
3122
|
+
if (list[i].exempt || list[j].exempt) continue;
|
|
3123
|
+
const distance3 = facingGap(list[i].box, list[j].box);
|
|
3124
|
+
if (distance3 !== void 0 && distance3 < gapLimit - 0.01 && (!gap || distance3 < gap.distance)) gap = { a: list[i], b: list[j], distance: distance3 };
|
|
3125
|
+
}
|
|
3126
|
+
}
|
|
3127
|
+
const inches = (px) => round3(px / scale / PX_PER_INCH, 2);
|
|
3128
|
+
if (gap)
|
|
3129
|
+
context.report(tightSpacingRule, {
|
|
3130
|
+
path: pointerOfDotted(gap.b.path),
|
|
3131
|
+
slide,
|
|
3132
|
+
message: `Two blocks are ${inches(gap.distance)} in apart (${pointerOfDotted(gap.a.path)} and ${pointerOfDotted(gap.b.path)}); at least ${TIGHT_GAP_INCHES} in keeps them apart as separate ideas.`,
|
|
3133
|
+
help: "Raise composition.gap, use fewer blocks or nested groups on the slide, or split it (opf paginate).",
|
|
3134
|
+
measured: { gapInches: inches(gap.distance), minimumGapInches: TIGHT_GAP_INCHES }
|
|
3135
|
+
});
|
|
3136
|
+
if (margin)
|
|
3137
|
+
context.report(tightSpacingRule, {
|
|
3138
|
+
path: pointerOfDotted(margin.entry.path),
|
|
3139
|
+
slide,
|
|
3140
|
+
message: `A block is ${inches(margin.distance)} in from the slide edge; at least ${TIGHT_MARGIN_INCHES} in keeps content clear of the edge, where projectors and screens crop.`,
|
|
3141
|
+
help: "Raise composition.padding or the design contentBox inset; for a picture meant to reach the edge, place it on the edge (placement) or use a bleed region.",
|
|
3142
|
+
measured: { marginInches: inches(margin.distance), minimumMarginInches: TIGHT_MARGIN_INCHES }
|
|
3143
|
+
});
|
|
3144
|
+
}
|
|
3145
|
+
}
|
|
3146
|
+
};
|
|
3147
|
+
var hasBody = (slide) => slide.payloads.some((payload) => ["text", "items", "bullets", "image", "video", "chart", "table", "code", "metric", "quote", "timeline", "diagram", "blocks"].some((field) => {
|
|
3148
|
+
const value = payload.node[field];
|
|
3149
|
+
return value !== void 0 && value !== null && !(Array.isArray(value) && value.length === 0) && !(typeof value === "string" && value.trim() === "");
|
|
3150
|
+
}));
|
|
3151
|
+
var layoutMonotony = {
|
|
3152
|
+
info: layoutMonotonyRule,
|
|
3153
|
+
run(context) {
|
|
3154
|
+
let run = [];
|
|
3155
|
+
const flush = () => {
|
|
3156
|
+
if (run.length >= MONOTONY_RUN) {
|
|
3157
|
+
const first = run[0], last = run.at(-1), layout = String(first.slide.layout);
|
|
3158
|
+
context.report(layoutMonotonyRule, {
|
|
3159
|
+
path: `${first.path}/layout`,
|
|
3160
|
+
slide: first,
|
|
3161
|
+
message: `Slides ${first.index + 1} to ${last.index + 1} (${run.length} in a row) all use the layout ${JSON.stringify(layout)}.`,
|
|
3162
|
+
help: "Vary the structure the content asks for (a comparison, a chart, a statement, a picture), or merge or split slides so the sequence does not repeat one arrangement.",
|
|
3163
|
+
measured: { layout, slides: run.length, first: first.index + 1, last: last.index + 1, minimumRun: MONOTONY_RUN }
|
|
3164
|
+
});
|
|
3165
|
+
}
|
|
3166
|
+
run = [];
|
|
3167
|
+
};
|
|
3168
|
+
for (const slide of context.slides) {
|
|
3169
|
+
if (slide.slide.hidden === true) continue;
|
|
3170
|
+
const id = layoutId(slide.slide);
|
|
3171
|
+
if (!id || FRAMING_LAYOUTS.has(id) || !hasBody(slide)) {
|
|
3172
|
+
flush();
|
|
3173
|
+
continue;
|
|
3174
|
+
}
|
|
3175
|
+
if (run.length && layoutId(run[0].slide) !== id) flush();
|
|
3176
|
+
run.push(slide);
|
|
3177
|
+
}
|
|
3178
|
+
flush();
|
|
3179
|
+
}
|
|
3180
|
+
};
|
|
3181
|
+
var PROSE_ROLES = /* @__PURE__ */ new Set(["title", "subtitle", "tag", "body", "list", "list-description", "quote", "quote-footer"]);
|
|
3182
|
+
var LETTER = /[\p{L}\p{N}]/u;
|
|
3183
|
+
var OPENING = /[\s([{—–-]/u;
|
|
3184
|
+
function straightQuoteMarks(text2) {
|
|
3185
|
+
let double = 0, single = 0, open = false;
|
|
3186
|
+
for (let i = 0; i < text2.length; i++) {
|
|
3187
|
+
const char = text2[i], before = text2[i - 1] ?? "", after = text2[i + 1] ?? "";
|
|
3188
|
+
if (char === '"') {
|
|
3189
|
+
if (!/\d/.test(before)) double++;
|
|
3190
|
+
} else if (char === "'") {
|
|
3191
|
+
const wordAfter = LETTER.test(after), opens = before === "" || OPENING.test(before);
|
|
3192
|
+
if (LETTER.test(before) && wordAfter || /\d/.test(before)) continue;
|
|
3193
|
+
if (opens && wordAfter && !/\d/.test(after)) open = true;
|
|
3194
|
+
else if (!opens && !wordAfter && open) {
|
|
3195
|
+
single += 2;
|
|
3196
|
+
open = false;
|
|
3197
|
+
}
|
|
3198
|
+
}
|
|
3199
|
+
}
|
|
3200
|
+
return { double, single };
|
|
3201
|
+
}
|
|
3202
|
+
function curlDoubleQuotes(text2, marks) {
|
|
3203
|
+
return text2.replace(/(^|.)"/gsu, (whole, before) => /\d/.test(before) ? whole : `${before}${before === "" || OPENING.test(before) ? marks.open : marks.close}`);
|
|
3204
|
+
}
|
|
3205
|
+
var straightQuotes = {
|
|
3206
|
+
info: straightQuotesRule,
|
|
3207
|
+
run(context) {
|
|
3208
|
+
for (const slide of context.slides) {
|
|
3209
|
+
const marks = quoteMarksFor(quoteLanguage(context.document, slide.index));
|
|
3210
|
+
if (marks.open === '"') continue;
|
|
3211
|
+
for (const tv of slide.texts) {
|
|
3212
|
+
if (!PROSE_ROLES.has(tv.role)) continue;
|
|
3213
|
+
let double = 0, single = 0;
|
|
3214
|
+
const fixes = [];
|
|
3215
|
+
for (const run of runsOf(tv)) {
|
|
3216
|
+
if (run.style.code === true) continue;
|
|
3217
|
+
const found = straightQuoteMarks(run.text);
|
|
3218
|
+
double += found.double;
|
|
3219
|
+
single += found.single;
|
|
3220
|
+
if (found.double) fixes.push({ op: "replace", path: run.index === -1 ? run.path : `${run.path}${typeof tv.value !== "string" && typeof tv.value[run.index] === "string" ? "" : "/text"}`, value: curlDoubleQuotes(run.text, marks) });
|
|
3221
|
+
}
|
|
3222
|
+
if (!double && !single) continue;
|
|
3223
|
+
const kinds = [double ? `${double} straight double quote${double === 1 ? "" : "s"} (")` : "", single ? `${single} straight single quotes (')` : ""].filter(Boolean).join(" and ");
|
|
3224
|
+
const text2 = plainText(tv.value);
|
|
3225
|
+
context.report(straightQuotesRule, {
|
|
3226
|
+
path: tv.path,
|
|
3227
|
+
slide,
|
|
3228
|
+
message: `Text has ${kinds}: ${JSON.stringify(text2.length > 60 ? `${text2.slice(0, 57)}...` : text2)}.`,
|
|
3229
|
+
help: `Use the typographic quotation marks of the deck's language (${marks.open}...${marks.close}).${tv.role === "quote" ? " A quote payload adds its own marks around the whole quote." : ""}`,
|
|
3230
|
+
measured: { double, single, open: marks.open, close: marks.close },
|
|
3231
|
+
...!single && fixes.length ? { fixes: [{ id: "use-typographic-quotes", title: `Use ${marks.open}${marks.close}`, kind: "patch", safe: false, patch: fixes }] } : {}
|
|
3232
|
+
});
|
|
3233
|
+
}
|
|
3234
|
+
}
|
|
3235
|
+
}
|
|
3236
|
+
};
|
|
3237
|
+
var layoutFindingRules = [textShrunk, centeredBody, tightSpacing, layoutMonotony, straightQuotes];
|
|
3238
|
+
|
|
3239
|
+
// src/rules-chart-findings.ts
|
|
3240
|
+
var chartPath = (payloadPath, slidePath) => `${payloadPath === slidePath ? slidePath : payloadPath}/chart`;
|
|
3241
|
+
var chartDualAxis = {
|
|
3242
|
+
info: chartDualAxisRule,
|
|
3243
|
+
run(context) {
|
|
3244
|
+
for (const slide of context.slides)
|
|
3245
|
+
for (const payload of slidePayloads(slide.slide, slide.path)) {
|
|
3246
|
+
const chart = rec(payload.node.chart);
|
|
3247
|
+
if (String(chart.type ?? "").trim().toLowerCase() !== "combo") continue;
|
|
3248
|
+
const resolved = resolveChartData(chart, context.document);
|
|
3249
|
+
if (!resolved.ok || !resolved.combo) continue;
|
|
3250
|
+
const secondary = resolved.combo.flatMap((entry2, index) => entry2.axis === "secondary" ? [String(resolved.columns[index + 1] ?? "")] : []);
|
|
3251
|
+
if (!secondary.length) continue;
|
|
3252
|
+
context.report(chartDualAxisRule, {
|
|
3253
|
+
path: `${chartPath(payload.path, slide.path)}/secondaryAxis`,
|
|
3254
|
+
slide,
|
|
3255
|
+
message: `The combo chart plots ${secondary.map((name) => JSON.stringify(name)).join(", ")} on a second value axis, so two scales share one plot.`,
|
|
3256
|
+
help: "Two charts read more truly than one with two scales: show the secondary series in a chart of its own beside this one, or drop `secondaryAxis` when the series share a unit.",
|
|
3257
|
+
measured: { secondary: secondary.length }
|
|
3258
|
+
});
|
|
3259
|
+
}
|
|
3260
|
+
}
|
|
3261
|
+
};
|
|
3262
|
+
var chartPieManySlices = {
|
|
3263
|
+
info: chartPieManySlicesRule,
|
|
3264
|
+
run(context) {
|
|
3265
|
+
for (const slide of context.slides)
|
|
3266
|
+
for (const payload of slidePayloads(slide.slide, slide.path)) {
|
|
3267
|
+
const chart = rec(payload.node.chart);
|
|
3268
|
+
const type = String(chart.type ?? "").trim().toLowerCase();
|
|
3269
|
+
if (type !== "pie" && type !== "doughnut") continue;
|
|
3270
|
+
const resolved = resolveChartData(chart, context.document);
|
|
3271
|
+
if (!resolved.ok || resolved.rows.length <= PIE_MAX_SLICES) continue;
|
|
3272
|
+
context.report(chartPieManySlicesRule, {
|
|
3273
|
+
path: chartPath(payload.path, slide.path),
|
|
3274
|
+
slide,
|
|
3275
|
+
message: `The ${type} chart has ${resolved.rows.length} slices, more than ${PIE_MAX_SLICES}; the small ones are hard to compare and to label.`,
|
|
3276
|
+
help: 'Compare the parts with a bar chart (`type: "bar"`, sorted if the order carries no meaning), or group the smallest categories into one "Other" slice.',
|
|
3277
|
+
measured: { slices: resolved.rows.length, limit: PIE_MAX_SLICES }
|
|
3278
|
+
});
|
|
3279
|
+
}
|
|
3280
|
+
}
|
|
3281
|
+
};
|
|
3282
|
+
var chartFindingRules = [chartDualAxis, chartPieManySlices];
|
|
3283
|
+
|
|
2846
3284
|
// src/validation-rules.ts
|
|
2847
|
-
var ruleImplementations = [...accessibilityRules, ...layoutContentRules, ...languageTagRules];
|
|
3285
|
+
var ruleImplementations = [...accessibilityRules, ...layoutContentRules, ...languageTagRules, ...layoutFindingRules, ...chartFindingRules];
|
|
2848
3286
|
|
|
2849
3287
|
// src/chart-shape.ts
|
|
2850
3288
|
var FOREIGN_CHART_KEYS = ["categories", "series", "labels", "datasets"];
|
|
@@ -3209,6 +3647,7 @@ function chartNumberFixPaths(document) {
|
|
|
3209
3647
|
var HELP = {
|
|
3210
3648
|
"chart-value-not-numeric": 'Write chart values as numbers (or strict decimal strings such as "12.5" or "1e6"); put currency, percent and units in the column format ({ "name": "Revenue", "format": "$#,##0" }). The value is plotted as a gap.',
|
|
3211
3649
|
"chart-mapping-adapted": "The mapping entry is ignored. Remove it, or name a different column.",
|
|
3650
|
+
"chart-series-dropped": "The chart type plots one series. Use a chart type that plots every series (column, bar, line), or one chart per series.",
|
|
3212
3651
|
"chart-highlight-adapted": "The highlight is adapted by every engine. Name a series or category the chart type can emphasise, or remove the entry.",
|
|
3213
3652
|
"slide-theme-dimensions": "A PPTX has one slide size. Set design.dimensions on the deck, or give every slide the same theme dimensions.",
|
|
3214
3653
|
"code-highlight-out-of-range": "Marked lines count from 1 by line break in code.source. The entry marks nothing past the last line; change it to a line the code has, or remove it.",
|
|
@@ -4370,7 +4809,7 @@ var COMMON_KEYS = Object.freeze({
|
|
|
4370
4809
|
/** The root of a document. */
|
|
4371
4810
|
deck: Object.freeze(["name", "slides", "design", "language", "audience", "purpose", "tone", "narrative", "organization", "speaker"]),
|
|
4372
4811
|
/** A slide (`slides[n]`). */
|
|
4373
|
-
slide: Object.freeze(["title", "subtitle", "layout", "items", "text", "notes", "image", "chart", "table", "quote", "code", "metric", "timeline", "blocks", "design", "id", "section", "tag", "hidden", "beat"]),
|
|
4812
|
+
slide: Object.freeze(["title", "subtitle", "layout", "items", "text", "notes", "image", "chart", "table", "quote", "code", "metric", "timeline", "diagram", "blocks", "design", "id", "section", "tag", "hidden", "beat"]),
|
|
4374
4813
|
/** `design`, on the deck and on a slide. */
|
|
4375
4814
|
design: Object.freeze(["theme", "colorScheme", "fontScheme", "dimensions", "background", "header", "footer"])
|
|
4376
4815
|
});
|
|
@@ -5929,7 +6368,7 @@ function freshName(base, taken = []) {
|
|
|
5929
6368
|
}
|
|
5930
6369
|
return `${base}-2`;
|
|
5931
6370
|
}
|
|
5932
|
-
var BLOCK_KINDS = ["chart", "image", "video", "table", "code", "metric", "quote", "timeline", "items", "bullets", "text"];
|
|
6371
|
+
var BLOCK_KINDS = ["chart", "image", "video", "table", "code", "metric", "quote", "timeline", "diagram", "items", "bullets", "text"];
|
|
5933
6372
|
function blockKind(node) {
|
|
5934
6373
|
if (!isRecord3(node)) return void 0;
|
|
5935
6374
|
if (typeof node.type === "string" && node.type !== "group") return node.type;
|
|
@@ -5979,6 +6418,12 @@ var textContrast = (finding2) => {
|
|
|
5979
6418
|
var textOnImage = (finding2) => {
|
|
5980
6419
|
const ratio = measuredNumber(finding2, "ratio");
|
|
5981
6420
|
const needed = measuredNumber(finding2, "needed");
|
|
6421
|
+
const scrim = measuredNumber(finding2, "scrimOpacity");
|
|
6422
|
+
if (scrim !== void 0)
|
|
6423
|
+
return {
|
|
6424
|
+
message: `Text sits on this picture, so a scrim at ${num(scrim * 100)}% is drawn behind it to keep it readable${needed !== void 0 ? ` at ${num(needed)}:1` : ""}.`,
|
|
6425
|
+
next: `nothing is needed; to choose your own scrim, set the background's ${code("overlay")}, or ${code("overlay: false")} to show the picture without one.`
|
|
6426
|
+
};
|
|
5982
6427
|
return {
|
|
5983
6428
|
message: `Contrast over this picture can't be measured${ratio !== void 0 && needed !== void 0 ? `: against the lightest or darkest possible pixels it is as low as ${num(ratio, 1)}:1, and ${num(needed)}:1 is needed` : ""}.`,
|
|
5984
6429
|
next: `add a full-frame ${code("overlay")} to the background image, so the text stays readable on any picture.`
|
|
@@ -6072,8 +6517,8 @@ var chartColorsAdjusted = (finding2, _context, helpers) => {
|
|
|
6072
6517
|
}
|
|
6073
6518
|
if (contrast === void 0) return void 0;
|
|
6074
6519
|
return {
|
|
6075
|
-
message: `${label} (${code(shown)}) has ${num(contrast, 1)}:1 contrast against the
|
|
6076
|
-
next: `pick a color with at least 3:1 contrast against ${panel ? code(panel) : "the
|
|
6520
|
+
message: `${label} (${code(shown)}) has ${num(contrast, 1)}:1 contrast against the slide background${panel ? ` (${code(panel)})` : ""}, so it is drawn lighter or darker to reach 3:1.`,
|
|
6521
|
+
next: `pick a color with at least 3:1 contrast against ${panel ? code(panel) : "the background"}, or remove ${code("colors")} to use the palette.`
|
|
6077
6522
|
};
|
|
6078
6523
|
};
|
|
6079
6524
|
var chartTextAlternative = (finding2) => {
|
|
@@ -6222,6 +6667,87 @@ var imageResolution = (finding2) => {
|
|
|
6222
6667
|
next: needed ? `use a file of${needed} or larger, or show it smaller.` : "use a larger file, or show the image smaller."
|
|
6223
6668
|
};
|
|
6224
6669
|
};
|
|
6670
|
+
var textShrunk2 = (finding2) => {
|
|
6671
|
+
const size = measuredNumber(finding2, "sizePx");
|
|
6672
|
+
const role = measuredNumber(finding2, "rolePx");
|
|
6673
|
+
const ratio = measuredNumber(finding2, "ratio");
|
|
6674
|
+
if (size === void 0 || role === void 0 || ratio === void 0) return void 0;
|
|
6675
|
+
const blocks = measuredNumber(finding2, "blocks") ?? 1;
|
|
6676
|
+
const what = match(finding2.message, /^The (.+?) is fitted at/)?.[1] ?? "text";
|
|
6677
|
+
const more = blocks > 1 ? ` (and ${blocks - 1} more block${blocks === 2 ? "" : "s"})` : "";
|
|
6678
|
+
return {
|
|
6679
|
+
message: `The ${what}${onSlide(finding2)}${more} is shrunk to ${num(size, 1)} px, ${Math.round(ratio * 100)}% of its ${num(role)} px starting size, so the slide is likely too dense.`,
|
|
6680
|
+
next: `split it with ${code("opf paginate")}, move detail to the speaker notes, or shorten the text.`
|
|
6681
|
+
};
|
|
6682
|
+
};
|
|
6683
|
+
var centeredBody2 = (finding2) => {
|
|
6684
|
+
const lines = measuredNumber(finding2, "lines");
|
|
6685
|
+
const characters = measuredNumber(finding2, "characters");
|
|
6686
|
+
if (lines === void 0 || characters === void 0) return void 0;
|
|
6687
|
+
const what = match(finding2.message, /^A centered (\w+) of/)?.[1] ?? "block";
|
|
6688
|
+
const blocks = measuredNumber(finding2, "blocks") ?? 1;
|
|
6689
|
+
return {
|
|
6690
|
+
message: `A centered ${what}${onSlide(finding2)} runs ${lines} line${lines === 1 ? "" : "s"} (${characters} characters)${blocks > 1 ? `, with ${blocks - 1} more like it` : ""}; each line starts at a different place, which is harder to read.`,
|
|
6691
|
+
next: `set ${code('contentAlignment: "left"')} in the slide's design, or cut it to a line or two.`
|
|
6692
|
+
};
|
|
6693
|
+
};
|
|
6694
|
+
var tightSpacing2 = (finding2) => {
|
|
6695
|
+
const gap = measuredNumber(finding2, "gapInches");
|
|
6696
|
+
const margin = measuredNumber(finding2, "marginInches");
|
|
6697
|
+
if (gap !== void 0) {
|
|
6698
|
+
const minimum = measuredNumber(finding2, "minimumGapInches");
|
|
6699
|
+
return {
|
|
6700
|
+
message: `Two blocks${onSlide(finding2)} are ${num(gap)} in apart${minimum !== void 0 ? `, closer than ${num(minimum)} in` : ""}, so they read as one crowded block.`,
|
|
6701
|
+
next: `raise ${code("composition.gap")}, use fewer blocks or nested groups, or split the slide.`
|
|
6702
|
+
};
|
|
6703
|
+
}
|
|
6704
|
+
if (margin !== void 0) {
|
|
6705
|
+
const minimum = measuredNumber(finding2, "minimumMarginInches");
|
|
6706
|
+
return {
|
|
6707
|
+
message: `A block${onSlide(finding2)} is ${num(margin)} in from the slide edge${minimum !== void 0 ? `, closer than ${num(minimum)} in` : ""}.`,
|
|
6708
|
+
next: `raise ${code("composition.padding")}, or place a picture meant to reach the edge with ${code("placement")}.`
|
|
6709
|
+
};
|
|
6710
|
+
}
|
|
6711
|
+
return void 0;
|
|
6712
|
+
};
|
|
6713
|
+
var layoutMonotony2 = (finding2) => {
|
|
6714
|
+
const layout = measuredText(finding2, "layout");
|
|
6715
|
+
const slides = measuredNumber(finding2, "slides");
|
|
6716
|
+
const first = measuredNumber(finding2, "first");
|
|
6717
|
+
const last = measuredNumber(finding2, "last");
|
|
6718
|
+
if (!layout || slides === void 0 || first === void 0 || last === void 0) return void 0;
|
|
6719
|
+
return {
|
|
6720
|
+
message: `Slides ${first} to ${last} (${slides} in a row) all use layout ${code(layout)}, so they look alike.`,
|
|
6721
|
+
next: "give some of them the layout their content asks for (a comparison, a chart, a statement, a picture), or merge or split slides."
|
|
6722
|
+
};
|
|
6723
|
+
};
|
|
6724
|
+
var straightQuotes2 = (finding2) => {
|
|
6725
|
+
const open = measuredText(finding2, "open");
|
|
6726
|
+
const close = measuredText(finding2, "close");
|
|
6727
|
+
const text2 = unquote(match(finding2.message, /: ("(?:[^"\\]|\\.)*")\.$/)?.[1]);
|
|
6728
|
+
if (!open || !close) return void 0;
|
|
6729
|
+
const fix = finding2.fixes?.find((entry2) => entry2.id === "use-typographic-quotes");
|
|
6730
|
+
return {
|
|
6731
|
+
message: `${text2 ? `${code(brief(text2, 50))} uses` : "This text uses"} straight quotation marks; this deck's language uses ${open}\u2026${close}.`,
|
|
6732
|
+
next: fix ? `apply the quick fix, or type ${open} and ${close} instead.` : `type ${open} and ${close} instead, and the matching single marks.`
|
|
6733
|
+
};
|
|
6734
|
+
};
|
|
6735
|
+
var chartDualAxis2 = (finding2) => {
|
|
6736
|
+
const names2 = match(finding2.message, /^The combo chart plots (.+) on a second value axis/)?.[1];
|
|
6737
|
+
return {
|
|
6738
|
+
message: `${names2 ? `${names2} ${/, /.test(names2) ? "are" : "is"}` : "A series is"} on a second value axis, so two scales share one plot and its crossings mean nothing.`,
|
|
6739
|
+
next: `show the secondary series in a chart of its own beside this one, or drop ${code("secondaryAxis")} when the series share a unit.`
|
|
6740
|
+
};
|
|
6741
|
+
};
|
|
6742
|
+
var chartPieManySlices2 = (finding2) => {
|
|
6743
|
+
const slices = measuredNumber(finding2, "slices");
|
|
6744
|
+
const limit = measuredNumber(finding2, "limit");
|
|
6745
|
+
if (slices === void 0) return void 0;
|
|
6746
|
+
return {
|
|
6747
|
+
message: `This chart has ${slices} slices${limit === void 0 ? "" : `, more than ${limit}`}; the small ones are hard to compare and to label.`,
|
|
6748
|
+
next: `compare the parts with bars (${code('type: "bar"')}), or group the smallest into one "Other" slice.`
|
|
6749
|
+
};
|
|
6750
|
+
};
|
|
6225
6751
|
var chartValueNotNumeric = (finding2) => {
|
|
6226
6752
|
const value = unquote(match(finding2.message, /^chart value ("(?:[^"\\]|\\.)*") is not a number/)?.[1]);
|
|
6227
6753
|
const fix = finding2.fixes?.find((entry2) => entry2.id === "store-chart-numbers");
|
|
@@ -6235,6 +6761,10 @@ var chartMappingAdapted = (finding2) => ({
|
|
|
6235
6761
|
message: keep(cap(finding2.message)),
|
|
6236
6762
|
next: "remove that mapping entry, or name a different column."
|
|
6237
6763
|
});
|
|
6764
|
+
var chartSeriesDropped = (finding2) => ({
|
|
6765
|
+
message: keep(cap(finding2.message)),
|
|
6766
|
+
next: "use a chart type that plots every series, or one chart per series."
|
|
6767
|
+
});
|
|
6238
6768
|
var chartHighlightAdapted = (finding2) => {
|
|
6239
6769
|
const name = unquote(match(finding2.message, /^highlight names \w+ ("(?:[^"\\]|\\.)*"), which is not plotted as a series/)?.[1]);
|
|
6240
6770
|
if (!name) return void 0;
|
|
@@ -6362,6 +6892,7 @@ var AUDIT_TEXT = {
|
|
|
6362
6892
|
"opf/chart-value-not-numeric": chartValueNotNumeric,
|
|
6363
6893
|
"opf/chart-mapping-adapted": chartMappingAdapted,
|
|
6364
6894
|
"opf/chart-highlight-adapted": chartHighlightAdapted,
|
|
6895
|
+
"opf/chart-series-dropped": chartSeriesDropped,
|
|
6365
6896
|
"opf/code-highlight-out-of-range": codeHighlightOutOfRange,
|
|
6366
6897
|
"opf/code-highlight-range-reversed": codeHighlightRangeReversed,
|
|
6367
6898
|
"opf/variable-builtin-missing": variableBuiltinMissing,
|
|
@@ -6371,7 +6902,14 @@ var AUDIT_TEXT = {
|
|
|
6371
6902
|
"opf/empty-text": emptyText,
|
|
6372
6903
|
"opf/unused-beat": unusedBeat,
|
|
6373
6904
|
"opf/empty-slide": emptySlide,
|
|
6374
|
-
"opf/language-tag": languageTag
|
|
6905
|
+
"opf/language-tag": languageTag,
|
|
6906
|
+
"opf/text-shrunk": textShrunk2,
|
|
6907
|
+
"opf/centered-body": centeredBody2,
|
|
6908
|
+
"opf/tight-spacing": tightSpacing2,
|
|
6909
|
+
"opf/layout-monotony": layoutMonotony2,
|
|
6910
|
+
"opf/straight-quotes": straightQuotes2,
|
|
6911
|
+
"opf/chart-dual-axis": chartDualAxis2,
|
|
6912
|
+
"opf/chart-pie-many-slices": chartPieManySlices2
|
|
6375
6913
|
};
|
|
6376
6914
|
|
|
6377
6915
|
// src/finding-text-format.ts
|
|
@@ -6539,6 +7077,16 @@ var chartHighlightUnknownName = (finding2) => {
|
|
|
6539
7077
|
}
|
|
6540
7078
|
return void 0;
|
|
6541
7079
|
};
|
|
7080
|
+
var tableHighlightUnknownName = (finding2) => {
|
|
7081
|
+
const row = match(finding2.message, /^highlight names row ("(?:[^"\\]|\\.)*"), which no body row has as its first cell(?:; the rows are (.+))?$/);
|
|
7082
|
+
if (!row) return void 0;
|
|
7083
|
+
const name = unquote(row[1]);
|
|
7084
|
+
const keys = unquoteList(row[2]);
|
|
7085
|
+
return {
|
|
7086
|
+
message: `${code(`highlight: "${name}"`)} matches no row.${keys.length ? ` Available: ${plainList(keys)}${/\.\.\.$/.test(row[2] ?? "") ? ", \u2026" : ""}.` : ""}`,
|
|
7087
|
+
next: keys.length ? chooseNext(name, keys) : "name a row by the text of its first cell, or remove the entry."
|
|
7088
|
+
};
|
|
7089
|
+
};
|
|
6542
7090
|
var tokenOf = (finding2, id) => finding2.message.includes(`var:${id}`) ? code(`var:${id}`) : code(`{{${id}}}`);
|
|
6543
7091
|
var SAMPLE_BY_KIND = {
|
|
6544
7092
|
number: "a plain number such as 42",
|
|
@@ -6872,6 +7420,7 @@ var FORMAT_TEXT = {
|
|
|
6872
7420
|
"opf/variable-invalid-value": variableInvalidValue,
|
|
6873
7421
|
"opf/variable-unknown-builtin": variableUnknownBuiltin,
|
|
6874
7422
|
"opf/chart-highlight-unknown-name": chartHighlightUnknownName,
|
|
7423
|
+
"opf/table-highlight-unknown-name": tableHighlightUnknownName,
|
|
6875
7424
|
"opf/variable-format": variableFormat,
|
|
6876
7425
|
"opf/variable-unfilled": variableUnfilled,
|
|
6877
7426
|
"opf/run-color-unrecognized": runColorUnrecognized,
|
|
@@ -6916,9 +7465,9 @@ var RULE_TEXT = Object.freeze(
|
|
|
6916
7465
|
var SLIDE_OPTION_KEYS = ["id", "type", "layout", "section", "tag", "hidden", "beat"];
|
|
6917
7466
|
var BLOCK_OPTION_KEYS = ["id", "type", "as", "region"];
|
|
6918
7467
|
var BLOCK_AS_VALUES = ["bullets", "video"];
|
|
6919
|
-
var FENCE_KINDS = ["chart", "metric", "timeline", "opf-block", "opf-slide"];
|
|
7468
|
+
var FENCE_KINDS = ["chart", "metric", "timeline", "mermaid", "opf-block", "opf-slide"];
|
|
6920
7469
|
var METRIC_KEYS = ["value", "label", "description", "unit", "delta", "trend", "sentiment"];
|
|
6921
|
-
var FENCE_ATTRIBUTES = { chart: ["alt"], timeline: ["name", "description"], code: ["title"] };
|
|
7470
|
+
var FENCE_ATTRIBUTES = { chart: ["alt"], mermaid: ["alt"], timeline: ["name", "description"], code: ["title"] };
|
|
6922
7471
|
var SPAN_FLAGS = ["bold", "italic", "underline", "strike", "sup", "sub"];
|
|
6923
7472
|
var SPAN_VALUES = ["color", "size", "font", "lang"];
|
|
6924
7473
|
var LINE_KEYWORDS = ["Note:", "Notes:"];
|
|
@@ -6975,6 +7524,8 @@ var markdown = {
|
|
|
6975
7524
|
"markdown/chart-attributes": (finding2) => keep2(finding2, 'write ```chart column alt="What the data shows" (`alt` is optional).'),
|
|
6976
7525
|
"markdown/chart-data": wholeHelp,
|
|
6977
7526
|
"markdown/chart-ragged": (finding2) => keep2(finding2, "give every row one value per column."),
|
|
7527
|
+
"markdown/diagram-attributes": (finding2) => keep2(finding2, 'write ```mermaid alt="What the diagram shows" (`alt` is optional).'),
|
|
7528
|
+
"markdown/diagram-source": wholeHelp,
|
|
6978
7529
|
"markdown/metric-block": (finding2) => keep2(finding2, `write ${code("key: value")} lines using ${METRIC_KEYS.join(", ")}; a value is plain text or a JSON string in double quotes.`),
|
|
6979
7530
|
"markdown/timeline-attributes": (finding2) => keep2(finding2, 'write ```timeline name="Roadmap" description="\u2026" (both are optional).'),
|
|
6980
7531
|
"markdown/timeline-description": (finding2) => keep2(finding2, "put the event first, then its description indented below it."),
|
|
@@ -7048,6 +7599,8 @@ var SOURCE_EXPLAIN = {
|
|
|
7048
7599
|
"markdown/chart-attributes": entry("format", "error", "A chart fence has an attribute it cannot take.", "A chart fence takes `alt`, a text alternative in double quotes.", 'Write ```chart column alt="What the data shows".'),
|
|
7049
7600
|
"markdown/chart-data": entry("format", "error", "A chart fence has no usable data.", "The chart is drawn from CSV with a header row, or a JSON object with `columns` and `rows`.", "Write CSV with a header row and at least one data row."),
|
|
7050
7601
|
"markdown/chart-ragged": entry("format", "warning", "A chart row has a different number of values than the header.", "Missing cells plot as gaps.", "Give every row one value per column."),
|
|
7602
|
+
"markdown/diagram-attributes": entry("format", "error", "A mermaid fence has an attribute it cannot take.", "A mermaid fence takes `alt`, a text alternative in double quotes.", 'Write ```mermaid alt="What the diagram shows".'),
|
|
7603
|
+
"markdown/diagram-source": entry("format", "error", "A mermaid fence has no source.", "A diagram is drawn from its Mermaid source.", "Write the diagram between the fences, starting with its type (`flowchart LR`, `sequenceDiagram`, `mindmap`, ...)."),
|
|
7051
7604
|
"markdown/metric-block": entry("format", "error", "A metric fence is malformed.", "A metric is `key: value` lines using a fixed set of keys.", "Write `value:` and, if you like, `label:`, `unit:`, `delta:`, `trend:` and `sentiment:`.", "```metric\nlabel: Revenue\n```", "```metric\nvalue: 42\nlabel: Revenue\n```"),
|
|
7052
7605
|
"markdown/timeline-attributes": entry("format", "error", "A timeline fence has an attribute it cannot take.", "A timeline fence takes `name` and `description`.", "Remove the attribute, or use `name=` or `description=`."),
|
|
7053
7606
|
"markdown/timeline-description": entry("format", "error", "An indented line has no event above it.", "A description belongs to the event before it.", "Put the event first, then its description indented below it."),
|
|
@@ -7439,7 +7992,9 @@ function resolveSlideContext(presentation, index, options2 = {}) {
|
|
|
7439
7992
|
} else diagnostics.push(unresolvedReference(presentation, "layouts", slide.layout, `slides.${index}.layout`, catalogs));
|
|
7440
7993
|
}
|
|
7441
7994
|
if (options2.strictReferences && diagnostics.length) throw new OPFUnresolvedReferenceError(diagnostics);
|
|
7442
|
-
const
|
|
7995
|
+
const levels = colorLevels(rec2(slide.design), layout, rec2(deck.design), theme, colorScheme, rec2(deck.variables));
|
|
7996
|
+
const roles = resolveColorRoles(colorScheme, colorChoice(levels, colorScheme, rec2(deck.variables)));
|
|
7997
|
+
const layoutVariant = levels.length > 3 && layoutVariantApplies(slide.design, layout, deck.design, theme.background) ? levels[1].variant : void 0;
|
|
7443
7998
|
const composeOptions = {
|
|
7444
7999
|
...resolveCanvasDimensions(design.dimensions ?? theme.dimensions),
|
|
7445
8000
|
...layout ? { layout } : {},
|
|
@@ -7449,6 +8004,8 @@ function resolveSlideContext(presentation, index, options2 = {}) {
|
|
|
7449
8004
|
slideCount: options2.slideCount ?? slides.length,
|
|
7450
8005
|
fontFamilies: resolveFontFamilies(fontScheme),
|
|
7451
8006
|
darkBackground: roles.dark,
|
|
8007
|
+
// LH-02: the colors the automatic scrim of a picture background is sized for.
|
|
8008
|
+
roles: { text: roles.text, textSecondary: roles.textSecondary, primary: roles.primary, background: roles.background },
|
|
7452
8009
|
...theme.background !== void 0 ? { themeBackground: theme.background } : {},
|
|
7453
8010
|
// OPF 0.19: a theme may carry the shared design keys (between the deck's design and the layout record's).
|
|
7454
8011
|
...theme.design !== void 0 && rec2(theme.design) === theme.design ? { themeDesign: theme.design } : {},
|
|
@@ -7456,7 +8013,7 @@ function resolveSlideContext(presentation, index, options2 = {}) {
|
|
|
7456
8013
|
...options2.date !== void 0 ? { date: options2.date } : {}
|
|
7457
8014
|
};
|
|
7458
8015
|
const resolvedSlide = resolveSlideVariables(slide, { slideNumber: composeOptions.slideNumber, slideCount: composeOptions.slideCount, presentation, darkBackground: composeOptions.darkBackground === true });
|
|
7459
|
-
return { slide: resolvedSlide, options: composeOptions, diagnostics, resolved: { theme, colorScheme, roles, fontScheme, fontSchemePath: records.fontSchemePath, ...layout ? { layout } : {}, provenance: { ...layoutProvenance ? { layout: layoutProvenance } : {}, ...records.provenance } } };
|
|
8016
|
+
return { slide: resolvedSlide, options: composeOptions, diagnostics, resolved: { theme, colorScheme, roles, fontScheme, fontSchemePath: records.fontSchemePath, ...layout ? { layout } : {}, ...layoutVariant ? { layoutVariant } : {}, provenance: { ...layoutProvenance ? { layout: layoutProvenance } : {}, ...records.provenance } } };
|
|
7460
8017
|
}
|
|
7461
8018
|
|
|
7462
8019
|
// src/rule-slides.ts
|