@iasiv5/dsh-skills 1.0.6 → 1.2.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/NOTICE.md +7 -10
- package/README.md +1 -1
- package/package.json +1 -1
- package/skills/answer-me-with-html/SKILL.md +3 -1
- package/skills/answer-me-with-html/references/settings.md +1 -1
- package/skills/answer-me-with-html/references/video.md +1 -0
- package/skills/answer-me-with-html/scripts/am.mjs +2567 -2064
- package/skills/docx/LICENSE.txt +202 -0
- package/skills/docx/SKILL.md +91 -0
- package/skills/docx/scripts/__init__.py +1 -0
- package/skills/docx/scripts/accept_changes.py +135 -0
- package/skills/docx/scripts/comment.py +368 -0
- package/skills/docx/scripts/merge_runs.py +310 -0
- package/skills/docx/scripts/office/helpers/__init__.py +111 -0
- package/skills/docx/scripts/office/helpers/pptx_chart.py +170 -0
- package/skills/docx/scripts/office/helpers/pptx_slide.py +60 -0
- package/skills/docx/scripts/office/helpers/pptx_theme.py +114 -0
- package/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-chart.xsd +1499 -0
- package/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-chartDrawing.xsd +146 -0
- package/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-diagram.xsd +1085 -0
- package/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-lockedCanvas.xsd +11 -0
- package/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-main.xsd +3081 -0
- package/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-picture.xsd +23 -0
- package/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-spreadsheetDrawing.xsd +185 -0
- package/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-wordprocessingDrawing.xsd +287 -0
- package/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/pml.xsd +1676 -0
- package/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-additionalCharacteristics.xsd +28 -0
- package/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-bibliography.xsd +144 -0
- package/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-commonSimpleTypes.xsd +174 -0
- package/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-customXmlDataProperties.xsd +25 -0
- package/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-customXmlSchemaProperties.xsd +18 -0
- package/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesCustom.xsd +59 -0
- package/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesExtended.xsd +56 -0
- package/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesVariantTypes.xsd +195 -0
- package/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-math.xsd +582 -0
- package/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-relationshipReference.xsd +25 -0
- package/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/sml.xsd +4439 -0
- package/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-main.xsd +570 -0
- package/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-officeDrawing.xsd +509 -0
- package/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-presentationDrawing.xsd +12 -0
- package/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-spreadsheetDrawing.xsd +108 -0
- package/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-wordprocessingDrawing.xsd +96 -0
- package/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/wml.xsd +3646 -0
- package/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/xml.xsd +116 -0
- package/skills/docx/scripts/office/schemas/ecma/fouth-edition/opc-contentTypes.xsd +42 -0
- package/skills/docx/scripts/office/schemas/ecma/fouth-edition/opc-coreProperties.xsd +50 -0
- package/skills/docx/scripts/office/schemas/ecma/fouth-edition/opc-digSig.xsd +49 -0
- package/skills/docx/scripts/office/schemas/ecma/fouth-edition/opc-relationships.xsd +33 -0
- package/skills/docx/scripts/office/schemas/mce/mc.xsd +75 -0
- package/skills/docx/scripts/office/schemas/microsoft/wml-2010.xsd +560 -0
- package/skills/docx/scripts/office/schemas/microsoft/wml-2012.xsd +67 -0
- package/skills/docx/scripts/office/schemas/microsoft/wml-2018.xsd +14 -0
- package/skills/docx/scripts/office/schemas/microsoft/wml-cex-2018.xsd +20 -0
- package/skills/docx/scripts/office/schemas/microsoft/wml-cid-2016.xsd +13 -0
- package/skills/docx/scripts/office/schemas/microsoft/wml-sdtdatahash-2020.xsd +4 -0
- package/skills/docx/scripts/office/schemas/microsoft/wml-symex-2015.xsd +8 -0
- package/skills/docx/scripts/office/soffice.py +192 -0
- package/skills/docx/scripts/office/validate.py +173 -0
- package/skills/docx/scripts/office/validators/__init__.py +15 -0
- package/skills/docx/scripts/office/validators/base.py +875 -0
- package/skills/docx/scripts/office/validators/docx.py +466 -0
- package/skills/docx/scripts/office/validators/pptx.py +441 -0
- package/skills/docx/scripts/office/validators/redlining.py +299 -0
- package/skills/docx/scripts/templates/comments.xml +3 -0
- package/skills/docx/scripts/templates/commentsExtended.xml +3 -0
- package/skills/docx/scripts/templates/commentsExtensible.xml +3 -0
- package/skills/docx/scripts/templates/commentsIds.xml +3 -0
- package/skills/docx/scripts/templates/people.xml +3 -0
- package/skills/impeccable/SKILL.md +87 -0
- package/skills/impeccable/reference/adapt.md +318 -0
- package/skills/impeccable/reference/adapt.native.md +58 -0
- package/skills/impeccable/reference/android.md +46 -0
- package/skills/impeccable/reference/animate.md +89 -0
- package/skills/impeccable/reference/audit.md +150 -0
- package/skills/impeccable/reference/audit.native.md +143 -0
- package/skills/impeccable/reference/bolder.md +33 -0
- package/skills/impeccable/reference/clarify.md +94 -0
- package/skills/impeccable/reference/colorize.md +86 -0
- package/skills/impeccable/reference/component-review.md +63 -0
- package/skills/impeccable/reference/craft-floor.md +44 -0
- package/skills/impeccable/reference/craft.md +5 -0
- package/skills/impeccable/reference/critique.md +819 -0
- package/skills/impeccable/reference/degraded/asset-producer.md +42 -0
- package/skills/impeccable/reference/degraded/documenter.md +24 -0
- package/skills/impeccable/reference/degraded/finish-reviewer.md +38 -0
- package/skills/impeccable/reference/degraded/manual-edit-applier.md +93 -0
- package/skills/impeccable/reference/delight.md +70 -0
- package/skills/impeccable/reference/distill.md +111 -0
- package/skills/impeccable/reference/doctor.md +54 -0
- package/skills/impeccable/reference/document.md +416 -0
- package/skills/impeccable/reference/extract.md +69 -0
- package/skills/impeccable/reference/generate.md +101 -0
- package/skills/impeccable/reference/harden.md +362 -0
- package/skills/impeccable/reference/hooks.md +120 -0
- package/skills/impeccable/reference/init.md +133 -0
- package/skills/impeccable/reference/ios.md +51 -0
- package/skills/impeccable/reference/layout.md +84 -0
- package/skills/impeccable/reference/live-setup.md +104 -0
- package/skills/impeccable/reference/live.md +327 -0
- package/skills/impeccable/reference/mode-operate.md +21 -0
- package/skills/impeccable/reference/mode-persuade.md +19 -0
- package/skills/impeccable/reference/mode-read.md +21 -0
- package/skills/impeccable/reference/new-work.md +152 -0
- package/skills/impeccable/reference/onboard.md +235 -0
- package/skills/impeccable/reference/operate.md +61 -0
- package/skills/impeccable/reference/optimize.md +257 -0
- package/skills/impeccable/reference/overdrive.md +127 -0
- package/skills/impeccable/reference/polish.md +105 -0
- package/skills/impeccable/reference/quieter.md +99 -0
- package/skills/impeccable/reference/region-map.md +26 -0
- package/skills/impeccable/reference/routing.md +24 -0
- package/skills/impeccable/reference/shape.md +59 -0
- package/skills/impeccable/reference/typeset.md +90 -0
- package/skills/impeccable/reference/visualize.md +47 -0
- package/skills/impeccable/scripts/VERSION +1 -0
- package/skills/impeccable/scripts/command-metadata.json +98 -0
- package/skills/impeccable/scripts/data/font-index-failures.json +121 -0
- package/skills/impeccable/scripts/data/font-index.json +1 -0
- package/skills/impeccable/scripts/engine-checksums.txt +9 -0
- package/skills/impeccable/scripts/impeccable +291 -0
- package/skills/impeccable/scripts/impeccable.cmd +337 -0
- package/skills/impeccable/scripts/live-browser-dom.js +320 -0
- package/skills/impeccable/scripts/live-browser-ignores.js +246 -0
- package/skills/impeccable/scripts/live-browser-session.js +183 -0
- package/skills/impeccable/scripts/live-browser.js +13872 -0
- package/skills/impeccable/scripts/modern-screenshot.umd.js +14 -0
- package/skills/pdf/LICENSE.txt +202 -0
- package/skills/pdf/SKILL.md +314 -0
- package/skills/pdf/forms.md +294 -0
- package/skills/pdf/reference.md +612 -0
- package/skills/pdf/scripts/check_bounding_boxes.py +65 -0
- package/skills/pdf/scripts/check_fillable_fields.py +11 -0
- package/skills/pdf/scripts/convert_pdf_to_images.py +33 -0
- package/skills/pdf/scripts/create_validation_image.py +37 -0
- package/skills/pdf/scripts/extract_form_field_info.py +122 -0
- package/skills/pdf/scripts/extract_form_structure.py +115 -0
- package/skills/pdf/scripts/fill_fillable_fields.py +98 -0
- package/skills/pdf/scripts/fill_pdf_form_with_annotations.py +107 -0
- package/skills/xlsx/LICENSE.txt +202 -0
- package/skills/xlsx/SKILL.md +99 -0
- package/skills/xlsx/scripts/office/helpers/__init__.py +111 -0
- package/skills/xlsx/scripts/office/helpers/pptx_chart.py +170 -0
- package/skills/xlsx/scripts/office/helpers/pptx_slide.py +60 -0
- package/skills/xlsx/scripts/office/helpers/pptx_theme.py +114 -0
- package/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-chart.xsd +1499 -0
- package/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-chartDrawing.xsd +146 -0
- package/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-diagram.xsd +1085 -0
- package/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-lockedCanvas.xsd +11 -0
- package/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-main.xsd +3081 -0
- package/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-picture.xsd +23 -0
- package/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-spreadsheetDrawing.xsd +185 -0
- package/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-wordprocessingDrawing.xsd +287 -0
- package/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/pml.xsd +1676 -0
- package/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-additionalCharacteristics.xsd +28 -0
- package/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-bibliography.xsd +144 -0
- package/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-commonSimpleTypes.xsd +174 -0
- package/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-customXmlDataProperties.xsd +25 -0
- package/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-customXmlSchemaProperties.xsd +18 -0
- package/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesCustom.xsd +59 -0
- package/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesExtended.xsd +56 -0
- package/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesVariantTypes.xsd +195 -0
- package/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-math.xsd +582 -0
- package/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-relationshipReference.xsd +25 -0
- package/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/sml.xsd +4439 -0
- package/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-main.xsd +570 -0
- package/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-officeDrawing.xsd +509 -0
- package/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-presentationDrawing.xsd +12 -0
- package/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-spreadsheetDrawing.xsd +108 -0
- package/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-wordprocessingDrawing.xsd +96 -0
- package/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/wml.xsd +3646 -0
- package/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/xml.xsd +116 -0
- package/skills/xlsx/scripts/office/schemas/ecma/fouth-edition/opc-contentTypes.xsd +42 -0
- package/skills/xlsx/scripts/office/schemas/ecma/fouth-edition/opc-coreProperties.xsd +50 -0
- package/skills/xlsx/scripts/office/schemas/ecma/fouth-edition/opc-digSig.xsd +49 -0
- package/skills/xlsx/scripts/office/schemas/ecma/fouth-edition/opc-relationships.xsd +33 -0
- package/skills/xlsx/scripts/office/schemas/mce/mc.xsd +75 -0
- package/skills/xlsx/scripts/office/schemas/microsoft/wml-2010.xsd +560 -0
- package/skills/xlsx/scripts/office/schemas/microsoft/wml-2012.xsd +67 -0
- package/skills/xlsx/scripts/office/schemas/microsoft/wml-2018.xsd +14 -0
- package/skills/xlsx/scripts/office/schemas/microsoft/wml-cex-2018.xsd +20 -0
- package/skills/xlsx/scripts/office/schemas/microsoft/wml-cid-2016.xsd +13 -0
- package/skills/xlsx/scripts/office/schemas/microsoft/wml-sdtdatahash-2020.xsd +4 -0
- package/skills/xlsx/scripts/office/schemas/microsoft/wml-symex-2015.xsd +8 -0
- package/skills/xlsx/scripts/office/soffice.py +192 -0
- package/skills/xlsx/scripts/office/validate.py +173 -0
- package/skills/xlsx/scripts/office/validators/__init__.py +15 -0
- package/skills/xlsx/scripts/office/validators/base.py +875 -0
- package/skills/xlsx/scripts/office/validators/docx.py +466 -0
- package/skills/xlsx/scripts/office/validators/pptx.py +441 -0
- package/skills/xlsx/scripts/office/validators/redlining.py +299 -0
- package/skills/xlsx/scripts/recalc.py +308 -0
- package/skills-manifest.json +36 -0
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: xlsx
|
|
3
|
+
description: "Use this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing .xlsx, .xlsm, .xltx, .csv, or .tsv file (e.g., adding columns, computing formulas, formatting, charting, cleaning messy data); create a new spreadsheet from scratch or from other data sources; or convert between tabular file formats. Trigger especially when the user references a spreadsheet file by name or path — even casually (like \"the xlsx in my downloads\") — and wants something done to it or produced from it. Also trigger for cleaning or restructuring messy tabular data files (malformed rows, misplaced headers, junk data) into proper spreadsheets. The deliverable must be a spreadsheet file. Do NOT trigger when the primary deliverable is a Word document, HTML report, standalone Python script, database pipeline, or Google Sheets API integration, even if tabular data is involved."
|
|
4
|
+
license: Complete terms in LICENSE.txt
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# XLSX creation, editing, and analysis
|
|
8
|
+
|
|
9
|
+
| Task | Approach |
|
|
10
|
+
|---|---|
|
|
11
|
+
| **Create** or **edit** with formulas/formatting | `openpyxl` — see gotchas below |
|
|
12
|
+
| **Bulk data** in or out | `pandas` (`read_excel`, `to_excel`) |
|
|
13
|
+
| **Quick look** at a sheet | `markitdown file.xlsx` — `## SheetName` per sheet; reads `.xlsm` too. No cell coordinates, so don't plan edits from it |
|
|
14
|
+
| **Read** a model (formulas *and* values) | two `load_workbook` passes — see gotchas |
|
|
15
|
+
|
|
16
|
+
> `openpyxl`, `pandas`, and `markitdown` are preinstalled — do not run `pip install` first; write the script and import directly. Only if an import fails (or the `markitdown` command is missing): `pip install` the missing package.
|
|
17
|
+
|
|
18
|
+
> Script paths below are relative to this skill's directory.
|
|
19
|
+
|
|
20
|
+
## Requirements for every output
|
|
21
|
+
|
|
22
|
+
- **Professional font** (Arial, Times New Roman) throughout, unless the user says otherwise.
|
|
23
|
+
- **Zero formula errors.** Never ship while `recalc.py` reports `errors_found`. If you think an error predates you, prove it: load the *original* with `data_only=True` and look at that cell. An error you introduced looks exactly like one you inherited.
|
|
24
|
+
- **Use formulas, never hardcoded results.** Write `sheet['B10'] = '=SUM(B2:B9)'`, not the Python-computed total. The sheet must recalculate when its inputs change.
|
|
25
|
+
- **Follow the user's spec literally.** Exact tab names, exact column headers, and the formula they spelled out. A redesign that computes something else fails, however elegant.
|
|
26
|
+
- **Document every assumption and hardcoded number** where the reader will see it — a cell comment, or an adjacent cell at a table's end. Cite a real source when one exists (`Source: Company 10-K, FY2024, Page 45, Revenue Note, [SEC EDGAR URL]`); when the number came from the user, say so plainly.
|
|
27
|
+
- **A workbook *you create* for someone to fill in** needs a short legend naming which cells to edit, and one example row of realistic values showing the expected format. Never add such a row to a file you were asked to edit.
|
|
28
|
+
- **Editing an existing file: match its conventions exactly.** They override every guideline here. Find its designated input cells first — a distinct font color, fill, or shading marks them — write only there, and leave every existing formula untouched.
|
|
29
|
+
|
|
30
|
+
## Recalculate (mandatory whenever the file contains formulas)
|
|
31
|
+
|
|
32
|
+
openpyxl writes formulas as strings with **no cached values**. Until you recalculate, every
|
|
33
|
+
formula cell reads back as `None` to anything reading cached values — `pandas`,
|
|
34
|
+
`load_workbook(data_only=True)`, and most previewers.
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
python scripts/recalc.py output.xlsx [timeout_seconds] # default 30
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
LibreOffice computes every formula, the file is **rewritten in place**, and you get JSON:
|
|
41
|
+
`status` (`success` | `errors_found`), `total_formulas`, `total_errors`, and an
|
|
42
|
+
`error_summary` naming up to 100 cells per error type (`locations_truncated` says how many it
|
|
43
|
+
withheld — trust `total_errors`, not the length of the list). Fix what it names and run it
|
|
44
|
+
again. **JSON with an `error` key instead of a `status` means nothing was recalculated**, and
|
|
45
|
+
only that case exits non-zero — `errors_found` exits 0, so never treat a clean exit as a clean
|
|
46
|
+
workbook.
|
|
47
|
+
|
|
48
|
+
**A green recalc proves your formulas *evaluate*, not that they are *right*.** An off-by-one
|
|
49
|
+
range or a reference to the wrong row yields a clean, error-free file with wrong numbers.
|
|
50
|
+
Write 2–3 formulas first and check they pull the values you expect, before building out a grid.
|
|
51
|
+
|
|
52
|
+
**A workbook that links to another file loses those links** if you re-save it with openpyxl and
|
|
53
|
+
then recalculate. Such a formula reads `='[1]Returns Analysis'!$B$2` — the `[1]` is an index
|
|
54
|
+
into the workbook's external-reference list, naming a *separate file on disk*, not a sheet.
|
|
55
|
+
That file is rarely present here, so the cell's cached value is the only thing holding its
|
|
56
|
+
data. openpyxl strips that value on save; LibreOffice then has to resolve the reference for
|
|
57
|
+
real, fails, writes `#NAME?`, and deletes every link. `recalc.py` refuses to run in that state
|
|
58
|
+
— copy those cells' values out of the original before you save over them (`--force` overrides,
|
|
59
|
+
and accepts the loss).
|
|
60
|
+
|
|
61
|
+
## Choosing formulas that survive verification
|
|
62
|
+
|
|
63
|
+
LibreOffice implements fewer functions than Excel, and one it cannot evaluate becomes a
|
|
64
|
+
literal `#NAME?` baked into the file you deliver.
|
|
65
|
+
|
|
66
|
+
- **Prefer Excel-2007-era functions** — `SUMIFS`, `INDEX`, `MATCH`, `IFERROR`, `SUMPRODUCT` — which need no prefix.
|
|
67
|
+
- **Six post-2007 functions work, but only with an `_xlfn.` prefix**, because openpyxl writes your formula into the XML verbatim and Excel stores post-2007 names prefixed (its UI hides the prefix): `_xlfn.TEXTJOIN`, `_xlfn.CONCAT`, `_xlfn.IFS`, `_xlfn.SWITCH`, `_xlfn.MAXIFS`, `_xlfn.MINIFS`. Written bare, each yields `#NAME?`.
|
|
68
|
+
- **Never use `XLOOKUP`, `XMATCH`, `SORT`, `FILTER`, `UNIQUE`, or `SEQUENCE`.** The runtime's LibreOffice cannot evaluate them under *any* prefix. Newer builds do evaluate them, but they are spilling array functions and an openpyxl-written file has no spill metadata, so only the top-left cell of the range gets a value — and `recalc.py` reports `total_errors: 0` on the truncated result. Use `INDEX`/`MATCH` for lookups, and sort, filter, and de-duplicate in Python before writing the cells.
|
|
69
|
+
- A formula LibreOffice could not parse is written back **lowercased** — a quick tell beside a `#NAME?`.
|
|
70
|
+
|
|
71
|
+
## openpyxl gotchas
|
|
72
|
+
|
|
73
|
+
- **Reading a model takes two loads.** `data_only=True` yields cached values with the formulas gone; the default yields formula strings with no values. One pass cannot give you both.
|
|
74
|
+
- **`data_only=True` is destructive if you save.** That workbook has no formulas left, so saving replaces every one with a literal — permanently.
|
|
75
|
+
- **`data_only=True` on a file openpyxl just wrote returns `None` everywhere** — run `recalc.py` first. (A formula whose result is `""` also reads back as `None`.)
|
|
76
|
+
- **Merged cells: write the top-left anchor only.** Every other cell in the range is a `MergedCell` whose `.value` is read-only.
|
|
77
|
+
- **`.xlsm` loses its macros unless you pass `keep_vba=True`** to `load_workbook`.
|
|
78
|
+
- **A sheet name containing a space must be quoted** in a cross-sheet reference: `='Assumptions Inputs'!$B$5`. Unquoted, it evaluates to `#VALUE!`.
|
|
79
|
+
|
|
80
|
+
## Financial models
|
|
81
|
+
|
|
82
|
+
Unless the user says otherwise, or the existing file already does something else.
|
|
83
|
+
|
|
84
|
+
**Color:** blue text (`0,0,255`) for hardcoded inputs and scenario levers · black for formulas ·
|
|
85
|
+
green (`0,128,0`) for links to another sheet · red (`255,0,0`) for links to another file ·
|
|
86
|
+
yellow fill (`255,255,0`) for key assumptions and cells the user should fill in.
|
|
87
|
+
|
|
88
|
+
**Numbers:** currency `$#,##0`, with the unit named in the header (`Revenue ($mm)`) · zeros
|
|
89
|
+
render as `-`, including in percentages (`$#,##0;($#,##0);-`) · negatives in parentheses ·
|
|
90
|
+
percentages `0.0%`, **stored as fractions** (`0.15` renders `15.0%`; storing `15` renders
|
|
91
|
+
`1500.0%`) · valuation multiples `0.0x` · years as text (`"2024"`, never `2,024`).
|
|
92
|
+
|
|
93
|
+
**Structure:** every assumption in its own labeled cell, referenced by the formulas that use it
|
|
94
|
+
(`=B5*(1+$B$6)`, never `=B5*1.05`) · formulas consistent across every projection period, since a
|
|
95
|
+
lone edited cell mid-row is the commonest silent error · guard denominators that can be zero.
|
|
96
|
+
|
|
97
|
+
## Dependencies
|
|
98
|
+
|
|
99
|
+
`openpyxl`, `pandas`, `markitdown` (pip, preinstalled — install only if an import fails or the command is missing) · LibreOffice (`soffice`, auto-configured for sandboxed environments via `scripts/office/soffice.py`)
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import posixpath
|
|
3
|
+
import re
|
|
4
|
+
import stat
|
|
5
|
+
import tempfile
|
|
6
|
+
import urllib.parse
|
|
7
|
+
import zipfile
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
|
|
10
|
+
OOXML_FAMILY = {
|
|
11
|
+
".docx": "docx",
|
|
12
|
+
".dotx": "docx",
|
|
13
|
+
".pptx": "pptx",
|
|
14
|
+
".potx": "pptx",
|
|
15
|
+
".xlsx": "xlsx",
|
|
16
|
+
".xltx": "xlsx",
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
_SCHEME_RE = re.compile(r"^[A-Za-z][A-Za-z0-9+.\-]*:")
|
|
20
|
+
|
|
21
|
+
SLIDE_REL_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide"
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def opc_target(target: str, source_part: str, target_mode: str = "") -> str | None:
|
|
25
|
+
if not target:
|
|
26
|
+
return None
|
|
27
|
+
if target_mode.lower() == "external":
|
|
28
|
+
return None
|
|
29
|
+
if _SCHEME_RE.match(target):
|
|
30
|
+
return None
|
|
31
|
+
|
|
32
|
+
target = urllib.parse.unquote(target)
|
|
33
|
+
|
|
34
|
+
if "\\" in target:
|
|
35
|
+
raise ValueError(f"relationship target is not a POSIX part name: {target!r}")
|
|
36
|
+
|
|
37
|
+
if target.startswith("/"):
|
|
38
|
+
joined = target.lstrip("/")
|
|
39
|
+
else:
|
|
40
|
+
joined = posixpath.join(posixpath.dirname(source_part), target)
|
|
41
|
+
|
|
42
|
+
parts: list[str] = []
|
|
43
|
+
for segment in posixpath.normpath(joined).split("/"):
|
|
44
|
+
if segment in ("", "."):
|
|
45
|
+
continue
|
|
46
|
+
if segment == "..":
|
|
47
|
+
if not parts:
|
|
48
|
+
raise ValueError(f"relationship target escapes the package: {target!r}")
|
|
49
|
+
parts.pop()
|
|
50
|
+
else:
|
|
51
|
+
parts.append(segment)
|
|
52
|
+
|
|
53
|
+
if not parts:
|
|
54
|
+
raise ValueError(f"relationship target resolves to nothing: {target!r}")
|
|
55
|
+
return "/".join(parts)
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def rels_source_part(rels_file: Path, unpacked_dir: Path) -> str:
|
|
59
|
+
owner_dir = rels_file.parent.parent.relative_to(unpacked_dir)
|
|
60
|
+
return posixpath.join(owner_dir.as_posix(), rels_file.name[: -len(".rels")]).lstrip("./")
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def part_text(data: bytes) -> str:
|
|
64
|
+
return data.decode("utf-8", "surrogateescape")
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
XML_SPACE = " \t\r\n"
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def rendered_text(text: str, preserve: bool) -> str:
|
|
71
|
+
return text if preserve else text.strip(XML_SPACE)
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def safe_extract(zf: zipfile.ZipFile, dest: Path) -> None:
|
|
75
|
+
dest = dest.resolve()
|
|
76
|
+
for m in zf.infolist():
|
|
77
|
+
if stat.S_ISLNK(m.external_attr >> 16):
|
|
78
|
+
raise ValueError(f"symlink archive entry not allowed: {m.filename!r}")
|
|
79
|
+
target = (dest / m.filename).resolve()
|
|
80
|
+
if not target.is_relative_to(dest):
|
|
81
|
+
raise ValueError(f"unsafe archive entry: {m.filename!r}")
|
|
82
|
+
zf.extract(m, dest)
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def rezip(src_dir: Path, out_path: Path) -> None:
|
|
86
|
+
files = sorted(p for p in src_dir.rglob("*") if p.is_file())
|
|
87
|
+
ct = src_dir / "[Content_Types].xml"
|
|
88
|
+
fd, tmp_name = tempfile.mkstemp(
|
|
89
|
+
prefix=out_path.name + ".", suffix=".tmp", dir=out_path.parent
|
|
90
|
+
)
|
|
91
|
+
tmp_out = Path(tmp_name)
|
|
92
|
+
try:
|
|
93
|
+
with os.fdopen(fd, "wb") as fh:
|
|
94
|
+
with zipfile.ZipFile(fh, "w", zipfile.ZIP_DEFLATED) as zf:
|
|
95
|
+
if ct.exists():
|
|
96
|
+
zf.write(ct, ct.relative_to(src_dir), compress_type=zipfile.ZIP_STORED)
|
|
97
|
+
for f in files:
|
|
98
|
+
if f == ct:
|
|
99
|
+
continue
|
|
100
|
+
zf.write(f, f.relative_to(src_dir))
|
|
101
|
+
if out_path.exists():
|
|
102
|
+
mode = out_path.stat().st_mode & 0o777
|
|
103
|
+
else:
|
|
104
|
+
umask = os.umask(0)
|
|
105
|
+
os.umask(umask)
|
|
106
|
+
mode = 0o666 & ~umask
|
|
107
|
+
os.chmod(tmp_out, mode)
|
|
108
|
+
os.replace(tmp_out, out_path)
|
|
109
|
+
finally:
|
|
110
|
+
if tmp_out.exists():
|
|
111
|
+
tmp_out.unlink()
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
"""Find chart XML that PowerPoint refuses but the schema accepts.
|
|
2
|
+
|
|
3
|
+
Detection only: for either fault more than one repair is valid, and only the
|
|
4
|
+
author knows which was meant.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
import re
|
|
11
|
+
from typing import Mapping
|
|
12
|
+
|
|
13
|
+
from . import part_text
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
_CHART_PART_RE = re.compile(r"ppt/charts/chart\d+\.xml")
|
|
17
|
+
|
|
18
|
+
_GROUPING_RE = re.compile(r"""<c:grouping\b[^>]*?\bval=["'](\w+)["']""")
|
|
19
|
+
_DLBL_POS_RE = re.compile(r"""<c:dLblPos\b[^>]*?\bval=["'](\w+)["']""")
|
|
20
|
+
|
|
21
|
+
def _strip_ext_lst(text: str) -> str:
|
|
22
|
+
out, cursor = [], 0
|
|
23
|
+
for lo, hi in _ext_lst_spans(text):
|
|
24
|
+
out.append(text[cursor:lo])
|
|
25
|
+
cursor = hi
|
|
26
|
+
out.append(text[cursor:])
|
|
27
|
+
return "".join(out)
|
|
28
|
+
|
|
29
|
+
_BAR_GROUP_RE = re.compile(r"<c:(bar3DChart|barChart)\b[^>]*(?<!/)>.*?</c:\1\s*>", re.DOTALL)
|
|
30
|
+
|
|
31
|
+
STACKED_GROUPINGS = frozenset({"stacked", "percentStacked"})
|
|
32
|
+
ILLEGAL_ON_STACKED = frozenset({"outEnd"})
|
|
33
|
+
LEGAL_ON_STACKED = ("ctr", "inEnd", "inBase")
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def _check_stacked_label_positions(part: str, xml: str) -> list[str]:
|
|
37
|
+
problems: list[str] = []
|
|
38
|
+
for match in _BAR_GROUP_RE.finditer(xml):
|
|
39
|
+
block = _strip_ext_lst(match.group(0))
|
|
40
|
+
group = match.group(1)
|
|
41
|
+
|
|
42
|
+
grouping = _GROUPING_RE.search(block)
|
|
43
|
+
if grouping is None or grouping.group(1) not in STACKED_GROUPINGS:
|
|
44
|
+
continue
|
|
45
|
+
|
|
46
|
+
bad = [p for p in _DLBL_POS_RE.findall(block) if p in ILLEGAL_ON_STACKED]
|
|
47
|
+
for pos in sorted(set(bad)):
|
|
48
|
+
problems.append(
|
|
49
|
+
f'{part}: {bad.count(pos)} data label(s) use dLblPos="{pos}" on a '
|
|
50
|
+
f"{grouping.group(1)} {group}; PowerPoint allows only "
|
|
51
|
+
f"{', '.join(LEGAL_ON_STACKED)} there"
|
|
52
|
+
)
|
|
53
|
+
return problems
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
_ANY_CHART_GROUP_RE = re.compile(r"<c:(\w+Chart)\b[^>]*(?<!/)>.*?</c:\1\s*>", re.DOTALL)
|
|
58
|
+
|
|
59
|
+
_AXID_RE = re.compile(
|
|
60
|
+
r"""\s*<c:axId\b[^>]*?\bval=["'](-?\d+)["']\s*(?:/>|>\s*</c:axId\s*>)"""
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
_AXIS_DECL_RE = re.compile(
|
|
64
|
+
r"""<c:(catAx|valAx|serAx|dateAx)\b[^>]*(?<!/)>\s*<c:axId\b[^>]*?\bval=["'](-?\d+)["']"""
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
AXID_LIMIT = {
|
|
68
|
+
"barChart": 2, "lineChart": 2, "areaChart": 2, "scatterChart": 2,
|
|
69
|
+
"bubbleChart": 2, "radarChart": 2, "stockChart": 2,
|
|
70
|
+
"bar3DChart": 3, "line3DChart": 3, "area3DChart": 3,
|
|
71
|
+
"surfaceChart": 3, "surface3DChart": 3,
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
AXID_MINIMUM = {
|
|
75
|
+
"barChart": 2, "lineChart": 2, "areaChart": 2, "scatterChart": 2,
|
|
76
|
+
"bubbleChart": 2, "radarChart": 2, "stockChart": 2,
|
|
77
|
+
"bar3DChart": 2, "area3DChart": 2, "surfaceChart": 2,
|
|
78
|
+
"line3DChart": 3, "surface3DChart": 3,
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def _declared_axes(xml: str) -> dict[str, list[str]]:
|
|
83
|
+
axes: dict[str, list[str]] = {}
|
|
84
|
+
for kind, axid in _AXIS_DECL_RE.findall(xml):
|
|
85
|
+
axes.setdefault(kind, []).append(axid)
|
|
86
|
+
return axes
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
def _canonical_ids(axes: dict[str, list[str]], limit: int) -> list[str] | None:
|
|
90
|
+
category = axes.get("catAx", []) + axes.get("dateAx", [])
|
|
91
|
+
value = axes.get("valAx", [])
|
|
92
|
+
series = axes.get("serAx", [])
|
|
93
|
+
if len(category) != 1 or len(value) != 1 or len(series) > 1:
|
|
94
|
+
return None
|
|
95
|
+
ids = [category[0], value[0]]
|
|
96
|
+
if limit >= 3 and series:
|
|
97
|
+
ids.append(series[0])
|
|
98
|
+
return ids
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
def _undeclared_axes(kind: str, block: str, axes: dict[str, list[str]]) -> list[str] | None:
|
|
102
|
+
if kind not in AXID_LIMIT:
|
|
103
|
+
return None
|
|
104
|
+
ids = _AXID_RE.findall(block)
|
|
105
|
+
declared = {i for group in axes.values() for i in group}
|
|
106
|
+
if len([i for i in ids if i in declared]) >= 2:
|
|
107
|
+
return None
|
|
108
|
+
return ids
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
def _check_chart_axis_references(part: str, xml: str) -> list[str]:
|
|
112
|
+
axes = _declared_axes(xml)
|
|
113
|
+
problems: list[str] = []
|
|
114
|
+
declared = {i for group in axes.values() for i in group}
|
|
115
|
+
for match in _ANY_CHART_GROUP_RE.finditer(xml):
|
|
116
|
+
kind, block = match.group(1), match.group(0)
|
|
117
|
+
ids = _undeclared_axes(kind, block, axes)
|
|
118
|
+
if ids is None:
|
|
119
|
+
continue
|
|
120
|
+
if not ids:
|
|
121
|
+
problems.append(
|
|
122
|
+
f"{part}: <c:{kind}> declares no <c:axId> this part can resolve; a chart "
|
|
123
|
+
f"group needs {AXID_MINIMUM[kind]}, and PowerPoint discards one with fewer"
|
|
124
|
+
)
|
|
125
|
+
continue
|
|
126
|
+
dead = [i for i in ids if i not in declared]
|
|
127
|
+
canonical = _canonical_ids(axes, AXID_LIMIT[kind])
|
|
128
|
+
if canonical is not None and len(canonical) >= AXID_MINIMUM[kind]:
|
|
129
|
+
hint = f"Fix: point them at the axes this part declares ({', '.join(canonical)})"
|
|
130
|
+
else:
|
|
131
|
+
hint = ("Fix: the part declares several axes of a kind -- declare the "
|
|
132
|
+
"secondary axes the series expects, or drop them")
|
|
133
|
+
detail = (f"of which {', '.join(dead)} name no declared axis"
|
|
134
|
+
if dead else f"only {len(ids)} of which this part declares")
|
|
135
|
+
problems.append(
|
|
136
|
+
f"{part}: <c:{kind}> references axId {', '.join(ids)}, {detail}, "
|
|
137
|
+
f"leaving fewer than two live axes; PowerPoint discards the chart. {hint}"
|
|
138
|
+
)
|
|
139
|
+
return problems
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
def _ext_lst_spans(text: str) -> list[tuple[int, int]]:
|
|
143
|
+
spans: list[tuple[int, int]] = []
|
|
144
|
+
depth = 0
|
|
145
|
+
start = 0
|
|
146
|
+
for match in re.finditer(r"<(/?)c:extLst\b[^>]*?(/?)>", text):
|
|
147
|
+
closing, self_closing = match.group(1), match.group(2)
|
|
148
|
+
if self_closing:
|
|
149
|
+
continue
|
|
150
|
+
if closing:
|
|
151
|
+
depth -= 1
|
|
152
|
+
if depth == 0:
|
|
153
|
+
spans.append((start, match.end()))
|
|
154
|
+
else:
|
|
155
|
+
if depth == 0:
|
|
156
|
+
start = match.start()
|
|
157
|
+
depth += 1
|
|
158
|
+
return spans
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
CHART_CHECKS = (_check_stacked_label_positions, _check_chart_axis_references)
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
def find_chart_problems(files: Mapping[str, bytes]) -> list[str]:
|
|
165
|
+
problems: list[str] = []
|
|
166
|
+
for part in sorted(n for n in files if _CHART_PART_RE.fullmatch(n)):
|
|
167
|
+
xml = part_text(files[part])
|
|
168
|
+
for check in CHART_CHECKS:
|
|
169
|
+
problems.extend(check(part, xml))
|
|
170
|
+
return problems
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"""Pick the slide-XML schema errors PowerPoint refuses the file over.
|
|
2
|
+
|
|
3
|
+
A denylist over lxml's messages, so an unrecognised error class is a miss rather
|
|
4
|
+
than a false alarm.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
import re
|
|
11
|
+
|
|
12
|
+
SLIDE_PART_RE = re.compile(
|
|
13
|
+
r"ppt/(slides|slideLayouts|slideMasters|notesSlides|notesMasters|handoutMasters)"
|
|
14
|
+
r"/[^/]+\.xml"
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
FATAL_SLIDE_ERRORS: tuple[tuple[re.Pattern[str], str], ...] = (
|
|
18
|
+
(
|
|
19
|
+
re.compile(r"\}tableStyleId': This element is not expected"),
|
|
20
|
+
"two <a:tableStyleId> in one <a:tblPr> (the schema allows one)",
|
|
21
|
+
),
|
|
22
|
+
(
|
|
23
|
+
re.compile(r"\}srgbClr', attribute 'val'"),
|
|
24
|
+
"a colour that is not six hex digits",
|
|
25
|
+
),
|
|
26
|
+
(
|
|
27
|
+
re.compile(r"\}txBody': Missing child element"),
|
|
28
|
+
"a <p:txBody> with no children",
|
|
29
|
+
),
|
|
30
|
+
(
|
|
31
|
+
re.compile(r"\}miter', attribute 'lim'"),
|
|
32
|
+
'a line join with lim="NaN"',
|
|
33
|
+
),
|
|
34
|
+
(
|
|
35
|
+
re.compile(r"\}uLnTx': This element is not expected"),
|
|
36
|
+
"<a:uLnTx> in a position the schema forbids",
|
|
37
|
+
),
|
|
38
|
+
(
|
|
39
|
+
re.compile(r"\}overrideClrMapping': This element is not expected"),
|
|
40
|
+
"<p:overrideClrMapping> in a position the schema forbids",
|
|
41
|
+
),
|
|
42
|
+
(
|
|
43
|
+
re.compile(r"\}nvGrpSpPr': Missing child element"),
|
|
44
|
+
"a <p:nvGrpSpPr> with no children",
|
|
45
|
+
),
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def is_schema_verdict(error: str) -> bool:
|
|
50
|
+
return error.startswith("Element ")
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def fatal_slide_errors(errors: set[str]) -> list[str]:
|
|
54
|
+
out = []
|
|
55
|
+
for error in sorted(errors):
|
|
56
|
+
for pattern, meaning in FATAL_SLIDE_ERRORS:
|
|
57
|
+
if pattern.search(error):
|
|
58
|
+
out.append(f"{meaning}: {error}")
|
|
59
|
+
break
|
|
60
|
+
return out
|