pptx-templates 0.3.9 → 0.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/AI-INSTRUCTOR.md +46 -3
- package/CHANGELOG.md +236 -1
- package/README.md +61 -168
- package/dist/automizer.d.ts +7 -0
- package/dist/automizer.js +168 -176
- package/dist/automizer.js.map +1 -1
- package/dist/classes/content-type-registry.js +23 -36
- package/dist/classes/content-type-registry.js.map +1 -1
- package/dist/classes/element-importer.js +130 -148
- package/dist/classes/element-importer.js.map +1 -1
- package/dist/classes/has-shapes.js +81 -126
- package/dist/classes/has-shapes.js.map +1 -1
- package/dist/classes/layout.js +47 -67
- package/dist/classes/layout.js.map +1 -1
- package/dist/classes/master.js +70 -89
- package/dist/classes/master.js.map +1 -1
- package/dist/classes/placeholder-normalizer.js +48 -37
- package/dist/classes/placeholder-normalizer.js.map +1 -1
- package/dist/classes/related-content-copier.js +65 -86
- package/dist/classes/related-content-copier.js.map +1 -1
- package/dist/classes/shape.js +79 -110
- package/dist/classes/shape.js.map +1 -1
- package/dist/classes/slide-master-remover.js +108 -130
- package/dist/classes/slide-master-remover.js.map +1 -1
- package/dist/classes/slide-notes-copier.js +24 -41
- package/dist/classes/slide-notes-copier.js.map +1 -1
- package/dist/classes/slide.js +112 -141
- package/dist/classes/slide.js.map +1 -1
- package/dist/classes/template.js +82 -117
- package/dist/classes/template.js.map +1 -1
- package/dist/constants/constants.js.map +1 -1
- package/dist/enums/chart-type.js.map +1 -1
- package/dist/enums/content-type-map.js.map +1 -1
- package/dist/enums/element-type.js.map +1 -1
- package/dist/errors.js +5 -5
- package/dist/errors.js.map +1 -1
- package/dist/extensions/cli/index.js +3 -13
- package/dist/extensions/cli/index.js.map +1 -1
- package/dist/extensions/hide-slide/index.js +48 -46
- package/dist/extensions/hide-slide/index.js.map +1 -1
- package/dist/extensions/index.d.ts +13 -3
- package/dist/extensions/index.js +3 -1
- package/dist/extensions/index.js.map +1 -1
- package/dist/extensions/link-scheme/index.d.ts +12 -0
- package/dist/extensions/link-scheme/index.js +40 -0
- package/dist/extensions/link-scheme/index.js.map +1 -0
- package/dist/extensions/master-parts/index.js +36 -49
- package/dist/extensions/master-parts/index.js.map +1 -1
- package/dist/extensions/pptxgenjs-compat/img-broken-png.js.map +1 -1
- package/dist/extensions/pptxgenjs-compat/index.js.map +1 -1
- package/dist/extensions/pptxgenjs-compat/svg-fallback.js +56 -70
- package/dist/extensions/pptxgenjs-compat/svg-fallback.js.map +1 -1
- package/dist/extensions/regexp-escape/index.d.ts +10 -0
- package/dist/extensions/regexp-escape/index.js +15 -0
- package/dist/extensions/regexp-escape/index.js.map +1 -0
- package/dist/extensions/run-merge/index.js +4 -5
- package/dist/extensions/run-merge/index.js.map +1 -1
- package/dist/extensions/shape-geometry/index.js +33 -11
- package/dist/extensions/shape-geometry/index.js.map +1 -1
- package/dist/extensions/shape-geometry/presets.d.ts +1 -1
- package/dist/extensions/shape-geometry/presets.js.map +1 -1
- package/dist/extensions/shape-geometry/types.js.map +1 -1
- package/dist/extensions/template-lint/cli.js +71 -49
- package/dist/extensions/template-lint/cli.js.map +1 -1
- package/dist/extensions/template-lint/config.js +29 -13
- package/dist/extensions/template-lint/config.js.map +1 -1
- package/dist/extensions/template-lint/data-model.js +17 -20
- package/dist/extensions/template-lint/data-model.js.map +1 -1
- package/dist/extensions/template-lint/hints.js.map +1 -1
- package/dist/extensions/template-lint/index.js.map +1 -1
- package/dist/extensions/template-lint/init-cli.d.ts +2 -0
- package/dist/extensions/template-lint/init-cli.js +33 -23
- package/dist/extensions/template-lint/init-cli.js.map +1 -1
- package/dist/extensions/template-lint/lint.d.ts +1 -1
- package/dist/extensions/template-lint/lint.js +83 -64
- package/dist/extensions/template-lint/lint.js.map +1 -1
- package/dist/extensions/template-lint/skeleton.js +5 -6
- package/dist/extensions/template-lint/skeleton.js.map +1 -1
- package/dist/extensions/template-lint/types.js.map +1 -1
- package/dist/extensions/template-lint/usage-cli.js +17 -18
- package/dist/extensions/template-lint/usage-cli.js.map +1 -1
- package/dist/extensions/template-lint/usage.js +8 -9
- package/dist/extensions/template-lint/usage.js.map +1 -1
- package/dist/extensions/template-lint/watch.d.ts +2 -0
- package/dist/extensions/template-lint/watch.js +52 -7
- package/dist/extensions/template-lint/watch.js.map +1 -1
- package/dist/extensions/template-logic/clone.d.ts +2 -16
- package/dist/extensions/template-logic/clone.js +15 -90
- package/dist/extensions/template-logic/clone.js.map +1 -1
- package/dist/extensions/template-logic/commands.d.ts +1 -1
- package/dist/extensions/template-logic/commands.js +12 -11
- package/dist/extensions/template-logic/commands.js.map +1 -1
- package/dist/extensions/template-logic/expression.d.ts +15 -2
- package/dist/extensions/template-logic/expression.js +143 -63
- package/dist/extensions/template-logic/expression.js.map +1 -1
- package/dist/extensions/template-logic/images.js +58 -55
- package/dist/extensions/template-logic/images.js.map +1 -1
- package/dist/extensions/template-logic/index.js +16 -24
- package/dist/extensions/template-logic/index.js.map +1 -1
- package/dist/extensions/template-logic/list-commands.js +8 -19
- package/dist/extensions/template-logic/list-commands.js.map +1 -1
- package/dist/extensions/template-logic/renderer.d.ts +9 -0
- package/dist/extensions/template-logic/renderer.js +480 -477
- package/dist/extensions/template-logic/renderer.js.map +1 -1
- package/dist/extensions/template-logic/types.d.ts +8 -1
- package/dist/extensions/template-logic/types.js.map +1 -1
- package/dist/extensions/template-render/cli.js +34 -22
- package/dist/extensions/template-render/cli.js.map +1 -1
- package/dist/extensions/template-render/index.js +152 -107
- package/dist/extensions/template-render/index.js.map +1 -1
- package/dist/extensions/template-render/prune.d.ts +14 -0
- package/dist/extensions/template-render/prune.js +131 -0
- package/dist/extensions/template-render/prune.js.map +1 -0
- package/dist/extensions/template-render/zip-text.d.ts +9 -0
- package/dist/extensions/template-render/zip-text.js +27 -0
- package/dist/extensions/template-render/zip-text.js.map +1 -0
- package/dist/extensions/template-render/zip-writer.d.ts +16 -0
- package/dist/extensions/template-render/zip-writer.js +151 -0
- package/dist/extensions/template-render/zip-writer.js.map +1 -0
- package/dist/extensions/text-flow/flow.js +183 -207
- package/dist/extensions/text-flow/flow.js.map +1 -1
- package/dist/extensions/text-flow/font-file.d.ts +9 -0
- package/dist/extensions/text-flow/font-file.js +40 -22
- package/dist/extensions/text-flow/font-file.js.map +1 -1
- package/dist/extensions/text-flow/fonts.d.ts +4 -0
- package/dist/extensions/text-flow/fonts.js +67 -23
- package/dist/extensions/text-flow/fonts.js.map +1 -1
- package/dist/extensions/text-flow/index.js.map +1 -1
- package/dist/extensions/text-flow/layout.js +8 -9
- package/dist/extensions/text-flow/layout.js.map +1 -1
- package/dist/extensions/text-flow/slide-styles.js +18 -22
- package/dist/extensions/text-flow/slide-styles.js.map +1 -1
- package/dist/extensions/text-flow/styles.d.ts +7 -1
- package/dist/extensions/text-flow/styles.js +108 -64
- package/dist/extensions/text-flow/styles.js.map +1 -1
- package/dist/helper/archive/archive-fs.d.ts +11 -0
- package/dist/helper/archive/archive-fs.js +195 -142
- package/dist/helper/archive/archive-fs.js.map +1 -1
- package/dist/helper/archive/archive-jszip.js +101 -125
- package/dist/helper/archive/archive-jszip.js.map +1 -1
- package/dist/helper/archive/archive.d.ts +6 -0
- package/dist/helper/archive/archive.js +21 -30
- package/dist/helper/archive/archive.js.map +1 -1
- package/dist/helper/archive/jszip-fast-read.d.ts +26 -0
- package/dist/helper/archive/jszip-fast-read.js +166 -0
- package/dist/helper/archive/jszip-fast-read.js.map +1 -0
- package/dist/helper/cell-id-helper.d.ts +1 -0
- package/dist/helper/cell-id-helper.js +6 -2
- package/dist/helper/cell-id-helper.js.map +1 -1
- package/dist/helper/compute-src-rect.js +4 -5
- package/dist/helper/compute-src-rect.js.map +1 -1
- package/dist/helper/content-tracker.js +86 -114
- package/dist/helper/content-tracker.js.map +1 -1
- package/dist/helper/count-helper.js +48 -78
- package/dist/helper/count-helper.js.map +1 -1
- package/dist/helper/css-style-parser.d.ts +1 -1
- package/dist/helper/css-style-parser.js +1 -2
- package/dist/helper/css-style-parser.js.map +1 -1
- package/dist/helper/file-helper.js +30 -48
- package/dist/helper/file-helper.js.map +1 -1
- package/dist/helper/general-helper.js.map +1 -1
- package/dist/helper/generate/generate-pptxgenjs.js +36 -48
- package/dist/helper/generate/generate-pptxgenjs.js.map +1 -1
- package/dist/helper/html-to-multitext-helper.d.ts +4 -4
- package/dist/helper/html-to-multitext-helper.js +46 -23
- package/dist/helper/html-to-multitext-helper.js.map +1 -1
- package/dist/helper/hyperlink-processor.js +125 -139
- package/dist/helper/hyperlink-processor.js.map +1 -1
- package/dist/helper/image-dimensions.js.map +1 -1
- package/dist/helper/jszip-helper.d.ts +1 -1
- package/dist/helper/jszip-helper.js +40 -33
- package/dist/helper/jszip-helper.js.map +1 -1
- package/dist/helper/layout-index.js +51 -71
- package/dist/helper/layout-index.js.map +1 -1
- package/dist/helper/logger.js +4 -4
- package/dist/helper/logger.js.map +1 -1
- package/dist/helper/media-deduplicator.d.ts +24 -0
- package/dist/helper/media-deduplicator.js +81 -34
- package/dist/helper/media-deduplicator.js.map +1 -1
- package/dist/helper/modify-background-helper.js +46 -46
- package/dist/helper/modify-background-helper.js.map +1 -1
- package/dist/helper/modify-chart-helper.d.ts +1 -1
- package/dist/helper/modify-chart-helper.js +597 -591
- package/dist/helper/modify-chart-helper.js.map +1 -1
- package/dist/helper/modify-cleanup-helper.js +112 -112
- package/dist/helper/modify-cleanup-helper.js.map +1 -1
- package/dist/helper/modify-color-helper.d.ts +1 -1
- package/dist/helper/modify-color-helper.js +53 -53
- package/dist/helper/modify-color-helper.js.map +1 -1
- package/dist/helper/modify-helper.js +25 -25
- package/dist/helper/modify-helper.js.map +1 -1
- package/dist/helper/modify-hyperlink-element.js.map +1 -1
- package/dist/helper/modify-hyperlink-helper.js +152 -158
- package/dist/helper/modify-hyperlink-helper.js.map +1 -1
- package/dist/helper/modify-image-helper.d.ts +1 -1
- package/dist/helper/modify-image-helper.js +121 -132
- package/dist/helper/modify-image-helper.js.map +1 -1
- package/dist/helper/modify-presentation-helper.js +137 -154
- package/dist/helper/modify-presentation-helper.js.map +1 -1
- package/dist/helper/modify-shape-helper.js +262 -262
- package/dist/helper/modify-shape-helper.js.map +1 -1
- package/dist/helper/modify-table-helper.js +95 -84
- package/dist/helper/modify-table-helper.js.map +1 -1
- package/dist/helper/modify-text-helper.d.ts +8 -0
- package/dist/helper/modify-text-helper.js +202 -190
- package/dist/helper/modify-text-helper.js.map +1 -1
- package/dist/helper/modify-xml-helper.js +36 -36
- package/dist/helper/modify-xml-helper.js.map +1 -1
- package/dist/helper/multitext-helper.js +13 -9
- package/dist/helper/multitext-helper.js.map +1 -1
- package/dist/helper/ppt-paths.js +17 -17
- package/dist/helper/ppt-paths.js.map +1 -1
- package/dist/helper/shape-type-detector.js +18 -29
- package/dist/helper/shape-type-detector.js.map +1 -1
- package/dist/helper/text-replace-helper.js +8 -8
- package/dist/helper/text-replace-helper.js.map +1 -1
- package/dist/helper/xml/lnLRTB.js.map +1 -1
- package/dist/helper/xml/prstGeom.js.map +1 -1
- package/dist/helper/xml-clone.d.ts +24 -0
- package/dist/helper/xml-clone.js +269 -0
- package/dist/helper/xml-clone.js.map +1 -0
- package/dist/helper/xml-elements.js +17 -20
- package/dist/helper/xml-elements.js.map +1 -1
- package/dist/helper/xml-find.d.ts +4 -0
- package/dist/helper/xml-find.js +48 -0
- package/dist/helper/xml-find.js.map +1 -0
- package/dist/helper/xml-helper.js +102 -135
- package/dist/helper/xml-helper.js.map +1 -1
- package/dist/helper/xml-parse-cache.d.ts +31 -0
- package/dist/helper/xml-parse-cache.js +71 -0
- package/dist/helper/xml-parse-cache.js.map +1 -0
- package/dist/helper/xml-placeholder-helper.js +10 -10
- package/dist/helper/xml-placeholder-helper.js.map +1 -1
- package/dist/helper/xml-pretty-print.js.map +1 -1
- package/dist/helper/xml-relationship-helper.js +132 -147
- package/dist/helper/xml-relationship-helper.js.map +1 -1
- package/dist/helper/xml-serializer.d.ts +2 -0
- package/dist/helper/xml-serializer.js +192 -0
- package/dist/helper/xml-serializer.js.map +1 -0
- package/dist/helper/xml-slide-helper.js +109 -129
- package/dist/helper/xml-slide-helper.js.map +1 -1
- package/dist/helper/xml-template-helper.js +120 -144
- package/dist/helper/xml-template-helper.js.map +1 -1
- package/dist/helper/xmldom-sax-patch.js +52 -2
- package/dist/helper/xmldom-sax-patch.js.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/interfaces/iarchive.js.map +1 -1
- package/dist/interfaces/ichart.js.map +1 -1
- package/dist/interfaces/icounter.js.map +1 -1
- package/dist/interfaces/igenerator.js.map +1 -1
- package/dist/interfaces/iimage.js.map +1 -1
- package/dist/interfaces/ilayout.js.map +1 -1
- package/dist/interfaces/imaster.js.map +1 -1
- package/dist/interfaces/imulti-text.js.map +1 -1
- package/dist/interfaces/ipptxgenjs-slide.js.map +1 -1
- package/dist/interfaces/ipresentation-props.js.map +1 -1
- package/dist/interfaces/ishape-action.js.map +1 -1
- package/dist/interfaces/ishape.js.map +1 -1
- package/dist/interfaces/islide.js.map +1 -1
- package/dist/interfaces/itemplate.js.map +1 -1
- package/dist/interfaces/pres-template.js.map +1 -1
- package/dist/interfaces/root-pres-template.js.map +1 -1
- package/dist/modify/modify-chart.d.ts +4 -4
- package/dist/modify/modify-chart.js +35 -23
- package/dist/modify/modify-chart.js.map +1 -1
- package/dist/modify/modify-table.d.ts +0 -1
- package/dist/modify/modify-table.js +19 -27
- package/dist/modify/modify-table.js.map +1 -1
- package/dist/shapes/chart.js +238 -287
- package/dist/shapes/chart.js.map +1 -1
- package/dist/shapes/diagram.d.ts +14 -0
- package/dist/shapes/diagram.js +167 -103
- package/dist/shapes/diagram.js.map +1 -1
- package/dist/shapes/generic.js +62 -83
- package/dist/shapes/generic.js.map +1 -1
- package/dist/shapes/hyperlink.d.ts +0 -1
- package/dist/shapes/hyperlink.js +84 -124
- package/dist/shapes/hyperlink.js.map +1 -1
- package/dist/shapes/image.js +118 -149
- package/dist/shapes/image.js.map +1 -1
- package/dist/shapes/ole.js +148 -188
- package/dist/shapes/ole.js.map +1 -1
- package/dist/types/chart-types.js.map +1 -1
- package/dist/types/modify-types.js.map +1 -1
- package/dist/types/shape-types.js.map +1 -1
- package/dist/types/table-types.js.map +1 -1
- package/dist/types/types.d.ts +7 -0
- package/dist/types/types.js.map +1 -1
- package/dist/types/xml-types.js.map +1 -1
- package/dist/vendor/pptxgenjs/README.md +8 -3
- package/dist/vendor/pptxgenjs/index.js +19 -2
- package/package.json +13 -16
package/AI-INSTRUCTOR.md
CHANGED
|
@@ -947,13 +947,31 @@ are rejected as well:
|
|
|
947
947
|
(also permitted by `allowStringPatterns`).
|
|
948
948
|
- `repeat`, `padStart` and `padEnd` for more than 1,000,000 characters.
|
|
949
949
|
|
|
950
|
+
These checks also apply when such a method is passed on as a callback
|
|
951
|
+
(`list.map(''.match, text)`).
|
|
952
|
+
|
|
953
|
+
Reflection is refused as well: `Object.getPrototypeOf`,
|
|
954
|
+
`Object.setPrototypeOf`, `Object.getOwnPropertyDescriptor(s)`,
|
|
955
|
+
`Object.defineProperty`/`defineProperties` and every `Reflect` method, even
|
|
956
|
+
if you pass `Object` or `Reflect` in. Other `Object` helpers (`keys`,
|
|
957
|
+
`values`, `entries`, `fromEntries`) work.
|
|
958
|
+
|
|
959
|
+
Each evaluation of one expression has a budget: at most 1,000,000 steps
|
|
960
|
+
(arrow function bodies included) and at most 20,000,000 characters or list
|
|
961
|
+
items in the strings and lists it produces. One renderer runs at most
|
|
962
|
+
200,000 `FOR` iterations in total, nested loops included. Going past a limit
|
|
963
|
+
is a render error.
|
|
964
|
+
|
|
950
965
|
#### Templates you did not write
|
|
951
966
|
|
|
952
967
|
The interpreter keeps a template away from Node.js, not away from your data.
|
|
953
968
|
A template can call every method of every value you pass in, so
|
|
954
969
|
`{{items.pop()}}` changes your array and `{{user.delete()}}` calls your
|
|
955
|
-
method.
|
|
956
|
-
|
|
970
|
+
method. renderDeck and `flow()` evaluate a tag more than once, so such a
|
|
971
|
+
change can happen several times. Sort a copy with `toSorted` instead of
|
|
972
|
+
`sort`. The limits above bound the work per expression and per renderer,
|
|
973
|
+
but not the total time of a large deck. For templates from people you do
|
|
974
|
+
not trust:
|
|
957
975
|
|
|
958
976
|
- Pass plain data (JSON-like copies), not model instances, database handles
|
|
959
977
|
or libraries such as lodash.
|
|
@@ -1011,6 +1029,7 @@ pres.addSlide('TextReplace.pptx', 1, (slide) => {
|
|
|
1011
1029
|
| `additionalJsContext` | | Extra helpers and constants. `data` takes precedence |
|
|
1012
1030
|
| `strict` | `false` | Throw on unknown top-level names instead of treating them as `undefined` |
|
|
1013
1031
|
| `allowStringPatterns` | `false` | Let `match`, `matchAll` and `search` take a string pattern (`name.match('^A')`). Only for templates you trust: a crafted pattern can block the process |
|
|
1032
|
+
| `allowedLinkSchemes` | | Schemes `{{LINK}}` and `<a href>` in `{{HTML}}` may use besides `http`, `https`, `mailto` and `tel`, e.g. `['file']`. See [allowed link schemes](https://daborsten.github.io/pptx-templates/hyperlinks.md#allowed-link-schemes) |
|
|
1014
1033
|
| `rejectNullish` | `false` | Throw when an insertion is `null` or `undefined` |
|
|
1015
1034
|
| `errorHandler(error, command)` | | Called when a command fails. Its return value is used instead (inserted text, condition, list, …) |
|
|
1016
1035
|
| `failFast` | `true` | `false`: keep going and throw one error listing all failed commands at the end |
|
|
@@ -1386,7 +1405,10 @@ as not shown. The second slide repeats as usual while projects are left.
|
|
|
1386
1405
|
- `flow`, `flowRest`, `flowContinue`, `flowPage` and `flowPages` are built in. The same name
|
|
1387
1406
|
in your data or in `additionalJsContext` takes precedence.
|
|
1388
1407
|
- To count the slides, `renderDeck` and `countFlowPages` render the slide
|
|
1389
|
-
once more. Functions in your data are called again then.
|
|
1408
|
+
once more. Functions in your data are called again then. Pictures of
|
|
1409
|
+
`{{IMAGE}}` are not loaded for the count, since they do not change where
|
|
1410
|
+
the text goes: a missing image file is reported when the slide itself is
|
|
1411
|
+
rendered, not by `countFlowPages`.
|
|
1390
1412
|
|
|
1391
1413
|
## Hide Slides
|
|
1392
1414
|
|
|
@@ -2572,6 +2594,27 @@ slide.modifyElement('TextShape', (element: XmlElement, relation?: XmlElement) =>
|
|
|
2572
2594
|
|
|
2573
2595
|
The `addHyperlink` function will automatically detect whether the target is an external URL or an internal slide number and set up the appropriate relationship type and attributes.
|
|
2574
2596
|
|
|
2597
|
+
### Allowed link schemes
|
|
2598
|
+
|
|
2599
|
+
New external links may use `http`, `https`, `mailto` and `tel`. Any other
|
|
2600
|
+
target makes `write()` fail: `javascript:`, `file:`, UNC paths (`\\host\share`),
|
|
2601
|
+
relative paths and app protocols such as `ms-msdt:`. A click on such a link can
|
|
2602
|
+
start a program or send the user's Windows credentials to another host. Links
|
|
2603
|
+
already in a template are copied unchecked.
|
|
2604
|
+
|
|
2605
|
+
Allow more schemes with `allowedLinkSchemes`. `'file'` also allows targets
|
|
2606
|
+
without a scheme:
|
|
2607
|
+
|
|
2608
|
+
```ts
|
|
2609
|
+
const automizer = new Automizer({
|
|
2610
|
+
templateDir: 'templates',
|
|
2611
|
+
allowedLinkSchemes: ['file'],
|
|
2612
|
+
});
|
|
2613
|
+
```
|
|
2614
|
+
|
|
2615
|
+
The check covers `addHyperlink`, `setHyperlinkTarget`, links in MultiText and
|
|
2616
|
+
HTML text, and `{{LINK}}`. Shapes from `slide.generate()` are not checked.
|
|
2617
|
+
|
|
2575
2618
|
### Update or remove existing hyperlinks
|
|
2576
2619
|
|
|
2577
2620
|
Use `modify.setHyperlinkTarget` to change the target of a hyperlink that already exists on a shape. The second argument controls whether the new target is external (default, `true`) or an internal slide link (`false`):
|
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,239 @@ semver, with the pre-1.0 convention that **breaking changes bump the minor**.
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [0.5.0] - 2026-12-05
|
|
10
|
+
|
|
11
|
+
### Security
|
|
12
|
+
|
|
13
|
+
- **Breaking:** new external hyperlinks only accept `http`, `https`,
|
|
14
|
+
`mailto` and `tel`. `javascript:`, `file:`, UNC paths, relative paths and
|
|
15
|
+
app protocols (`ms-msdt:`, `search-ms:`, …) make `write()` fail; a click on
|
|
16
|
+
them could start a program or leak Windows credentials. Allow more with
|
|
17
|
+
`allowedLinkSchemes: ['file']` on `Automizer` or in the render options.
|
|
18
|
+
Covers `addHyperlink`, `setHyperlinkTarget`, MultiText/HTML links and
|
|
19
|
+
`{{LINK}}`; links already in a template are copied unchecked.
|
|
20
|
+
- fs mode (`archiveType.mode: 'fs'`): a template whose relationships point
|
|
21
|
+
outside the package (`Target="../media/../../../../secret"`) could read any
|
|
22
|
+
file into the output deck or write a file outside the work dir. Such part
|
|
23
|
+
paths are now refused with an `ArchiveError`.
|
|
24
|
+
- Template expressions: `match`, `search`, `matchAll`, `repeat`, `padStart`
|
|
25
|
+
and `padEnd` passed as a callback (`list.map(''.match, text)`) skipped the
|
|
26
|
+
RegExp and string size checks. They are checked now. One evaluation may
|
|
27
|
+
take at most 1,000,000 steps and produce at most 20,000,000 characters or
|
|
28
|
+
list items, and one renderer runs at most 200,000 `FOR` iterations, so a
|
|
29
|
+
template cannot block the process or exhaust its memory.
|
|
30
|
+
- Template tags: an unclosed `{{` no longer makes tag matching quadratic
|
|
31
|
+
(80 KB of text took several seconds). A tag can no longer contain the
|
|
32
|
+
opening tag.
|
|
33
|
+
- `slide.generate()`: an unreachable image URL rejects `write()` instead of
|
|
34
|
+
crashing the Node process, and downloads time out after 30 s. Non-200
|
|
35
|
+
responses are an error instead of being embedded.
|
|
36
|
+
- Template expressions with `Object` or `Reflect` in the data (or in
|
|
37
|
+
`additionalJsContext`, or from `--helpers`) could reach the `Function`
|
|
38
|
+
constructor through property descriptors and run any code.
|
|
39
|
+
`getPrototypeOf`, `setPrototypeOf`, `getOwnPropertyDescriptor(s)`,
|
|
40
|
+
`defineProperty`/`defineProperties` and every `Reflect` method are refused
|
|
41
|
+
now, and so is a forbidden built-in function (`Function`, `call`, an
|
|
42
|
+
unchecked `repeat`, …) returned by a call or passed as an argument.
|
|
43
|
+
- Templates (jszip and fs mode): a part whose zip header gives more than
|
|
44
|
+
1 GiB uncompressed is refused before it is inflated; fs mode also stops
|
|
45
|
+
after 4 GiB in total. A zip bomb with an honest size header filled the
|
|
46
|
+
memory or the disk before.
|
|
47
|
+
- A relationship target with a long run of digits no longer takes seconds
|
|
48
|
+
per `addSlide` (quadratic regex).
|
|
49
|
+
- `pptx-templates init`: a `"data"` path in the config that leads out of the
|
|
50
|
+
config's folder (`../escaped/evil.json`) is refused instead of written.
|
|
51
|
+
Absolute `"data"` and `"schema"` paths are a config error.
|
|
52
|
+
- `{{IMAGE 'path'}}` resolves symlinks before checking that the file is
|
|
53
|
+
inside `imageRoot`; a link in that folder can no longer point elsewhere.
|
|
54
|
+
- Text and hyperlink targets drop U+FFFE, U+FFFF and unpaired surrogates,
|
|
55
|
+
and `{{LINK}}` targets, picture alt texts and hyperlink relationships drop
|
|
56
|
+
control characters, so the written XML stays well-formed.
|
|
57
|
+
- The CLI replaces zero-width and bidi control characters in file names and
|
|
58
|
+
messages, so a file name cannot reorder its line in the output.
|
|
59
|
+
|
|
60
|
+
### Fixed
|
|
61
|
+
|
|
62
|
+
- fs mode: templates with the same file name in different folders, or a
|
|
63
|
+
template edited on disk, are no longer served from a stale cache. Parallel
|
|
64
|
+
instances get their own work dir (`tmp-<uuid>`, removed after output
|
|
65
|
+
unless `cleanupWorkDir: false`) instead of sharing and wiping `tmp`.
|
|
66
|
+
- A picture hyperlink from `slide.generate()` (`addImage({ hyperlink })`)
|
|
67
|
+
keeps its relationship; before, the slide had an `r:id` without a target.
|
|
68
|
+
- `modify.setHyperlinkTarget(n, false)` targets `slide<n>.xml` instead of
|
|
69
|
+
`../slides/<n>`.
|
|
70
|
+
- `ModifyCleanupHelper.removeBackground` no longer removes the outline color
|
|
71
|
+
of a shape without fill.
|
|
72
|
+
- `pptx-templates lint --watch` with a config pattern whose folder does not
|
|
73
|
+
exist yet waits for the folder instead of exiting with "Cannot watch".
|
|
74
|
+
- fs mode on Windows: parallel instances extracting the same template no
|
|
75
|
+
longer fail with `EPERM` on rename.
|
|
76
|
+
- `modify.setText` on a shape whose first paragraph has no run sets the text
|
|
77
|
+
instead of leaving the shape empty.
|
|
78
|
+
- `modify.replaceText`: `$&`, `$'` and `$$` in the replacement are inserted
|
|
79
|
+
as text.
|
|
80
|
+
- Several `modifyElement` calls on one shape run their callbacks in the
|
|
81
|
+
order they were queued (was reversed), and a `removeElement` on the same
|
|
82
|
+
shape is no longer ignored.
|
|
83
|
+
- Chart and cell ranges from the 27th column on get letters (`AA`, `AB`, …);
|
|
84
|
+
before, they were empty (`Sheet1!$$1:$$3`).
|
|
85
|
+
- `setTable` with a row `expand` no longer widens merged cells; rows that
|
|
86
|
+
`setTable` adds no longer inherit the merges of the first row (a merged
|
|
87
|
+
header hid their values).
|
|
88
|
+
- A slide with a linked picture (`TargetMode="External"`) no longer makes
|
|
89
|
+
`write()` fail with "Could not find file ppt/media/https://…".
|
|
90
|
+
- A second `write()`, `stream()` or `getJSZip()` on one instance outputs the
|
|
91
|
+
same presentation instead of appending the slides again.
|
|
92
|
+
- `flow()` with `defTabSz="0"` measures tabs with 72 pt instead of
|
|
93
|
+
producing `NaN`.
|
|
94
|
+
- `{{LINK n}}` requires a whole slide number from 1; `2.5` gave
|
|
95
|
+
`slide2.5.xml`.
|
|
96
|
+
- An empty opening or closing tag is refused.
|
|
97
|
+
- A lint config placeholder named like an `Object` member (`{constructor}`)
|
|
98
|
+
no longer crashes `resolveConfig`.
|
|
99
|
+
- An image imported into a root template that already has `media<n>` (the
|
|
100
|
+
output of an earlier run as root) gets a free name instead of replacing
|
|
101
|
+
that picture on the other slides.
|
|
102
|
+
- `loadMedia()`/`loadMediaBuffer()` with the name of a picture already in
|
|
103
|
+
the output makes `write()` fail instead of silently replacing it; pass a
|
|
104
|
+
prefix.
|
|
105
|
+
- A copied SmartArt keeps its pictures: the `_rels` of its data and drawing
|
|
106
|
+
parts and their images are copied. Its parts are found through the
|
|
107
|
+
shape's relationships, so they need not share a number, and the data part
|
|
108
|
+
points to the new drawing relationship.
|
|
109
|
+
- `modify.setTableStyle` inserts `a:tableStyleId` before `a:extLst`, and
|
|
110
|
+
`modify.addHyperlink` puts `a:hlinkClick` in schema order in `a:rPr`;
|
|
111
|
+
PowerPoint offered to repair such files.
|
|
112
|
+
- `modify.setCornerRadius` keeps the other adjust values of a rounded preset
|
|
113
|
+
(`adj2` of `round2DiagRect`).
|
|
114
|
+
- `flow()` on Windows measures "Arial" with Arial, not Arial Narrow (whose
|
|
115
|
+
typographic family is also "Arial"); about a fifth too much text fit
|
|
116
|
+
into a box. Among faces of one family, the legacy name, normal width and
|
|
117
|
+
the closest weight win.
|
|
118
|
+
- `flow()`: a broken font file no longer allocates gigabytes or throws a
|
|
119
|
+
bare `RangeError`; the error names the file. Cached faces no longer keep
|
|
120
|
+
the whole font file in memory.
|
|
121
|
+
- fs mode: writing the output opens one part at a time instead of all at
|
|
122
|
+
once (`EMFILE` on large decks).
|
|
123
|
+
- `pptx-templates lint`/`usage`: an unreadable deck is reported and the
|
|
124
|
+
other decks are still checked (also with `--json`); the exit code stays 2.
|
|
125
|
+
- `pptx-templates render -o` with the template itself as output is refused;
|
|
126
|
+
the output is written to a temporary file and renamed.
|
|
127
|
+
- CLI options that take a value no longer take the next option as it
|
|
128
|
+
(`--data --watch`), and `--` ends the options.
|
|
129
|
+
- `htmlToMultiText` reports HTML nested too deeply with a clear error
|
|
130
|
+
instead of a `RangeError`.
|
|
131
|
+
- New hyperlink relationships get `rId<n>-created` ids, like every other
|
|
132
|
+
relationship the library creates.
|
|
133
|
+
- The source maps in the package contain the sources (`inlineSources`);
|
|
134
|
+
they pointed to a `src/` folder the package does not ship.
|
|
135
|
+
|
|
136
|
+
- Adding a table column inside a horizontally merged cell (`setTable` with
|
|
137
|
+
`expand` in column mode) now widens the merge when the column is added
|
|
138
|
+
after its third or a later column.
|
|
139
|
+
|
|
140
|
+
## [0.4.0] - 2026-11-24
|
|
141
|
+
|
|
142
|
+
Generating is several times faster, with the same slides. Most of the
|
|
143
|
+
speed-ups are in code every `Automizer` run uses (reading, parsing and
|
|
144
|
+
writing parts, copying XML nodes, finding duplicate pictures), not only in
|
|
145
|
+
`renderDeck`. Compared with 0.3.9, the content of every part is the same;
|
|
146
|
+
the bytes of a `renderDeck` deck differ: parts it does not change are taken
|
|
147
|
+
over from the template as they are instead of parsed and written again,
|
|
148
|
+
pictures are stored instead of deflated (about 1 % larger), and parts no
|
|
149
|
+
relationship reaches are left out.
|
|
150
|
+
|
|
151
|
+
### Changed
|
|
152
|
+
|
|
153
|
+
- **Behavior change:** `countFlowPages` loads no `{{IMAGE}}` picture. The
|
|
154
|
+
value is still evaluated, so an error in the expression is still
|
|
155
|
+
reported, but a missing file, a path outside `imageRoot`, an unknown
|
|
156
|
+
image format, `IMAGE` in a table cell or two `IMAGE` tags in one alt
|
|
157
|
+
text are reported only when the slide is rendered, not by
|
|
158
|
+
`countFlowPages`. `renderDeck` renders every slide it counts, so it
|
|
159
|
+
reports the same errors as before; an `errorHandler` gets them once
|
|
160
|
+
instead of twice on a `flow()` slide.
|
|
161
|
+
- `renderDeck` is more than twice as fast, with the same slides: a deck
|
|
162
|
+
of 8 template slides, three of them with `flow()` lists that make 2 to 4
|
|
163
|
+
slides each, takes about 0.1 instead of 0.23 seconds.
|
|
164
|
+
- `renderDeck` and `countFlowPages` count the slides a `flow()` slide
|
|
165
|
+
needs by rendering that slide by itself, instead of building a whole
|
|
166
|
+
deck for each such slide. The count is the same.
|
|
167
|
+
- The system font folders are listed once per process, not on every
|
|
168
|
+
render with `flow()` (on Windows a `stat` for each of hundreds of
|
|
169
|
+
fonts). Fonts installed while the process runs are found after a
|
|
170
|
+
restart. The `fonts` folders passed in the options are still listed on
|
|
171
|
+
every render, so font files added to them are found right away.
|
|
172
|
+
- `renderDeck` drops the parts no relationship reaches any more (the
|
|
173
|
+
template's own slides with their notes, charts, embeddings and
|
|
174
|
+
pictures) from the `.rels` parts, instead of parsing every slide once
|
|
175
|
+
more for Automizer's `cleanup`. A picture whose relationship the slide
|
|
176
|
+
does not use is still dropped.
|
|
177
|
+
- `renderDeck` packs the .pptx with Node's zlib instead of JSZip's
|
|
178
|
+
JavaScript deflate. Stored pictures stay stored, as PowerPoint saves
|
|
179
|
+
them, and so do the pictures `{{IMAGE}}` adds (JSZip deflated them for
|
|
180
|
+
about 1 % less).
|
|
181
|
+
- `renderDeck` loads the template once instead of three times (JSZip
|
|
182
|
+
reads the whole file byte by byte on every load).
|
|
183
|
+
- Identical pictures are found by comparing only pictures of the same
|
|
184
|
+
size: each run read and hashed every picture of the template before.
|
|
185
|
+
With 3 MB of pictures in the template, a deck takes 0.1 instead of
|
|
186
|
+
0.5 seconds.
|
|
187
|
+
- `flow()` tokenizes a box once for all the entries it measures, and
|
|
188
|
+
neither its trial renders nor counting the slides load `{{IMAGE}}`
|
|
189
|
+
pictures.
|
|
190
|
+
- `renderDeck` is about 40 % faster again, with the same output byte for
|
|
191
|
+
byte. A deck of 25 template slides (360 text boxes with tags, 30
|
|
192
|
+
pictures of 0.5 MB, 10 `flow()` slides that make 35 slides) takes 0.28
|
|
193
|
+
instead of 0.5 seconds; the same deck with pptx-automizer 0.9.4 (tags
|
|
194
|
+
replaced with `replaceText`, pictures swapped, lists split by hand,
|
|
195
|
+
nothing measured) takes 1.3 to 1.9 seconds.
|
|
196
|
+
- The build targets ES2022 instead of ES6, so `async`/`await` runs
|
|
197
|
+
natively instead of through generators (Node 20 is required already).
|
|
198
|
+
- Parts are read without JSZip's pipeline where the result is the same:
|
|
199
|
+
parts of the template inflated with Node's zlib, parts written during
|
|
200
|
+
the run taken as they were given. JSZip inflated in JavaScript and
|
|
201
|
+
passed every 16 KB through a chain of workers. Parts above 1 MB are
|
|
202
|
+
inflated on Node's thread pool, so they do not block the event loop.
|
|
203
|
+
A part that inflates to more than its zip header says (a corrupt file
|
|
204
|
+
or a zip bomb) is rejected before it fills the memory; JSZip rejected
|
|
205
|
+
it only after inflating all of it.
|
|
206
|
+
- A part parsed before is copied instead of parsed again (a slide added
|
|
207
|
+
several times, the many identical `.rels` parts). A part parsed once
|
|
208
|
+
keeps only a checksum; the copies kept are limited to 4 million
|
|
209
|
+
characters of XML per archive (about 150 MB at most).
|
|
210
|
+
- XML is written by a serializer of its own, with the output of
|
|
211
|
+
xmldom's, about a third faster.
|
|
212
|
+
- Copying XML nodes is about three times as fast (properties copied by
|
|
213
|
+
name instead of by `Object.keys`), and so is finding elements by tag
|
|
214
|
+
name; the unsupported tags of a slide are found in one pass.
|
|
215
|
+
- xmldom checks each element and attribute name against a long Unicode
|
|
216
|
+
pattern; the result is now kept per name.
|
|
217
|
+
- The .pptx is deflated on Node's thread pool, several parts at a time.
|
|
218
|
+
- `flow()` looks up the list styles of a paragraph level once per box
|
|
219
|
+
instead of once per paragraph, and the font of a run once per box.
|
|
220
|
+
- The system fonts are read only when the `fonts` folders have no exact
|
|
221
|
+
match (same family, bold and italic) for a font the slide uses. Before,
|
|
222
|
+
the first render with `flow()` in a process read every system font.
|
|
223
|
+
- A picture `{{IMAGE}}` adds is hashed once instead of twice.
|
|
224
|
+
- `@xmldom/xmldom` is pinned to exactly 0.9.12 instead of `^0.9.12`. The
|
|
225
|
+
library's own XML serializer and node copy produce xmldom 0.9.12's
|
|
226
|
+
output; a newer xmldom comes with a release of this library once that
|
|
227
|
+
output is checked against it.
|
|
228
|
+
|
|
229
|
+
### Fixed
|
|
230
|
+
|
|
231
|
+
- `renderDeck`: a `{{HIDE-SLIDE …}}` tag that spell check had split inside
|
|
232
|
+
the keyword (`{{HI` and `DE-SLIDE …}}` in two runs) stayed in the speaker
|
|
233
|
+
notes of a slide that is shown. The slide itself was hidden or shown
|
|
234
|
+
correctly.
|
|
235
|
+
|
|
236
|
+
### Removed
|
|
237
|
+
|
|
238
|
+
- The dependency `regexp.escape`, which installed 91 packages. Tag
|
|
239
|
+
delimiters are escaped by a small function in the library instead, with
|
|
240
|
+
the same matches.
|
|
241
|
+
|
|
9
242
|
## [0.3.9] - 2026-11-22
|
|
10
243
|
|
|
11
244
|
### Added
|
|
@@ -395,7 +628,9 @@ for that history.
|
|
|
395
628
|
into one `.png` part. The fallback now gets the same placeholder PNG that
|
|
396
629
|
pptxgenjs 3.12 wrote.
|
|
397
630
|
|
|
398
|
-
[Unreleased]: https://github.com/DaBorsten/pptx-templates/compare/v0.
|
|
631
|
+
[Unreleased]: https://github.com/DaBorsten/pptx-templates/compare/v0.5.0...HEAD
|
|
632
|
+
[0.5.0]: https://github.com/DaBorsten/pptx-templates/compare/v0.4.0...v0.5.0
|
|
633
|
+
[0.4.0]: https://github.com/DaBorsten/pptx-templates/compare/v0.3.9...v0.4.0
|
|
399
634
|
[0.3.9]: https://github.com/DaBorsten/pptx-templates/compare/v0.3.8...v0.3.9
|
|
400
635
|
[0.3.8]: https://github.com/DaBorsten/pptx-templates/compare/v0.3.7...v0.3.8
|
|
401
636
|
[0.3.7]: https://github.com/DaBorsten/pptx-templates/compare/v0.3.6...v0.3.7
|
package/README.md
CHANGED
|
@@ -7,32 +7,24 @@
|
|
|
7
7
|
**Fill PowerPoint templates with data.** Design the slide in PowerPoint, type
|
|
8
8
|
`{{tags}}` into it, and render it from JavaScript or TypeScript.
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
Offer for {{customer.name}} Offer for Ada
|
|
12
|
-
{{FOR item IN items}} → Apples: 1.50 €
|
|
13
|
-
{{item.name}}: {{item.price.toFixed(2)}} € Pears: 2.00 €
|
|
14
|
-
{{END-FOR}}
|
|
15
|
-
```
|
|
10
|
+

|
|
16
11
|
|
|
17
12
|
The library edits your .pptx instead of rebuilding it. Fonts, colors,
|
|
18
|
-
positions, masters and layouts stay exactly as the designer left
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
- **
|
|
26
|
-
project or month into one deck
|
|
27
|
-
- **A linter for templates**: `npx pptx-templates lint` finds broken tags,
|
|
28
|
-
unclosed blocks and misspelled field names before you render, also in CI and
|
|
29
|
-
in watch mode while the deck is open in PowerPoint
|
|
30
|
-
- **Safe expressions**: tags run in a small interpreter, not `eval`, and can't
|
|
13
|
+
positions, masters and layouts stay exactly as the designer left them, and the
|
|
14
|
+
designer can change the template later without touching your code.
|
|
15
|
+
|
|
16
|
+
- **Logic in the slide:** values, `IF`/`ELSE`, `FOR` loops over paragraphs and
|
|
17
|
+
table rows, variables, HTML, links and images, all typed in PowerPoint
|
|
18
|
+
- **A linter for templates:** finds broken tags and misspelled field names
|
|
19
|
+
before you render
|
|
20
|
+
- **Safe expressions:** tags run in a small interpreter, not `eval`, and can't
|
|
31
21
|
reach Node.js
|
|
32
22
|
- **Charts, tables and images from code** when a tag is not enough
|
|
33
23
|
- TypeScript types included, runs on Node.js 20+ and Bun, MIT licensed
|
|
34
24
|
|
|
35
|
-
|
|
25
|
+
**[Read the documentation →](https://daborsten.github.io/pptx-templates/)**
|
|
26
|
+
|
|
27
|
+
## Quick start
|
|
36
28
|
|
|
37
29
|
With npm:
|
|
38
30
|
|
|
@@ -46,24 +38,20 @@ With Bun:
|
|
|
46
38
|
bun add pptx-templates
|
|
47
39
|
```
|
|
48
40
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
**1. Write the template.** Put this into a text box on slide 1 of
|
|
52
|
-
`templates/Offer.pptx` and format it however you like:
|
|
41
|
+
Put this into a text box on slide 1 of `templates/Offer.pptx` and format it
|
|
42
|
+
however you like:
|
|
53
43
|
|
|
54
44
|
```text
|
|
55
45
|
Offer for {{customer.name}}
|
|
56
46
|
{{IF customer.vip}}
|
|
57
47
|
Thank you for being a loyal customer.
|
|
58
|
-
{{ELSE}}
|
|
59
|
-
Have a look at our new offers.
|
|
60
48
|
{{END-IF}}
|
|
61
49
|
{{FOR item IN items}}
|
|
62
|
-
{{
|
|
50
|
+
{{item.name}}: {{item.price.toFixed(2)}} €
|
|
63
51
|
{{END-FOR}}
|
|
64
52
|
```
|
|
65
53
|
|
|
66
|
-
|
|
54
|
+
Render it:
|
|
67
55
|
|
|
68
56
|
```ts
|
|
69
57
|
import Automizer, { modify } from 'pptx-templates';
|
|
@@ -92,80 +80,51 @@ pres.addSlide('offer', 1, (slide) => {
|
|
|
92
80
|
await pres.write('Offer-Ada.pptx');
|
|
93
81
|
```
|
|
94
82
|
|
|
95
|
-
|
|
83
|
+
`output/Offer-Ada.pptx` now reads, with the formatting of your template:
|
|
96
84
|
|
|
97
85
|
```text
|
|
98
86
|
Offer for Ada
|
|
99
87
|
Thank you for being a loyal customer.
|
|
100
|
-
|
|
101
|
-
|
|
88
|
+
Apples: 1.50 €
|
|
89
|
+
Pears: 2.00 €
|
|
102
90
|
```
|
|
103
91
|
|
|
104
|
-
|
|
105
|
-
|
|
92
|
+
Call `addSlide` once per record to get one slide per customer, project or month.
|
|
93
|
+
Slides from several template files can be mixed into one deck. All tags and
|
|
94
|
+
expressions are described in
|
|
95
|
+
[Template Logic](https://daborsten.github.io/pptx-templates/template-logic).
|
|
106
96
|
|
|
107
|
-
|
|
97
|
+
**Using quotes in a tag?** PowerPoint turns `'Ada'` into `‘Ada’` as you type.
|
|
98
|
+
Render with `modify.renderTemplate(data, { fixSmartQuotes: true })`, or turn the
|
|
99
|
+
replacement off:
|
|
108
100
|
|
|
109
|
-
|
|
101
|
+
<details>
|
|
102
|
+
<summary>How to turn off smart quotes in PowerPoint</summary>
|
|
110
103
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
{ name: 'Ada', vip: true },
|
|
114
|
-
{ name: 'Grace', vip: false },
|
|
115
|
-
];
|
|
116
|
-
|
|
117
|
-
for (const customer of customers) {
|
|
118
|
-
pres.addSlide('offer', 1, (slide) => {
|
|
119
|
-
slide.modify(modify.renderTemplate({ customer, items: [] }));
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
await pres.write('All-Offers.pptx');
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
Load several template files and mix their slides to build a full deck: a
|
|
127
|
-
title slide from one file, a chart slide from another, a closing slide from a
|
|
128
|
-
third.
|
|
129
|
-
|
|
130
|
-
## Tags
|
|
104
|
+
*File › Options › Proofing › AutoCorrect Options… › AutoFormat As You Type*,
|
|
105
|
+
then uncheck *"Straight quotes" with “smart quotes”*.
|
|
131
106
|
|
|
132
|
-
|
|
133
|
-
|---|---|
|
|
134
|
-
| `{{expr}}` | Insert a value. `\n` becomes a line break, arrays are joined with `, ` |
|
|
135
|
-
| `{{IF expr}}` … `{{ELSE-IF expr}}` … `{{ELSE}}` … `{{END-IF}}` | Keep the first branch whose condition is true |
|
|
136
|
-
| `{{FOR item IN list}}` … `{{END-FOR}}` | Repeat paragraphs or table rows. `$idx` is the index |
|
|
137
|
-
| `{{EXEC total = 0}}`, `{{! total = total + x}}` | Set variables for the rest of the slide |
|
|
138
|
-
| `{{ALIAS name command}}`, `{{*name}}` | Shorthand for a command you use often |
|
|
139
|
-
| `{{HTML expr}}` | Insert HTML as formatted text: bold, italic, lists, links |
|
|
140
|
-
| `{{LINK expr}}` | Insert a hyperlink, to a URL or to a slide of the output |
|
|
141
|
-
| `{{IMAGE expr}}` | Place a picture where the text box is, optionally cropped to a shape with a border |
|
|
142
|
-
| `{{HIDE-SLIDE expr}}` | In the speaker notes: leave the slide out of the deck when `expr` is true |
|
|
107
|
+

|
|
143
108
|
|
|
144
|
-
|
|
145
|
-
comparisons, `&&`, `||`, `??`, `? :`, arrow functions
|
|
146
|
-
(`items.filter(i => i.active)`), methods of the values (`name.toUpperCase()`)
|
|
147
|
-
and functions you pass in the data.
|
|
109
|
+
</details>
|
|
148
110
|
|
|
149
|
-
|
|
150
|
-
`{{END-FOR}}` closes in the last cell of the same row:
|
|
151
|
-
|
|
152
|
-
| `{{FOR p IN products}}{{p.name}}` | `{{p.price}} €{{END-FOR}}` |
|
|
153
|
-
|---|---|
|
|
111
|
+
## How it compares
|
|
154
112
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
113
|
+
| | pptx-templates | [PptxGenJS](https://github.com/gitbrent/PptxGenJS) | [pptx-automizer](https://github.com/singerla/pptx-automizer) |
|
|
114
|
+
|---|---|---|---|
|
|
115
|
+
| Slide design lives in | the .pptx, edited in PowerPoint | your code | the .pptx |
|
|
116
|
+
| Text logic | tags in the slide: `IF`, `FOR`, … | your code | a callback per shape, simple `{{tag}}` replacement |
|
|
117
|
+
| Repeat table rows from a list | `{{FOR}}` in the row | your code | from code |
|
|
118
|
+
| Template linter | yes | no | no |
|
|
161
119
|
|
|
162
|
-
|
|
120
|
+
Pick PptxGenJS when there is no designed template and the code should draw
|
|
121
|
+
every slide. Pick `pptx-templates` when someone designs the slides in
|
|
122
|
+
PowerPoint and your code only brings the data.
|
|
163
123
|
|
|
164
124
|
## Check templates before you render
|
|
165
125
|
|
|
166
|
-
Templates get edited in PowerPoint, often by people who never run the code.
|
|
167
|
-
|
|
168
|
-
underlined:
|
|
126
|
+
Templates get edited in PowerPoint, often by people who never run the code. The
|
|
127
|
+
linter reports what they broke, slide by slide:
|
|
169
128
|
|
|
170
129
|
```bash
|
|
171
130
|
npx pptx-templates lint templates/*.pptx --data example.json
|
|
@@ -181,101 +140,35 @@ Offer.pptx
|
|
|
181
140
|
1 problem(s): 1 error(s), 0 warning(s)
|
|
182
141
|
```
|
|
183
142
|
|
|
184
|
-
It
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
- `--watch` lints again every time you press Ctrl+S in PowerPoint.
|
|
189
|
-
- The exit code fails a CI job when a template is broken.
|
|
190
|
-
- `npx pptx-templates usage` lists which data fields the tags read, and which
|
|
191
|
-
ones no tag reads.
|
|
192
|
-
- `npx pptx-templates init` writes example data with every field the tags
|
|
193
|
-
read, combined over several decks; run again, it only adds what is missing.
|
|
194
|
-
- `npx pptx-templates render deck.pptx --data data.json -o out.pptx` fills
|
|
195
|
-
every slide with the data, to see the result without writing code
|
|
196
|
-
(`renderDeck()` from code).
|
|
197
|
-
- A `pptx-templates.json` maps many decks to their data, for example one data
|
|
198
|
-
file per language for every customer folder:
|
|
199
|
-
|
|
200
|
-
```json
|
|
201
|
-
{
|
|
202
|
-
"templates": [
|
|
203
|
-
{ "files": "{customer}/cover_{lang}.pptx", "data": "data/cover_{lang}.json" }
|
|
204
|
-
]
|
|
205
|
-
}
|
|
206
|
-
```
|
|
207
|
-
|
|
208
|
-
Both commands are also available from code:
|
|
209
|
-
|
|
210
|
-
```ts
|
|
211
|
-
import { lintTemplate, listTemplateCommands } from 'pptx-templates';
|
|
212
|
-
|
|
213
|
-
const { issues, errorCount } = await lintTemplate('templates/Offer.pptx', {
|
|
214
|
-
data: { customer: { name: 'Ada', vip: true }, items: [] },
|
|
215
|
-
});
|
|
216
|
-
const commands = await listTemplateCommands('templates/Offer.pptx');
|
|
217
|
-
```
|
|
218
|
-
|
|
219
|
-
More in [Template Linter](https://daborsten.github.io/pptx-templates/template-lint).
|
|
143
|
+
It runs in CI, or in watch mode while the deck is open in PowerPoint. See
|
|
144
|
+
[Template Linter](https://daborsten.github.io/pptx-templates/template-lint),
|
|
145
|
+
which also covers the commands that render a deck or write example data without
|
|
146
|
+
any code.
|
|
220
147
|
|
|
221
148
|
## When tags are not enough
|
|
222
149
|
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
Selection Pane:
|
|
226
|
-
|
|
227
|
-
```ts
|
|
228
|
-
pres.addSlide('offer', 1, (slide) => {
|
|
229
|
-
slide.modifyElement('Title', modify.setText('Offer 2026'));
|
|
230
|
-
slide.modifyElement('Logo', modify.setCornerRadius('10%'));
|
|
231
|
-
});
|
|
232
|
-
```
|
|
233
|
-
|
|
234
|
-
The [`modify.*` helpers](https://daborsten.github.io/pptx-templates/helpers)
|
|
235
|
-
fill [charts](https://daborsten.github.io/pptx-templates/charts) and
|
|
150
|
+
From code you can fill
|
|
151
|
+
[charts](https://daborsten.github.io/pptx-templates/charts) and
|
|
236
152
|
[tables](https://daborsten.github.io/pptx-templates/tables), swap
|
|
237
153
|
[images](https://daborsten.github.io/pptx-templates/images), crop pictures to
|
|
238
154
|
[any preset shape](https://daborsten.github.io/pptx-templates/shape-geometry)
|
|
239
|
-
and move or resize elements
|
|
155
|
+
and move or resize elements with the
|
|
156
|
+
[`modify.*` helpers](https://daborsten.github.io/pptx-templates/helpers).
|
|
157
|
+
For shapes that don't exist in any template,
|
|
240
158
|
[PptxGenJS is built in](https://daborsten.github.io/pptx-templates/generation).
|
|
241
159
|
|
|
242
|
-
## How it compares
|
|
243
|
-
|
|
244
|
-
| | pptx-templates | [PptxGenJS](https://github.com/gitbrent/PptxGenJS) | [pptx-automizer](https://github.com/singerla/pptx-automizer) |
|
|
245
|
-
|---|---|---|---|
|
|
246
|
-
| Slide design lives in | the .pptx, edited in PowerPoint | your code | the .pptx |
|
|
247
|
-
| Text logic | tags in the slide: `IF`, `FOR`, … | your code | a callback per shape, simple `{{tag}}` replacement |
|
|
248
|
-
| Repeat table rows from a list | `{{FOR}}` in the row | your code | from code |
|
|
249
|
-
| Template linter | yes | no | no |
|
|
250
|
-
|
|
251
|
-
Pick PptxGenJS when there is no designed template and the code should draw
|
|
252
|
-
every slide. Pick `pptx-templates` when someone designs the slides in
|
|
253
|
-
PowerPoint and your code only brings the data.
|
|
254
|
-
|
|
255
|
-
## Documentation
|
|
256
|
-
|
|
257
|
-
Guides for every feature and the API reference are at
|
|
258
|
-
**[daborsten.github.io/pptx-templates](https://daborsten.github.io/pptx-templates/)**.
|
|
259
|
-
|
|
260
160
|
Using an AI assistant? Point it to
|
|
261
161
|
[AI-INSTRUCTOR.md](https://github.com/DaBorsten/pptx-templates/blob/main/AI-INSTRUCTOR.md),
|
|
262
|
-
|
|
162
|
+
which ships with the npm package.
|
|
263
163
|
|
|
264
164
|
## Contributing
|
|
265
165
|
|
|
266
|
-
Bug reports, ideas and
|
|
267
|
-
|
|
268
|
-
security
|
|
269
|
-
[security policy](https://github.com/DaBorsten/pptx-templates/blob/main/SECURITY.md)
|
|
270
|
-
instead.
|
|
271
|
-
|
|
272
|
-
## Credits
|
|
273
|
-
|
|
274
|
-
`pptx-templates` is a fork of [pptx-automizer](https://github.com/singerla/pptx-automizer),
|
|
275
|
-
which copies slides and edits the OOXML underneath. The tag syntax comes from
|
|
276
|
-
[docx-templates](https://github.com/guigrpa/docx-templates), so if you fill
|
|
277
|
-
Word templates that way, you already know it.
|
|
166
|
+
[Bug reports, ideas](https://github.com/DaBorsten/pptx-templates/issues/new) and
|
|
167
|
+
pull requests are welcome. Report security problems as described in the
|
|
168
|
+
[security policy](https://github.com/DaBorsten/pptx-templates/blob/main/SECURITY.md).
|
|
278
169
|
|
|
279
|
-
##
|
|
170
|
+
## Credits and license
|
|
280
171
|
|
|
281
|
-
|
|
172
|
+
A fork of [pptx-automizer](https://github.com/singerla/pptx-automizer), with the
|
|
173
|
+
tag syntax of [docx-templates](https://github.com/guigrpa/docx-templates). MIT
|
|
174
|
+
licensed.
|
package/dist/automizer.d.ts
CHANGED
|
@@ -181,7 +181,14 @@ export default class Automizer implements IPresentationProps {
|
|
|
181
181
|
* @returns Promise<NodeJS.ReadableStream>
|
|
182
182
|
*/
|
|
183
183
|
getJSZip(): Promise<JSZip>;
|
|
184
|
+
private finalized;
|
|
185
|
+
/**
|
|
186
|
+
* Runs once: a second write()/stream()/getJSZip() outputs the same
|
|
187
|
+
* presentation instead of appending the queued slides again.
|
|
188
|
+
*/
|
|
184
189
|
finalizePresentation(): Promise<void>;
|
|
190
|
+
private withContext;
|
|
191
|
+
private runFinalize;
|
|
185
192
|
/**
|
|
186
193
|
* Write all masterSlides to archive.
|
|
187
194
|
*/
|